kordophoned sans kpcli building on macos
This commit is contained in:
@@ -21,6 +21,7 @@ impl DatabaseAuthenticationStore {
|
||||
|
||||
#[async_trait]
|
||||
impl AuthenticationStore for DatabaseAuthenticationStore {
|
||||
#[cfg(target_os = "linux")]
|
||||
async fn get_credentials(&mut self) -> Option<Credentials> {
|
||||
use keyring::secret_service::SsCredential;
|
||||
|
||||
@@ -61,6 +62,11 @@ impl AuthenticationStore for DatabaseAuthenticationStore {
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
async fn get_credentials(&mut self) -> Option<Credentials> {
|
||||
None
|
||||
}
|
||||
|
||||
async fn get_token(&mut self) -> Option<String> {
|
||||
self.database
|
||||
.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 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;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ pub use attachment_store::AttachmentStoreEvent;
|
||||
|
||||
pub mod contact_resolver;
|
||||
use contact_resolver::ContactResolver;
|
||||
use contact_resolver::EDSContactResolverBackend;
|
||||
use contact_resolver::DefaultContactResolverBackend;
|
||||
|
||||
use kordophone_db::models::participant::Participant as DbParticipant;
|
||||
|
||||
@@ -507,7 +507,7 @@ impl Daemon {
|
||||
|
||||
// Insert each conversation
|
||||
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 {
|
||||
// Insert or update conversation and its participants
|
||||
database
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::daemon::{
|
||||
settings::Settings,
|
||||
signals::Signal,
|
||||
DaemonResult,
|
||||
contact_resolver::{ContactResolver, EDSContactResolverBackend},
|
||||
contact_resolver::{ContactResolver, DefaultContactResolverBackend},
|
||||
};
|
||||
|
||||
use kordophone_db::models::participant::Participant;
|
||||
@@ -23,7 +23,7 @@ use dbus_tokio::connection;
|
||||
pub struct DBusAgent {
|
||||
event_sink: mpsc::Sender<Event>,
|
||||
signal_receiver: Arc<Mutex<Option<mpsc::Receiver<Signal>>>>,
|
||||
contact_resolver: ContactResolver<EDSContactResolverBackend>,
|
||||
contact_resolver: ContactResolver<DefaultContactResolverBackend>,
|
||||
}
|
||||
|
||||
impl DBusAgent {
|
||||
@@ -31,7 +31,7 @@ impl DBusAgent {
|
||||
Self {
|
||||
event_sink,
|
||||
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;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
mod dbus;
|
||||
|
||||
use log::LevelFilter;
|
||||
@@ -6,8 +8,6 @@ use std::future;
|
||||
|
||||
use daemon::Daemon;
|
||||
|
||||
use dbus::agent::DBusAgent;
|
||||
|
||||
fn initialize_logging() {
|
||||
// Weird: is this the best way to do this?
|
||||
let log_level = std::env::var("RUST_LOG")
|
||||
@@ -20,6 +20,27 @@ fn initialize_logging() {
|
||||
.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]
|
||||
async fn main() {
|
||||
initialize_logging();
|
||||
@@ -32,11 +53,8 @@ async fn main() {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
// 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;
|
||||
});
|
||||
// Start the IPC agent.
|
||||
start_ipc_agent(&daemon).await;
|
||||
|
||||
// Run the main daemon loop.
|
||||
daemon.run().await;
|
||||
|
||||
Reference in New Issue
Block a user