Add and set the "Bcc self" option.

This commit is contained in:
2020-05-23 23:52:42 +01:00
parent 373311e826
commit 370f5076a1
4 changed files with 32 additions and 7 deletions

View File

@@ -182,10 +182,11 @@ whitespace!
This bit is still extremely janky; it should instead be a magic channel type or
action button of some kind. It is, however, functional.
Delta wants us to enable the "Send copy to self" option in settings, but that
isn't exposed in padfoot yet, so messages you send from padfoot won't appear in
other clients. Messages from other clients won't appear either, because messages
from yourself are mostly ingnored by padfoot. Still, it's progress.
Delta wants us to enable the "Send copy to self" option in settings. That's
exposed as "Bcc self" in the advanced options in Empathy. Once enabled, messages
you send via Padfoot will appear in other clients. However, messages you send
from other clients don't appear in Padfoot yet because it mostly ignores self
messages as a dirty hack to avoid double-showing messages. Progess though.
### Autogenerated telepathy DBUS bindings

View File

@@ -7,6 +7,7 @@ ObjectPath=/org/freedesktop/Telepathy/ConnectionManager/padfoot
[Protocol delta]
param-account=s required
param-password=s required secret
param-bcc-self=b
status-available=2 settable
status-offline = 1 settable

View File

@@ -75,6 +75,7 @@ pub struct Connection {
pub struct ConnSettings {
account: String,
password: String,
bcc_self: bool,
id: String,
}
@@ -100,9 +101,24 @@ impl ConnSettings {
None => return err,
};
let bcc_self = match params.get("bcc-self") {
Some(variant) => match variant.0.as_u64() {
Some(i) => i != 0,
None => {
println!("0!");
return err;
}
},
None => {
println!("1!");
false
}
};
Ok(Self {
account,
password,
bcc_self,
id,
})
}
@@ -211,8 +227,14 @@ impl Connection {
.map_err(|_e| MethodErr::no_arg())?;
ctx.set_config(Config::MailPw, Some(&settings.password))
.map_err(|_e| MethodErr::no_arg())?;
ctx.set_config(Config::SentboxWatch, Some(&"Sent"))
.map_err(|_e| MethodErr::no_arg())?;
if settings.bcc_self {
ctx.set_config(Config::BccSelf, Some(&"1"))
.map_err(|_e| MethodErr::no_arg())?;
} else {
ctx.set_config(Config::BccSelf, Some(&"0"))
.map_err(|_e| MethodErr::no_arg())?;
}
if !ctx.is_configured() {
ctx.configure();

View File

@@ -1,4 +1,4 @@
use crate::padfoot::{var_str, var_u32, VarArg};
use crate::padfoot::{var_bool, var_str, var_u32, VarArg};
use crate::telepathy;
use dbus::tree::MethodErr;
@@ -49,6 +49,7 @@ pub fn parameters() -> Vec<ParamSpec> {
"s".to_string(),
var_str("".to_string()),
),
("bcc-self".to_string(), 0, "b".to_string(), var_bool(false)),
]
}