Files
telepathy-padfoot/src/telepathy/connection_interface_contacts.rs

105 lines
3.5 KiB
Rust

#![allow(clippy::all)]
// This code was autogenerated with `dbus-codegen-rust --file telepathy-spec/spec/Connection_Interface_Contacts.xml -i org.freedesktop.Telepathy -a AsRefClosure -o src/telepathy/connection_interface_contacts.rs`, see https://github.com/diwic/dbus-rs
use dbus;
use dbus::arg;
use dbus::tree;
pub trait ConnectionInterfaceContacts {
fn get_contact_attributes(
&self,
handles: Vec<u32>,
interfaces: Vec<&str>,
hold: bool,
) -> Result<
::std::collections::HashMap<
u32,
::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg + 'static>>>,
>,
tree::MethodErr,
>;
fn get_contact_by_id(
&self,
identifier: &str,
interfaces: Vec<&str>,
) -> Result<
(
u32,
::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg + 'static>>>,
),
tree::MethodErr,
>;
fn contact_attribute_interfaces(&self) -> Result<Vec<String>, tree::MethodErr>;
}
pub fn connection_interface_contacts_server<F, T, D>(
factory: &tree::Factory<tree::MTFn<D>, D>,
data: D::Interface,
f: F,
) -> tree::Interface<tree::MTFn<D>, D>
where
D: tree::DataType,
D::Method: Default,
D::Property: Default,
T: AsRef<dyn ConnectionInterfaceContacts>,
F: 'static + Fn(&tree::MethodInfo<tree::MTFn<D>, D>) -> T,
{
let i = factory.interface(
"org.freedesktop.Telepathy.Connection.Interface.Contacts",
data,
);
let f = ::std::sync::Arc::new(f);
let fclone = f.clone();
let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| {
let mut i = minfo.msg.iter_init();
let handles: Vec<u32> = i.read()?;
let interfaces: Vec<&str> = i.read()?;
let hold: bool = i.read()?;
let dd = fclone(minfo);
let d = dd.as_ref();
let attributes = d.get_contact_attributes(handles, interfaces, hold)?;
let rm = minfo.msg.method_return();
let rm = rm.append1(attributes);
Ok(vec![rm])
};
let m = factory.method("GetContactAttributes", Default::default(), h);
let m = m.in_arg(("Handles", "au"));
let m = m.in_arg(("Interfaces", "as"));
let m = m.in_arg(("Hold", "b"));
let m = m.out_arg(("Attributes", "a{ua{sv}}"));
let i = i.add_m(m);
let fclone = f.clone();
let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| {
let mut i = minfo.msg.iter_init();
let identifier: &str = i.read()?;
let interfaces: Vec<&str> = i.read()?;
let dd = fclone(minfo);
let d = dd.as_ref();
let (handle, attributes) = d.get_contact_by_id(identifier, interfaces)?;
let rm = minfo.msg.method_return();
let rm = rm.append1(handle);
let rm = rm.append1(attributes);
Ok(vec![rm])
};
let m = factory.method("GetContactByID", Default::default(), h);
let m = m.in_arg(("Identifier", "s"));
let m = m.in_arg(("Interfaces", "as"));
let m = m.out_arg(("Handle", "u"));
let m = m.out_arg(("Attributes", "a{sv}"));
let i = i.add_m(m);
let p = factory.property::<Vec<&str>, _>("ContactAttributeInterfaces", Default::default());
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let dd = fclone(&minfo);
let d = dd.as_ref();
a.append(d.contact_attribute_interfaces()?);
Ok(())
});
let i = i.add_p(p);
i
}