diff options
Diffstat (limited to 'src/dbus_api/sink.rs')
-rw-r--r-- | src/dbus_api/sink.rs | 1128 |
1 files changed, 1128 insertions, 0 deletions
diff --git a/src/dbus_api/sink.rs b/src/dbus_api/sink.rs new file mode 100644 index 0000000..6bd1756 --- /dev/null +++ b/src/dbus_api/sink.rs | |||
@@ -0,0 +1,1128 @@ | |||
1 | // This code was autogenerated with dbus-codegen-rust, see https://github.com/diwic/dbus-rs | ||
2 | |||
3 | #![allow(dead_code)] | ||
4 | use dbus as dbus; | ||
5 | use dbus::arg; | ||
6 | use dbus::tree; | ||
7 | |||
8 | pub trait OrgPulseAudioExtEqualizing1Equalizer { | ||
9 | type Err; | ||
10 | fn filter_at_points(&self, channel: u32, xs: Vec<u32>) -> Result<(Vec<f64>, f64), Self::Err>; | ||
11 | fn seed_filter(&self, channel: u32, xs: Vec<u32>, ys: Vec<f64>, preamp: f64) -> Result<(), Self::Err>; | ||
12 | fn save_profile(&self, channel: u32, name: &str) -> Result<(), Self::Err>; | ||
13 | fn load_profile(&self, channel: u32, name: &str) -> Result<(), Self::Err>; | ||
14 | fn set_filter(&self, channel: u32, ys: Vec<f64>, preamp: f64) -> Result<(), Self::Err>; | ||
15 | fn get_filter(&self, channel: u32) -> Result<(Vec<f64>, f64), Self::Err>; | ||
16 | fn save_state(&self) -> Result<(), Self::Err>; | ||
17 | fn base_profile(&self, channel: u32) -> Result<String, Self::Err>; | ||
18 | fn get_interface_revision(&self) -> Result<u32, Self::Err>; | ||
19 | fn get_sample_rate(&self) -> Result<u32, Self::Err>; | ||
20 | fn get_filter_sample_rate(&self) -> Result<u32, Self::Err>; | ||
21 | fn get_nfilter_coefficients(&self) -> Result<u32, Self::Err>; | ||
22 | fn get_nchannels(&self) -> Result<u32, Self::Err>; | ||
23 | } | ||
24 | |||
25 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgPulseAudioExtEqualizing1Equalizer for dbus::ConnPath<'a, C> { | ||
26 | type Err = dbus::Error; | ||
27 | |||
28 | fn filter_at_points(&self, channel: u32, xs: Vec<u32>) -> Result<(Vec<f64>, f64), Self::Err> { | ||
29 | let mut m = try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"FilterAtPoints".into(), |msg| { | ||
30 | let mut i = arg::IterAppend::new(msg); | ||
31 | i.append(channel); | ||
32 | i.append(xs); | ||
33 | })); | ||
34 | try!(m.as_result()); | ||
35 | let mut i = m.iter_init(); | ||
36 | let ys: Vec<f64> = try!(i.read()); | ||
37 | let preamp: f64 = try!(i.read()); | ||
38 | Ok((ys, preamp)) | ||
39 | } | ||
40 | |||
41 | fn seed_filter(&self, channel: u32, xs: Vec<u32>, ys: Vec<f64>, preamp: f64) -> Result<(), Self::Err> { | ||
42 | let mut m = try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"SeedFilter".into(), |msg| { | ||
43 | let mut i = arg::IterAppend::new(msg); | ||
44 | i.append(channel); | ||
45 | i.append(xs); | ||
46 | i.append(ys); | ||
47 | i.append(preamp); | ||
48 | })); | ||
49 | try!(m.as_result()); | ||
50 | Ok(()) | ||
51 | } | ||
52 | |||
53 | fn save_profile(&self, channel: u32, name: &str) -> Result<(), Self::Err> { | ||
54 | let mut m = try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"SaveProfile".into(), |msg| { | ||
55 | let mut i = arg::IterAppend::new(msg); | ||
56 | i.append(channel); | ||
57 | i.append(name); | ||
58 | })); | ||
59 | try!(m.as_result()); | ||
60 | Ok(()) | ||
61 | } | ||
62 | |||
63 | fn load_profile(&self, channel: u32, name: &str) -> Result<(), Self::Err> { | ||
64 | let mut m = try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"LoadProfile".into(), |msg| { | ||
65 | let mut i = arg::IterAppend::new(msg); | ||
66 | i.append(channel); | ||
67 | i.append(name); | ||
68 | })); | ||
69 | try!(m.as_result()); | ||
70 | Ok(()) | ||
71 | } | ||
72 | |||
73 | fn set_filter(&self, channel: u32, ys: Vec<f64>, preamp: f64) -> Result<(), Self::Err> { | ||
74 | let mut m = try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"SetFilter".into(), |msg| { | ||
75 | let mut i = arg::IterAppend::new(msg); | ||
76 | i.append(channel); | ||
77 | i.append(ys); | ||
78 | i.append(preamp); | ||
79 | })); | ||
80 | try!(m.as_result()); | ||
81 | Ok(()) | ||
82 | } | ||
83 | |||
84 | fn get_filter(&self, channel: u32) -> Result<(Vec<f64>, f64), Self::Err> { | ||
85 | let mut m = try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"GetFilter".into(), |msg| { | ||
86 | let mut i = arg::IterAppend::new(msg); | ||
87 | i.append(channel); | ||
88 | })); | ||
89 | try!(m.as_result()); | ||
90 | let mut i = m.iter_init(); | ||
91 | let ys: Vec<f64> = try!(i.read()); | ||
92 | let preamp: f64 = try!(i.read()); | ||
93 | Ok((ys, preamp)) | ||
94 | } | ||
95 | |||
96 | fn save_state(&self) -> Result<(), Self::Err> { | ||
97 | let mut m = try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"SaveState".into(), |_| { | ||
98 | })); | ||
99 | try!(m.as_result()); | ||
100 | Ok(()) | ||
101 | } | ||
102 | |||
103 | fn base_profile(&self, channel: u32) -> Result<String, Self::Err> { | ||
104 | let mut m = try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"BaseProfile".into(), |msg| { | ||
105 | let mut i = arg::IterAppend::new(msg); | ||
106 | i.append(channel); | ||
107 | })); | ||
108 | try!(m.as_result()); | ||
109 | let mut i = m.iter_init(); | ||
110 | let name: String = try!(i.read()); | ||
111 | Ok(name) | ||
112 | } | ||
113 | |||
114 | fn get_interface_revision(&self) -> Result<u32, Self::Err> { | ||
115 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Equalizer", "InterfaceRevision") | ||
116 | } | ||
117 | |||
118 | fn get_sample_rate(&self) -> Result<u32, Self::Err> { | ||
119 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Equalizer", "SampleRate") | ||
120 | } | ||
121 | |||
122 | fn get_filter_sample_rate(&self) -> Result<u32, Self::Err> { | ||
123 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Equalizer", "FilterSampleRate") | ||
124 | } | ||
125 | |||
126 | fn get_nfilter_coefficients(&self) -> Result<u32, Self::Err> { | ||
127 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Equalizer", "NFilterCoefficients") | ||
128 | } | ||
129 | |||
130 | fn get_nchannels(&self) -> Result<u32, Self::Err> { | ||
131 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Equalizer", "NChannels") | ||
132 | } | ||
133 | } | ||
134 | |||
135 | pub fn org_pulse_audio_ext_equalizing1_equalizer_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
136 | where | ||
137 | D: tree::DataType, | ||
138 | D::Method: Default, | ||
139 | D::Property: Default, | ||
140 | T: OrgPulseAudioExtEqualizing1Equalizer<Err=tree::MethodErr>, | ||
141 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<tree::MTFn<D>, D>) -> & 'z T, | ||
142 | { | ||
143 | let i = factory.interface("org.PulseAudio.Ext.Equalizing1.Equalizer", data); | ||
144 | let f = ::std::sync::Arc::new(f); | ||
145 | let fclone = f.clone(); | ||
146 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
147 | let mut i = minfo.msg.iter_init(); | ||
148 | let channel: u32 = try!(i.read()); | ||
149 | let xs: Vec<u32> = try!(i.read()); | ||
150 | let d = fclone(minfo); | ||
151 | let (ys, preamp) = try!(d.filter_at_points(channel, xs)); | ||
152 | let rm = minfo.msg.method_return(); | ||
153 | let rm = rm.append1(ys); | ||
154 | let rm = rm.append1(preamp); | ||
155 | Ok(vec!(rm)) | ||
156 | }; | ||
157 | let m = factory.method("FilterAtPoints", Default::default(), h); | ||
158 | let m = m.in_arg(("channel", "u")); | ||
159 | let m = m.in_arg(("xs", "au")); | ||
160 | let m = m.out_arg(("ys", "ad")); | ||
161 | let m = m.out_arg(("preamp", "d")); | ||
162 | let i = i.add_m(m); | ||
163 | |||
164 | let fclone = f.clone(); | ||
165 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
166 | let mut i = minfo.msg.iter_init(); | ||
167 | let channel: u32 = try!(i.read()); | ||
168 | let xs: Vec<u32> = try!(i.read()); | ||
169 | let ys: Vec<f64> = try!(i.read()); | ||
170 | let preamp: f64 = try!(i.read()); | ||
171 | let d = fclone(minfo); | ||
172 | try!(d.seed_filter(channel, xs, ys, preamp)); | ||
173 | let rm = minfo.msg.method_return(); | ||
174 | Ok(vec!(rm)) | ||
175 | }; | ||
176 | let m = factory.method("SeedFilter", Default::default(), h); | ||
177 | let m = m.in_arg(("channel", "u")); | ||
178 | let m = m.in_arg(("xs", "au")); | ||
179 | let m = m.in_arg(("ys", "ad")); | ||
180 | let m = m.in_arg(("preamp", "d")); | ||
181 | let i = i.add_m(m); | ||
182 | |||
183 | let fclone = f.clone(); | ||
184 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
185 | let mut i = minfo.msg.iter_init(); | ||
186 | let channel: u32 = try!(i.read()); | ||
187 | let name: &str = try!(i.read()); | ||
188 | let d = fclone(minfo); | ||
189 | try!(d.save_profile(channel, name)); | ||
190 | let rm = minfo.msg.method_return(); | ||
191 | Ok(vec!(rm)) | ||
192 | }; | ||
193 | let m = factory.method("SaveProfile", Default::default(), h); | ||
194 | let m = m.in_arg(("channel", "u")); | ||
195 | let m = m.in_arg(("name", "s")); | ||
196 | let i = i.add_m(m); | ||
197 | |||
198 | let fclone = f.clone(); | ||
199 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
200 | let mut i = minfo.msg.iter_init(); | ||
201 | let channel: u32 = try!(i.read()); | ||
202 | let name: &str = try!(i.read()); | ||
203 | let d = fclone(minfo); | ||
204 | try!(d.load_profile(channel, name)); | ||
205 | let rm = minfo.msg.method_return(); | ||
206 | Ok(vec!(rm)) | ||
207 | }; | ||
208 | let m = factory.method("LoadProfile", Default::default(), h); | ||
209 | let m = m.in_arg(("channel", "u")); | ||
210 | let m = m.in_arg(("name", "s")); | ||
211 | let i = i.add_m(m); | ||
212 | |||
213 | let fclone = f.clone(); | ||
214 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
215 | let mut i = minfo.msg.iter_init(); | ||
216 | let channel: u32 = try!(i.read()); | ||
217 | let ys: Vec<f64> = try!(i.read()); | ||
218 | let preamp: f64 = try!(i.read()); | ||
219 | let d = fclone(minfo); | ||
220 | try!(d.set_filter(channel, ys, preamp)); | ||
221 | let rm = minfo.msg.method_return(); | ||
222 | Ok(vec!(rm)) | ||
223 | }; | ||
224 | let m = factory.method("SetFilter", Default::default(), h); | ||
225 | let m = m.in_arg(("channel", "u")); | ||
226 | let m = m.in_arg(("ys", "ad")); | ||
227 | let m = m.in_arg(("preamp", "d")); | ||
228 | let i = i.add_m(m); | ||
229 | |||
230 | let fclone = f.clone(); | ||
231 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
232 | let mut i = minfo.msg.iter_init(); | ||
233 | let channel: u32 = try!(i.read()); | ||
234 | let d = fclone(minfo); | ||
235 | let (ys, preamp) = try!(d.get_filter(channel)); | ||
236 | let rm = minfo.msg.method_return(); | ||
237 | let rm = rm.append1(ys); | ||
238 | let rm = rm.append1(preamp); | ||
239 | Ok(vec!(rm)) | ||
240 | }; | ||
241 | let m = factory.method("GetFilter", Default::default(), h); | ||
242 | let m = m.in_arg(("channel", "u")); | ||
243 | let m = m.out_arg(("ys", "ad")); | ||
244 | let m = m.out_arg(("preamp", "d")); | ||
245 | let i = i.add_m(m); | ||
246 | |||
247 | let fclone = f.clone(); | ||
248 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
249 | let d = fclone(minfo); | ||
250 | try!(d.save_state()); | ||
251 | let rm = minfo.msg.method_return(); | ||
252 | Ok(vec!(rm)) | ||
253 | }; | ||
254 | let m = factory.method("SaveState", Default::default(), h); | ||
255 | let i = i.add_m(m); | ||
256 | |||
257 | let fclone = f.clone(); | ||
258 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
259 | let mut i = minfo.msg.iter_init(); | ||
260 | let channel: u32 = try!(i.read()); | ||
261 | let d = fclone(minfo); | ||
262 | let name = try!(d.base_profile(channel)); | ||
263 | let rm = minfo.msg.method_return(); | ||
264 | let rm = rm.append1(name); | ||
265 | Ok(vec!(rm)) | ||
266 | }; | ||
267 | let m = factory.method("BaseProfile", Default::default(), h); | ||
268 | let m = m.in_arg(("channel", "u")); | ||
269 | let m = m.out_arg(("name", "s")); | ||
270 | let i = i.add_m(m); | ||
271 | |||
272 | let p = factory.property::<u32, _>("InterfaceRevision", Default::default()); | ||
273 | let p = p.access(tree::Access::Read); | ||
274 | let fclone = f.clone(); | ||
275 | let p = p.on_get(move |a, pinfo| { | ||
276 | let minfo = pinfo.to_method_info(); | ||
277 | let d = fclone(&minfo); | ||
278 | a.append(try!(d.get_interface_revision())); | ||
279 | Ok(()) | ||
280 | }); | ||
281 | let i = i.add_p(p); | ||
282 | |||
283 | let p = factory.property::<u32, _>("SampleRate", Default::default()); | ||
284 | let p = p.access(tree::Access::Read); | ||
285 | let fclone = f.clone(); | ||
286 | let p = p.on_get(move |a, pinfo| { | ||
287 | let minfo = pinfo.to_method_info(); | ||
288 | let d = fclone(&minfo); | ||
289 | a.append(try!(d.get_sample_rate())); | ||
290 | Ok(()) | ||
291 | }); | ||
292 | let i = i.add_p(p); | ||
293 | |||
294 | let p = factory.property::<u32, _>("FilterSampleRate", Default::default()); | ||
295 | let p = p.access(tree::Access::Read); | ||
296 | let fclone = f.clone(); | ||
297 | let p = p.on_get(move |a, pinfo| { | ||
298 | let minfo = pinfo.to_method_info(); | ||
299 | let d = fclone(&minfo); | ||
300 | a.append(try!(d.get_filter_sample_rate())); | ||
301 | Ok(()) | ||
302 | }); | ||
303 | let i = i.add_p(p); | ||
304 | |||
305 | let p = factory.property::<u32, _>("NFilterCoefficients", Default::default()); | ||
306 | let p = p.access(tree::Access::Read); | ||
307 | let fclone = f.clone(); | ||
308 | let p = p.on_get(move |a, pinfo| { | ||
309 | let minfo = pinfo.to_method_info(); | ||
310 | let d = fclone(&minfo); | ||
311 | a.append(try!(d.get_nfilter_coefficients())); | ||
312 | Ok(()) | ||
313 | }); | ||
314 | let i = i.add_p(p); | ||
315 | |||
316 | let p = factory.property::<u32, _>("NChannels", Default::default()); | ||
317 | let p = p.access(tree::Access::Read); | ||
318 | let fclone = f.clone(); | ||
319 | let p = p.on_get(move |a, pinfo| { | ||
320 | let minfo = pinfo.to_method_info(); | ||
321 | let d = fclone(&minfo); | ||
322 | a.append(try!(d.get_nchannels())); | ||
323 | Ok(()) | ||
324 | }); | ||
325 | let i = i.add_p(p); | ||
326 | i | ||
327 | } | ||
328 | |||
329 | #[derive(Debug, Default)] | ||
330 | pub struct OrgPulseAudioExtEqualizing1EqualizerFilterChanged { | ||
331 | } | ||
332 | |||
333 | impl dbus::SignalArgs for OrgPulseAudioExtEqualizing1EqualizerFilterChanged { | ||
334 | const NAME: &'static str = "FilterChanged"; | ||
335 | const INTERFACE: &'static str = "org.PulseAudio.Ext.Equalizing1.Equalizer"; | ||
336 | fn append(&self, _: &mut arg::IterAppend) { | ||
337 | } | ||
338 | fn get(&mut self, _: &mut arg::Iter) -> Result<(), arg::TypeMismatchError> { | ||
339 | Ok(()) | ||
340 | } | ||
341 | } | ||
342 | |||
343 | #[derive(Debug, Default)] | ||
344 | pub struct OrgPulseAudioExtEqualizing1EqualizerSinkReconfigured { | ||
345 | } | ||
346 | |||
347 | impl dbus::SignalArgs for OrgPulseAudioExtEqualizing1EqualizerSinkReconfigured { | ||
348 | const NAME: &'static str = "SinkReconfigured"; | ||
349 | const INTERFACE: &'static str = "org.PulseAudio.Ext.Equalizing1.Equalizer"; | ||
350 | fn append(&self, _: &mut arg::IterAppend) { | ||
351 | } | ||
352 | fn get(&mut self, _: &mut arg::Iter) -> Result<(), arg::TypeMismatchError> { | ||
353 | Ok(()) | ||
354 | } | ||
355 | } | ||
356 | |||
357 | pub trait OrgPulseAudioCore1Device { | ||
358 | type Err; | ||
359 | fn suspend(&self, suspend: bool) -> Result<(), Self::Err>; | ||
360 | fn get_port_by_name(&self, name: &str) -> Result<dbus::Path<'static>, Self::Err>; | ||
361 | fn get_index(&self) -> Result<u32, Self::Err>; | ||
362 | fn get_name(&self) -> Result<String, Self::Err>; | ||
363 | fn get_driver(&self) -> Result<String, Self::Err>; | ||
364 | fn get_owner_module(&self) -> Result<dbus::Path<'static>, Self::Err>; | ||
365 | fn get_card(&self) -> Result<dbus::Path<'static>, Self::Err>; | ||
366 | fn get_sample_format(&self) -> Result<u32, Self::Err>; | ||
367 | fn get_sample_rate(&self) -> Result<u32, Self::Err>; | ||
368 | fn get_channels(&self) -> Result<Vec<u32>, Self::Err>; | ||
369 | fn get_volume(&self) -> Result<Vec<u32>, Self::Err>; | ||
370 | fn set_volume(&self, value: Vec<u32>) -> Result<(), Self::Err>; | ||
371 | fn get_has_flat_volume(&self) -> Result<bool, Self::Err>; | ||
372 | fn get_has_convertible_to_decibel_volume(&self) -> Result<bool, Self::Err>; | ||
373 | fn get_base_volume(&self) -> Result<u32, Self::Err>; | ||
374 | fn get_volume_steps(&self) -> Result<u32, Self::Err>; | ||
375 | fn get_mute(&self) -> Result<bool, Self::Err>; | ||
376 | fn set_mute(&self, value: bool) -> Result<(), Self::Err>; | ||
377 | fn get_has_hardware_volume(&self) -> Result<bool, Self::Err>; | ||
378 | fn get_has_hardware_mute(&self) -> Result<bool, Self::Err>; | ||
379 | fn get_configured_latency(&self) -> Result<u64, Self::Err>; | ||
380 | fn get_has_dynamic_latency(&self) -> Result<bool, Self::Err>; | ||
381 | fn get_latency(&self) -> Result<u64, Self::Err>; | ||
382 | fn get_is_hardware_device(&self) -> Result<bool, Self::Err>; | ||
383 | fn get_is_network_device(&self) -> Result<bool, Self::Err>; | ||
384 | fn get_state(&self) -> Result<u32, Self::Err>; | ||
385 | fn get_ports(&self) -> Result<Vec<dbus::Path<'static>>, Self::Err>; | ||
386 | fn get_active_port(&self) -> Result<dbus::Path<'static>, Self::Err>; | ||
387 | fn set_active_port(&self, value: dbus::Path<'static>) -> Result<(), Self::Err>; | ||
388 | fn get_property_list(&self) -> Result<::std::collections::HashMap<String, Vec<u8>>, Self::Err>; | ||
389 | } | ||
390 | |||
391 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgPulseAudioCore1Device for dbus::ConnPath<'a, C> { | ||
392 | type Err = dbus::Error; | ||
393 | |||
394 | fn suspend(&self, suspend: bool) -> Result<(), Self::Err> { | ||
395 | let mut m = try!(self.method_call_with_args(&"org.PulseAudio.Core1.Device".into(), &"Suspend".into(), |msg| { | ||
396 | let mut i = arg::IterAppend::new(msg); | ||
397 | i.append(suspend); | ||
398 | })); | ||
399 | try!(m.as_result()); | ||
400 | Ok(()) | ||
401 | } | ||
402 | |||
403 | fn get_port_by_name(&self, name: &str) -> Result<dbus::Path<'static>, Self::Err> { | ||
404 | let mut m = try!(self.method_call_with_args(&"org.PulseAudio.Core1.Device".into(), &"GetPortByName".into(), |msg| { | ||
405 | let mut i = arg::IterAppend::new(msg); | ||
406 | i.append(name); | ||
407 | })); | ||
408 | try!(m.as_result()); | ||
409 | let mut i = m.iter_init(); | ||
410 | let port: dbus::Path<'static> = try!(i.read()); | ||
411 | Ok(port) | ||
412 | } | ||
413 | |||
414 | fn get_index(&self) -> Result<u32, Self::Err> { | ||
415 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Index") | ||
416 | } | ||
417 | |||
418 | fn get_name(&self) -> Result<String, Self::Err> { | ||
419 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Name") | ||
420 | } | ||
421 | |||
422 | fn get_driver(&self) -> Result<String, Self::Err> { | ||
423 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Driver") | ||
424 | } | ||
425 | |||
426 | fn get_owner_module(&self) -> Result<dbus::Path<'static>, Self::Err> { | ||
427 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "OwnerModule") | ||
428 | } | ||
429 | |||
430 | fn get_card(&self) -> Result<dbus::Path<'static>, Self::Err> { | ||
431 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Card") | ||
432 | } | ||
433 | |||
434 | fn get_sample_format(&self) -> Result<u32, Self::Err> { | ||
435 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "SampleFormat") | ||
436 | } | ||
437 | |||
438 | fn get_sample_rate(&self) -> Result<u32, Self::Err> { | ||
439 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "SampleRate") | ||
440 | } | ||
441 | |||
442 | fn get_channels(&self) -> Result<Vec<u32>, Self::Err> { | ||
443 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Channels") | ||
444 | } | ||
445 | |||
446 | fn get_volume(&self) -> Result<Vec<u32>, Self::Err> { | ||
447 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Volume") | ||
448 | } | ||
449 | |||
450 | fn get_has_flat_volume(&self) -> Result<bool, Self::Err> { | ||
451 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "HasFlatVolume") | ||
452 | } | ||
453 | |||
454 | fn get_has_convertible_to_decibel_volume(&self) -> Result<bool, Self::Err> { | ||
455 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "HasConvertibleToDecibelVolume") | ||
456 | } | ||
457 | |||
458 | fn get_base_volume(&self) -> Result<u32, Self::Err> { | ||
459 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "BaseVolume") | ||
460 | } | ||
461 | |||
462 | fn get_volume_steps(&self) -> Result<u32, Self::Err> { | ||
463 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "VolumeSteps") | ||
464 | } | ||
465 | |||
466 | fn get_mute(&self) -> Result<bool, Self::Err> { | ||
467 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Mute") | ||
468 | } | ||
469 | |||
470 | fn get_has_hardware_volume(&self) -> Result<bool, Self::Err> { | ||
471 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "HasHardwareVolume") | ||
472 | } | ||
473 | |||
474 | fn get_has_hardware_mute(&self) -> Result<bool, Self::Err> { | ||
475 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "HasHardwareMute") | ||
476 | } | ||
477 | |||
478 | fn get_configured_latency(&self) -> Result<u64, Self::Err> { | ||
479 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "ConfiguredLatency") | ||
480 | } | ||
481 | |||
482 | fn get_has_dynamic_latency(&self) -> Result<bool, Self::Err> { | ||
483 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "HasDynamicLatency") | ||
484 | } | ||
485 | |||
486 | fn get_latency(&self) -> Result<u64, Self::Err> { | ||
487 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Latency") | ||
488 | } | ||
489 | |||
490 | fn get_is_hardware_device(&self) -> Result<bool, Self::Err> { | ||
491 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "IsHardwareDevice") | ||
492 | } | ||
493 | |||
494 | fn get_is_network_device(&self) -> Result<bool, Self::Err> { | ||
495 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "IsNetworkDevice") | ||
496 | } | ||
497 | |||
498 | fn get_state(&self) -> Result<u32, Self::Err> { | ||
499 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "State") | ||
500 | } | ||
501 | |||
502 | fn get_ports(&self) -> Result<Vec<dbus::Path<'static>>, Self::Err> { | ||
503 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Ports") | ||
504 | } | ||
505 | |||
506 | fn get_active_port(&self) -> Result<dbus::Path<'static>, Self::Err> { | ||
507 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "ActivePort") | ||
508 | } | ||
509 | |||
510 | fn get_property_list(&self) -> Result<::std::collections::HashMap<String, Vec<u8>>, Self::Err> { | ||
511 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "PropertyList") | ||
512 | } | ||
513 | |||
514 | fn set_volume(&self, value: Vec<u32>) -> Result<(), Self::Err> { | ||
515 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::set(&self, "org.PulseAudio.Core1.Device", "Volume", value) | ||
516 | } | ||
517 | |||
518 | fn set_mute(&self, value: bool) -> Result<(), Self::Err> { | ||
519 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::set(&self, "org.PulseAudio.Core1.Device", "Mute", value) | ||
520 | } | ||
521 | |||
522 | fn set_active_port(&self, value: dbus::Path<'static>) -> Result<(), Self::Err> { | ||
523 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::set(&self, "org.PulseAudio.Core1.Device", "ActivePort", value) | ||
524 | } | ||
525 | } | ||
526 | |||
527 | pub fn org_pulse_audio_core1_device_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
528 | where | ||
529 | D: tree::DataType, | ||
530 | D::Method: Default, | ||
531 | D::Property: Default, | ||
532 | T: OrgPulseAudioCore1Device<Err=tree::MethodErr>, | ||
533 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<tree::MTFn<D>, D>) -> & 'z T, | ||
534 | { | ||
535 | let i = factory.interface("org.PulseAudio.Core1.Device", data); | ||
536 | let f = ::std::sync::Arc::new(f); | ||
537 | let fclone = f.clone(); | ||
538 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
539 | let mut i = minfo.msg.iter_init(); | ||
540 | let suspend: bool = try!(i.read()); | ||
541 | let d = fclone(minfo); | ||
542 | try!(d.suspend(suspend)); | ||
543 | let rm = minfo.msg.method_return(); | ||
544 | Ok(vec!(rm)) | ||
545 | }; | ||
546 | let m = factory.method("Suspend", Default::default(), h); | ||
547 | let m = m.in_arg(("suspend", "b")); | ||
548 | let i = i.add_m(m); | ||
549 | |||
550 | let fclone = f.clone(); | ||
551 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
552 | let mut i = minfo.msg.iter_init(); | ||
553 | let name: &str = try!(i.read()); | ||
554 | let d = fclone(minfo); | ||
555 | let port = try!(d.get_port_by_name(name)); | ||
556 | let rm = minfo.msg.method_return(); | ||
557 | let rm = rm.append1(port); | ||
558 | Ok(vec!(rm)) | ||
559 | }; | ||
560 | let m = factory.method("GetPortByName", Default::default(), h); | ||
561 | let m = m.in_arg(("name", "s")); | ||
562 | let m = m.out_arg(("port", "o")); | ||
563 | let i = i.add_m(m); | ||
564 | |||
565 | let p = factory.property::<u32, _>("Index", Default::default()); | ||
566 | let p = p.access(tree::Access::Read); | ||
567 | let fclone = f.clone(); | ||
568 | let p = p.on_get(move |a, pinfo| { | ||
569 | let minfo = pinfo.to_method_info(); | ||
570 | let d = fclone(&minfo); | ||
571 | a.append(try!(d.get_index())); | ||
572 | Ok(()) | ||
573 | }); | ||
574 | let i = i.add_p(p); | ||
575 | |||
576 | let p = factory.property::<&str, _>("Name", Default::default()); | ||
577 | let p = p.access(tree::Access::Read); | ||
578 | let fclone = f.clone(); | ||
579 | let p = p.on_get(move |a, pinfo| { | ||
580 | let minfo = pinfo.to_method_info(); | ||
581 | let d = fclone(&minfo); | ||
582 | a.append(try!(d.get_name())); | ||
583 | Ok(()) | ||
584 | }); | ||
585 | let i = i.add_p(p); | ||
586 | |||
587 | let p = factory.property::<&str, _>("Driver", Default::default()); | ||
588 | let p = p.access(tree::Access::Read); | ||
589 | let fclone = f.clone(); | ||
590 | let p = p.on_get(move |a, pinfo| { | ||
591 | let minfo = pinfo.to_method_info(); | ||
592 | let d = fclone(&minfo); | ||
593 | a.append(try!(d.get_driver())); | ||
594 | Ok(()) | ||
595 | }); | ||
596 | let i = i.add_p(p); | ||
597 | |||
598 | let p = factory.property::<dbus::Path, _>("OwnerModule", Default::default()); | ||
599 | let p = p.access(tree::Access::Read); | ||
600 | let fclone = f.clone(); | ||
601 | let p = p.on_get(move |a, pinfo| { | ||
602 | let minfo = pinfo.to_method_info(); | ||
603 | let d = fclone(&minfo); | ||
604 | a.append(try!(d.get_owner_module())); | ||
605 | Ok(()) | ||
606 | }); | ||
607 | let i = i.add_p(p); | ||
608 | |||
609 | let p = factory.property::<dbus::Path, _>("Card", Default::default()); | ||
610 | let p = p.access(tree::Access::Read); | ||
611 | let fclone = f.clone(); | ||
612 | let p = p.on_get(move |a, pinfo| { | ||
613 | let minfo = pinfo.to_method_info(); | ||
614 | let d = fclone(&minfo); | ||
615 | a.append(try!(d.get_card())); | ||
616 | Ok(()) | ||
617 | }); | ||
618 | let i = i.add_p(p); | ||
619 | |||
620 | let p = factory.property::<u32, _>("SampleFormat", Default::default()); | ||
621 | let p = p.access(tree::Access::Read); | ||
622 | let fclone = f.clone(); | ||
623 | let p = p.on_get(move |a, pinfo| { | ||
624 | let minfo = pinfo.to_method_info(); | ||
625 | let d = fclone(&minfo); | ||
626 | a.append(try!(d.get_sample_format())); | ||
627 | Ok(()) | ||
628 | }); | ||
629 | let i = i.add_p(p); | ||
630 | |||
631 | let p = factory.property::<u32, _>("SampleRate", Default::default()); | ||
632 | let p = p.access(tree::Access::Read); | ||
633 | let fclone = f.clone(); | ||
634 | let p = p.on_get(move |a, pinfo| { | ||
635 | let minfo = pinfo.to_method_info(); | ||
636 | let d = fclone(&minfo); | ||
637 | a.append(try!(d.get_sample_rate())); | ||
638 | Ok(()) | ||
639 | }); | ||
640 | let i = i.add_p(p); | ||
641 | |||
642 | let p = factory.property::<Vec<u32>, _>("Channels", Default::default()); | ||
643 | let p = p.access(tree::Access::Read); | ||
644 | let fclone = f.clone(); | ||
645 | let p = p.on_get(move |a, pinfo| { | ||
646 | let minfo = pinfo.to_method_info(); | ||
647 | let d = fclone(&minfo); | ||
648 | a.append(try!(d.get_channels())); | ||
649 | Ok(()) | ||
650 | }); | ||
651 | let i = i.add_p(p); | ||
652 | |||
653 | let p = factory.property::<Vec<u32>, _>("Volume", Default::default()); | ||
654 | let p = p.access(tree::Access::ReadWrite); | ||
655 | let fclone = f.clone(); | ||
656 | let p = p.on_get(move |a, pinfo| { | ||
657 | let minfo = pinfo.to_method_info(); | ||
658 | let d = fclone(&minfo); | ||
659 | a.append(try!(d.get_volume())); | ||
660 | Ok(()) | ||
661 | }); | ||
662 | let fclone = f.clone(); | ||
663 | let p = p.on_set(move |iter, pinfo| { | ||
664 | let minfo = pinfo.to_method_info(); | ||
665 | let d = fclone(&minfo); | ||
666 | try!(d.set_volume(try!(iter.read()))); | ||
667 | Ok(()) | ||
668 | }); | ||
669 | let i = i.add_p(p); | ||
670 | |||
671 | let p = factory.property::<bool, _>("HasFlatVolume", Default::default()); | ||
672 | let p = p.access(tree::Access::Read); | ||
673 | let fclone = f.clone(); | ||
674 | let p = p.on_get(move |a, pinfo| { | ||
675 | let minfo = pinfo.to_method_info(); | ||
676 | let d = fclone(&minfo); | ||
677 | a.append(try!(d.get_has_flat_volume())); | ||
678 | Ok(()) | ||
679 | }); | ||
680 | let i = i.add_p(p); | ||
681 | |||
682 | let p = factory.property::<bool, _>("HasConvertibleToDecibelVolume", Default::default()); | ||
683 | let p = p.access(tree::Access::Read); | ||
684 | let fclone = f.clone(); | ||
685 | let p = p.on_get(move |a, pinfo| { | ||
686 | let minfo = pinfo.to_method_info(); | ||
687 | let d = fclone(&minfo); | ||
688 | a.append(try!(d.get_has_convertible_to_decibel_volume())); | ||
689 | Ok(()) | ||
690 | }); | ||
691 | let i = i.add_p(p); | ||
692 | |||
693 | let p = factory.property::<u32, _>("BaseVolume", Default::default()); | ||
694 | let p = p.access(tree::Access::Read); | ||
695 | let fclone = f.clone(); | ||
696 | let p = p.on_get(move |a, pinfo| { | ||
697 | let minfo = pinfo.to_method_info(); | ||
698 | let d = fclone(&minfo); | ||
699 | a.append(try!(d.get_base_volume())); | ||
700 | Ok(()) | ||
701 | }); | ||
702 | let i = i.add_p(p); | ||
703 | |||
704 | let p = factory.property::<u32, _>("VolumeSteps", Default::default()); | ||
705 | let p = p.access(tree::Access::Read); | ||
706 | let fclone = f.clone(); | ||
707 | let p = p.on_get(move |a, pinfo| { | ||
708 | let minfo = pinfo.to_method_info(); | ||
709 | let d = fclone(&minfo); | ||
710 | a.append(try!(d.get_volume_steps())); | ||
711 | Ok(()) | ||
712 | }); | ||
713 | let i = i.add_p(p); | ||
714 | |||
715 | let p = factory.property::<bool, _>("Mute", Default::default()); | ||
716 | let p = p.access(tree::Access::ReadWrite); | ||
717 | let fclone = f.clone(); | ||
718 | let p = p.on_get(move |a, pinfo| { | ||
719 | let minfo = pinfo.to_method_info(); | ||
720 | let d = fclone(&minfo); | ||
721 | a.append(try!(d.get_mute())); | ||
722 | Ok(()) | ||
723 | }); | ||
724 | let fclone = f.clone(); | ||
725 | let p = p.on_set(move |iter, pinfo| { | ||
726 | let minfo = pinfo.to_method_info(); | ||
727 | let d = fclone(&minfo); | ||
728 | try!(d.set_mute(try!(iter.read()))); | ||
729 | Ok(()) | ||
730 | }); | ||
731 | let i = i.add_p(p); | ||
732 | |||
733 | let p = factory.property::<bool, _>("HasHardwareVolume", Default::default()); | ||
734 | let p = p.access(tree::Access::Read); | ||
735 | let fclone = f.clone(); | ||
736 | let p = p.on_get(move |a, pinfo| { | ||
737 | let minfo = pinfo.to_method_info(); | ||
738 | let d = fclone(&minfo); | ||
739 | a.append(try!(d.get_has_hardware_volume())); | ||
740 | Ok(()) | ||
741 | }); | ||
742 | let i = i.add_p(p); | ||
743 | |||
744 | let p = factory.property::<bool, _>("HasHardwareMute", Default::default()); | ||
745 | let p = p.access(tree::Access::Read); | ||
746 | let fclone = f.clone(); | ||
747 | let p = p.on_get(move |a, pinfo| { | ||
748 | let minfo = pinfo.to_method_info(); | ||
749 | let d = fclone(&minfo); | ||
750 | a.append(try!(d.get_has_hardware_mute())); | ||
751 | Ok(()) | ||
752 | }); | ||
753 | let i = i.add_p(p); | ||
754 | |||
755 | let p = factory.property::<u64, _>("ConfiguredLatency", Default::default()); | ||
756 | let p = p.access(tree::Access::Read); | ||
757 | let fclone = f.clone(); | ||
758 | let p = p.on_get(move |a, pinfo| { | ||
759 | let minfo = pinfo.to_method_info(); | ||
760 | let d = fclone(&minfo); | ||
761 | a.append(try!(d.get_configured_latency())); | ||
762 | Ok(()) | ||
763 | }); | ||
764 | let i = i.add_p(p); | ||
765 | |||
766 | let p = factory.property::<bool, _>("HasDynamicLatency", Default::default()); | ||
767 | let p = p.access(tree::Access::Read); | ||
768 | let fclone = f.clone(); | ||
769 | let p = p.on_get(move |a, pinfo| { | ||
770 | let minfo = pinfo.to_method_info(); | ||
771 | let d = fclone(&minfo); | ||
772 | a.append(try!(d.get_has_dynamic_latency())); | ||
773 | Ok(()) | ||
774 | }); | ||
775 | let i = i.add_p(p); | ||
776 | |||
777 | let p = factory.property::<u64, _>("Latency", Default::default()); | ||
778 | let p = p.access(tree::Access::Read); | ||
779 | let fclone = f.clone(); | ||
780 | let p = p.on_get(move |a, pinfo| { | ||
781 | let minfo = pinfo.to_method_info(); | ||
782 | let d = fclone(&minfo); | ||
783 | a.append(try!(d.get_latency())); | ||
784 | Ok(()) | ||
785 | }); | ||
786 | let i = i.add_p(p); | ||
787 | |||
788 | let p = factory.property::<bool, _>("IsHardwareDevice", Default::default()); | ||
789 | let p = p.access(tree::Access::Read); | ||
790 | let fclone = f.clone(); | ||
791 | let p = p.on_get(move |a, pinfo| { | ||
792 | let minfo = pinfo.to_method_info(); | ||
793 | let d = fclone(&minfo); | ||
794 | a.append(try!(d.get_is_hardware_device())); | ||
795 | Ok(()) | ||
796 | }); | ||
797 | let i = i.add_p(p); | ||
798 | |||
799 | let p = factory.property::<bool, _>("IsNetworkDevice", Default::default()); | ||
800 | let p = p.access(tree::Access::Read); | ||
801 | let fclone = f.clone(); | ||
802 | let p = p.on_get(move |a, pinfo| { | ||
803 | let minfo = pinfo.to_method_info(); | ||
804 | let d = fclone(&minfo); | ||
805 | a.append(try!(d.get_is_network_device())); | ||
806 | Ok(()) | ||
807 | }); | ||
808 | let i = i.add_p(p); | ||
809 | |||
810 | let p = factory.property::<u32, _>("State", Default::default()); | ||
811 | let p = p.access(tree::Access::Read); | ||
812 | let fclone = f.clone(); | ||
813 | let p = p.on_get(move |a, pinfo| { | ||
814 | let minfo = pinfo.to_method_info(); | ||
815 | let d = fclone(&minfo); | ||
816 | a.append(try!(d.get_state())); | ||
817 | Ok(()) | ||
818 | }); | ||
819 | let i = i.add_p(p); | ||
820 | |||
821 | let p = factory.property::<Vec<dbus::Path>, _>("Ports", Default::default()); | ||
822 | let p = p.access(tree::Access::Read); | ||
823 | let fclone = f.clone(); | ||
824 | let p = p.on_get(move |a, pinfo| { | ||
825 | let minfo = pinfo.to_method_info(); | ||
826 | let d = fclone(&minfo); | ||
827 | a.append(try!(d.get_ports())); | ||
828 | Ok(()) | ||
829 | }); | ||
830 | let i = i.add_p(p); | ||
831 | |||
832 | let p = factory.property::<dbus::Path, _>("ActivePort", Default::default()); | ||
833 | let p = p.access(tree::Access::ReadWrite); | ||
834 | let fclone = f.clone(); | ||
835 | let p = p.on_get(move |a, pinfo| { | ||
836 | let minfo = pinfo.to_method_info(); | ||
837 | let d = fclone(&minfo); | ||
838 | a.append(try!(d.get_active_port())); | ||
839 | Ok(()) | ||
840 | }); | ||
841 | let fclone = f.clone(); | ||
842 | let p = p.on_set(move |iter, pinfo| { | ||
843 | let minfo = pinfo.to_method_info(); | ||
844 | let d = fclone(&minfo); | ||
845 | try!(d.set_active_port(try!(iter.read()))); | ||
846 | Ok(()) | ||
847 | }); | ||
848 | let i = i.add_p(p); | ||
849 | |||
850 | let p = factory.property::<::std::collections::HashMap<&str, Vec<u8>>, _>("PropertyList", Default::default()); | ||
851 | let p = p.access(tree::Access::Read); | ||
852 | let fclone = f.clone(); | ||
853 | let p = p.on_get(move |a, pinfo| { | ||
854 | let minfo = pinfo.to_method_info(); | ||
855 | let d = fclone(&minfo); | ||
856 | a.append(try!(d.get_property_list())); | ||
857 | Ok(()) | ||
858 | }); | ||
859 | let i = i.add_p(p); | ||
860 | i | ||
861 | } | ||
862 | |||
863 | #[derive(Debug, Default)] | ||
864 | pub struct OrgPulseAudioCore1DeviceVolumeUpdated { | ||
865 | pub volume: Vec<u32>, | ||
866 | } | ||
867 | |||
868 | impl dbus::SignalArgs for OrgPulseAudioCore1DeviceVolumeUpdated { | ||
869 | const NAME: &'static str = "VolumeUpdated"; | ||
870 | const INTERFACE: &'static str = "org.PulseAudio.Core1.Device"; | ||
871 | fn append(&self, i: &mut arg::IterAppend) { | ||
872 | (&self.volume as &arg::RefArg).append(i); | ||
873 | } | ||
874 | fn get(&mut self, i: &mut arg::Iter) -> Result<(), arg::TypeMismatchError> { | ||
875 | self.volume = try!(i.read()); | ||
876 | Ok(()) | ||
877 | } | ||
878 | } | ||
879 | |||
880 | #[derive(Debug, Default)] | ||
881 | pub struct OrgPulseAudioCore1DeviceMuteUpdated { | ||
882 | pub muted: bool, | ||
883 | } | ||
884 | |||
885 | impl dbus::SignalArgs for OrgPulseAudioCore1DeviceMuteUpdated { | ||
886 | const NAME: &'static str = "MuteUpdated"; | ||
887 | const INTERFACE: &'static str = "org.PulseAudio.Core1.Device"; | ||
888 | fn append(&self, i: &mut arg::IterAppend) { | ||
889 | (&self.muted as &arg::RefArg).append(i); | ||
890 | } | ||
891 | fn get(&mut self, i: &mut arg::Iter) -> Result<(), arg::TypeMismatchError> { | ||
892 | self.muted = try!(i.read()); | ||
893 | Ok(()) | ||
894 | } | ||
895 | } | ||
896 | |||
897 | #[derive(Debug, Default)] | ||
898 | pub struct OrgPulseAudioCore1DeviceStateUpdated { | ||
899 | pub state: u32, | ||
900 | } | ||
901 | |||
902 | impl dbus::SignalArgs for OrgPulseAudioCore1DeviceStateUpdated { | ||
903 | const NAME: &'static str = "StateUpdated"; | ||
904 | const INTERFACE: &'static str = "org.PulseAudio.Core1.Device"; | ||
905 | fn append(&self, i: &mut arg::IterAppend) { | ||
906 | (&self.state as &arg::RefArg).append(i); | ||
907 | } | ||
908 | fn get(&mut self, i: &mut arg::Iter) -> Result<(), arg::TypeMismatchError> { | ||
909 | self.state = try!(i.read()); | ||
910 | Ok(()) | ||
911 | } | ||
912 | } | ||
913 | |||
914 | #[derive(Debug, Default)] | ||
915 | pub struct OrgPulseAudioCore1DeviceActivePortUpdated { | ||
916 | pub port: dbus::Path<'static>, | ||
917 | } | ||
918 | |||
919 | impl dbus::SignalArgs for OrgPulseAudioCore1DeviceActivePortUpdated { | ||
920 | const NAME: &'static str = "ActivePortUpdated"; | ||
921 | const INTERFACE: &'static str = "org.PulseAudio.Core1.Device"; | ||
922 | fn append(&self, i: &mut arg::IterAppend) { | ||
923 | (&self.port as &arg::RefArg).append(i); | ||
924 | } | ||
925 | fn get(&mut self, i: &mut arg::Iter) -> Result<(), arg::TypeMismatchError> { | ||
926 | self.port = try!(i.read()); | ||
927 | Ok(()) | ||
928 | } | ||
929 | } | ||
930 | |||
931 | #[derive(Debug, Default)] | ||
932 | pub struct OrgPulseAudioCore1DevicePropertyListUpdated { | ||
933 | pub property_list: ::std::collections::HashMap<String, Vec<u8>>, | ||
934 | } | ||
935 | |||
936 | impl dbus::SignalArgs for OrgPulseAudioCore1DevicePropertyListUpdated { | ||
937 | const NAME: &'static str = "PropertyListUpdated"; | ||
938 | const INTERFACE: &'static str = "org.PulseAudio.Core1.Device"; | ||
939 | fn append(&self, i: &mut arg::IterAppend) { | ||
940 | (&self.property_list as &arg::RefArg).append(i); | ||
941 | } | ||
942 | fn get(&mut self, i: &mut arg::Iter) -> Result<(), arg::TypeMismatchError> { | ||
943 | self.property_list = try!(i.read()); | ||
944 | Ok(()) | ||
945 | } | ||
946 | } | ||
947 | |||
948 | pub trait OrgPulseAudioCore1Sink { | ||
949 | type Err; | ||
950 | fn get_monitor_source(&self) -> Result<dbus::Path<'static>, Self::Err>; | ||
951 | } | ||
952 | |||
953 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgPulseAudioCore1Sink for dbus::ConnPath<'a, C> { | ||
954 | type Err = dbus::Error; | ||
955 | |||
956 | fn get_monitor_source(&self) -> Result<dbus::Path<'static>, Self::Err> { | ||
957 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Sink", "MonitorSource") | ||
958 | } | ||
959 | } | ||
960 | |||
961 | pub fn org_pulse_audio_core1_sink_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
962 | where | ||
963 | D: tree::DataType, | ||
964 | D::Method: Default, | ||
965 | D::Property: Default, | ||
966 | T: OrgPulseAudioCore1Sink<Err=tree::MethodErr>, | ||
967 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<tree::MTFn<D>, D>) -> & 'z T, | ||
968 | { | ||
969 | let i = factory.interface("org.PulseAudio.Core1.Sink", data); | ||
970 | let f = ::std::sync::Arc::new(f); | ||
971 | let p = factory.property::<dbus::Path, _>("MonitorSource", Default::default()); | ||
972 | let p = p.access(tree::Access::Read); | ||
973 | let fclone = f.clone(); | ||
974 | let p = p.on_get(move |a, pinfo| { | ||
975 | let minfo = pinfo.to_method_info(); | ||
976 | let d = fclone(&minfo); | ||
977 | a.append(try!(d.get_monitor_source())); | ||
978 | Ok(()) | ||
979 | }); | ||
980 | let i = i.add_p(p); | ||
981 | i | ||
982 | } | ||
983 | |||
984 | pub trait OrgFreedesktopDBusIntrospectable { | ||
985 | type Err; | ||
986 | fn introspect(&self) -> Result<String, Self::Err>; | ||
987 | } | ||
988 | |||
989 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgFreedesktopDBusIntrospectable for dbus::ConnPath<'a, C> { | ||
990 | type Err = dbus::Error; | ||
991 | |||
992 | fn introspect(&self) -> Result<String, Self::Err> { | ||
993 | let mut m = try!(self.method_call_with_args(&"org.freedesktop.DBus.Introspectable".into(), &"Introspect".into(), |_| { | ||
994 | })); | ||
995 | try!(m.as_result()); | ||
996 | let mut i = m.iter_init(); | ||
997 | let data: String = try!(i.read()); | ||
998 | Ok(data) | ||
999 | } | ||
1000 | } | ||
1001 | |||
1002 | pub fn org_freedesktop_dbus_introspectable_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
1003 | where | ||
1004 | D: tree::DataType, | ||
1005 | D::Method: Default, | ||
1006 | T: OrgFreedesktopDBusIntrospectable<Err=tree::MethodErr>, | ||
1007 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<tree::MTFn<D>, D>) -> & 'z T, | ||
1008 | { | ||
1009 | let i = factory.interface("org.freedesktop.DBus.Introspectable", data); | ||
1010 | let f = ::std::sync::Arc::new(f); | ||
1011 | let fclone = f.clone(); | ||
1012 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
1013 | let d = fclone(minfo); | ||
1014 | let data = try!(d.introspect()); | ||
1015 | let rm = minfo.msg.method_return(); | ||
1016 | let rm = rm.append1(data); | ||
1017 | Ok(vec!(rm)) | ||
1018 | }; | ||
1019 | let m = factory.method("Introspect", Default::default(), h); | ||
1020 | let m = m.out_arg(("data", "s")); | ||
1021 | let i = i.add_m(m); | ||
1022 | i | ||
1023 | } | ||
1024 | |||
1025 | pub trait OrgFreedesktopDBusProperties { | ||
1026 | type Err; | ||
1027 | fn get(&self, interface_name: &str, property_name: &str) -> Result<arg::Variant<Box<arg::RefArg>>, Self::Err>; | ||
1028 | fn set(&self, interface_name: &str, property_name: &str, value: arg::Variant<Box<arg::RefArg>>) -> Result<(), Self::Err>; | ||
1029 | fn get_all(&self, interface_name: &str) -> Result<::std::collections::HashMap<String, arg::Variant<Box<arg::RefArg>>>, Self::Err>; | ||
1030 | } | ||
1031 | |||
1032 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgFreedesktopDBusProperties for dbus::ConnPath<'a, C> { | ||
1033 | type Err = dbus::Error; | ||
1034 | |||
1035 | fn get(&self, interface_name: &str, property_name: &str) -> Result<arg::Variant<Box<arg::RefArg>>, Self::Err> { | ||
1036 | let mut m = try!(self.method_call_with_args(&"org.freedesktop.DBus.Properties".into(), &"Get".into(), |msg| { | ||
1037 | let mut i = arg::IterAppend::new(msg); | ||
1038 | i.append(interface_name); | ||
1039 | i.append(property_name); | ||
1040 | })); | ||
1041 | try!(m.as_result()); | ||
1042 | let mut i = m.iter_init(); | ||
1043 | let value: arg::Variant<Box<arg::RefArg>> = try!(i.read()); | ||
1044 | Ok(value) | ||
1045 | } | ||
1046 | |||
1047 | fn set(&self, interface_name: &str, property_name: &str, value: arg::Variant<Box<arg::RefArg>>) -> Result<(), Self::Err> { | ||
1048 | let mut m = try!(self.method_call_with_args(&"org.freedesktop.DBus.Properties".into(), &"Set".into(), |msg| { | ||
1049 | let mut i = arg::IterAppend::new(msg); | ||
1050 | i.append(interface_name); | ||
1051 | i.append(property_name); | ||
1052 | i.append(value); | ||
1053 | })); | ||
1054 | try!(m.as_result()); | ||
1055 | Ok(()) | ||
1056 | } | ||
1057 | |||
1058 | fn get_all(&self, interface_name: &str) -> Result<::std::collections::HashMap<String, arg::Variant<Box<arg::RefArg>>>, Self::Err> { | ||
1059 | let mut m = try!(self.method_call_with_args(&"org.freedesktop.DBus.Properties".into(), &"GetAll".into(), |msg| { | ||
1060 | let mut i = arg::IterAppend::new(msg); | ||
1061 | i.append(interface_name); | ||
1062 | })); | ||
1063 | try!(m.as_result()); | ||
1064 | let mut i = m.iter_init(); | ||
1065 | let props: ::std::collections::HashMap<String, arg::Variant<Box<arg::RefArg>>> = try!(i.read()); | ||
1066 | Ok(props) | ||
1067 | } | ||
1068 | } | ||
1069 | |||
1070 | pub fn org_freedesktop_dbus_properties_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
1071 | where | ||
1072 | D: tree::DataType, | ||
1073 | D::Method: Default, | ||
1074 | T: OrgFreedesktopDBusProperties<Err=tree::MethodErr>, | ||
1075 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<tree::MTFn<D>, D>) -> & 'z T, | ||
1076 | { | ||
1077 | let i = factory.interface("org.freedesktop.DBus.Properties", data); | ||
1078 | let f = ::std::sync::Arc::new(f); | ||
1079 | let fclone = f.clone(); | ||
1080 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
1081 | let mut i = minfo.msg.iter_init(); | ||
1082 | let interface_name: &str = try!(i.read()); | ||
1083 | let property_name: &str = try!(i.read()); | ||
1084 | let d = fclone(minfo); | ||
1085 | let value = try!(d.get(interface_name, property_name)); | ||
1086 | let rm = minfo.msg.method_return(); | ||
1087 | let rm = rm.append1(value); | ||
1088 | Ok(vec!(rm)) | ||
1089 | }; | ||
1090 | let m = factory.method("Get", Default::default(), h); | ||
1091 | let m = m.in_arg(("interface_name", "s")); | ||
1092 | let m = m.in_arg(("property_name", "s")); | ||
1093 | let m = m.out_arg(("value", "v")); | ||
1094 | let i = i.add_m(m); | ||
1095 | |||
1096 | let fclone = f.clone(); | ||
1097 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
1098 | let mut i = minfo.msg.iter_init(); | ||
1099 | let interface_name: &str = try!(i.read()); | ||
1100 | let property_name: &str = try!(i.read()); | ||
1101 | let value: arg::Variant<Box<arg::RefArg>> = try!(i.read()); | ||
1102 | let d = fclone(minfo); | ||
1103 | try!(d.set(interface_name, property_name, value)); | ||
1104 | let rm = minfo.msg.method_return(); | ||
1105 | Ok(vec!(rm)) | ||
1106 | }; | ||
1107 | let m = factory.method("Set", Default::default(), h); | ||
1108 | let m = m.in_arg(("interface_name", "s")); | ||
1109 | let m = m.in_arg(("property_name", "s")); | ||
1110 | let m = m.in_arg(("value", "v")); | ||
1111 | let i = i.add_m(m); | ||
1112 | |||
1113 | let fclone = f.clone(); | ||
1114 | let h = move |minfo: &tree::MethodInfo<tree::MTFn<D>, D>| { | ||
1115 | let mut i = minfo.msg.iter_init(); | ||
1116 | let interface_name: &str = try!(i.read()); | ||
1117 | let d = fclone(minfo); | ||
1118 | let props = try!(d.get_all(interface_name)); | ||
1119 | let rm = minfo.msg.method_return(); | ||
1120 | let rm = rm.append1(props); | ||
1121 | Ok(vec!(rm)) | ||
1122 | }; | ||
1123 | let m = factory.method("GetAll", Default::default(), h); | ||
1124 | let m = m.in_arg(("interface_name", "s")); | ||
1125 | let m = m.out_arg(("props", "a{sv}")); | ||
1126 | let i = i.add_m(m); | ||
1127 | i | ||
1128 | } | ||