Implement the Presence interface for the protocol
This commit is contained in:
@@ -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())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user