kordophoned: reorg: server impl in separate file, skeleton for conversations
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct Daemon {
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
@@ -1,26 +1,16 @@
|
||||
use crate::{dbus::interface::OBJECT_PATH, daemon::Daemon};
|
||||
use log::info;
|
||||
use std::sync::Arc;
|
||||
use crate::{daemon::Daemon, dbus::interface};
|
||||
|
||||
use crossroads::Crossroads;
|
||||
use dbus_crossroads::Crossroads;
|
||||
use dbus_tokio::connection;
|
||||
use dbus::{
|
||||
channel::{MatchingReceiver, Sender},
|
||||
message::MatchRule,
|
||||
nonblock::SyncConnection,
|
||||
channel::{Sender, MatchingReceiver},
|
||||
Path,
|
||||
};
|
||||
|
||||
use dbus_crossroads as crossroads;
|
||||
use dbus_tokio::connection;
|
||||
use dbus_tree::{DataType, MethodErr};
|
||||
use log::info;
|
||||
use std::{future::Future, sync::Arc, thread};
|
||||
|
||||
mod dbus_interface {
|
||||
#![allow(unused)]
|
||||
include!(concat!(env!("OUT_DIR"), "/kordophone-server.rs"));
|
||||
}
|
||||
|
||||
use dbus_interface::NetBuzzertKordophoneServer;
|
||||
|
||||
pub struct Endpoint {
|
||||
connection: Arc<SyncConnection>,
|
||||
daemon: Arc<Daemon>,
|
||||
@@ -62,8 +52,8 @@ impl Endpoint {
|
||||
)));
|
||||
|
||||
// Register the daemon as a D-Bus object.
|
||||
let token = dbus_interface::register_net_buzzert_kordophone_server(&mut cr);
|
||||
cr.insert(OBJECT_PATH, &[token], self.daemon.clone());
|
||||
let token = interface::register_net_buzzert_kordophone_server(&mut cr);
|
||||
cr.insert(interface::OBJECT_PATH, &[token], self.daemon.clone());
|
||||
|
||||
// Start receiving messages.
|
||||
self.connection.start_receive(
|
||||
@@ -80,14 +70,7 @@ impl Endpoint {
|
||||
where
|
||||
S: dbus::message::SignalArgs + dbus::arg::AppendAll,
|
||||
{
|
||||
let message = signal.to_emit_message(&Path::new(OBJECT_PATH).unwrap());
|
||||
let message = signal.to_emit_message(&Path::new(interface::OBJECT_PATH).unwrap());
|
||||
self.connection.send(message)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl NetBuzzertKordophoneServer for Arc<Daemon> {
|
||||
fn get_version(&mut self) -> Result<String, MethodErr> {
|
||||
Ok(self.version.clone())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
pub mod endpoint;
|
||||
mod server_impl;
|
||||
|
||||
pub mod interface {
|
||||
pub static NAME: &str = "net.buzzert.kordophonecd";
|
||||
pub static OBJECT_PATH: &str = "/net/buzzert/kordophone/Server";
|
||||
}
|
||||
mod interface {
|
||||
#![allow(unused)]
|
||||
|
||||
pub const NAME: &str = "net.buzzert.kordophonecd";
|
||||
pub const OBJECT_PATH: &str = "/net/buzzert/kordophonecd";
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/kordophone-server.rs"));
|
||||
}
|
||||
16
kordophoned/src/dbus/server_impl.rs
Normal file
16
kordophoned/src/dbus/server_impl.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use dbus::arg;
|
||||
use dbus_tree::MethodErr;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::daemon::Daemon;
|
||||
use crate::dbus::interface::NetBuzzertKordophoneServer as DbusServer;
|
||||
|
||||
impl DbusServer for Arc<Daemon> {
|
||||
fn get_version(&mut self) -> Result<String, MethodErr> {
|
||||
Ok(self.version.clone())
|
||||
}
|
||||
|
||||
fn get_conversations(&mut self) -> Result<Vec<arg::PropMap>, dbus::MethodErr> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user