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/.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
[ConnectionManager]
|
[ConnectionManager]
|
||||||
|
Interfaces=
|
||||||
Name=padfoot
|
Name=padfoot
|
||||||
BusName=org.freedesktop.Telepathy.ConnectionManager.padfoot
|
BusName=org.freedesktop.Telepathy.ConnectionManager.padfoot
|
||||||
ObjectPath=/org/freedesktop/Telepathy/ConnectionManager/padfoot
|
ObjectPath=/org/freedesktop/Telepathy/ConnectionManager/padfoot
|
||||||
@@ -6,6 +7,16 @@ ObjectPath=/org/freedesktop/Telepathy/ConnectionManager/padfoot
|
|||||||
[Protocol delta]
|
[Protocol delta]
|
||||||
param-account=s required
|
param-account=s required
|
||||||
param-password=s required secret
|
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
|
EnglishName=Delta Chat
|
||||||
VCardField=email
|
|
||||||
Icon=im-delta
|
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;
|
||||||
|
@@ -45,12 +45,17 @@ impl telepathy::ConnectionManager for ConnectionManager {
|
|||||||
|
|
||||||
props.insert(
|
props.insert(
|
||||||
"org.freedesktop.Telepathy.Protocol.AuthenticationTypes".to_string(),
|
"org.freedesktop.Telepathy.Protocol.AuthenticationTypes".to_string(),
|
||||||
arg::Variant(Box::new(Vec::<String>::new())),
|
arg::Variant(Box::new(vec![
|
||||||
|
"org.freedesktop.Telepathy.Channel.Type.ServerTLSConnection".to_string(),
|
||||||
|
])),
|
||||||
);
|
);
|
||||||
|
|
||||||
props.insert(
|
props.insert(
|
||||||
"org.freedesktop.Telepathy.Protocol.ConnectionInterfaces".to_string(),
|
"org.freedesktop.Telepathy.Protocol.ConnectionInterfaces".to_string(),
|
||||||
arg::Variant(Box::new(Vec::<String>::new())),
|
arg::Variant(Box::new(vec![
|
||||||
|
"org.freedesktop.Telepathy.Connection.Interface.Contacts".to_string(),
|
||||||
|
"org.freedesktop.Telepathy.Connection.Interface.Requests".to_string(),
|
||||||
|
])),
|
||||||
);
|
);
|
||||||
props.insert(
|
props.insert(
|
||||||
"org.freedesktop.Telepathy.Protocol.EnglishName".to_string(),
|
"org.freedesktop.Telepathy.Protocol.EnglishName".to_string(),
|
||||||
@@ -70,7 +75,7 @@ impl telepathy::ConnectionManager for ConnectionManager {
|
|||||||
);
|
);
|
||||||
props.insert(
|
props.insert(
|
||||||
"org.freedesktop.Telepathy.Protocol.RequestableChannelClasses".to_string(),
|
"org.freedesktop.Telepathy.Protocol.RequestableChannelClasses".to_string(),
|
||||||
arg::Variant(Box::new(Vec::<String>::new())),
|
arg::Variant(Box::new(protocol::requestables())),
|
||||||
);
|
);
|
||||||
props.insert(
|
props.insert(
|
||||||
"org.freedesktop.Telepathy.Protocol.VCardField".to_string(),
|
"org.freedesktop.Telepathy.Protocol.VCardField".to_string(),
|
||||||
|
@@ -5,14 +5,20 @@ use std::collections::HashMap;
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Protocol {}
|
pub struct Protocol {}
|
||||||
|
|
||||||
|
pub type Variant = arg::Variant<Box<dyn arg::RefArg + 'static>>;
|
||||||
|
|
||||||
pub type ParamSpec = (
|
pub type ParamSpec = (
|
||||||
String, // Name
|
String, // Name
|
||||||
u32, // Flags (Conn_Mgr_Param_Flags)
|
u32, // Flags (Conn_Mgr_Param_Flags)
|
||||||
String, // Signature
|
String, // Signature
|
||||||
arg::Variant<Box<dyn arg::RefArg + 'static>>, // Default
|
Variant, // Default
|
||||||
);
|
);
|
||||||
|
|
||||||
pub type Variant = arg::Variant<Box<dyn arg::RefArg + 'static>>;
|
pub type RequestableChannelSpec = (
|
||||||
|
// Requestable_Channel_Class
|
||||||
|
HashMap<String, Variant>, // Fixed properties
|
||||||
|
Vec<String>, // Allowed properties
|
||||||
|
);
|
||||||
|
|
||||||
pub const NAME: &'static str = "delta";
|
pub const NAME: &'static str = "delta";
|
||||||
|
|
||||||
@@ -41,6 +47,29 @@ pub fn parameters() -> Vec<ParamSpec> {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn requestables() -> Vec<RequestableChannelSpec> {
|
||||||
|
let mut rf = HashMap::<String, Variant>::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 {
|
impl telepathy::Protocol for Protocol {
|
||||||
fn identify_account(&self, params: HashMap<&str, Variant>) -> Result<String, tree::MethodErr> {
|
fn identify_account(&self, params: HashMap<&str, Variant>) -> Result<String, tree::MethodErr> {
|
||||||
println!("Protocol::identify_account({:?})", params);
|
println!("Protocol::identify_account({:?})", params);
|
||||||
@@ -68,39 +97,40 @@ impl telepathy::Protocol for Protocol {
|
|||||||
fn connection_interfaces(&self) -> Result<Vec<String>, tree::MethodErr> {
|
fn connection_interfaces(&self) -> Result<Vec<String>, tree::MethodErr> {
|
||||||
println!("Protocol::connection_interfaces()");
|
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(
|
fn requestable_channel_classes(&self) -> Result<Vec<RequestableChannelSpec>, tree::MethodErr> {
|
||||||
&self,
|
|
||||||
) -> Result<
|
|
||||||
Vec<(
|
|
||||||
::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg + 'static>>>,
|
|
||||||
Vec<String>,
|
|
||||||
)>,
|
|
||||||
tree::MethodErr,
|
|
||||||
> {
|
|
||||||
println!("Protocol::requestable_channel_classes()");
|
println!("Protocol::requestable_channel_classes()");
|
||||||
|
|
||||||
Ok(vec![])
|
Ok(requestables())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vcard_field(&self) -> Result<String, tree::MethodErr> {
|
fn vcard_field(&self) -> Result<String, tree::MethodErr> {
|
||||||
println!("Protocol::vcard_field()");
|
println!("Protocol::vcard_field()");
|
||||||
|
|
||||||
Ok("email".to_string())
|
Ok("email".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn english_name(&self) -> Result<String, tree::MethodErr> {
|
fn english_name(&self) -> Result<String, tree::MethodErr> {
|
||||||
println!("Protocol::english_name()");
|
println!("Protocol::english_name()");
|
||||||
|
|
||||||
Ok("Delta Chat".to_string())
|
Ok("Delta Chat".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn icon(&self) -> Result<String, tree::MethodErr> {
|
fn icon(&self) -> Result<String, tree::MethodErr> {
|
||||||
println!("Protocol::icon()");
|
println!("Protocol::icon()");
|
||||||
|
|
||||||
Ok("im-delta".to_string())
|
Ok("im-delta".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn authentication_types(&self) -> Result<Vec<String>, tree::MethodErr> {
|
fn authentication_types(&self) -> Result<Vec<String>, tree::MethodErr> {
|
||||||
println!("Protocol::authentication_types()");
|
println!("Protocol::authentication_types()");
|
||||||
|
|
||||||
Ok(vec![])
|
Ok(vec![
|
||||||
|
"org.freedesktop.Telepathy.Channel.Type.ServerTLSConnection".to_string(),
|
||||||
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user