Clean up dbus::arg::Variant type alias

This commit is contained in:
2020-05-16 22:11:38 +01:00
parent 0f9dcf476b
commit a202dd84e8
8 changed files with 60 additions and 53 deletions

View File

@@ -1,6 +1,6 @@
use crate::padfoot::{var_str, var_u32, VarArg};
use crate::telepathy;
use dbus::arg;
use dbus::tree::MethodErr;
use deltachat as dc;
use std::collections::HashMap;
@@ -14,19 +14,17 @@ pub const PROTO_NAME: &str = "delta";
#[derive(Debug)]
pub struct Protocol {}
pub type Variant = arg::Variant<Box<dyn arg::RefArg + 'static>>;
pub type ParamSpec = (
String, // Name
u32, // Flags (Conn_Mgr_Param_Flags)
String, // Signature
Variant, // Default
VarArg, // Default value
);
// Requestable_Channel_Class
pub type RequestableChannelSpec = (
HashMap<String, Variant>, // Fixed properties
Vec<String>, // Allowed properties
HashMap<String, VarArg>, // Fixed properties
Vec<String>, // Allowed properties
);
// FIXME: these should come from codegen
@@ -43,13 +41,13 @@ pub fn parameters() -> Vec<ParamSpec> {
"account".to_string(),
FLAG_REQUIRED,
"s".to_string(),
arg::Variant(Box::new("".to_string())),
var_str("".to_string()),
),
(
"password".to_string(),
FLAG_REQUIRED | FLAG_SECRET,
"s".to_string(),
arg::Variant(Box::new("".to_string())),
var_str("".to_string()),
),
]
}
@@ -62,19 +60,14 @@ pub fn protocol_interfaces() -> Vec<String> {
}
pub fn requestables() -> Vec<RequestableChannelSpec> {
let mut rf = HashMap::<String, Variant>::new();
let mut rf = HashMap::<String, VarArg>::new();
rf.insert(
"org.freedesktop.Telepathy.Channel.ChannelType".to_string(),
arg::Variant(Box::new(
"org.freedesktop.Telepathy.Channel.Type.Text".to_string(),
)),
var_str("org.freedesktop.Telepathy.Channel.Type.Text".to_string()),
);
rf.insert(
"org.freedesktop.Telepathy.Channel.TargetHandleType".to_string(),
arg::Variant(Box::new(1)),
);
rf.insert("org.freedesktop.Telepathy.Channel.TargetHandleType".to_string(), var_u32(1));
let ra = vec![
"org.freedesktop.Telepathy.Channel.TargetHandle".to_string(),
@@ -91,7 +84,7 @@ impl AsRef<dyn telepathy::Protocol + 'static> for std::rc::Rc<Protocol> {
}
impl telepathy::Protocol for Protocol {
fn identify_account(&self, params: HashMap<&str, Variant>) -> Result<String, MethodErr> {
fn identify_account(&self, params: HashMap<&str, VarArg>) -> Result<String, MethodErr> {
println!("Protocol::identify_account(...)");
let settings = ConnSettings::from_params(params)?;