173 lines
5.9 KiB
Rust
173 lines
5.9 KiB
Rust
// This code was autogenerated with `dbus-codegen-rust --file telepathy-spec/spec/Account_Manager.xml -i org.freedesktop.Telepathy -a AsRefClosure -o src/telepathy/account_manager.rs`, see https://github.com/diwic/dbus-rs
|
|
use dbus;
|
|
use dbus::arg;
|
|
use dbus::tree;
|
|
|
|
pub trait AccountManager {
|
|
fn create_account(
|
|
&self,
|
|
connection_manager: &str,
|
|
protocol: &str,
|
|
display_name: &str,
|
|
parameters: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
|
|
properties: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
|
|
) -> Result<dbus::Path<'static>, tree::MethodErr>;
|
|
fn interfaces(&self) -> Result<Vec<String>, tree::MethodErr>;
|
|
fn valid_accounts(&self) -> Result<Vec<dbus::Path<'static>>, tree::MethodErr>;
|
|
fn invalid_accounts(&self) -> Result<Vec<dbus::Path<'static>>, tree::MethodErr>;
|
|
fn supported_account_properties(&self) -> Result<Vec<String>, tree::MethodErr>;
|
|
}
|
|
|
|
pub fn account_manager_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 AccountManager>,
|
|
F: 'static + Fn(&tree::MethodInfo<tree::MTFn<D>, D>) -> T,
|
|
{
|
|
let i = factory.interface("org.freedesktop.Telepathy.AccountManager", 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 connection_manager: &str = i.read()?;
|
|
let protocol: &str = i.read()?;
|
|
let display_name: &str = i.read()?;
|
|
let parameters: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>> =
|
|
i.read()?;
|
|
let properties: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>> =
|
|
i.read()?;
|
|
let dd = fclone(minfo);
|
|
let d = dd.as_ref();
|
|
let account = d.create_account(
|
|
connection_manager,
|
|
protocol,
|
|
display_name,
|
|
parameters,
|
|
properties,
|
|
)?;
|
|
let rm = minfo.msg.method_return();
|
|
let rm = rm.append1(account);
|
|
Ok(vec![rm])
|
|
};
|
|
let m = factory.method("CreateAccount", Default::default(), h);
|
|
let m = m.in_arg(("Connection_Manager", "s"));
|
|
let m = m.in_arg(("Protocol", "s"));
|
|
let m = m.in_arg(("Display_Name", "s"));
|
|
let m = m.in_arg(("Parameters", "a{sv}"));
|
|
let m = m.in_arg(("Properties", "a{sv}"));
|
|
let m = m.out_arg(("Account", "o"));
|
|
let i = i.add_m(m);
|
|
|
|
let p = factory.property::<Vec<&str>, _>("Interfaces", 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.interfaces()?);
|
|
Ok(())
|
|
});
|
|
let i = i.add_p(p);
|
|
|
|
let p = factory.property::<Vec<dbus::Path>, _>("ValidAccounts", 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.valid_accounts()?);
|
|
Ok(())
|
|
});
|
|
let i = i.add_p(p);
|
|
|
|
let p = factory.property::<Vec<dbus::Path>, _>("InvalidAccounts", 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.invalid_accounts()?);
|
|
Ok(())
|
|
});
|
|
let i = i.add_p(p);
|
|
|
|
let p = factory.property::<Vec<&str>, _>("SupportedAccountProperties", 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.supported_account_properties()?);
|
|
Ok(())
|
|
});
|
|
let i = i.add_p(p);
|
|
let s = factory.signal("AccountRemoved", Default::default());
|
|
let s = s.arg(("Account", "o"));
|
|
let i = i.add_s(s);
|
|
let s = factory.signal("AccountValidityChanged", Default::default());
|
|
let s = s.arg(("Account", "o"));
|
|
let s = s.arg(("Valid", "b"));
|
|
let i = i.add_s(s);
|
|
i
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct AccountManagerAccountRemoved {
|
|
pub account: dbus::Path<'static>,
|
|
}
|
|
|
|
impl arg::AppendAll for AccountManagerAccountRemoved {
|
|
fn append(&self, i: &mut arg::IterAppend) {
|
|
arg::RefArg::append(&self.account, i);
|
|
}
|
|
}
|
|
|
|
impl arg::ReadAll for AccountManagerAccountRemoved {
|
|
fn read(i: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
|
|
Ok(AccountManagerAccountRemoved { account: i.read()? })
|
|
}
|
|
}
|
|
|
|
impl dbus::message::SignalArgs for AccountManagerAccountRemoved {
|
|
const NAME: &'static str = "AccountRemoved";
|
|
const INTERFACE: &'static str = "org.freedesktop.Telepathy.AccountManager";
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct AccountManagerAccountValidityChanged {
|
|
pub account: dbus::Path<'static>,
|
|
pub valid: bool,
|
|
}
|
|
|
|
impl arg::AppendAll for AccountManagerAccountValidityChanged {
|
|
fn append(&self, i: &mut arg::IterAppend) {
|
|
arg::RefArg::append(&self.account, i);
|
|
arg::RefArg::append(&self.valid, i);
|
|
}
|
|
}
|
|
|
|
impl arg::ReadAll for AccountManagerAccountValidityChanged {
|
|
fn read(i: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
|
|
Ok(AccountManagerAccountValidityChanged {
|
|
account: i.read()?,
|
|
valid: i.read()?,
|
|
})
|
|
}
|
|
}
|
|
|
|
impl dbus::message::SignalArgs for AccountManagerAccountValidityChanged {
|
|
const NAME: &'static str = "AccountValidityChanged";
|
|
const INTERFACE: &'static str = "org.freedesktop.Telepathy.AccountManager";
|
|
}
|