Browse Source

Initial checkin

main
Nick Thomas 2 years ago
parent
commit
5328ae9bd6
  1. 1
      .gitignore
  2. 1
      .rustfmt.toml
  3. 46
      Cargo.lock
  4. 11
      Cargo.toml
  5. 18
      LICENSE
  6. 41
      README.md
  7. 38
      scripts/dbus-codegen
  8. 73
      src/main.rs
  9. 5
      src/padfoot.rs
  10. 64
      src/padfoot/connection_manager.rs
  11. 2
      src/padfoot/protocol.rs
  12. 365
      src/telepathy.rs
  13. 459
      src/telepathy/account.rs
  14. 58
      src/telepathy/account_interface_addressing.rs
  15. 64
      src/telepathy/account_interface_avatar.rs
  16. 49
      src/telepathy/account_interface_external_password_storage.rs
  17. 38
      src/telepathy/account_interface_hidden.rs
  18. 83
      src/telepathy/account_interface_storage.rs
  19. 167
      src/telepathy/account_manager.rs
  20. 111
      src/telepathy/account_manager_interface_hidden.rs
  21. 4
      src/telepathy/all.rs
  22. 175
      src/telepathy/authentication_tls_certificate.rs
  23. 151
      src/telepathy/call_content.rs
  24. 78
      src/telepathy/call_content_interface_audio_control.rs
  25. 167
      src/telepathy/call_content_interface_dtmf.rs
  26. 350
      src/telepathy/call_content_interface_media.rs
  27. 218
      src/telepathy/call_content_interface_video_control.rs
  28. 155
      src/telepathy/call_content_media_description.rs
  29. 110
      src/telepathy/call_content_media_description_interface_rtcp_extended_reports.rs
  30. 59
      src/telepathy/call_content_media_description_interface_rtcp_feedback.rs
  31. 39
      src/telepathy/call_content_media_description_interface_rtp_header_extensions.rs
  32. 77
      src/telepathy/call_interface_mute.rs
  33. 190
      src/telepathy/call_stream.rs
  34. 467
      src/telepathy/call_stream_endpoint.rs
  35. 550
      src/telepathy/call_stream_interface_media.rs
  36. 192
      src/telepathy/channel.rs
  37. 35
      src/telepathy/channel_bundle.rs
  38. 192
      src/telepathy/channel_dispatch_operation.rs
  39. 255
      src/telepathy/channel_dispatcher.rs
  40. 54
      src/telepathy/channel_dispatcher_interface_messages1.rs
  41. 117
      src/telepathy/channel_dispatcher_interface_operation_list.rs
  42. 35
      src/telepathy/channel_future.rs
  43. 61
      src/telepathy/channel_handler.rs
  44. 74
      src/telepathy/channel_interface_addressing.rs
  45. 62
      src/telepathy/channel_interface_anonymity.rs
  46. 70
      src/telepathy/channel_interface_call_state.rs
  47. 153
      src/telepathy/channel_interface_captcha_authentication.rs
  48. 85
      src/telepathy/channel_interface_chat_state.rs
  49. 171
      src/telepathy/channel_interface_conference.rs
  50. 39
      src/telepathy/channel_interface_credentials_storage.rs
  51. 36
      src/telepathy/channel_interface_destroyable.rs
  52. 181
      src/telepathy/channel_interface_dtmf.rs
  53. 73
      src/telepathy/channel_interface_file_transfer_metadata.rs
  54. 532
      src/telepathy/channel_interface_group.rs
  55. 83
      src/telepathy/channel_interface_hold.rs
  56. 25
      src/telepathy/channel_interface_html.rs
  57. 70
      src/telepathy/channel_interface_media_signalling.rs
  58. 39
      src/telepathy/channel_interface_mergeable_conference.rs
  59. 226
      src/telepathy/channel_interface_messages.rs
  60. 83
      src/telepathy/channel_interface_password.rs
  61. 195
      src/telepathy/channel_interface_picture.rs
  62. 83
      src/telepathy/channel_interface_room.rs
  63. 212
      src/telepathy/channel_interface_room_config.rs
  64. 295
      src/telepathy/channel_interface_sasl_authentication.rs
  65. 50
      src/telepathy/channel_interface_securable.rs
  66. 78
      src/telepathy/channel_interface_service_point.rs
  67. 99
      src/telepathy/channel_interface_sms.rs
  68. 36
      src/telepathy/channel_interface_splittable.rs
  69. 97
      src/telepathy/channel_interface_subject.rs
  70. 38
      src/telepathy/channel_interface_transfer.rs
  71. 82
      src/telepathy/channel_interface_tube.rs
  72. 228
      src/telepathy/channel_request.rs
  73. 423
      src/telepathy/channel_type_call.rs
  74. 22
      src/telepathy/channel_type_contact_list.rs
  75. 169
      src/telepathy/channel_type_contact_search.rs
  76. 131
      src/telepathy/channel_type_dbus_tube.rs
  77. 354
      src/telepathy/channel_type_file_transfer.rs
  78. 125
      src/telepathy/channel_type_room_list.rs
  79. 38
      src/telepathy/channel_type_server_authentication.rs
  80. 62
      src/telepathy/channel_type_server_tls_connection.rs
  81. 202
      src/telepathy/channel_type_stream_tube.rs
  82. 292
      src/telepathy/channel_type_streamed_media.rs
  83. 226
      src/telepathy/channel_type_text.rs
  84. 423
      src/telepathy/channel_type_tubes.rs
  85. 35
      src/telepathy/client.rs
  86. 74
      src/telepathy/client_approver.rs
  87. 126
      src/telepathy/client_handler.rs
  88. 47
      src/telepathy/client_handler_future.rs
  89. 66
      src/telepathy/client_interface_requests.rs
  90. 114
      src/telepathy/client_observer.rs
  91. 468
      src/telepathy/connection.rs
  92. 95
      src/telepathy/connection_interface_addressing.rs
  93. 116
      src/telepathy/connection_interface_aliasing.rs
  94. 104
      src/telepathy/connection_interface_anonymity.rs
  95. 315
      src/telepathy/connection_interface_avatars.rs
  96. 76
      src/telepathy/connection_interface_balance.rs
  97. 92
      src/telepathy/connection_interface_capabilities.rs
  98. 164
      src/telepathy/connection_interface_cellular.rs
  99. 92
      src/telepathy/connection_interface_client_types.rs
  100. 106
      src/telepathy/connection_interface_communication_policy.rs
  101. Some files were not shown because too many files have changed in this diff Show More

