A bit more progress on channels

This commit is contained in:
2020-05-17 00:49:46 +01:00
parent 09afdf51a4
commit 7003b56ce6
9 changed files with 224 additions and 162 deletions

220
Cargo.lock generated
View File

@@ -1,5 +1,14 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "addr2line"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456d75cbb82da1ad150c8a9d97285ffcd21c9931dcb11e995903e7d75141b38b"
dependencies = [
"gimli",
]
[[package]]
name = "adler32"
version = "1.0.4"
@@ -49,9 +58,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.28"
version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9a60d744a80c30fcb657dfe2c1b22bcb3e814c1a1e3674f32bf5820b570fbff"
checksum = "85bb70cc08ec97ca5450e6eba421deeea5f172c0fc61f78b5357b2a8e8be195f"
[[package]]
name = "arrayref"
@@ -86,8 +95,8 @@ version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efd3d156917d94862e779f356c5acae312b08fd3121e792c857d7928c8088423"
dependencies = [
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
@@ -186,13 +195,13 @@ dependencies = [
[[package]]
name = "async-trait"
version = "0.1.30"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da71fef07bc806586090247e971229289f64c210a278ee5ae419314eb386b31d"
checksum = "26c4f3195085c36ea8d24d32b2f828d23296a9370a28aa39d111f6f16bef9f3b"
dependencies = [
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
@@ -220,26 +229,17 @@ checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "backtrace"
version = "0.3.46"
version = "0.3.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e"
checksum = "0df2f85c8a2abbe3b7d7e748052fdd9b76a0458fdeb16ad4223f5eca78c7c130"
dependencies = [
"backtrace-sys",
"addr2line",
"cfg-if",
"libc",
"object",
"rustc-demangle",
]
[[package]]
name = "backtrace-sys"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "base64"
version = "0.10.1"
@@ -361,9 +361,9 @@ checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8"
[[package]]
name = "bumpalo"
version = "3.2.1"
version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187"
checksum = "5356f1d23ee24a1f785a56d1d1a5f0fd5b0f6a0c0fb2412ce11da71649ab78f6"
[[package]]
name = "byte-pool"
@@ -425,9 +425,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.0.52"
version = "1.0.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d"
checksum = "404b1fe4f65288577753b17e3b36a04596ee784493ec249bf81c7f2d2acd751c"
[[package]]
name = "cfb-mode"
@@ -622,9 +622,9 @@ dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote 1.0.4",
"quote 1.0.5",
"strsim",
"syn 1.0.19",
"syn 1.0.22",
]
[[package]]
@@ -634,15 +634,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
dependencies = [
"darling_core",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
name = "dbus"
version = "0.8.2"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38f8875bb7afbc20dec12db09e18af3dcbd672b08592d2932950326a6437c616"
checksum = "26b17a12ffaff26515889b006fc029493a3e340366a137c13cec2cdd545ea3b8"
dependencies = [
"libc",
"libdbus-sys",
@@ -728,8 +728,8 @@ name = "deltachat_derive"
version = "2.0.0"
source = "git+https://github.com/deltachat/deltachat-core-rust?tag=1.31.0#fcf3786fc5e74c0cf348a5864014300d0993db92"
dependencies = [
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
@@ -741,8 +741,8 @@ dependencies = [
"darling",
"derive_builder_core",
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
@@ -753,8 +753,8 @@ checksum = "2791ea3e372c8495c0bc2033991d76b512cd799d07491fbd6890124db9458bef"
dependencies = [
"darling",
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
@@ -924,9 +924,9 @@ checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
[[package]]
name = "encoding_rs"
version = "0.8.22"
version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd8d03faa7fe0c1431609dfad7bbe827af30f82e1e2ae6f7ee4fca6bd764bc28"
checksum = "e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171"
dependencies = [
"cfg-if",
]
@@ -986,8 +986,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
"synstructure",
]
@@ -1032,9 +1032,9 @@ dependencies = [
[[package]]
name = "fnv"
version = "1.0.6"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foreign-types"
@@ -1129,8 +1129,8 @@ checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39"
dependencies = [
"proc-macro-hack",
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
@@ -1204,6 +1204,12 @@ dependencies = [
"lzw",
]
[[package]]
name = "gimli"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c"
[[package]]
name = "glob"
version = "0.2.11"
@@ -1240,9 +1246,9 @@ dependencies = [
[[package]]
name = "hermit-abi"
version = "0.1.12"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4"
checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71"
dependencies = [
"libc",
]
@@ -1521,9 +1527,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.69"
version = "0.2.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005"
checksum = "3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f"
[[package]]
name = "libdbus-sys"
@@ -1788,8 +1794,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c8b15b261814f992e33760b1fca9fe8b693d8a65299f20c9901688636cfb746"
dependencies = [
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
@@ -1844,10 +1850,16 @@ dependencies = [
]
[[package]]
name = "once_cell"
version = "1.3.1"
name = "object"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b"
checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2"
[[package]]
name = "once_cell"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d"
[[package]]
name = "opaque-debug"
@@ -1977,22 +1989,22 @@ dependencies = [
[[package]]
name = "pin-project"
version = "0.4.14"
version = "0.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bbe07cee13ca15295ce93a5b1094d63e0420603e91ffda4f86d4478988916f2"
checksum = "81d480cb4e89522ccda96d0eed9af94180b7a5f93fb28f66e1fd7d68431663d1"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "0.4.14"
version = "0.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b789ec51a10e5a985a9863ef8791412523334d6240fab2cf40dd9fd47496dc6"
checksum = "a82996f11efccb19b685b14b5df818de31c1edcee3daa256ab5775dd98e72feb"
dependencies = [
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
@@ -2027,9 +2039,9 @@ dependencies = [
[[package]]
name = "ppv-lite86"
version = "0.2.6"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
[[package]]
name = "pretty_env_logger"
@@ -2056,9 +2068,9 @@ checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694"
[[package]]
name = "proc-macro2"
version = "1.0.12"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8872cf6f48eee44265156c111456a700ab3483686b3f96df4cf5481c89157319"
checksum = "53f5ffe53a6b28e37c9c1ce74893477864d64f74778a93a4beb43c8fa167f639"
dependencies = [
"unicode-xid 0.2.0",
]
@@ -2095,9 +2107,9 @@ checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
[[package]]
name = "quote"
version = "1.0.4"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c1f4b0efa5fc5e8ceb705136bfee52cfdb6a4e3509f770b478cd6ed434232a7"
checksum = "42934bc9c8ab0d3b273a16d8551c8f0fcff46be73276ca083ec2414c15c4ba5e"
dependencies = [
"proc-macro2",
]
@@ -2269,8 +2281,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de"
dependencies = [
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
@@ -2477,29 +2489,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "serde"
version = "1.0.107"
version = "1.0.110"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eba7550f2cdf88ffc23ab0f1607133486c390a8c0f89b57e589b9654ee15e04d"
checksum = "99e7b308464d16b56eba9964e4972a3eee817760ab60d88c3f86e1fecb08204c"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.107"
version = "1.0.110"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10be45e22e5597d4b88afcc71f9d7bfadcd604bf0c78a3ab4582b8d2b37f39f3"
checksum = "818fbf6bfa9a42d3bfcaca148547aa00c7b915bec71d1757aa2d44ca68771984"
dependencies = [
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
name = "serde_json"
version = "1.0.52"
version = "1.0.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7894c8ed05b7a3a279aeb79025fdec1d3158080b75b98a08faf2806bb799edd"
checksum = "993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2"
dependencies = [
"itoa",
"ryu",
@@ -2585,9 +2597,9 @@ checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4"
[[package]]
name = "snafu"
version = "0.6.7"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a46f872f9a2ee1ad10a6d18003ab012a235c8f5bb90fa986202231a62e570575"
checksum = "c7f5aed652511f5c9123cf2afbe9c244c29db6effa2abb05c866e965c82405ce"
dependencies = [
"doc-comment",
"snafu-derive",
@@ -2595,13 +2607,13 @@ dependencies = [
[[package]]
name = "snafu-derive"
version = "0.6.7"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d107ea16557fc819e8f9165ce4f5586b40449ba4a30a25814f71b442c7ddbe9e"
checksum = "ebf8f7d5720104a9df0f7076a8682024e958bba0fe9848767bb44f251f3648e9"
dependencies = [
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
@@ -2661,8 +2673,8 @@ checksum = "0054a7df764039a6cd8592b9de84be4bec368ff081d203a7d5371cbfa8e65c81"
dependencies = [
"heck",
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
@@ -2684,12 +2696,12 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.19"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8e5aa70697bb26ee62214ae3288465ecec0000f05182f039b477001f08f5ae7"
checksum = "1425de3c33b0941002740a420b1a906a350b88d08b82b2c8a01035a3f9447bac"
dependencies = [
"proc-macro2",
"quote 1.0.4",
"quote 1.0.5",
"unicode-xid 0.2.0",
]
@@ -2709,8 +2721,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
dependencies = [
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
"unicode-xid 0.2.0",
]
@@ -2760,22 +2772,22 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.16"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d12a1dae4add0f0d568eebc7bf142f145ba1aa2544cafb195c76f0f409091b60"
checksum = "5976891d6950b4f68477850b5b9e5aa64d955961466f9e174363f573e54e8ca7"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.16"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f34e0c1caaa462fd840ec6b768946ea1e7842620d94fe29d5b847138f521269"
checksum = "ab81dbd1cd69cd2ce22ecfbdd3bdb73334ba25350649408cc6c085f46d89573d"
dependencies = [
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
]
[[package]]
@@ -2808,9 +2820,9 @@ dependencies = [
[[package]]
name = "tokio"
version = "0.2.20"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05c1d570eb1a36f0345a5ce9c6c6e665b70b73d11236912c0b477616aeec47b1"
checksum = "d099fa27b9702bed751524694adbe393e18b36b204da91eb1cbbbbb4a5ee2d58"
dependencies = [
"bytes",
"fnv",
@@ -3033,8 +3045,8 @@ dependencies = [
"lazy_static",
"log",
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
"wasm-bindgen-shared",
]
@@ -3056,7 +3068,7 @@ version = "0.2.62"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776"
dependencies = [
"quote 1.0.4",
"quote 1.0.5",
"wasm-bindgen-macro-support",
]
@@ -3067,8 +3079,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a"
dependencies = [
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -3187,7 +3199,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2"
dependencies = [
"proc-macro2",
"quote 1.0.4",
"syn 1.0.19",
"quote 1.0.5",
"syn 1.0.22",
"synstructure",
]

View File

@@ -64,7 +64,7 @@ regenerated like so:
```bash
$ git submodule init telepathy-spec
$ git submodule update telepathy-spec
$ cargo install dbus-codegen-rust
$ cargo install dbus-codegen
$ ./scripts/dbus-codegen
```

View File

@@ -13,13 +13,12 @@ use crate::telepathy;
// FIXME: I'm assuming that all channels will be of type text and 1-1 for now.
#[derive(Debug)]
pub struct Channel {
pub path: dbus::Path<'static>,
}
// "This SHOULD NOT include the channel type and channel interface itself"
pub fn channel_interfaces() -> Vec<String> {
vec![
"org.freedesktop.Telepathy.Channel.Interface.Messages".to_string(),
]
vec!["org.freedesktop.Telepathy.Channel.Interface.Messages".to_string()]
}
type Result<T> = std::result::Result<T, dbus::tree::MethodErr>;
@@ -37,8 +36,7 @@ impl Channel {
let messages_iface =
telepathy::channel_interface_messages_server(&f, (), move |_| c_rc2.clone());
let type_text_iface =
telepathy::channel_type_text_server(&f, (), move |_| c_rc.clone());
let type_text_iface = telepathy::channel_type_text_server(&f, (), move |_| c_rc.clone());
tree = tree.add(
f.object_path("", ())

View File

@@ -14,39 +14,44 @@ impl AsRef<dyn telepathy::ChannelInterfaceMessages + 'static> for std::rc::Rc<Ch
impl telepathy::ChannelInterfaceMessages for Channel {
fn send_message(&self, message: Vec<HashMap<&str, VarArg>>, flags: u32) -> Result<String> {
println!("Channel::send_message({:?}, {})", message, flags);
Err(MethodErr::no_arg())
println!("Channel::send_message({:?}, {})", message, flags);
Err(MethodErr::no_arg())
}
fn get_pending_message_content(&self, message_id: u32, parts: Vec<u32>) -> Result<HashMap<u32, VarArg>> {
println!("Channel::get_pending_message_content({}, {:?})", message_id, parts);
Err(MethodErr::no_arg())
fn get_pending_message_content(
&self,
message_id: u32,
parts: Vec<u32>,
) -> Result<HashMap<u32, VarArg>> {
println!(
"Channel::get_pending_message_content({}, {:?})",
message_id, parts
);
Err(MethodErr::no_arg())
}
fn supported_content_types(&self) -> Result<Vec<String>> {
println!("Channel::supported_content_types()");
Err(MethodErr::no_arg())
println!("Channel::supported_content_types()");
Err(MethodErr::no_arg())
}
fn message_types(&self) -> Result<Vec<u32>> {
println!("Channel::message_types()");
Err(MethodErr::no_arg())
println!("Channel::message_types()");
Err(MethodErr::no_arg())
}
fn message_part_support_flags(&self) -> Result<u32> {
println!("Channel::message_part_support_flags()");
Err(MethodErr::no_arg())
println!("Channel::message_part_support_flags()");
Err(MethodErr::no_arg())
}
fn pending_messages(&self) -> Result<Vec<Vec<HashMap<String, VarArg>>>> {
println!("Channel::pending_messages()");
Err(MethodErr::no_arg())
println!("Channel::pending_messages()");
Err(MethodErr::no_arg())
}
fn delivery_reporting_support(&self) -> Result<u32> {
println!("Channel::delivery_reporting_support()");
Err(MethodErr::no_arg())
println!("Channel::delivery_reporting_support()");
Err(MethodErr::no_arg())
}
}

View File

@@ -10,11 +10,11 @@ impl AsRef<dyn telepathy::ChannelTypeText + 'static> for std::rc::Rc<Channel> {
}
type PendingMessagesSpec = (
u32, // numeric identifier
u32, // Unix timestamp indicating when the message was received
u32, // contact handle for the contact who sent the message
u32, // message type, taken from ChannelTextMessageType
u32, // bitwise-OR of the message flags from ChannelTextMessageFlags
u32, // numeric identifier
u32, // Unix timestamp indicating when the message was received
u32, // contact handle for the contact who sent the message
u32, // message type, taken from ChannelTextMessageType
u32, // bitwise-OR of the message flags from ChannelTextMessageFlags
String, // text of the message
);

View File

@@ -20,7 +20,7 @@ pub use self::requests::*;
mod simple_presence;
pub use self::simple_presence::*;
use crate::padfoot::VarArg;
use crate::padfoot::{Channel, VarArg};
use crate::telepathy;
use dbus::blocking::{stdintf::org_freedesktop_dbus::RequestNameReply, LocalConnection};
@@ -39,18 +39,30 @@ use std::time::Duration;
pub const CONN_BUS_NAME: &str = "org.freedesktop.Telepathy.Connection.padfoot.delta";
pub const CONN_OBJECT_PATH: &str = "/org/freedesktop/Telepathy/Connection/padfoot/delta";
// Only the main loop has access to the DBUS connection. Interacting with DBUS
// outside of method return values requires one of these to be added to actq
#[derive(Debug)]
// A Deltachast connection uses email addresses as handles, and delta's Db IDs
enum DbusAction {
Signal(dbus::Message), // Generic signal to send
NewChannel(Channel), // Add this channel
CloseChannel(dbus::Path<'static>), // Close this channel
}
#[derive(Debug)]
// A connection uses delta database IDs as handles, and email addresses as IDs
pub struct Connection {
// Remove ourselves from this when done
// Used for sending out messages
actq: Arc<Mutex<VecDeque<DbusAction>>>,
// Channels we own
channels: Arc<RwLock<HashMap<dbus::Path<'static>, Channel>>>,
// Owned by the CM. Remove ourselves from this when done
conns: Arc<Mutex<HashSet<String>>>,
ctx: Arc<RwLock<Context>>,
settings: ConnSettings,
state: Arc<RwLock<ConnState>>,
// Used for sending out messages
msgq: Arc<Mutex<VecDeque<dbus::Message>>>,
}
#[derive(Debug)]
@@ -115,11 +127,11 @@ impl Connection {
dbfile.push("db.sqlite3");
// FIXME: how to give it access to the connection (initialized later)?
let msgq = Arc::new(Mutex::new(VecDeque::<dbus::Message>::new()));
let actq = Arc::new(Mutex::new(VecDeque::<DbusAction>::new()));
let id = settings.id();
// Use this if we need to send messages in response to DC events:
// let msgq2 = msgq.clone();
// let acqt2 = actq.clone();
let f = move |_c: &Context, e: Event| {
match e {
Event::Info(msg) => println!("Connection<{}>: INFO: {}", id, msg),
@@ -181,7 +193,8 @@ impl Connection {
Ok(Connection {
conns,
settings,
msgq,
actq,
channels: Arc::new(RwLock::new(HashMap::<dbus::Path<'static>, Channel>::new())),
ctx: Arc::new(RwLock::new(ctx)),
state: Arc::new(RwLock::new(ConnState::Initial)),
})
@@ -198,7 +211,8 @@ impl Connection {
let path = self.path();
let conns = self.conns.clone();
let msgq = self.msgq.clone();
let chans = self.channels.clone();
let actq = self.actq.clone();
let state = self.state.clone();
let tree = self.build_tree();
@@ -242,12 +256,31 @@ impl Connection {
};
// Spend a bit of time sending any outgoing messages - signals, mostly
while let Some(msg) = msgq.lock().unwrap().pop_front() {
print!("Connection<{}>: Sending message...", id);
while let Some(act) = actq.lock().unwrap().pop_front() {
match act {
DbusAction::Signal(msg) => {
print!("Connection<{}>: Sending message...", id);
match c.send(msg) {
Err(e) => println!("error! {:?}", e), // FIXME: handle error better?
_ => println!("OK!"),
match c.send(msg) {
Err(e) => println!("error! {:?}", e), // FIXME: handle error better?
_ => println!("OK!"),
}
}
DbusAction::NewChannel(channel) => {
Arc::clone(&chans)
.write()
.unwrap()
.insert(channel.path.clone(), channel);
// TODO: add channel to tree
// TODO: emit signals
}
DbusAction::CloseChannel(path) => {
let _chan = Arc::clone(&chans).write().unwrap().remove(&path);
// TODO: add channel to tree
// TODO: emit signals
}
}
}
}

View File

@@ -5,7 +5,7 @@ use dbus::tree::MethodErr;
use deltachat as dc;
use std::thread;
use super::Connection;
use super::{Connection, DbusAction};
#[derive(Debug, PartialEq, Eq)]
pub enum ConnState {
@@ -112,10 +112,10 @@ impl telepathy::Connection for Connection {
let dbus_conn_path = dbus::strings::Path::new(self.path())
.expect("Object path should meet DBUS requirements");
self.msgq
self.actq
.lock()
.unwrap()
.push_back(sig.to_emit_message(&dbus_conn_path));
.push_back(DbusAction::Signal(sig.to_emit_message(&dbus_conn_path)));
Ok(())
}
@@ -225,9 +225,10 @@ impl telepathy::Connection for Connection {
Ok(())
}
// RequestChannel is deprecated in favour of the Requests interface.
fn request_channel(
&self,
type_: &str,
channel_type: &str,
handle_type: u32,
handle: u32,
suppress_handler: bool,
@@ -235,7 +236,7 @@ impl telepathy::Connection for Connection {
println!(
"Connection<{}>::request_channel({}, {}, {}, {})",
self.id(),
type_,
channel_type,
handle_type,
handle,
suppress_handler

View File

@@ -6,21 +6,26 @@ use std::collections::HashMap;
use super::Connection;
type ChannelSpec = (
dbus::Path<'static>, // Object path on this connection
HashMap<String, VarArg>, // Map of channel property -> value
);
type RequestableChannelSpec = (HashMap<String, VarArg>, Vec<String>);
type Result<T> = std::result::Result<T, MethodErr>;
impl AsRef<dyn telepathy::ConnectionInterfaceRequests + 'static> for std::rc::Rc<Connection> {
fn as_ref(&self) -> &(dyn telepathy::ConnectionInterfaceRequests + 'static) {
&**self
}
}
type ChannelSpec = (dbus::Path<'static>, HashMap<String, VarArg>);
type RequestableChannelSpec = (HashMap<String, VarArg>, Vec<String>);
impl telepathy::ConnectionInterfaceRequests for Connection {
fn create_channel(
&self,
request: HashMap<&str, VarArg>,
) -> Result<(dbus::Path<'static>, HashMap<String, VarArg>), MethodErr> {
) -> Result<(dbus::Path<'static>, HashMap<String, VarArg>)> {
println!("Connection<{}>::create_channel({:?})", self.id(), request);
Err(MethodErr::no_arg()) // FIXME: should be NotImplemented?
@@ -29,17 +34,26 @@ impl telepathy::ConnectionInterfaceRequests for Connection {
fn ensure_channel(
&self,
request: HashMap<&str, VarArg>,
) -> Result<(bool, dbus::Path<'static>, HashMap<String, VarArg>), MethodErr> {
) -> Result<(bool, dbus::Path<'static>, HashMap<String, VarArg>)> {
println!("Connection<{}>::ensure_channel({:?})", self.id(), request);
Err(MethodErr::no_arg()) // FIXME: should be NotImplemented?
}
fn channels(&self) -> Result<Vec<ChannelSpec>, MethodErr> {
fn channels(&self) -> Result<Vec<ChannelSpec>> {
println!("Connection<{}>::channels()", self.id());
Ok(vec![])
let mut out = Vec::<ChannelSpec>::new();
for channel in self.channels.read().unwrap().values() {
out.push((
channel.path.clone(),
HashMap::<String, VarArg>::new(), // FIXME: work out what props should be shown
));
}
Ok(out)
}
fn requestable_channel_classes(&self) -> Result<Vec<RequestableChannelSpec>, MethodErr> {
fn requestable_channel_classes(&self) -> Result<Vec<RequestableChannelSpec>> {
println!("Connection<{}>::requestable_channel_classes()", self.id());
Ok(requestables())
}

View File

@@ -1,6 +1,5 @@
#![allow(unused)]
#![allow(clippy::all)]
mod account_interface_addressing;
pub use self::account_interface_addressing::*;