Return protocol parameters

This commit is contained in:
2020-05-09 11:19:40 +01:00
parent 5328ae9bd6
commit 40ea57a0cc
5 changed files with 62 additions and 30 deletions

View File

@@ -19,22 +19,43 @@ impl dbus::tree::DataType for CMData {
const PROTO: &'static str = "delta";
pub type ParamSpec = (
String, // Name
u32, // Flags (Conn_Mgr_Param_Flags)
String, // Signature
arg::Variant<Box<dyn arg::RefArg + 'static>>, // Default
);
pub type Dict = HashMap<String, arg::Variant<Box<dyn arg::RefArg + 'static>>>;
// FIXME: these should come from codegen
const FLAG_REQUIRED: u32 = 1;
//const FLAG_REGISTER: u32 = 2;
//const FLAG_HAS_DEFAULT: u32 = 4;
const FLAG_SECRET: u32 = 8;
//const FLAG_DBUS_PROP: u32 = 16;
impl telepathy::ConnectionManager for ConnectionManager {
fn get_parameters(
&self,
protocol: &str,
) -> Result<
Vec<(
String,
u32,
String,
arg::Variant<Box<dyn arg::RefArg + 'static>>,
)>,
tree::MethodErr,
> {
Err(tree::MethodErr::no_arg()) // FIXME: should be NotImplemented
fn get_parameters(&self, protocol: &str) -> Result<Vec<ParamSpec>, tree::MethodErr> {
if protocol != PROTO {
return Err(tree::MethodErr::no_arg()); // FIXME: should be NotImplemented?
}
// TODO: query the protocol for these?
Ok(vec![
(
"account".to_string(),
FLAG_REQUIRED,
"s".to_string(),
arg::Variant(Box::new("".to_string())),
),
(
"password".to_string(),
FLAG_REQUIRED | FLAG_SECRET,
"s".to_string(),
arg::Variant(Box::new("".to_string())),
),
])
}
fn list_protocols(&self) -> Result<Vec<String>, tree::MethodErr> {
@@ -43,22 +64,19 @@ impl telepathy::ConnectionManager for ConnectionManager {
fn request_connection(
&self,
protocol: &str,
parameters: HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
_protocol: &str,
_parameters: HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
) -> Result<(String, dbus::Path<'static>), tree::MethodErr> {
Err(tree::MethodErr::no_arg())
}
fn protocols(&self) -> Result<HashMap<String, Dict>, tree::MethodErr> {
let mut hm = HashMap::new();
let mut props = Dict::new();
hm.insert(PROTO.to_string(), props);
Ok(hm)
// If this map is empty or missing, clients SHOULD fall back to
// calling ListProtocol and GetParameters
Ok(HashMap::new())
}
fn interfaces(&self) -> Result<Vec<String>, tree::MethodErr> {
Err(tree::MethodErr::no_arg())
Ok(vec![])
}
}

View File

@@ -1,2 +1 @@
pub struct Protocol {}