1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
use crate::{HandleToken, WindowIdentifier};
use zbus::{dbus_proxy, fdo::Result};
use zvariant::{Fd, OwnedObjectPath};
use zvariant_derive::{DeserializeDict, SerializeDict, TypeDict};
#[derive(SerializeDict, DeserializeDict, TypeDict, Debug, Default)]
pub struct EmailOptions {
pub handle_token: Option<HandleToken>,
pub address: Option<String>,
pub addresses: Option<Vec<String>>,
pub cc: Option<Vec<String>>,
pub bcc: Option<Vec<String>>,
pub subject: Option<String>,
pub body: Option<String>,
pub attachment_fds: Option<Vec<Fd>>,
}
impl EmailOptions {
pub fn handle_token(mut self, handle_token: HandleToken) -> Self {
self.handle_token = Some(handle_token);
self
}
pub fn address(mut self, address: &str) -> Self {
self.address = Some(address.to_string());
self
}
pub fn addresses(mut self, addresses: Vec<String>) -> Self {
self.addresses = Some(addresses);
self
}
pub fn bcc(mut self, bcc: Vec<String>) -> Self {
self.bcc = Some(bcc);
self
}
pub fn cc(mut self, cc: Vec<String>) -> Self {
self.cc = Some(cc);
self
}
pub fn subject(mut self, subject: &str) -> Self {
self.subject = Some(subject.to_string());
self
}
pub fn body(mut self, body: &str) -> Self {
self.body = Some(body.to_string());
self
}
pub fn attach(mut self, attachment: Fd) -> Self {
match self.attachment_fds {
Some(ref mut attachments) => attachments.push(attachment),
None => {
self.attachment_fds.replace(vec![attachment]);
}
};
self
}
}
#[dbus_proxy(
interface = "org.freedesktop.portal.Email",
default_service = "org.freedesktop.portal.Desktop",
default_path = "/org/freedesktop/portal/desktop"
)]
trait Email {
fn compose_email(
&self,
parent_window: WindowIdentifier,
options: EmailOptions,
) -> Result<OwnedObjectPath>;
#[dbus_proxy(property, name = "version")]
fn version(&self) -> Result<u32>;
}