This commit contains autogenerated telepathy DBUS code and the output of `cargo new telepathy-delta`. It's pretty chill.
107 lines
3.8 KiB
Rust
107 lines
3.8 KiB
Rust
// This code was autogenerated with `dbus-codegen-rust --file telepathy-spec/spec/Connection_Interface_Communication_Policy.xml -i org.freedesktop.Telepathy -o src/telepathy/connection_interface_communication_policy.rs`, see https://github.com/diwic/dbus-rs
|
|
use dbus;
|
|
use dbus::arg;
|
|
use dbus::tree;
|
|
|
|
pub trait ConnectionInterfaceCommunicationPolicyDRAFT {
|
|
fn set_policy(
|
|
&self,
|
|
channel_type: &str,
|
|
policy: (u32, arg::Variant<Box<dyn arg::RefArg>>),
|
|
) -> Result<(), tree::MethodErr>;
|
|
fn supported_policies(&self) -> Result<Vec<(Vec<String>, Vec<u32>)>, tree::MethodErr>;
|
|
fn active_policies(
|
|
&self,
|
|
) -> Result<
|
|
::std::collections::HashMap<String, (u32, arg::Variant<Box<dyn arg::RefArg + 'static>>)>,
|
|
tree::MethodErr,
|
|
>;
|
|
}
|
|
|
|
pub fn connection_interface_communication_policy_draft_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: ConnectionInterfaceCommunicationPolicyDRAFT,
|
|
F: 'static + for<'z> Fn(&'z tree::MethodInfo<tree::MTFn<D>, D>) -> &'z T,
|
|
{
|
|
let i = factory.interface(
|
|
"org.freedesktop.Telepathy.Connection.Interface.CommunicationPolicy.DRAFT",
|
|
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 channel_type: &str = i.read()?;
|
|
let policy: (u32, arg::Variant<Box<dyn arg::RefArg>>) = i.read()?;
|
|
let d = fclone(minfo);
|
|
d.set_policy(channel_type, policy)?;
|
|
let rm = minfo.msg.method_return();
|
|
Ok(vec![rm])
|
|
};
|
|
let m = factory.method("SetPolicy", Default::default(), h);
|
|
let m = m.in_arg(("Channel_Type", "s"));
|
|
let m = m.in_arg(("Policy", "(uv)"));
|
|
let i = i.add_m(m);
|
|
|
|
let p =
|
|
factory.property::<Vec<(Vec<&str>, Vec<u32>)>, _>("SupportedPolicies", 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 d = fclone(&minfo);
|
|
a.append(d.supported_policies()?);
|
|
Ok(())
|
|
});
|
|
let i = i.add_p(p);
|
|
|
|
let p = factory.property::<::std::collections::HashMap<&str, (u32, arg::Variant<Box<dyn arg::RefArg>>)>, _>("ActivePolicies", 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 d = fclone(&minfo);
|
|
a.append(d.active_policies()?);
|
|
Ok(())
|
|
});
|
|
let i = i.add_p(p);
|
|
let s = factory.signal("PolicyChanged", Default::default());
|
|
let s = s.arg(("Changed_Policies", "a{s(uv)}"));
|
|
let i = i.add_s(s);
|
|
i
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct ConnectionInterfaceCommunicationPolicyDRAFTPolicyChanged {
|
|
pub changed_policies:
|
|
::std::collections::HashMap<String, (u32, arg::Variant<Box<dyn arg::RefArg + 'static>>)>,
|
|
}
|
|
|
|
impl arg::AppendAll for ConnectionInterfaceCommunicationPolicyDRAFTPolicyChanged {
|
|
fn append(&self, i: &mut arg::IterAppend) {
|
|
arg::RefArg::append(&self.changed_policies, i);
|
|
}
|
|
}
|
|
|
|
impl arg::ReadAll for ConnectionInterfaceCommunicationPolicyDRAFTPolicyChanged {
|
|
fn read(i: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
|
|
Ok(ConnectionInterfaceCommunicationPolicyDRAFTPolicyChanged {
|
|
changed_policies: i.read()?,
|
|
})
|
|
}
|
|
}
|
|
|
|
impl dbus::message::SignalArgs for ConnectionInterfaceCommunicationPolicyDRAFTPolicyChanged {
|
|
const NAME: &'static str = "PolicyChanged";
|
|
const INTERFACE: &'static str =
|
|
"org.freedesktop.Telepathy.Connection.Interface.CommunicationPolicy.DRAFT";
|
|
}
|