kordophoned sans kpcli building on macos
This commit is contained in:
@@ -7,10 +7,6 @@ edition = "2021"
|
|||||||
anyhow = "1.0.98"
|
anyhow = "1.0.98"
|
||||||
async-trait = "0.1.88"
|
async-trait = "0.1.88"
|
||||||
chrono = "0.4.38"
|
chrono = "0.4.38"
|
||||||
dbus = { version = "0.9.7", features = ["futures"] }
|
|
||||||
dbus-crossroads = "0.5.2"
|
|
||||||
dbus-tokio = "0.7.6"
|
|
||||||
dbus-tree = "0.9.2"
|
|
||||||
directories = "6.0.0"
|
directories = "6.0.0"
|
||||||
env_logger = "0.11.6"
|
env_logger = "0.11.6"
|
||||||
futures-util = "0.3.31"
|
futures-util = "0.3.31"
|
||||||
@@ -25,6 +21,14 @@ tokio-condvar = "0.3.0"
|
|||||||
uuid = "1.16.0"
|
uuid = "1.16.0"
|
||||||
once_cell = "1.19.0"
|
once_cell = "1.19.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
|
# D-Bus dependencies only on Linux
|
||||||
|
dbus = { version = "0.9.7", features = ["futures"] }
|
||||||
|
dbus-crossroads = "0.5.2"
|
||||||
|
dbus-tokio = "0.7.6"
|
||||||
|
dbus-tree = "0.9.2"
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "linux")'.build-dependencies]
|
||||||
|
# D-Bus codegen only on Linux
|
||||||
dbus-codegen = "0.10.0"
|
dbus-codegen = "0.10.0"
|
||||||
dbus-crossroads = "0.5.1"
|
dbus-crossroads = "0.5.1"
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
const KORDOPHONE_XML: &str = "include/net.buzzert.kordophonecd.Server.xml";
|
const KORDOPHONE_XML: &str = "include/net.buzzert.kordophonecd.Server.xml";
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
fn main() {
|
||||||
|
// No D-Bus code generation on non-Linux platforms
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
fn main() {
|
fn main() {
|
||||||
// Generate D-Bus code
|
// Generate D-Bus code
|
||||||
let out_dir = std::env::var("OUT_DIR").unwrap();
|
let out_dir = std::env::var("OUT_DIR").unwrap();
|
||||||
@@ -14,8 +20,8 @@ fn main() {
|
|||||||
|
|
||||||
let xml = std::fs::read_to_string(KORDOPHONE_XML).expect("Error reading server dbus interface");
|
let xml = std::fs::read_to_string(KORDOPHONE_XML).expect("Error reading server dbus interface");
|
||||||
|
|
||||||
let output =
|
let output = dbus_codegen::generate(&xml, &opts)
|
||||||
dbus_codegen::generate(&xml, &opts).expect("Error generating server dbus interface");
|
.expect("Error generating server dbus interface");
|
||||||
|
|
||||||
std::fs::write(out_path, output).expect("Error writing server dbus code");
|
std::fs::write(out_path, output).expect("Error writing server dbus code");
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ impl DatabaseAuthenticationStore {
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl AuthenticationStore for DatabaseAuthenticationStore {
|
impl AuthenticationStore for DatabaseAuthenticationStore {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
async fn get_credentials(&mut self) -> Option<Credentials> {
|
async fn get_credentials(&mut self) -> Option<Credentials> {
|
||||||
use keyring::secret_service::SsCredential;
|
use keyring::secret_service::SsCredential;
|
||||||
|
|
||||||
@@ -61,6 +62,11 @@ impl AuthenticationStore for DatabaseAuthenticationStore {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
async fn get_credentials(&mut self) -> Option<Credentials> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
async fn get_token(&mut self) -> Option<String> {
|
async fn get_token(&mut self) -> Option<String> {
|
||||||
self.database
|
self.database
|
||||||
.lock()
|
.lock()
|
||||||
|
|||||||
16
kordophoned/src/daemon/contact_resolver/generic.rs
Normal file
16
kordophoned/src/daemon/contact_resolver/generic.rs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
use super::ContactResolverBackend;
|
||||||
|
|
||||||
|
#[derive(Clone, Default)]
|
||||||
|
pub struct GenericContactResolverBackend;
|
||||||
|
|
||||||
|
impl ContactResolverBackend for GenericContactResolverBackend {
|
||||||
|
type ContactID = String;
|
||||||
|
|
||||||
|
fn resolve_contact_id(&self, address: &str) -> Option<Self::ContactID> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_contact_display_name(&self, contact_id: &Self::ContactID) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,35 @@
|
|||||||
|
#[cfg(target_os = "linux")]
|
||||||
pub mod eds;
|
pub mod eds;
|
||||||
pub use eds::EDSContactResolverBackend;
|
|
||||||
|
pub mod generic;
|
||||||
|
|
||||||
|
// Convenient alias for the platform's default backend
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub type DefaultContactResolverBackend = eds::EDSContactResolverBackend;
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
pub type DefaultContactResolverBackend = generic::GenericContactResolverBackend;
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct EDSContactResolverBackend;
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
impl Default for EDSContactResolverBackend {
|
||||||
|
fn default() -> Self { EDSContactResolverBackend }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
impl ContactResolverBackend for EDSContactResolverBackend {
|
||||||
|
type ContactID = String;
|
||||||
|
|
||||||
|
fn resolve_contact_id(&self, _address: &str) -> Option<Self::ContactID> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_contact_display_name(&self, _contact_id: &Self::ContactID) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ pub use attachment_store::AttachmentStoreEvent;
|
|||||||
|
|
||||||
pub mod contact_resolver;
|
pub mod contact_resolver;
|
||||||
use contact_resolver::ContactResolver;
|
use contact_resolver::ContactResolver;
|
||||||
use contact_resolver::EDSContactResolverBackend;
|
use contact_resolver::DefaultContactResolverBackend;
|
||||||
|
|
||||||
use kordophone_db::models::participant::Participant as DbParticipant;
|
use kordophone_db::models::participant::Participant as DbParticipant;
|
||||||
|
|
||||||
@@ -507,7 +507,7 @@ impl Daemon {
|
|||||||
|
|
||||||
// Insert each conversation
|
// Insert each conversation
|
||||||
let num_conversations = db_conversations.len();
|
let num_conversations = db_conversations.len();
|
||||||
let mut contact_resolver = ContactResolver::new(EDSContactResolverBackend::default());
|
let mut contact_resolver = ContactResolver::new(DefaultContactResolverBackend::default());
|
||||||
for conversation in db_conversations {
|
for conversation in db_conversations {
|
||||||
// Insert or update conversation and its participants
|
// Insert or update conversation and its participants
|
||||||
database
|
database
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use crate::daemon::{
|
|||||||
settings::Settings,
|
settings::Settings,
|
||||||
signals::Signal,
|
signals::Signal,
|
||||||
DaemonResult,
|
DaemonResult,
|
||||||
contact_resolver::{ContactResolver, EDSContactResolverBackend},
|
contact_resolver::{ContactResolver, DefaultContactResolverBackend},
|
||||||
};
|
};
|
||||||
|
|
||||||
use kordophone_db::models::participant::Participant;
|
use kordophone_db::models::participant::Participant;
|
||||||
@@ -23,7 +23,7 @@ use dbus_tokio::connection;
|
|||||||
pub struct DBusAgent {
|
pub struct DBusAgent {
|
||||||
event_sink: mpsc::Sender<Event>,
|
event_sink: mpsc::Sender<Event>,
|
||||||
signal_receiver: Arc<Mutex<Option<mpsc::Receiver<Signal>>>>,
|
signal_receiver: Arc<Mutex<Option<mpsc::Receiver<Signal>>>>,
|
||||||
contact_resolver: ContactResolver<EDSContactResolverBackend>,
|
contact_resolver: ContactResolver<DefaultContactResolverBackend>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DBusAgent {
|
impl DBusAgent {
|
||||||
@@ -31,7 +31,7 @@ impl DBusAgent {
|
|||||||
Self {
|
Self {
|
||||||
event_sink,
|
event_sink,
|
||||||
signal_receiver: Arc::new(Mutex::new(Some(signal_receiver))),
|
signal_receiver: Arc::new(Mutex::new(Some(signal_receiver))),
|
||||||
contact_resolver: ContactResolver::new(EDSContactResolverBackend::default()),
|
contact_resolver: ContactResolver::new(DefaultContactResolverBackend::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
mod daemon;
|
mod daemon;
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
mod dbus;
|
mod dbus;
|
||||||
|
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
@@ -6,8 +8,6 @@ use std::future;
|
|||||||
|
|
||||||
use daemon::Daemon;
|
use daemon::Daemon;
|
||||||
|
|
||||||
use dbus::agent::DBusAgent;
|
|
||||||
|
|
||||||
fn initialize_logging() {
|
fn initialize_logging() {
|
||||||
// Weird: is this the best way to do this?
|
// Weird: is this the best way to do this?
|
||||||
let log_level = std::env::var("RUST_LOG")
|
let log_level = std::env::var("RUST_LOG")
|
||||||
@@ -20,6 +20,27 @@ fn initialize_logging() {
|
|||||||
.init();
|
.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
async fn start_ipc_agent(daemon: &Daemon) {
|
||||||
|
use dbus::agent::DBusAgent;
|
||||||
|
|
||||||
|
// Start the D-Bus agent (events in, signals out).
|
||||||
|
let agent = DBusAgent::new(daemon.event_sender.clone(), daemon.obtain_signal_receiver());
|
||||||
|
tokio::spawn(async move {
|
||||||
|
agent.run().await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
async fn start_ipc_agent(daemon: &Daemon) {
|
||||||
|
// TODO: Implement macOS IPC agent.
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||||
|
async fn start_ipc_agent(daemon: &Daemon) {
|
||||||
|
panic!("Unsupported IPC platform");
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
initialize_logging();
|
initialize_logging();
|
||||||
@@ -32,11 +53,8 @@ async fn main() {
|
|||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Start the D-Bus agent (events in, signals out).
|
// Start the IPC agent.
|
||||||
let agent = DBusAgent::new(daemon.event_sender.clone(), daemon.obtain_signal_receiver());
|
start_ipc_agent(&daemon).await;
|
||||||
tokio::spawn(async move {
|
|
||||||
agent.run().await;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Run the main daemon loop.
|
// Run the main daemon loop.
|
||||||
daemon.run().await;
|
daemon.run().await;
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.93"
|
anyhow = "1.0.93"
|
||||||
clap = { version = "4.5.20", features = ["derive"] }
|
clap = { version = "4.5.20", features = ["derive"] }
|
||||||
dbus = "0.9.7"
|
|
||||||
dbus-tree = "0.9.2"
|
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
env_logger = "0.11.8"
|
env_logger = "0.11.8"
|
||||||
futures-util = "0.3.31"
|
futures-util = "0.3.31"
|
||||||
@@ -22,5 +20,11 @@ serde_json = "1.0"
|
|||||||
time = "0.3.37"
|
time = "0.3.37"
|
||||||
tokio = "1.41.1"
|
tokio = "1.41.1"
|
||||||
|
|
||||||
[build-dependencies]
|
# D-Bus dependencies only on Linux
|
||||||
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
|
dbus = "0.9.7"
|
||||||
|
dbus-tree = "0.9.2"
|
||||||
|
|
||||||
|
# D-Bus codegen only on Linux
|
||||||
|
[target.'cfg(target_os = "linux")'.build-dependencies]
|
||||||
dbus-codegen = "0.10.0"
|
dbus-codegen = "0.10.0"
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
const KORDOPHONE_XML: &str = "../kordophoned/include/net.buzzert.kordophonecd.Server.xml";
|
const KORDOPHONE_XML: &str = "../kordophoned/include/net.buzzert.kordophonecd.Server.xml";
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
fn main() {
|
||||||
|
// No D-Bus codegen on non-Linux platforms
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
fn main() {
|
fn main() {
|
||||||
let out_dir = std::env::var("OUT_DIR").unwrap();
|
let out_dir = std::env::var("OUT_DIR").unwrap();
|
||||||
let out_path = std::path::Path::new(&out_dir).join("kordophone-client.rs");
|
let out_path = std::path::Path::new(&out_dir).join("kordophone-client.rs");
|
||||||
@@ -10,10 +16,11 @@ fn main() {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let xml = std::fs::read_to_string(KORDOPHONE_XML).expect("Error reading server dbus interface");
|
let xml = std::fs::read_to_string(KORDOPHONE_XML)
|
||||||
|
.expect("Error reading server dbus interface");
|
||||||
|
|
||||||
let output =
|
let output = dbus_codegen::generate(&xml, &opts)
|
||||||
dbus_codegen::generate(&xml, &opts).expect("Error generating client dbus interface");
|
.expect("Error generating client dbus interface");
|
||||||
|
|
||||||
std::fs::write(out_path, output).expect("Error writing client dbus code");
|
std::fs::write(out_path, output).expect("Error writing client dbus code");
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
mod client;
|
mod client;
|
||||||
mod daemon;
|
|
||||||
mod db;
|
mod db;
|
||||||
mod printers;
|
mod printers;
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
mod daemon;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
|
|||||||
Reference in New Issue
Block a user