1
0
forked from brl/citadel-tools
citadel-tools/realmsd/src/main.rs

40 lines
963 B
Rust
Raw Normal View History

2019-08-25 17:15:13 -04:00
#[macro_use] extern crate libcitadel;
2021-10-04 06:02:35 -04:00
use zbus::{Connection, fdo};
use libcitadel::{Logger, LogLevel, Result};
use crate::realms_manager::RealmsManagerServer;
mod realms_manager;
mod events;
2019-08-25 17:15:13 -04:00
fn main() {
2021-10-04 06:02:35 -04:00
if let Err(e) = run_realm_manager() {
2019-08-25 17:15:13 -04:00
warn!("Error: {}", e);
}
}
2021-10-04 06:02:35 -04:00
fn create_system_connection() -> zbus::Result<Connection> {
let connection = zbus::Connection::new_system()?;
fdo::DBusProxy::new(&connection)?.request_name("com.subgraph.realms", fdo::RequestNameFlags::AllowReplacement.into())?;
Ok(connection)
}
fn run_realm_manager() -> Result<()> {
2020-08-03 19:17:05 -04:00
Logger::set_log_level(LogLevel::Verbose);
2021-10-04 06:02:35 -04:00
let connection = create_system_connection()
.map_err(context!("ZBus Connection error"))?;
let mut object_server = RealmsManagerServer::register(&connection)?;
loop {
if let Err(err) = object_server.try_handle_next() {
warn!("Error handling DBus message: {}", err);
}
}
2019-08-25 17:15:13 -04:00
}