Implement the Presence interface for the protocol

This commit is contained in:
2020-05-16 21:22:49 +01:00
parent 4a501b2e07
commit 011ee98340
3 changed files with 48 additions and 15 deletions

View File

@@ -54,6 +54,13 @@ pub fn parameters() -> Vec<ParamSpec> {
]
}
pub fn protocol_interfaces() -> Vec<String> {
vec![
"org.freedesktop.Telepathy.Protocol".to_string(),
"org.freedesktop.Telepathy.Protocol.Interface.Presence".to_string(),
]
}
pub fn requestables() -> Vec<RequestableChannelSpec> {
let mut rf = HashMap::<String, Variant>::new();
@@ -101,7 +108,7 @@ impl telepathy::Protocol for Protocol {
fn interfaces(&self) -> Result<Vec<String>, MethodErr> {
println!("Protocol::interfaces()");
Ok(vec![])
Ok(protocol_interfaces())
}
fn parameters(&self) -> Result<Vec<ParamSpec>, MethodErr> {
@@ -148,3 +155,32 @@ impl telepathy::Protocol for Protocol {
])
}
}
pub type SimpleStatusSpec = (
u32, // connection presence type
bool, // may set on self?
bool, // can have message?
);
pub fn statuses() -> HashMap<String, SimpleStatusSpec> {
let mut out = HashMap::<String, SimpleStatusSpec>::new();
out.insert("available".to_string(), (2, true, false));
out.insert("offline".to_string(), (1, true, false));
out
}
impl AsRef<dyn telepathy::ProtocolInterfacePresence + 'static> for std::rc::Rc<Protocol> {
fn as_ref(&self) -> &(dyn telepathy::ProtocolInterfacePresence + 'static) {
&**self
}
}
impl telepathy::ProtocolInterfacePresence for Protocol {
fn statuses(&self) -> Result<HashMap<String, SimpleStatusSpec>, MethodErr> {
println!("Protocol::presences()");
Ok(statuses())
}
}