From ffb190385e7e79606c8c40ecb684439b6b971efc Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Sun, 10 May 2020 00:33:15 +0100 Subject: [PATCH] Make the protocol advertise a requestable channel Without this, telepathy-glib/empathy doesn't believe the protocol is bonafide (i.e., implementing TP_PROTOCOL_FEATURE_CORE). Adding a dummy gets empathy to display the protocol without needing to be patched \o/. --- share/telepathy/managers/padfoot.manager | 13 ++++- src/padfoot/connection_manager.rs | 11 ++-- src/padfoot/protocol.rs | 64 +++++++++++++++++------- 3 files changed, 67 insertions(+), 21 deletions(-) diff --git a/share/telepathy/managers/padfoot.manager b/share/telepathy/managers/padfoot.manager index 215ebd5..f14780c 100644 --- a/share/telepathy/managers/padfoot.manager +++ b/share/telepathy/managers/padfoot.manager @@ -1,4 +1,5 @@ [ConnectionManager] +Interfaces= Name=padfoot BusName=org.freedesktop.Telepathy.ConnectionManager.padfoot ObjectPath=/org/freedesktop/Telepathy/ConnectionManager/padfoot @@ -6,6 +7,16 @@ ObjectPath=/org/freedesktop/Telepathy/ConnectionManager/padfoot [Protocol delta] param-account=s required param-password=s required secret + +AuthenticationTypes=org.freedesktop.Telepathy.Channel.Type.ServerTLSConnection; +ConnectionInterfaces=org.freedesktop.Telepathy.Connection.Interface.Requests;org.freedesktop.Telepathy.Connection.Interface.Contacts; EnglishName=Delta Chat -VCardField=email Icon=im-delta +Interfaces= +RequestableChannelClasses=text; +VCardField=email + +[text] +org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Text +org.freedesktop.Telepathy.Channel.TargetHandleType u=1 +allowed=org.freedesktop.Telepathy.Channel.TargetHandle;org.freedesktop.Telepathy.Channel.TargetID; diff --git a/src/padfoot/connection_manager.rs b/src/padfoot/connection_manager.rs index d4e03c7..ec877c8 100644 --- a/src/padfoot/connection_manager.rs +++ b/src/padfoot/connection_manager.rs @@ -45,12 +45,17 @@ impl telepathy::ConnectionManager for ConnectionManager { props.insert( "org.freedesktop.Telepathy.Protocol.AuthenticationTypes".to_string(), - arg::Variant(Box::new(Vec::::new())), + arg::Variant(Box::new(vec![ + "org.freedesktop.Telepathy.Channel.Type.ServerTLSConnection".to_string(), + ])), ); props.insert( "org.freedesktop.Telepathy.Protocol.ConnectionInterfaces".to_string(), - arg::Variant(Box::new(Vec::::new())), + arg::Variant(Box::new(vec![ + "org.freedesktop.Telepathy.Connection.Interface.Contacts".to_string(), + "org.freedesktop.Telepathy.Connection.Interface.Requests".to_string(), + ])), ); props.insert( "org.freedesktop.Telepathy.Protocol.EnglishName".to_string(), @@ -70,7 +75,7 @@ impl telepathy::ConnectionManager for ConnectionManager { ); props.insert( "org.freedesktop.Telepathy.Protocol.RequestableChannelClasses".to_string(), - arg::Variant(Box::new(Vec::::new())), + arg::Variant(Box::new(protocol::requestables())), ); props.insert( "org.freedesktop.Telepathy.Protocol.VCardField".to_string(), diff --git a/src/padfoot/protocol.rs b/src/padfoot/protocol.rs index bd18306..dbdde17 100644 --- a/src/padfoot/protocol.rs +++ b/src/padfoot/protocol.rs @@ -5,14 +5,20 @@ use std::collections::HashMap; #[derive(Debug)] pub struct Protocol {} +pub type Variant = arg::Variant>; + pub type ParamSpec = ( - String, // Name - u32, // Flags (Conn_Mgr_Param_Flags) - String, // Signature - arg::Variant>, // Default + String, // Name + u32, // Flags (Conn_Mgr_Param_Flags) + String, // Signature + Variant, // Default ); -pub type Variant = arg::Variant>; +pub type RequestableChannelSpec = ( + // Requestable_Channel_Class + HashMap, // Fixed properties + Vec, // Allowed properties +); pub const NAME: &'static str = "delta"; @@ -41,6 +47,29 @@ pub fn parameters() -> Vec { ] } +pub fn requestables() -> Vec { + let mut rf = HashMap::::new(); + + rf.insert( + "org.freedesktop.Telepathy.Channel.ChannelType".to_string(), + arg::Variant(Box::new( + "org.freedesktop.Telepathy.Channel.Type.Text".to_string(), + )), + ); + + rf.insert( + "org.freedesktop.Telepathy.Channel.TargetHandleType".to_string(), + arg::Variant(Box::new(1)), + ); + + let ra = vec![ + "org.freedesktop.Telepathy.Channel.TargetHandle".to_string(), + "org.freedesktop.Telepathy.Channel.TargetID".to_string(), + ]; + + vec![(rf, ra)] +} + impl telepathy::Protocol for Protocol { fn identify_account(&self, params: HashMap<&str, Variant>) -> Result { println!("Protocol::identify_account({:?})", params); @@ -68,39 +97,40 @@ impl telepathy::Protocol for Protocol { fn connection_interfaces(&self) -> Result, tree::MethodErr> { println!("Protocol::connection_interfaces()"); - Ok(vec![]) + Ok(vec![ + "org.freedesktop.Telepathy.Connection.Interface.Contacts".to_string(), + "org.freedesktop.Telepathy.Connection.Interface.Requests".to_string(), + ]) } - fn requestable_channel_classes( - &self, - ) -> Result< - Vec<( - ::std::collections::HashMap>>, - Vec, - )>, - tree::MethodErr, - > { + fn requestable_channel_classes(&self) -> Result, tree::MethodErr> { println!("Protocol::requestable_channel_classes()"); - Ok(vec![]) + Ok(requestables()) } + fn vcard_field(&self) -> Result { println!("Protocol::vcard_field()"); Ok("email".to_string()) } + fn english_name(&self) -> Result { println!("Protocol::english_name()"); Ok("Delta Chat".to_string()) } + fn icon(&self) -> Result { println!("Protocol::icon()"); Ok("im-delta".to_string()) } + fn authentication_types(&self) -> Result, tree::MethodErr> { println!("Protocol::authentication_types()"); - Ok(vec![]) + Ok(vec![ + "org.freedesktop.Telepathy.Channel.Type.ServerTLSConnection".to_string(), + ]) } }