1
.gitignore vendored

@ -0,0 +1 @@
/target

1
.rustfmt.toml

@ -0,0 +1 @@
edition = "2018"

46
Cargo.lock generated

@ -0,0 +1,46 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "anyhow"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9a60d744a80c30fcb657dfe2c1b22bcb3e814c1a1e3674f32bf5820b570fbff"
[[package]]
name = "dbus"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38f8875bb7afbc20dec12db09e18af3dcbd672b08592d2932950326a6437c616"
dependencies = [
"libc",
"libdbus-sys",
]
[[package]]
name = "libc"
version = "0.2.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005"
[[package]]
name = "libdbus-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc12a3bc971424edbbf7edaf6e5740483444db63aa8e23d3751ff12a30f306f0"
dependencies = [
"pkg-config",
]
[[package]]
name = "pkg-config"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
[[package]]
name = "telepathy-padfoot"
version = "0.1.0"
dependencies = [
"anyhow",
"dbus",
]

11
Cargo.toml

@ -0,0 +1,11 @@
[package]
name = "telepathy-padfoot"
version = "0.1.0"
authors = ["Nick Thomas <me@ur.gs>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0"
dbus = "0.8.2"

18
LICENSE

@ -0,0 +1,18 @@
Copyright 2020 Nick Thomas <telepathy-delta@ur.gs>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

41
README.md

@ -0,0 +1,41 @@
# Telepathy for Delta Chat
## Who
Authored by [Nick Thomas](https://ur.gs) under the [MIT License](LICENSE).
## What
[Delta Chat](https://delta.chat) is IM over email.
[Telepathy](https://telepathy.freedesktop.org) is a framework for abstracting
over multiple IM protocols. This project glues the two together, allowing
Telepathy clients to send/receive Delta messages.
Telepathy CMs should have a name that is not the same as their protocol; so this
CM is hereby named "padfoot".
## Why
Mobile IM, mostly. Desktop IM, also. It's ideal for my pinephone, and lighter
than the electron desktop client.
## How
This project is written in Rust, just like the main Delta library, so you'll
need a rust compiler to build it.
It makes use of the `dbus-codegen-rust` crate to convert the
[telepathy interface specs](https://github.com/TelepathyIM/telepathy-spec) into
the executable code in `src/telepathy`. This is checked in, but can be
regenerated like so:
```bash
$ git submodule init telepathy-spec
$ git submodule update telepathy-spec
$ cargo install dbus-codegen-rust
$ ./scripts/dbus-codegen
```
`dbus-codegen-rust` doesn't seem to handle namespaced attributes properly, so
we modify the XML files in `telepathy-spec`... with `sed`. The `tp:type`
attribute is renamed to `tp:typehint`.

38
scripts/dbus-codegen

@ -0,0 +1,38 @@
#!/bin/sh
specs="telepathy-spec/spec"
dest="src/telepathy"
modfile="$dest.rs"
#if [ -d "$dest" ]; then
# mv "$dest" "$dest.$$"
#fi
rm -f "$dest.rs"
rm -rf "$dest"
mkdir -p "$dest"
echo "#![allow(unused)]\n#![allow(clippy::all)]" > "$modfile"
for file in $(ls -a $specs/*.xml); do
sed -i 's/tp:type=/tp:typehint=/g' "$file"
name=$( \
echo $(basename "$file") | \
tr '[:upper:]' '[:lower:]' | \
tr '-' '_' | \
sed --expression 's/\.xml$//' \
)
out="$dest/$name.rs"
dbus-codegen-rust \
--file "$file" \
-i "org.freedesktop.Telepathy" \
-o "$out"
rustfmt $out
echo "\nmod $name;\npub use self::$name::*;" >> "$modfile"
done
git -C telepathy-spec checkout -- .

73
src/main.rs

@ -0,0 +1,73 @@
mod padfoot;
mod telepathy;
//use dbus::tree::{Interface, MTFn, MethodErr};
use dbus::{
blocking::{stdintf::org_freedesktop_dbus::RequestNameReply, LocalConnection},
tree::{Factory, Interface, MTFn, Tree},
};
use padfoot::{CMData, ConnectionManager};
use std::sync::Arc;
use std::time::Duration;
use anyhow::{anyhow, Result};
const BUS_NAME: &'static str = "org.freedesktop.Telepathy.ConnectionManager.padfoot";
const OBJECT_PATH: &'static str = "/org/freedesktop/Telepathy/ConnectionManager/padfoot";
fn create_tree(cm: &Arc<ConnectionManager>) -> Tree<MTFn<CMData>, CMData> {
let f = Factory::new_fn();
let mut tree = f.tree(());
let iface = telepathy::connection_manager_server(&f, (), |m| {
let a: &Arc<ConnectionManager> = m.path.get_data();
let b: &ConnectionManager = &a;
b
});
tree = tree.add(
f.object_path(OBJECT_PATH, cm.clone())
.introspectable()
.add(iface),
);
tree = tree.add(f.object_path("/", cm.clone()).introspectable());
tree
}
fn run() -> Result<()> {
let cm: ConnectionManager = ConnectionManager {};
let tree = create_tree(&Arc::new(cm));
// Setup DBus connection
let mut c = LocalConnection::new_session()?;
let result = c.request_name(BUS_NAME, false, false, true)?;
match result {
RequestNameReply::Exists => {
return Err(anyhow!(
"Another process is already registered on {}",
BUS_NAME
))
}
_ => {} // All other responses we can get are a success
};
println!("Bus registered: {}", BUS_NAME);
tree.start_receive(&c);
loop {
c.process(Duration::from_secs(1))?;
println!("Tick");
}
}
fn main() {
if let Err(e) = run() {
println!("{}", e);
std::process::exit(1);
}
}

5
src/padfoot.rs

@ -0,0 +1,5 @@
mod connection_manager;
pub use self::connection_manager::*;
mod protocol;
pub use self::protocol::*;

64
src/padfoot/connection_manager.rs

@ -0,0 +1,64 @@
use crate::telepathy;
use dbus::{arg, tree};
use std::collections::HashMap;
#[derive(Debug)]
pub struct ConnectionManager {}
#[derive(Copy, Clone, Default, Debug)]
pub struct CMData;
impl dbus::tree::DataType for CMData {
type Tree = ();
type Property = ();
type Interface = ();
type Method = ();
type Signal = ();
type ObjectPath = std::sync::Arc<ConnectionManager>;
}
const PROTO: &'static str = "delta";
pub type Dict = HashMap<String, arg::Variant<Box<dyn arg::RefArg + 'static>>>;
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 list_protocols(&self) -> Result<Vec<String>, tree::MethodErr> {
Ok(vec![PROTO.to_string()])
}
fn request_connection(
&self,
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)
}
fn interfaces(&self) -> Result<Vec<String>, tree::MethodErr> {
Err(tree::MethodErr::no_arg())
}
}

2
src/padfoot/protocol.rs

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

365
src/telepathy.rs

@ -0,0 +1,365 @@
#![allow(unused)]
#![allow(clippy::all)]
mod account_interface_addressing;
pub use self::account_interface_addressing::*;
mod account_interface_avatar;
pub use self::account_interface_avatar::*;
mod account_interface_external_password_storage;
pub use self::account_interface_external_password_storage::*;
mod account_interface_hidden;
pub use self::account_interface_hidden::*;
mod account_interface_storage;
pub use self::account_interface_storage::*;
mod account_manager_interface_hidden;
pub use self::account_manager_interface_hidden::*;
mod account_manager;
pub use self::account_manager::*;
mod account;
pub use self::account::*;
mod all;
pub use self::all::*;
mod authentication_tls_certificate;
pub use self::authentication_tls_certificate::*;
mod call_content_interface_audio_control;
pub use self::call_content_interface_audio_control::*;
mod call_content_interface_dtmf;
pub use self::call_content_interface_dtmf::*;
mod call_content_interface_media;
pub use self::call_content_interface_media::*;
mod call_content_interface_video_control;
pub use self::call_content_interface_video_control::*;
mod call_content_media_description_interface_rtcp_extended_reports;
pub use self::call_content_media_description_interface_rtcp_extended_reports::*;
mod call_content_media_description_interface_rtcp_feedback;
pub use self::call_content_media_description_interface_rtcp_feedback::*;
mod call_content_media_description_interface_rtp_header_extensions;
pub use self::call_content_media_description_interface_rtp_header_extensions::*;
mod call_content_media_description;
pub use self::call_content_media_description::*;
mod call_content;
pub use self::call_content::*;
mod call_interface_mute;
pub use self::call_interface_mute::*;
mod call_stream_endpoint;
pub use self::call_stream_endpoint::*;
mod call_stream_interface_media;
pub use self::call_stream_interface_media::*;
mod call_stream;
pub use self::call_stream::*;
mod channel_bundle;
pub use self::channel_bundle::*;
mod channel_dispatcher_interface_messages1;
pub use self::channel_dispatcher_interface_messages1::*;
mod channel_dispatcher_interface_operation_list;
pub use self::channel_dispatcher_interface_operation_list::*;
mod channel_dispatcher;
pub use self::channel_dispatcher::*;
mod channel_dispatch_operation;
pub use self::channel_dispatch_operation::*;
mod channel_future;
pub use self::channel_future::*;
mod channel_handler;
pub use self::channel_handler::*;
mod channel_interface_addressing;
pub use self::channel_interface_addressing::*;
mod channel_interface_anonymity;
pub use self::channel_interface_anonymity::*;
mod channel_interface_call_state;
pub use self::channel_interface_call_state::*;
mod channel_interface_captcha_authentication;
pub use self::channel_interface_captcha_authentication::*;
mod channel_interface_chat_state;
pub use self::channel_interface_chat_state::*;
mod channel_interface_conference;
pub use self::channel_interface_conference::*;
mod channel_interface_credentials_storage;
pub use self::channel_interface_credentials_storage::*;
mod channel_interface_destroyable;
pub use self::channel_interface_destroyable::*;
mod channel_interface_dtmf;
pub use self::channel_interface_dtmf::*;
mod channel_interface_file_transfer_metadata;
pub use self::channel_interface_file_transfer_metadata::*;
mod channel_interface_group;
pub use self::channel_interface_group::*;
mod channel_interface_hold;
pub use self::channel_interface_hold::*;
mod channel_interface_html;
pub use self::channel_interface_html::*;
mod channel_interface_media_signalling;
pub use self::channel_interface_media_signalling::*;
mod channel_interface_mergeable_conference;
pub use self::channel_interface_mergeable_conference::*;
mod channel_interface_messages;
pub use self::channel_interface_messages::*;
mod channel_interface_password;
pub use self::channel_interface_password::*;
mod channel_interface_picture;
pub use self::channel_interface_picture::*;
mod channel_interface_room_config;
pub use self::channel_interface_room_config::*;
mod channel_interface_room;
pub use self::channel_interface_room::*;
mod channel_interface_sasl_authentication;
pub use self::channel_interface_sasl_authentication::*;
mod channel_interface_securable;
pub use self::channel_interface_securable::*;
mod channel_interface_service_point;
pub use self::channel_interface_service_point::*;
mod channel_interface_sms;
pub use self::channel_interface_sms::*;
mod channel_interface_splittable;
pub use self::channel_interface_splittable::*;
mod channel_interface_subject;
pub use self::channel_interface_subject::*;
mod channel_interface_transfer;
pub use self::channel_interface_transfer::*;
mod channel_interface_tube;
pub use self::channel_interface_tube::*;
mod channel_request;
pub use self::channel_request::*;
mod channel_type_call;
pub use self::channel_type_call::*;
mod channel_type_contact_list;
pub use self::channel_type_contact_list::*;
mod channel_type_contact_search;
pub use self::channel_type_contact_search::*;
mod channel_type_dbus_tube;
pub use self::channel_type_dbus_tube::*;
mod channel_type_file_transfer;
pub use self::channel_type_file_transfer::*;
mod channel_type_room_list;
pub use self::channel_type_room_list::*;
mod channel_type_server_authentication;
pub use self::channel_type_server_authentication::*;
mod channel_type_server_tls_connection;
pub use self::channel_type_server_tls_connection::*;
mod channel_type_streamed_media;
pub use self::channel_type_streamed_media::*;
mod channel_type_stream_tube;
pub use self::channel_type_stream_tube::*;
mod channel_type_text;
pub use self::channel_type_text::*;
mod channel_type_tubes;
pub use self::channel_type_tubes::*;
mod channel;
pub use self::channel::*;
mod client_approver;
pub use self::client_approver::*;
mod client_handler_future;
pub use self::client_handler_future::*;
mod client_handler;
pub use self::client_handler::*;
mod client_interface_requests;
pub use self::client_interface_requests::*;
mod client_observer;
pub use self::client_observer::*;
mod client;
pub use self::client::*;
mod connection_interface_addressing;
pub use self::connection_interface_addressing::*;
mod connection_interface_aliasing;
pub use self::connection_interface_aliasing::*;
mod connection_interface_anonymity;
pub use self::connection_interface_anonymity::*;
mod connection_interface_avatars;
pub use self::connection_interface_avatars::*;
mod connection_interface_balance;
pub use self::connection_interface_balance::*;
mod connection_interface_capabilities;
pub use self::connection_interface_capabilities::*;
mod connection_interface_cellular;
pub use self::connection_interface_cellular::*;
mod connection_interface_client_types;
pub use self::connection_interface_client_types::*;
mod connection_interface_communication_policy;
pub use self::connection_interface_communication_policy::*;
mod connection_interface_contact_blocking;
pub use self::connection_interface_contact_blocking::*;
mod connection_interface_contact_capabilities;
pub use self::connection_interface_contact_capabilities::*;
mod connection_interface_contact_groups;
pub use self::connection_interface_contact_groups::*;
mod connection_interface_contact_info;
pub use self::connection_interface_contact_info::*;
mod connection_interface_contact_list;
pub use self::connection_interface_contact_list::*;
mod connection_interface_contacts;
pub use self::connection_interface_contacts::*;
mod connection_interface_forwarding;
pub use self::connection_interface_forwarding::*;
mod connection_interface_irc_command1;
pub use self::connection_interface_irc_command1::*;
mod connection_interface_keepalive;
pub use self::connection_interface_keepalive::*;
mod connection_interface_location;
pub use self::connection_interface_location::*;
mod connection_interface_mail_notification;
pub use self::connection_interface_mail_notification::*;
mod connection_interface_power_saving;
pub use self::connection_interface_power_saving::*;
mod connection_interface_presence;
pub use self::connection_interface_presence::*;
mod connection_interface_privacy;
pub use self::connection_interface_privacy::*;
mod connection_interface_renaming;
pub use self::connection_interface_renaming::*;
mod connection_interface_requests;
pub use self::connection_interface_requests::*;
mod connection_interface_resources;
pub use self::connection_interface_resources::*;
mod connection_interface_service_point;
pub use self::connection_interface_service_point::*;
mod connection_interface_sidecars1;
pub use self::connection_interface_sidecars1::*;
mod connection_interface_simple_presence;
pub use self::connection_interface_simple_presence::*;
mod connection_manager_interface_account_storage;
pub use self::connection_manager_interface_account_storage::*;
mod connection_manager;
pub use self::connection_manager::*;
mod connection;
pub use self::connection::*;
mod debug;
pub use self::debug::*;
mod errors;
pub use self::errors::*;
mod generic_types;
pub use self::generic_types::*;
mod media_session_handler;
pub use self::media_session_handler::*;
mod media_stream_handler;
pub use self::media_stream_handler::*;
mod properties_interface;
pub use self::properties_interface::*;
mod protocol_interface_addressing;
pub use self::protocol_interface_addressing::*;
mod protocol_interface_avatars;
pub use self::protocol_interface_avatars::*;
mod protocol_interface_presence;
pub use self::protocol_interface_presence::*;
mod protocol;
pub use self::protocol::*;
mod template;
pub use self::template::*;

459
src/telepathy/account.rs

@ -0,0 +1,459 @@
// This code was autogenerated with `dbus-codegen-rust --file telepathy-spec/spec/Account.xml -i org.freedesktop.Telepathy -o src/telepathy/account.rs`, see https://github.com/diwic/dbus-rs
use dbus;
use dbus::arg;
use dbus::tree;
pub trait Account {
fn remove(&self) -> Result<(), tree::MethodErr>;
fn update_parameters(
&self,
set: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
unset: Vec<&str>,
) -> Result<Vec<String>, tree::MethodErr>;
fn reconnect(&self) -> Result<(), tree::MethodErr>;
fn interfaces(&self) -> Result<Vec<String>, tree::MethodErr>;
fn display_name(&self) -> Result<String, tree::MethodErr>;
fn set_display_name(&self, value: String) -> Result<(), tree::MethodErr>;
fn icon(&self) -> Result<String, tree::MethodErr>;
fn set_icon(&self, value: String) -> Result<(), tree::MethodErr>;
fn valid(&self) -> Result<bool, tree::MethodErr>;
fn enabled(&self) -> Result<bool, tree::MethodErr>;
fn set_enabled(&self, value: bool) -> Result<(), tree::MethodErr>;
fn nickname(&self) -> Result<String, tree::MethodErr>;
fn set_nickname(&self, value: String) -> Result<(), tree::MethodErr>;
fn service(&self) -> Result<String, tree::MethodErr>;
fn set_service(&self, value: String) -> Result<(), tree::MethodErr>;
fn parameters(
&self,
) -> Result<
::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg + 'static>>>,
tree::MethodErr,
>;
fn automatic_presence(&self) -> Result<(u32, String, String), tree::MethodErr>;
fn set_automatic_presence(&self, value: (u32, String, String)) -> Result<(), tree::MethodErr>;
fn connect_automatically(&self) -> Result<bool, tree::MethodErr>;
fn set_connect_automatically(&self, value: bool) -> Result<(), tree::MethodErr>;
fn connection(&self) -> Result<dbus::Path<'static>, tree::MethodErr>;
fn connection_status(&self) -> Result<u32, tree::MethodErr>;
fn connection_status_reason(&self) -> Result<u32, tree::MethodErr>;
fn connection_error(&self) -> Result<String, tree::MethodErr>;
fn connection_error_details(
&self,
) -> Result<
::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg + 'static>>>,
tree::MethodErr,
>;
fn current_presence(&self) -> Result<(u32, String, String), tree::MethodErr>;
fn requested_presence(&self) -> Result<(u32, String, String), tree::MethodErr>;
fn set_requested_presence(&self, value: (u32, String, String)) -> Result<(), tree::MethodErr>;
fn changing_presence(&self) -> Result<bool, tree::MethodErr>;
fn normalized_name(&self) -> Result<String, tree::MethodErr>;
fn has_been_online(&self) -> Result<bool, tree::MethodErr>;
fn supersedes(&self) -> Result<Vec<dbus::Path<'static>>, tree::MethodErr>;
fn set_supersedes(&self, value: Vec<dbus::Path<'static>>) -> Result<(), tree::MethodErr>;
}
pub fn account_server<F, T, D>(
factory: &tree::Factory<tree::MTFn<D>, D>,
data: D::Interface,
f: F,
) -> tree::Interface<tree::MTFn<D>, D>
where
D: tree::DataType,
D::Method: Default,
D::Property: Default,
D::Signal: Default,
T: Account,
F: 'static + for<'z> Fn(&'z tree::MethodInfo<tree::MTFn<D>, D>) -> &'z T,
{
let i = factory.interface("org.freedesktop.Telepathy.Account", data);
let f = ::std::sync::Arc::new(f);
let fclone = f.clone();
let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| {
let d = fclone(minfo);
d.remove()?;
let rm = minfo.msg.method_return();
Ok(vec![rm])
};
let m = factory.method("Remove", Default::default(), h);
let i = i.add_m(m);
let fclone = f.clone();
let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| {
let mut i = minfo.msg.iter_init();
let set: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>> =
i.read()?;
let unset: Vec<&str> = i.read()?;
let d = fclone(minfo);
let reconnect_required = d.update_parameters(set, unset)?;
let rm = minfo.msg.method_return();
let rm = rm.append1(reconnect_required);
Ok(vec![rm])
};
let m = factory.method("UpdateParameters", Default::default(), h);
let m = m.in_arg(("Set", "a{sv}"));
let m = m.in_arg(("Unset", "as"));
let m = m.out_arg(("Reconnect_Required", "as"));
let i = i.add_m(m);
let fclone = f.clone();
let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| {
let d = fclone(minfo);
d.reconnect()?;
let rm = minfo.msg.method_return();
Ok(vec![rm])
};
let m = factory.method("Reconnect", Default::default(), h);
let i = i.add_m(m);
let p = factory.property::<Vec<&str>, _>("Interfaces", Default::default());
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.interfaces()?);
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<&str, _>("DisplayName", Default::default());
let p = p.access(tree::Access::ReadWrite);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.display_name()?);
Ok(())
});
let fclone = f.clone();
let p = p.on_set(move |iter, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
d.set_display_name(iter.read()?)?;
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<&str, _>("Icon", Default::default());
let p = p.access(tree::Access::ReadWrite);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.icon()?);
Ok(())
});
let fclone = f.clone();
let p = p.on_set(move |iter, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
d.set_icon(iter.read()?)?;
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<bool, _>("Valid", Default::default());
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.valid()?);
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<bool, _>("Enabled", Default::default());
let p = p.access(tree::Access::ReadWrite);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.enabled()?);
Ok(())
});
let fclone = f.clone();
let p = p.on_set(move |iter, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
d.set_enabled(iter.read()?)?;
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<&str, _>("Nickname", Default::default());
let p = p.access(tree::Access::ReadWrite);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.nickname()?);
Ok(())
});
let fclone = f.clone();
let p = p.on_set(move |iter, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
d.set_nickname(iter.read()?)?;
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<&str, _>("Service", Default::default());
let p = p.access(tree::Access::ReadWrite);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.service()?);
Ok(())
});
let fclone = f.clone();
let p = p.on_set(move |iter, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
d.set_service(iter.read()?)?;
Ok(())
});
let i = i.add_p(p);
let p = factory
.property::<::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>, _>(
"Parameters",
Default::default(),
);
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.parameters()?);
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<(u32, &str, &str), _>("AutomaticPresence", Default::default());
let p = p.access(tree::Access::ReadWrite);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.automatic_presence()?);
Ok(())
});
let fclone = f.clone();
let p = p.on_set(move |iter, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
d.set_automatic_presence(iter.read()?)?;
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<bool, _>("ConnectAutomatically", Default::default());
let p = p.access(tree::Access::ReadWrite);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.connect_automatically()?);
Ok(())
});
let fclone = f.clone();
let p = p.on_set(move |iter, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
d.set_connect_automatically(iter.read()?)?;
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<dbus::Path, _>("Connection", Default::default());
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.connection()?);
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<u32, _>("ConnectionStatus", Default::default());
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.connection_status()?);
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<u32, _>("ConnectionStatusReason", Default::default());
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.connection_status_reason()?);
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<&str, _>("ConnectionError", Default::default());
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.connection_error()?);
Ok(())
});
let i = i.add_p(p);
let p = factory
.property::<::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>, _>(
"ConnectionErrorDetails",
Default::default(),
);
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.connection_error_details()?);
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<(u32, &str, &str), _>("CurrentPresence", Default::default());
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.current_presence()?);
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<(u32, &str, &str), _>("RequestedPresence", Default::default());
let p = p.access(tree::Access::ReadWrite);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.requested_presence()?);
Ok(())
});
let fclone = f.clone();
let p = p.on_set(move |iter, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
d.set_requested_presence(iter.read()?)?;
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<bool, _>("ChangingPresence", Default::default());
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.changing_presence()?);
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<&str, _>("NormalizedName", Default::default());
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.normalized_name()?);
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<bool, _>("HasBeenOnline", Default::default());
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.has_been_online()?);
Ok(())
});
let i = i.add_p(p);
let p = factory.property::<Vec<dbus::Path>, _>("Supersedes", Default::default());
let p = p.access(tree::Access::ReadWrite);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.supersedes()?);
Ok(())
});
let fclone = f.clone();
let p = p.on_set(move |iter, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
d.set_supersedes(iter.read()?)?;
Ok(())
});
let i = i.add_p(p);
let s = factory.signal("Removed", Default::default());
let i = i.add_s(s);
let s = factory.signal("AccountPropertyChanged", Default::default());
let s = s.arg(("Properties", "a{sv}"));
let i = i.add_s(s);
i
}
#[derive(Debug)]
pub struct AccountRemoved {}
impl arg::AppendAll for AccountRemoved {
fn append(&self, _: &mut arg::IterAppend) {}
}
impl arg::ReadAll for AccountRemoved {
fn read(_: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
Ok(AccountRemoved {})
}
}
impl dbus::message::SignalArgs for AccountRemoved {
const NAME: &'static str = "Removed";
const INTERFACE: &'static str = "org.freedesktop.Telepathy.Account";
}
#[derive(Debug)]
pub struct AccountAccountPropertyChanged {
pub properties:
::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg + 'static>>>,
}
impl arg::AppendAll for AccountAccountPropertyChanged {
fn append(&self, i: &mut arg::IterAppend) {
arg::RefArg::append(&self.properties, i);
}
}
impl arg::ReadAll for AccountAccountPropertyChanged {
fn read(i: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
Ok(AccountAccountPropertyChanged {
properties: i.read()?,
})
}
}
impl dbus::message::SignalArgs for AccountAccountPropertyChanged {
const NAME: &'static str = "AccountPropertyChanged";
const INTERFACE: &'static str = "org.freedesktop.Telepathy.Account";
}

58
src/telepathy/account_interface_addressing.rs

@ -0,0 +1,58 @@
// This code was autogenerated with `dbus-codegen-rust --file telepathy-spec/spec/Account_Interface_Addressing.xml -i org.freedesktop.Telepathy -o src/telepathy/account_interface_addressing.rs`, see https://github.com/diwic/dbus-rs
use dbus;
use dbus::arg;
use dbus::tree;
pub trait AccountInterfaceAddressing {
fn set_urischeme_association(
&self,
urischeme: &str,
association: bool,
) -> Result<(), tree::MethodErr>;
fn urischemes(&self) -> Result<Vec<String>, tree::MethodErr>;
}
pub fn account_interface_addressing_server<F, T, D>(
factory: &tree::Factory<tree::MTFn<D>, D>,
data: D::Interface,
f: F,
) -> tree::Interface<tree::MTFn<D>, D>
where
D: tree::DataType,
D::Method: Default,
D::Property: Default,
T: AccountInterfaceAddressing,
F: 'static + for<'z> Fn(&'z tree::MethodInfo<tree::MTFn<D>, D>) -> &'z T,
{
let i = factory.interface(
"org.freedesktop.Telepathy.Account.Interface.Addressing",
data,
);
let f = ::std::sync::Arc::new(f);
let fclone = f.clone();
let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| {
let mut i = minfo.msg.iter_init();
let urischeme: &str = i.read()?;
let association: bool = i.read()?;
let d = fclone(minfo);
d.set_urischeme_association(urischeme, association)?;
let rm = minfo.msg.method_return();
Ok(vec![rm])
};
let m = factory.method("SetURISchemeAssociation", Default::default(), h);
let m = m.in_arg(("URI_Scheme", "s"));
let m = m.in_arg(("Association", "b"));
let i = i.add_m(m);
let p = factory.property::<Vec<&str>, _>("URISchemes", Default::default());
let p = p.access(tree::Access::Read);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.urischemes()?);
Ok(())
});
let i = i.add_p(p);
i
}

64
src/telepathy/account_interface_avatar.rs

@ -0,0 +1,64 @@
// This code was autogenerated with `dbus-codegen-rust --file telepathy-spec/spec/Account_Interface_Avatar.xml -i org.freedesktop.Telepathy -o src/telepathy/account_interface_avatar.rs`, see https://github.com/diwic/dbus-rs
use dbus;
use dbus::arg;
use dbus::tree;
pub trait AccountInterfaceAvatar {
fn avatar(&self) -> Result<(Vec<u8>, String), tree::MethodErr>;
fn set_avatar(&self, value: (Vec<u8>, String)) -> Result<(), tree::MethodErr>;
}
pub fn account_interface_avatar_server<F, T, D>(
factory: &tree::Factory<tree::MTFn<D>, D>,
data: D::Interface,
f: F,
) -> tree::Interface<tree::MTFn<D>, D>
where
D: tree::DataType,
D::Method: Default,
D::Property: Default,
D::Signal: Default,
T: AccountInterfaceAvatar,
F: 'static + for<'z> Fn(&'z tree::MethodInfo<tree::MTFn<D>, D>) -> &'z T,
{
let i = factory.interface("org.freedesktop.Telepathy.Account.Interface.Avatar", data);
let f = ::std::sync::Arc::new(f);
let p = factory.property::<(Vec<u8>, &str), _>("Avatar", Default::default());
let p = p.access(tree::Access::ReadWrite);
let fclone = f.clone();
let p = p.on_get(move |a, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
a.append(d.avatar()?);
Ok(())
});
let fclone = f.clone();
let p = p.on_set(move |iter, pinfo| {
let minfo = pinfo.to_method_info();
let d = fclone(&minfo);
d.set_avatar(iter.read()?)?;
Ok(())
});
let i = i.add_p(p);
let s = factory.signal("AvatarChanged", Default::default());
let i = i.add_s(s);
i
}
#[derive(Debug)]
pub struct AccountInterfaceAvatarAvatarChanged {}
impl arg::AppendAll for AccountInterfaceAvatarAvatarChanged {
fn append(&self, _: &mut arg::IterAppend) {}
}
impl arg::ReadAll for AccountInterfaceAvatarAvatarChanged {
fn read(_: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
Ok(AccountInterfaceAvatarAvatarChanged {})
}
}
impl dbus::message::SignalArgs for AccountInterfaceAvatarAvatarChanged {
const NAME: &'static str = "AvatarChanged";
const INTERFACE: &'static str = "org.freedesktop.Telepathy.Account.Interface.Avatar";
}