125 lines
4.5 KiB
Rust
125 lines
4.5 KiB
Rust
// This code was autogenerated with `dbus-codegen-rust --file telepathy-spec/spec/Connection_Interface_Contact_Blocking.xml -i org.freedesktop.Telepathy -a AsRefClosure -o src/telepathy/connection_interface_contact_blocking.rs`, see https://github.com/diwic/dbus-rs
|
|
use dbus;
|
|
use dbus::arg;
|
|
use dbus::tree;
|
|
|
|
pub trait ConnectionInterfaceContactBlocking {
|
|
fn block_contacts(
|
|
&self,
|
|
contacts: Vec<u32>,
|
|
report_abusive: bool,
|
|
) -> Result<(), tree::MethodErr>;
|
|
fn unblock_contacts(&self, contacts: Vec<u32>) -> Result<(), tree::MethodErr>;
|
|
fn request_blocked_contacts(
|
|
&self,
|
|
) -> Result<::std::collections::HashMap<u32, String>, tree::MethodErr>;
|
|
fn contact_blocking_capabilities(&self) -> Result<u32, tree::MethodErr>;
|
|
}
|
|
|
|
pub fn connection_interface_contact_blocking_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,
|
|
D::Signal: Default,
|
|
T: AsRef<dyn ConnectionInterfaceContactBlocking>,
|
|
F: 'static + Fn(&tree::MethodInfo<tree::MTFn<D>, D>) -> T,
|
|
{
|
|
let i = factory.interface(
|
|
"org.freedesktop.Telepathy.Connection.Interface.ContactBlocking",
|
|
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 contacts: Vec<u32> = i.read()?;
|
|
let report_abusive: bool = i.read()?;
|
|
let dd = fclone(minfo);
|
|
let d = dd.as_ref();
|
|
d.block_contacts(contacts, report_abusive)?;
|
|
let rm = minfo.msg.method_return();
|
|
Ok(vec![rm])
|
|
};
|
|
let m = factory.method("BlockContacts", Default::default(), h);
|
|
let m = m.in_arg(("Contacts", "au"));
|
|
let m = m.in_arg(("Report_Abusive", "b"));
|
|
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 contacts: Vec<u32> = i.read()?;
|
|
let dd = fclone(minfo);
|
|
let d = dd.as_ref();
|
|
d.unblock_contacts(contacts)?;
|
|
let rm = minfo.msg.method_return();
|
|
Ok(vec![rm])
|
|
};
|
|
let m = factory.method("UnblockContacts", Default::default(), h);
|
|
let m = m.in_arg(("Contacts", "au"));
|
|
let i = i.add_m(m);
|
|
|
|
let fclone = f.clone();
|
|
let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| {
|
|
let dd = fclone(minfo);
|
|
let d = dd.as_ref();
|
|
let contacts = d.request_blocked_contacts()?;
|
|
let rm = minfo.msg.method_return();
|
|
let rm = rm.append1(contacts);
|
|
Ok(vec![rm])
|
|
};
|
|
let m = factory.method("RequestBlockedContacts", Default::default(), h);
|
|
let m = m.out_arg(("Contacts", "a{us}"));
|
|
let i = i.add_m(m);
|
|
|
|
let p = factory.property::<u32, _>("ContactBlockingCapabilities", 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_blocking_capabilities()?);
|
|
Ok(())
|
|
});
|
|
let i = i.add_p(p);
|
|
let s = factory.signal("BlockedContactsChanged", Default::default());
|
|
let s = s.arg(("Blocked_Contacts", "a{us}"));
|
|
let s = s.arg(("Unblocked_Contacts", "a{us}"));
|
|
let i = i.add_s(s);
|
|
i
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct ConnectionInterfaceContactBlockingBlockedContactsChanged {
|
|
pub blocked_contacts: ::std::collections::HashMap<u32, String>,
|
|
pub unblocked_contacts: ::std::collections::HashMap<u32, String>,
|
|
}
|
|
|
|
impl arg::AppendAll for ConnectionInterfaceContactBlockingBlockedContactsChanged {
|
|
fn append(&self, i: &mut arg::IterAppend) {
|
|
arg::RefArg::append(&self.blocked_contacts, i);
|
|
arg::RefArg::append(&self.unblocked_contacts, i);
|
|
}
|
|
}
|
|
|
|
impl arg::ReadAll for ConnectionInterfaceContactBlockingBlockedContactsChanged {
|
|
fn read(i: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
|
|
Ok(ConnectionInterfaceContactBlockingBlockedContactsChanged {
|
|
blocked_contacts: i.read()?,
|
|
unblocked_contacts: i.read()?,
|
|
})
|
|
}
|
|
}
|
|
|
|
impl dbus::message::SignalArgs for ConnectionInterfaceContactBlockingBlockedContactsChanged {
|
|
const NAME: &'static str = "BlockedContactsChanged";
|
|
const INTERFACE: &'static str =
|
|
"org.freedesktop.Telepathy.Connection.Interface.ContactBlocking";
|
|
}
|