119 lines
4.0 KiB
Rust
119 lines
4.0 KiB
Rust
// This code was autogenerated with `dbus-codegen-rust --file telepathy-spec/spec/Client_Observer.xml -i org.freedesktop.Telepathy -a AsRefClosure -o src/telepathy/client_observer.rs`, see https://github.com/diwic/dbus-rs
|
|
use dbus;
|
|
use dbus::arg;
|
|
use dbus::tree;
|
|
|
|
pub trait ClientObserver {
|
|
fn observe_channels(
|
|
&self,
|
|
account: dbus::Path,
|
|
connection: dbus::Path,
|
|
channels: Vec<(
|
|
dbus::Path,
|
|
::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
|
|
)>,
|
|
dispatch_operation: dbus::Path,
|
|
requests_satisfied: Vec<dbus::Path>,
|
|
observer_info: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
|
|
) -> Result<(), tree::MethodErr>;
|
|
fn observer_channel_filter(
|
|
&self,
|
|
) -> Result<
|
|
Vec<::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg + 'static>>>>,
|
|
tree::MethodErr,
|
|
>;
|
|
fn recover(&self) -> Result<bool, tree::MethodErr>;
|
|
fn delay_approvers(&self) -> Result<bool, tree::MethodErr>;
|
|
}
|
|
|
|
pub fn client_observer_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 ClientObserver>,
|
|
F: 'static + Fn(&tree::MethodInfo<tree::MTFn<D>, D>) -> T,
|
|
{
|
|
let i = factory.interface("org.freedesktop.Telepathy.Client.Observer", 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 account: dbus::Path = i.read()?;
|
|
let connection: dbus::Path = i.read()?;
|
|
let channels: Vec<(
|
|
dbus::Path,
|
|
::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
|
|
)> = i.read()?;
|
|
let dispatch_operation: dbus::Path = i.read()?;
|
|
let requests_satisfied: Vec<dbus::Path> = i.read()?;
|
|
let observer_info: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>> =
|
|
i.read()?;
|
|
let dd = fclone(minfo);
|
|
let d = dd.as_ref();
|
|
d.observe_channels(
|
|
account,
|
|
connection,
|
|
channels,
|
|
dispatch_operation,
|
|
requests_satisfied,
|
|
observer_info,
|
|
)?;
|
|
let rm = minfo.msg.method_return();
|
|
Ok(vec![rm])
|
|
};
|
|
let m = factory.method("ObserveChannels", Default::default(), h);
|
|
let m = m.in_arg(("Account", "o"));
|
|
let m = m.in_arg(("Connection", "o"));
|
|
let m = m.in_arg(("Channels", "a(oa{sv})"));
|
|
let m = m.in_arg(("Dispatch_Operation", "o"));
|
|
let m = m.in_arg(("Requests_Satisfied", "ao"));
|
|
let m = m.in_arg(("Observer_Info", "a{sv}"));
|
|
let i = i.add_m(m);
|
|
|
|
let p = factory
|
|
.property::<Vec<::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>>, _>(
|
|
"ObserverChannelFilter",
|
|
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.observer_channel_filter()?);
|
|
Ok(())
|
|
});
|
|
let i = i.add_p(p);
|
|
|
|
let p = factory.property::<bool, _>("Recover", 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.recover()?);
|
|
Ok(())
|
|
});
|
|
let i = i.add_p(p);
|
|
|
|
let p = factory.property::<bool, _>("DelayApprovers", 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.delay_approvers()?);
|
|
Ok(())
|
|
});
|
|
let i = i.add_p(p);
|
|
i
|
|
}
|