Clean up dbus::arg::Variant type alias
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::padfoot::{var_str, VarArg};
|
||||
use crate::telepathy;
|
||||
|
||||
use dbus::arg::{RefArg, Variant};
|
||||
use dbus::tree::MethodErr;
|
||||
use deltachat::contact::{Contact, Origin};
|
||||
use std::collections::HashMap;
|
||||
@@ -13,16 +13,13 @@ impl AsRef<dyn telepathy::ConnectionInterfaceContacts + 'static> for std::rc::Rc
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: extract a utility module for this?
|
||||
type VarArgs = Variant<Box<dyn RefArg + 'static>>;
|
||||
|
||||
impl telepathy::ConnectionInterfaceContacts for Connection {
|
||||
fn get_contact_attributes(
|
||||
&self,
|
||||
handles: Vec<u32>,
|
||||
interfaces: Vec<&str>,
|
||||
hold: bool,
|
||||
) -> Result<HashMap<u32, HashMap<String, VarArgs>>, MethodErr> {
|
||||
) -> Result<HashMap<u32, HashMap<String, VarArg>>, MethodErr> {
|
||||
println!(
|
||||
"Connection<{}>::get_contact_attributes({:?}, {:?}, {})",
|
||||
self.id(),
|
||||
@@ -31,7 +28,7 @@ impl telepathy::ConnectionInterfaceContacts for Connection {
|
||||
hold
|
||||
);
|
||||
|
||||
let mut out = HashMap::<u32, HashMap<String, VarArgs>>::new();
|
||||
let mut out = HashMap::<u32, HashMap<String, VarArg>>::new();
|
||||
for id in handles.iter() {
|
||||
// FIXME: work out how to use get_all
|
||||
let contact = match Contact::get_by_id(&self.ctx.read().unwrap(), *id) {
|
||||
@@ -39,28 +36,28 @@ impl telepathy::ConnectionInterfaceContacts for Connection {
|
||||
Err(_e) => continue, // Invalid IDs are silently ignored
|
||||
};
|
||||
|
||||
let mut props = HashMap::<String, VarArgs>::new();
|
||||
let mut props = HashMap::<String, VarArg>::new();
|
||||
// This is mandatory
|
||||
props.insert(
|
||||
"org.freedesktop.Telepathy.Connection/contact-id".to_string(),
|
||||
Variant(Box::new(contact.get_addr().to_string())),
|
||||
var_str(contact.get_addr().to_string()),
|
||||
);
|
||||
|
||||
// The empty string means "no avatar"
|
||||
props.insert(
|
||||
"org.freedesktop.Telepathy.Connection.Interface.Avatars/token".to_string(),
|
||||
Variant(Box::new("".to_string())),
|
||||
var_str("".to_string()),
|
||||
);
|
||||
/*
|
||||
// TODO: we need to publish DBUS services on these endpoints
|
||||
props.insert(
|
||||
"org.freedesktop.Telepathy.Connection.Interface.ContactList/publish".to_string(),
|
||||
Variant(Box::new(4)),
|
||||
var_arg(Box::new(4)),
|
||||
);
|
||||
|
||||
props.insert(
|
||||
"org.freedesktop.Telepathy.Connection.Interface.ContactList/subscribe".to_string(),
|
||||
Variant(Box::new(4)),
|
||||
var_arg(Box::new(4)),
|
||||
);
|
||||
*/
|
||||
out.insert(*id, props);
|
||||
@@ -73,7 +70,7 @@ impl telepathy::ConnectionInterfaceContacts for Connection {
|
||||
&self,
|
||||
identifier: &str,
|
||||
interfaces: Vec<&str>,
|
||||
) -> Result<(u32, HashMap<String, VarArgs>), MethodErr> {
|
||||
) -> Result<(u32, HashMap<String, VarArg>), MethodErr> {
|
||||
println!(
|
||||
"Connection<{}>::get_contact_by_id({}, {:?})",
|
||||
self.id(),
|
||||
|
Reference in New Issue
Block a user