comparison libervia/frontends/bridge/dbus_bridge.py @ 4074:26b7ed2817da

refactoring: rename `sat_frontends` to `libervia.frontends`
author Goffi <goffi@goffi.org>
date Fri, 02 Jun 2023 14:12:38 +0200
parents sat_frontends/bridge/dbus_bridge.py@4b842c1fb686
children 02f0adc745c6
comparison
equal deleted inserted replaced
4073:7c5654c54fed 4074:26b7ed2817da
1 #!/usr/bin/env python3
2
3 # SàT communication bridge
4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
5
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
15
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 import asyncio
20 import dbus
21 import ast
22 from libervia.backend.core.i18n import _
23 from libervia.backend.tools import config
24 from libervia.backend.core.log import getLogger
25 from libervia.backend.core.exceptions import BridgeExceptionNoService, BridgeInitError
26 from dbus.mainloop.glib import DBusGMainLoop
27 from .bridge_frontend import BridgeException
28
29
30 DBusGMainLoop(set_as_default=True)
31 log = getLogger(__name__)
32
33
34 # Interface prefix
35 const_INT_PREFIX = config.config_get(
36 config.parse_main_conf(),
37 "",
38 "bridge_dbus_int_prefix",
39 "org.libervia.Libervia")
40 const_ERROR_PREFIX = const_INT_PREFIX + ".error"
41 const_OBJ_PATH = '/org/libervia/Libervia/bridge'
42 const_CORE_SUFFIX = ".core"
43 const_PLUGIN_SUFFIX = ".plugin"
44 const_TIMEOUT = 120
45
46
47 def dbus_to_bridge_exception(dbus_e):
48 """Convert a DBusException to a BridgeException.
49
50 @param dbus_e (DBusException)
51 @return: BridgeException
52 """
53 full_name = dbus_e.get_dbus_name()
54 if full_name.startswith(const_ERROR_PREFIX):
55 name = dbus_e.get_dbus_name()[len(const_ERROR_PREFIX) + 1:]
56 else:
57 name = full_name
58 # XXX: dbus_e.args doesn't contain the original DBusException args, but we
59 # receive its serialized form in dbus_e.args[0]. From that we can rebuild
60 # the original arguments list thanks to ast.literal_eval (secure eval).
61 message = dbus_e.get_dbus_message() # similar to dbus_e.args[0]
62 try:
63 message, condition = ast.literal_eval(message)
64 except (SyntaxError, ValueError, TypeError):
65 condition = ''
66 return BridgeException(name, message, condition)
67
68
69 class bridge:
70
71 def bridge_connect(self, callback, errback):
72 try:
73 self.sessions_bus = dbus.SessionBus()
74 self.db_object = self.sessions_bus.get_object(const_INT_PREFIX,
75 const_OBJ_PATH)
76 self.db_core_iface = dbus.Interface(self.db_object,
77 dbus_interface=const_INT_PREFIX + const_CORE_SUFFIX)
78 self.db_plugin_iface = dbus.Interface(self.db_object,
79 dbus_interface=const_INT_PREFIX + const_PLUGIN_SUFFIX)
80 except dbus.exceptions.DBusException as e:
81 if e._dbus_error_name in ('org.freedesktop.DBus.Error.ServiceUnknown',
82 'org.freedesktop.DBus.Error.Spawn.ExecFailed'):
83 errback(BridgeExceptionNoService())
84 elif e._dbus_error_name == 'org.freedesktop.DBus.Error.NotSupported':
85 log.error(_("D-Bus is not launched, please see README to see instructions on how to launch it"))
86 errback(BridgeInitError)
87 else:
88 errback(e)
89 else:
90 callback()
91 #props = self.db_core_iface.getProperties()
92
93 def register_signal(self, functionName, handler, iface="core"):
94 if iface == "core":
95 self.db_core_iface.connect_to_signal(functionName, handler)
96 elif iface == "plugin":
97 self.db_plugin_iface.connect_to_signal(functionName, handler)
98 else:
99 log.error(_('Unknown interface'))
100
101 def __getattribute__(self, name):
102 """ usual __getattribute__ if the method exists, else try to find a plugin method """
103 try:
104 return object.__getattribute__(self, name)
105 except AttributeError:
106 # The attribute is not found, we try the plugin proxy to find the requested method
107
108 def get_plugin_method(*args, **kwargs):
109 # We first check if we have an async call. We detect this in two ways:
110 # - if we have the 'callback' and 'errback' keyword arguments
111 # - or if the last two arguments are callable
112
113 async_ = False
114 args = list(args)
115
116 if kwargs:
117 if 'callback' in kwargs:
118 async_ = True
119 _callback = kwargs.pop('callback')
120 _errback = kwargs.pop('errback', lambda failure: log.error(str(failure)))
121 try:
122 args.append(kwargs.pop('profile'))
123 except KeyError:
124 try:
125 args.append(kwargs.pop('profile_key'))
126 except KeyError:
127 pass
128 # at this point, kwargs should be empty
129 if kwargs:
130 log.warning("unexpected keyword arguments, they will be ignored: {}".format(kwargs))
131 elif len(args) >= 2 and callable(args[-1]) and callable(args[-2]):
132 async_ = True
133 _errback = args.pop()
134 _callback = args.pop()
135
136 method = getattr(self.db_plugin_iface, name)
137
138 if async_:
139 kwargs['timeout'] = const_TIMEOUT
140 kwargs['reply_handler'] = _callback
141 kwargs['error_handler'] = lambda err: _errback(dbus_to_bridge_exception(err))
142
143 try:
144 return method(*args, **kwargs)
145 except ValueError as e:
146 if e.args[0].startswith("Unable to guess signature"):
147 # XXX: if frontend is started too soon after backend, the
148 # inspection misses methods (notably plugin dynamically added
149 # methods). The following hack works around that by redoing the
150 # cache of introspected methods signatures.
151 log.debug("using hack to work around inspection issue")
152 proxy = self.db_plugin_iface.proxy_object
153 IN_PROGRESS = proxy.INTROSPECT_STATE_INTROSPECT_IN_PROGRESS
154 proxy._introspect_state = IN_PROGRESS
155 proxy._Introspect()
156 return self.db_plugin_iface.get_dbus_method(name)(*args, **kwargs)
157 raise e
158
159 return get_plugin_method
160
161 def action_launch(self, callback_id, data, profile_key="@DEFAULT@", callback=None, errback=None):
162 if callback is None:
163 error_handler = None
164 else:
165 if errback is None:
166 errback = log.error
167 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
168 return str(self.db_core_iface.action_launch(callback_id, data, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
169
170 def actions_get(self, profile_key="@DEFAULT@", callback=None, errback=None):
171 if callback is None:
172 error_handler = None
173 else:
174 if errback is None:
175 errback = log.error
176 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
177 kwargs={}
178 if callback is not None:
179 kwargs['timeout'] = const_TIMEOUT
180 kwargs['reply_handler'] = callback
181 kwargs['error_handler'] = error_handler
182 return self.db_core_iface.actions_get(profile_key, **kwargs)
183
184 def config_get(self, section, name, callback=None, errback=None):
185 if callback is None:
186 error_handler = None
187 else:
188 if errback is None:
189 errback = log.error
190 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
191 kwargs={}
192 if callback is not None:
193 kwargs['timeout'] = const_TIMEOUT
194 kwargs['reply_handler'] = callback
195 kwargs['error_handler'] = error_handler
196 return str(self.db_core_iface.config_get(section, name, **kwargs))
197
198 def connect(self, profile_key="@DEFAULT@", password='', options={}, callback=None, errback=None):
199 if callback is None:
200 error_handler = None
201 else:
202 if errback is None:
203 errback = log.error
204 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
205 return self.db_core_iface.connect(profile_key, password, options, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
206
207 def contact_add(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None):
208 if callback is None:
209 error_handler = None
210 else:
211 if errback is None:
212 errback = log.error
213 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
214 kwargs={}
215 if callback is not None:
216 kwargs['timeout'] = const_TIMEOUT
217 kwargs['reply_handler'] = callback
218 kwargs['error_handler'] = error_handler
219 return self.db_core_iface.contact_add(entity_jid, profile_key, **kwargs)
220
221 def contact_del(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None):
222 if callback is None:
223 error_handler = None
224 else:
225 if errback is None:
226 errback = log.error
227 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
228 return self.db_core_iface.contact_del(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
229
230 def contact_get(self, arg_0, profile_key="@DEFAULT@", callback=None, errback=None):
231 if callback is None:
232 error_handler = None
233 else:
234 if errback is None:
235 errback = log.error
236 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
237 return self.db_core_iface.contact_get(arg_0, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
238
239 def contact_update(self, entity_jid, name, groups, profile_key="@DEFAULT@", callback=None, errback=None):
240 if callback is None:
241 error_handler = None
242 else:
243 if errback is None:
244 errback = log.error
245 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
246 kwargs={}
247 if callback is not None:
248 kwargs['timeout'] = const_TIMEOUT
249 kwargs['reply_handler'] = callback
250 kwargs['error_handler'] = error_handler
251 return self.db_core_iface.contact_update(entity_jid, name, groups, profile_key, **kwargs)
252
253 def contacts_get(self, profile_key="@DEFAULT@", callback=None, errback=None):
254 if callback is None:
255 error_handler = None
256 else:
257 if errback is None:
258 errback = log.error
259 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
260 return self.db_core_iface.contacts_get(profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
261
262 def contacts_get_from_group(self, group, profile_key="@DEFAULT@", callback=None, errback=None):
263 if callback is None:
264 error_handler = None
265 else:
266 if errback is None:
267 errback = log.error
268 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
269 kwargs={}
270 if callback is not None:
271 kwargs['timeout'] = const_TIMEOUT
272 kwargs['reply_handler'] = callback
273 kwargs['error_handler'] = error_handler
274 return self.db_core_iface.contacts_get_from_group(group, profile_key, **kwargs)
275
276 def devices_infos_get(self, bare_jid, profile_key, callback=None, errback=None):
277 if callback is None:
278 error_handler = None
279 else:
280 if errback is None:
281 errback = log.error
282 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
283 return str(self.db_core_iface.devices_infos_get(bare_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
284
285 def disco_find_by_features(self, namespaces, identities, bare_jid=False, service=True, roster=True, own_jid=True, local_device=False, profile_key="@DEFAULT@", callback=None, errback=None):
286 if callback is None:
287 error_handler = None
288 else:
289 if errback is None:
290 errback = log.error
291 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
292 return self.db_core_iface.disco_find_by_features(namespaces, identities, bare_jid, service, roster, own_jid, local_device, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
293
294 def disco_infos(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@", callback=None, errback=None):
295 if callback is None:
296 error_handler = None
297 else:
298 if errback is None:
299 errback = log.error
300 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
301 return self.db_core_iface.disco_infos(entity_jid, node, use_cache, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
302
303 def disco_items(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@", callback=None, errback=None):
304 if callback is None:
305 error_handler = None
306 else:
307 if errback is None:
308 errback = log.error
309 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
310 return self.db_core_iface.disco_items(entity_jid, node, use_cache, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
311
312 def disconnect(self, profile_key="@DEFAULT@", callback=None, errback=None):
313 if callback is None:
314 error_handler = None
315 else:
316 if errback is None:
317 errback = log.error
318 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
319 return self.db_core_iface.disconnect(profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
320
321 def encryption_namespace_get(self, arg_0, callback=None, errback=None):
322 if callback is None:
323 error_handler = None
324 else:
325 if errback is None:
326 errback = log.error
327 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
328 kwargs={}
329 if callback is not None:
330 kwargs['timeout'] = const_TIMEOUT
331 kwargs['reply_handler'] = callback
332 kwargs['error_handler'] = error_handler
333 return str(self.db_core_iface.encryption_namespace_get(arg_0, **kwargs))
334
335 def encryption_plugins_get(self, callback=None, errback=None):
336 if callback is None:
337 error_handler = None
338 else:
339 if errback is None:
340 errback = log.error
341 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
342 kwargs={}
343 if callback is not None:
344 kwargs['timeout'] = const_TIMEOUT
345 kwargs['reply_handler'] = callback
346 kwargs['error_handler'] = error_handler
347 return str(self.db_core_iface.encryption_plugins_get(**kwargs))
348
349 def encryption_trust_ui_get(self, to_jid, namespace, profile_key, callback=None, errback=None):
350 if callback is None:
351 error_handler = None
352 else:
353 if errback is None:
354 errback = log.error
355 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
356 return str(self.db_core_iface.encryption_trust_ui_get(to_jid, namespace, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
357
358 def entities_data_get(self, jids, keys, profile, callback=None, errback=None):
359 if callback is None:
360 error_handler = None
361 else:
362 if errback is None:
363 errback = log.error
364 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
365 kwargs={}
366 if callback is not None:
367 kwargs['timeout'] = const_TIMEOUT
368 kwargs['reply_handler'] = callback
369 kwargs['error_handler'] = error_handler
370 return self.db_core_iface.entities_data_get(jids, keys, profile, **kwargs)
371
372 def entity_data_get(self, jid, keys, profile, callback=None, errback=None):
373 if callback is None:
374 error_handler = None
375 else:
376 if errback is None:
377 errback = log.error
378 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
379 kwargs={}
380 if callback is not None:
381 kwargs['timeout'] = const_TIMEOUT
382 kwargs['reply_handler'] = callback
383 kwargs['error_handler'] = error_handler
384 return self.db_core_iface.entity_data_get(jid, keys, profile, **kwargs)
385
386 def features_get(self, profile_key, callback=None, errback=None):
387 if callback is None:
388 error_handler = None
389 else:
390 if errback is None:
391 errback = log.error
392 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
393 return self.db_core_iface.features_get(profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
394
395 def history_get(self, from_jid, to_jid, limit, between=True, filters='', profile="@NONE@", callback=None, errback=None):
396 if callback is None:
397 error_handler = None
398 else:
399 if errback is None:
400 errback = log.error
401 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
402 return self.db_core_iface.history_get(from_jid, to_jid, limit, between, filters, profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
403
404 def image_check(self, arg_0, callback=None, errback=None):
405 if callback is None:
406 error_handler = None
407 else:
408 if errback is None:
409 errback = log.error
410 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
411 kwargs={}
412 if callback is not None:
413 kwargs['timeout'] = const_TIMEOUT
414 kwargs['reply_handler'] = callback
415 kwargs['error_handler'] = error_handler
416 return str(self.db_core_iface.image_check(arg_0, **kwargs))
417
418 def image_convert(self, source, dest, arg_2, extra, callback=None, errback=None):
419 if callback is None:
420 error_handler = None
421 else:
422 if errback is None:
423 errback = log.error
424 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
425 return str(self.db_core_iface.image_convert(source, dest, arg_2, extra, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
426
427 def image_generate_preview(self, image_path, profile_key, callback=None, errback=None):
428 if callback is None:
429 error_handler = None
430 else:
431 if errback is None:
432 errback = log.error
433 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
434 return str(self.db_core_iface.image_generate_preview(image_path, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
435
436 def image_resize(self, image_path, width, height, callback=None, errback=None):
437 if callback is None:
438 error_handler = None
439 else:
440 if errback is None:
441 errback = log.error
442 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
443 return str(self.db_core_iface.image_resize(image_path, width, height, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
444
445 def is_connected(self, profile_key="@DEFAULT@", callback=None, errback=None):
446 if callback is None:
447 error_handler = None
448 else:
449 if errback is None:
450 errback = log.error
451 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
452 kwargs={}
453 if callback is not None:
454 kwargs['timeout'] = const_TIMEOUT
455 kwargs['reply_handler'] = callback
456 kwargs['error_handler'] = error_handler
457 return self.db_core_iface.is_connected(profile_key, **kwargs)
458
459 def main_resource_get(self, contact_jid, profile_key="@DEFAULT@", callback=None, errback=None):
460 if callback is None:
461 error_handler = None
462 else:
463 if errback is None:
464 errback = log.error
465 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
466 kwargs={}
467 if callback is not None:
468 kwargs['timeout'] = const_TIMEOUT
469 kwargs['reply_handler'] = callback
470 kwargs['error_handler'] = error_handler
471 return str(self.db_core_iface.main_resource_get(contact_jid, profile_key, **kwargs))
472
473 def menu_help_get(self, menu_id, language, callback=None, errback=None):
474 if callback is None:
475 error_handler = None
476 else:
477 if errback is None:
478 errback = log.error
479 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
480 kwargs={}
481 if callback is not None:
482 kwargs['timeout'] = const_TIMEOUT
483 kwargs['reply_handler'] = callback
484 kwargs['error_handler'] = error_handler
485 return str(self.db_core_iface.menu_help_get(menu_id, language, **kwargs))
486
487 def menu_launch(self, menu_type, path, data, security_limit, profile_key, callback=None, errback=None):
488 if callback is None:
489 error_handler = None
490 else:
491 if errback is None:
492 errback = log.error
493 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
494 return self.db_core_iface.menu_launch(menu_type, path, data, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
495
496 def menus_get(self, language, security_limit, callback=None, errback=None):
497 if callback is None:
498 error_handler = None
499 else:
500 if errback is None:
501 errback = log.error
502 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
503 kwargs={}
504 if callback is not None:
505 kwargs['timeout'] = const_TIMEOUT
506 kwargs['reply_handler'] = callback
507 kwargs['error_handler'] = error_handler
508 return self.db_core_iface.menus_get(language, security_limit, **kwargs)
509
510 def message_encryption_get(self, to_jid, profile_key, callback=None, errback=None):
511 if callback is None:
512 error_handler = None
513 else:
514 if errback is None:
515 errback = log.error
516 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
517 kwargs={}
518 if callback is not None:
519 kwargs['timeout'] = const_TIMEOUT
520 kwargs['reply_handler'] = callback
521 kwargs['error_handler'] = error_handler
522 return str(self.db_core_iface.message_encryption_get(to_jid, profile_key, **kwargs))
523
524 def message_encryption_start(self, to_jid, namespace='', replace=False, profile_key="@NONE@", callback=None, errback=None):
525 if callback is None:
526 error_handler = None
527 else:
528 if errback is None:
529 errback = log.error
530 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
531 return self.db_core_iface.message_encryption_start(to_jid, namespace, replace, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
532
533 def message_encryption_stop(self, to_jid, profile_key, callback=None, errback=None):
534 if callback is None:
535 error_handler = None
536 else:
537 if errback is None:
538 errback = log.error
539 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
540 return self.db_core_iface.message_encryption_stop(to_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
541
542 def message_send(self, to_jid, message, subject={}, mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None):
543 if callback is None:
544 error_handler = None
545 else:
546 if errback is None:
547 errback = log.error
548 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
549 return self.db_core_iface.message_send(to_jid, message, subject, mess_type, extra, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
550
551 def namespaces_get(self, callback=None, errback=None):
552 if callback is None:
553 error_handler = None
554 else:
555 if errback is None:
556 errback = log.error
557 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
558 kwargs={}
559 if callback is not None:
560 kwargs['timeout'] = const_TIMEOUT
561 kwargs['reply_handler'] = callback
562 kwargs['error_handler'] = error_handler
563 return self.db_core_iface.namespaces_get(**kwargs)
564
565 def param_get_a(self, name, category, attribute="value", profile_key="@DEFAULT@", callback=None, errback=None):
566 if callback is None:
567 error_handler = None
568 else:
569 if errback is None:
570 errback = log.error
571 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
572 kwargs={}
573 if callback is not None:
574 kwargs['timeout'] = const_TIMEOUT
575 kwargs['reply_handler'] = callback
576 kwargs['error_handler'] = error_handler
577 return str(self.db_core_iface.param_get_a(name, category, attribute, profile_key, **kwargs))
578
579 def param_get_a_async(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None):
580 if callback is None:
581 error_handler = None
582 else:
583 if errback is None:
584 errback = log.error
585 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
586 return str(self.db_core_iface.param_get_a_async(name, category, attribute, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
587
588 def param_set(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None):
589 if callback is None:
590 error_handler = None
591 else:
592 if errback is None:
593 errback = log.error
594 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
595 kwargs={}
596 if callback is not None:
597 kwargs['timeout'] = const_TIMEOUT
598 kwargs['reply_handler'] = callback
599 kwargs['error_handler'] = error_handler
600 return self.db_core_iface.param_set(name, value, category, security_limit, profile_key, **kwargs)
601
602 def param_ui_get(self, security_limit=-1, app='', extra='', profile_key="@DEFAULT@", callback=None, errback=None):
603 if callback is None:
604 error_handler = None
605 else:
606 if errback is None:
607 errback = log.error
608 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
609 return str(self.db_core_iface.param_ui_get(security_limit, app, extra, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
610
611 def params_categories_get(self, callback=None, errback=None):
612 if callback is None:
613 error_handler = None
614 else:
615 if errback is None:
616 errback = log.error
617 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
618 kwargs={}
619 if callback is not None:
620 kwargs['timeout'] = const_TIMEOUT
621 kwargs['reply_handler'] = callback
622 kwargs['error_handler'] = error_handler
623 return self.db_core_iface.params_categories_get(**kwargs)
624
625 def params_register_app(self, xml, security_limit=-1, app='', callback=None, errback=None):
626 if callback is None:
627 error_handler = None
628 else:
629 if errback is None:
630 errback = log.error
631 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
632 kwargs={}
633 if callback is not None:
634 kwargs['timeout'] = const_TIMEOUT
635 kwargs['reply_handler'] = callback
636 kwargs['error_handler'] = error_handler
637 return self.db_core_iface.params_register_app(xml, security_limit, app, **kwargs)
638
639 def params_template_load(self, filename, callback=None, errback=None):
640 if callback is None:
641 error_handler = None
642 else:
643 if errback is None:
644 errback = log.error
645 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
646 kwargs={}
647 if callback is not None:
648 kwargs['timeout'] = const_TIMEOUT
649 kwargs['reply_handler'] = callback
650 kwargs['error_handler'] = error_handler
651 return self.db_core_iface.params_template_load(filename, **kwargs)
652
653 def params_template_save(self, filename, callback=None, errback=None):
654 if callback is None:
655 error_handler = None
656 else:
657 if errback is None:
658 errback = log.error
659 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
660 kwargs={}
661 if callback is not None:
662 kwargs['timeout'] = const_TIMEOUT
663 kwargs['reply_handler'] = callback
664 kwargs['error_handler'] = error_handler
665 return self.db_core_iface.params_template_save(filename, **kwargs)
666
667 def params_values_from_category_get_async(self, category, security_limit=-1, app="", extra="", profile_key="@DEFAULT@", callback=None, errback=None):
668 if callback is None:
669 error_handler = None
670 else:
671 if errback is None:
672 errback = log.error
673 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
674 return self.db_core_iface.params_values_from_category_get_async(category, security_limit, app, extra, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
675
676 def presence_set(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@", callback=None, errback=None):
677 if callback is None:
678 error_handler = None
679 else:
680 if errback is None:
681 errback = log.error
682 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
683 kwargs={}
684 if callback is not None:
685 kwargs['timeout'] = const_TIMEOUT
686 kwargs['reply_handler'] = callback
687 kwargs['error_handler'] = error_handler
688 return self.db_core_iface.presence_set(to_jid, show, statuses, profile_key, **kwargs)
689
690 def presence_statuses_get(self, profile_key="@DEFAULT@", callback=None, errback=None):
691 if callback is None:
692 error_handler = None
693 else:
694 if errback is None:
695 errback = log.error
696 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
697 kwargs={}
698 if callback is not None:
699 kwargs['timeout'] = const_TIMEOUT
700 kwargs['reply_handler'] = callback
701 kwargs['error_handler'] = error_handler
702 return self.db_core_iface.presence_statuses_get(profile_key, **kwargs)
703
704 def private_data_delete(self, namespace, key, arg_2, callback=None, errback=None):
705 if callback is None:
706 error_handler = None
707 else:
708 if errback is None:
709 errback = log.error
710 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
711 return self.db_core_iface.private_data_delete(namespace, key, arg_2, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
712
713 def private_data_get(self, namespace, key, profile_key, callback=None, errback=None):
714 if callback is None:
715 error_handler = None
716 else:
717 if errback is None:
718 errback = log.error
719 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
720 return str(self.db_core_iface.private_data_get(namespace, key, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
721
722 def private_data_set(self, namespace, key, data, profile_key, callback=None, errback=None):
723 if callback is None:
724 error_handler = None
725 else:
726 if errback is None:
727 errback = log.error
728 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
729 return self.db_core_iface.private_data_set(namespace, key, data, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
730
731 def profile_create(self, profile, password='', component='', callback=None, errback=None):
732 if callback is None:
733 error_handler = None
734 else:
735 if errback is None:
736 errback = log.error
737 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
738 return self.db_core_iface.profile_create(profile, password, component, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
739
740 def profile_delete_async(self, profile, callback=None, errback=None):
741 if callback is None:
742 error_handler = None
743 else:
744 if errback is None:
745 errback = log.error
746 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
747 return self.db_core_iface.profile_delete_async(profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
748
749 def profile_is_session_started(self, profile_key="@DEFAULT@", callback=None, errback=None):
750 if callback is None:
751 error_handler = None
752 else:
753 if errback is None:
754 errback = log.error
755 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
756 kwargs={}
757 if callback is not None:
758 kwargs['timeout'] = const_TIMEOUT
759 kwargs['reply_handler'] = callback
760 kwargs['error_handler'] = error_handler
761 return self.db_core_iface.profile_is_session_started(profile_key, **kwargs)
762
763 def profile_name_get(self, profile_key="@DEFAULT@", callback=None, errback=None):
764 if callback is None:
765 error_handler = None
766 else:
767 if errback is None:
768 errback = log.error
769 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
770 kwargs={}
771 if callback is not None:
772 kwargs['timeout'] = const_TIMEOUT
773 kwargs['reply_handler'] = callback
774 kwargs['error_handler'] = error_handler
775 return str(self.db_core_iface.profile_name_get(profile_key, **kwargs))
776
777 def profile_set_default(self, profile, callback=None, errback=None):
778 if callback is None:
779 error_handler = None
780 else:
781 if errback is None:
782 errback = log.error
783 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
784 kwargs={}
785 if callback is not None:
786 kwargs['timeout'] = const_TIMEOUT
787 kwargs['reply_handler'] = callback
788 kwargs['error_handler'] = error_handler
789 return self.db_core_iface.profile_set_default(profile, **kwargs)
790
791 def profile_start_session(self, password='', profile_key="@DEFAULT@", callback=None, errback=None):
792 if callback is None:
793 error_handler = None
794 else:
795 if errback is None:
796 errback = log.error
797 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
798 return self.db_core_iface.profile_start_session(password, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
799
800 def profiles_list_get(self, clients=True, components=False, callback=None, errback=None):
801 if callback is None:
802 error_handler = None
803 else:
804 if errback is None:
805 errback = log.error
806 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
807 kwargs={}
808 if callback is not None:
809 kwargs['timeout'] = const_TIMEOUT
810 kwargs['reply_handler'] = callback
811 kwargs['error_handler'] = error_handler
812 return self.db_core_iface.profiles_list_get(clients, components, **kwargs)
813
814 def progress_get(self, id, profile, callback=None, errback=None):
815 if callback is None:
816 error_handler = None
817 else:
818 if errback is None:
819 errback = log.error
820 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
821 kwargs={}
822 if callback is not None:
823 kwargs['timeout'] = const_TIMEOUT
824 kwargs['reply_handler'] = callback
825 kwargs['error_handler'] = error_handler
826 return self.db_core_iface.progress_get(id, profile, **kwargs)
827
828 def progress_get_all(self, profile, callback=None, errback=None):
829 if callback is None:
830 error_handler = None
831 else:
832 if errback is None:
833 errback = log.error
834 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
835 kwargs={}
836 if callback is not None:
837 kwargs['timeout'] = const_TIMEOUT
838 kwargs['reply_handler'] = callback
839 kwargs['error_handler'] = error_handler
840 return self.db_core_iface.progress_get_all(profile, **kwargs)
841
842 def progress_get_all_metadata(self, profile, callback=None, errback=None):
843 if callback is None:
844 error_handler = None
845 else:
846 if errback is None:
847 errback = log.error
848 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
849 kwargs={}
850 if callback is not None:
851 kwargs['timeout'] = const_TIMEOUT
852 kwargs['reply_handler'] = callback
853 kwargs['error_handler'] = error_handler
854 return self.db_core_iface.progress_get_all_metadata(profile, **kwargs)
855
856 def ready_get(self, callback=None, errback=None):
857 if callback is None:
858 error_handler = None
859 else:
860 if errback is None:
861 errback = log.error
862 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
863 return self.db_core_iface.ready_get(timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
864
865 def roster_resync(self, profile_key="@DEFAULT@", callback=None, errback=None):
866 if callback is None:
867 error_handler = None
868 else:
869 if errback is None:
870 errback = log.error
871 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
872 return self.db_core_iface.roster_resync(profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
873
874 def session_infos_get(self, profile_key, callback=None, errback=None):
875 if callback is None:
876 error_handler = None
877 else:
878 if errback is None:
879 errback = log.error
880 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
881 return self.db_core_iface.session_infos_get(profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
882
883 def sub_waiting_get(self, profile_key="@DEFAULT@", callback=None, errback=None):
884 if callback is None:
885 error_handler = None
886 else:
887 if errback is None:
888 errback = log.error
889 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
890 kwargs={}
891 if callback is not None:
892 kwargs['timeout'] = const_TIMEOUT
893 kwargs['reply_handler'] = callback
894 kwargs['error_handler'] = error_handler
895 return self.db_core_iface.sub_waiting_get(profile_key, **kwargs)
896
897 def subscription(self, sub_type, entity, profile_key="@DEFAULT@", callback=None, errback=None):
898 if callback is None:
899 error_handler = None
900 else:
901 if errback is None:
902 errback = log.error
903 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
904 kwargs={}
905 if callback is not None:
906 kwargs['timeout'] = const_TIMEOUT
907 kwargs['reply_handler'] = callback
908 kwargs['error_handler'] = error_handler
909 return self.db_core_iface.subscription(sub_type, entity, profile_key, **kwargs)
910
911 def version_get(self, callback=None, errback=None):
912 if callback is None:
913 error_handler = None
914 else:
915 if errback is None:
916 errback = log.error
917 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
918 kwargs={}
919 if callback is not None:
920 kwargs['timeout'] = const_TIMEOUT
921 kwargs['reply_handler'] = callback
922 kwargs['error_handler'] = error_handler
923 return str(self.db_core_iface.version_get(**kwargs))
924
925
926 class AIOBridge(bridge):
927
928 def register_signal(self, functionName, handler, iface="core"):
929 loop = asyncio.get_running_loop()
930 async_handler = lambda *args: asyncio.run_coroutine_threadsafe(handler(*args), loop)
931 return super().register_signal(functionName, async_handler, iface)
932
933 def __getattribute__(self, name):
934 """ usual __getattribute__ if the method exists, else try to find a plugin method """
935 try:
936 return object.__getattribute__(self, name)
937 except AttributeError:
938 # The attribute is not found, we try the plugin proxy to find the requested method
939 def get_plugin_method(*args, **kwargs):
940 loop = asyncio.get_running_loop()
941 fut = loop.create_future()
942 method = getattr(self.db_plugin_iface, name)
943 reply_handler = lambda ret=None: loop.call_soon_threadsafe(
944 fut.set_result, ret)
945 error_handler = lambda err: loop.call_soon_threadsafe(
946 fut.set_exception, dbus_to_bridge_exception(err))
947 try:
948 method(
949 *args,
950 **kwargs,
951 timeout=const_TIMEOUT,
952 reply_handler=reply_handler,
953 error_handler=error_handler
954 )
955 except ValueError as e:
956 if e.args[0].startswith("Unable to guess signature"):
957 # same hack as for bridge.__getattribute__
958 log.warning("using hack to work around inspection issue")
959 proxy = self.db_plugin_iface.proxy_object
960 IN_PROGRESS = proxy.INTROSPECT_STATE_INTROSPECT_IN_PROGRESS
961 proxy._introspect_state = IN_PROGRESS
962 proxy._Introspect()
963 self.db_plugin_iface.get_dbus_method(name)(
964 *args,
965 **kwargs,
966 timeout=const_TIMEOUT,
967 reply_handler=reply_handler,
968 error_handler=error_handler
969 )
970
971 else:
972 raise e
973 return fut
974
975 return get_plugin_method
976
977 def bridge_connect(self):
978 loop = asyncio.get_running_loop()
979 fut = loop.create_future()
980 super().bridge_connect(
981 callback=lambda: loop.call_soon_threadsafe(fut.set_result, None),
982 errback=lambda e: loop.call_soon_threadsafe(fut.set_exception, e)
983 )
984 return fut
985
986 def action_launch(self, callback_id, data, profile_key="@DEFAULT@"):
987 loop = asyncio.get_running_loop()
988 fut = loop.create_future()
989 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
990 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
991 self.db_core_iface.action_launch(callback_id, data, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
992 return fut
993
994 def actions_get(self, profile_key="@DEFAULT@"):
995 loop = asyncio.get_running_loop()
996 fut = loop.create_future()
997 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
998 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
999 self.db_core_iface.actions_get(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1000 return fut
1001
1002 def config_get(self, section, name):
1003 loop = asyncio.get_running_loop()
1004 fut = loop.create_future()
1005 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1006 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1007 self.db_core_iface.config_get(section, name, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1008 return fut
1009
1010 def connect(self, profile_key="@DEFAULT@", password='', options={}):
1011 loop = asyncio.get_running_loop()
1012 fut = loop.create_future()
1013 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1014 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1015 self.db_core_iface.connect(profile_key, password, options, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1016 return fut
1017
1018 def contact_add(self, entity_jid, profile_key="@DEFAULT@"):
1019 loop = asyncio.get_running_loop()
1020 fut = loop.create_future()
1021 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1022 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1023 self.db_core_iface.contact_add(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1024 return fut
1025
1026 def contact_del(self, entity_jid, profile_key="@DEFAULT@"):
1027 loop = asyncio.get_running_loop()
1028 fut = loop.create_future()
1029 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1030 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1031 self.db_core_iface.contact_del(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1032 return fut
1033
1034 def contact_get(self, arg_0, profile_key="@DEFAULT@"):
1035 loop = asyncio.get_running_loop()
1036 fut = loop.create_future()
1037 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1038 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1039 self.db_core_iface.contact_get(arg_0, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1040 return fut
1041
1042 def contact_update(self, entity_jid, name, groups, profile_key="@DEFAULT@"):
1043 loop = asyncio.get_running_loop()
1044 fut = loop.create_future()
1045 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1046 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1047 self.db_core_iface.contact_update(entity_jid, name, groups, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1048 return fut
1049
1050 def contacts_get(self, profile_key="@DEFAULT@"):
1051 loop = asyncio.get_running_loop()
1052 fut = loop.create_future()
1053 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1054 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1055 self.db_core_iface.contacts_get(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1056 return fut
1057
1058 def contacts_get_from_group(self, group, profile_key="@DEFAULT@"):
1059 loop = asyncio.get_running_loop()
1060 fut = loop.create_future()
1061 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1062 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1063 self.db_core_iface.contacts_get_from_group(group, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1064 return fut
1065
1066 def devices_infos_get(self, bare_jid, profile_key):
1067 loop = asyncio.get_running_loop()
1068 fut = loop.create_future()
1069 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1070 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1071 self.db_core_iface.devices_infos_get(bare_jid, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1072 return fut
1073
1074 def disco_find_by_features(self, namespaces, identities, bare_jid=False, service=True, roster=True, own_jid=True, local_device=False, profile_key="@DEFAULT@"):
1075 loop = asyncio.get_running_loop()
1076 fut = loop.create_future()
1077 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1078 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1079 self.db_core_iface.disco_find_by_features(namespaces, identities, bare_jid, service, roster, own_jid, local_device, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1080 return fut
1081
1082 def disco_infos(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@"):
1083 loop = asyncio.get_running_loop()
1084 fut = loop.create_future()
1085 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1086 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1087 self.db_core_iface.disco_infos(entity_jid, node, use_cache, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1088 return fut
1089
1090 def disco_items(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@"):
1091 loop = asyncio.get_running_loop()
1092 fut = loop.create_future()
1093 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1094 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1095 self.db_core_iface.disco_items(entity_jid, node, use_cache, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1096 return fut
1097
1098 def disconnect(self, profile_key="@DEFAULT@"):
1099 loop = asyncio.get_running_loop()
1100 fut = loop.create_future()
1101 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1102 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1103 self.db_core_iface.disconnect(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1104 return fut
1105
1106 def encryption_namespace_get(self, arg_0):
1107 loop = asyncio.get_running_loop()
1108 fut = loop.create_future()
1109 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1110 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1111 self.db_core_iface.encryption_namespace_get(arg_0, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1112 return fut
1113
1114 def encryption_plugins_get(self):
1115 loop = asyncio.get_running_loop()
1116 fut = loop.create_future()
1117 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1118 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1119 self.db_core_iface.encryption_plugins_get(timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1120 return fut
1121
1122 def encryption_trust_ui_get(self, to_jid, namespace, profile_key):
1123 loop = asyncio.get_running_loop()
1124 fut = loop.create_future()
1125 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1126 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1127 self.db_core_iface.encryption_trust_ui_get(to_jid, namespace, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1128 return fut
1129
1130 def entities_data_get(self, jids, keys, profile):
1131 loop = asyncio.get_running_loop()
1132 fut = loop.create_future()
1133 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1134 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1135 self.db_core_iface.entities_data_get(jids, keys, profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1136 return fut
1137
1138 def entity_data_get(self, jid, keys, profile):
1139 loop = asyncio.get_running_loop()
1140 fut = loop.create_future()
1141 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1142 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1143 self.db_core_iface.entity_data_get(jid, keys, profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1144 return fut
1145
1146 def features_get(self, profile_key):
1147 loop = asyncio.get_running_loop()
1148 fut = loop.create_future()
1149 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1150 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1151 self.db_core_iface.features_get(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1152 return fut
1153
1154 def history_get(self, from_jid, to_jid, limit, between=True, filters='', profile="@NONE@"):
1155 loop = asyncio.get_running_loop()
1156 fut = loop.create_future()
1157 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1158 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1159 self.db_core_iface.history_get(from_jid, to_jid, limit, between, filters, profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1160 return fut
1161
1162 def image_check(self, arg_0):
1163 loop = asyncio.get_running_loop()
1164 fut = loop.create_future()
1165 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1166 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1167 self.db_core_iface.image_check(arg_0, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1168 return fut
1169
1170 def image_convert(self, source, dest, arg_2, extra):
1171 loop = asyncio.get_running_loop()
1172 fut = loop.create_future()
1173 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1174 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1175 self.db_core_iface.image_convert(source, dest, arg_2, extra, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1176 return fut
1177
1178 def image_generate_preview(self, image_path, profile_key):
1179 loop = asyncio.get_running_loop()
1180 fut = loop.create_future()
1181 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1182 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1183 self.db_core_iface.image_generate_preview(image_path, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1184 return fut
1185
1186 def image_resize(self, image_path, width, height):
1187 loop = asyncio.get_running_loop()
1188 fut = loop.create_future()
1189 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1190 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1191 self.db_core_iface.image_resize(image_path, width, height, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1192 return fut
1193
1194 def is_connected(self, profile_key="@DEFAULT@"):
1195 loop = asyncio.get_running_loop()
1196 fut = loop.create_future()
1197 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1198 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1199 self.db_core_iface.is_connected(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1200 return fut
1201
1202 def main_resource_get(self, contact_jid, profile_key="@DEFAULT@"):
1203 loop = asyncio.get_running_loop()
1204 fut = loop.create_future()
1205 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1206 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1207 self.db_core_iface.main_resource_get(contact_jid, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1208 return fut
1209
1210 def menu_help_get(self, menu_id, language):
1211 loop = asyncio.get_running_loop()
1212 fut = loop.create_future()
1213 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1214 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1215 self.db_core_iface.menu_help_get(menu_id, language, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1216 return fut
1217
1218 def menu_launch(self, menu_type, path, data, security_limit, profile_key):
1219 loop = asyncio.get_running_loop()
1220 fut = loop.create_future()
1221 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1222 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1223 self.db_core_iface.menu_launch(menu_type, path, data, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1224 return fut
1225
1226 def menus_get(self, language, security_limit):
1227 loop = asyncio.get_running_loop()
1228 fut = loop.create_future()
1229 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1230 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1231 self.db_core_iface.menus_get(language, security_limit, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1232 return fut
1233
1234 def message_encryption_get(self, to_jid, profile_key):
1235 loop = asyncio.get_running_loop()
1236 fut = loop.create_future()
1237 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1238 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1239 self.db_core_iface.message_encryption_get(to_jid, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1240 return fut
1241
1242 def message_encryption_start(self, to_jid, namespace='', replace=False, profile_key="@NONE@"):
1243 loop = asyncio.get_running_loop()
1244 fut = loop.create_future()
1245 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1246 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1247 self.db_core_iface.message_encryption_start(to_jid, namespace, replace, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1248 return fut
1249
1250 def message_encryption_stop(self, to_jid, profile_key):
1251 loop = asyncio.get_running_loop()
1252 fut = loop.create_future()
1253 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1254 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1255 self.db_core_iface.message_encryption_stop(to_jid, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1256 return fut
1257
1258 def message_send(self, to_jid, message, subject={}, mess_type="auto", extra={}, profile_key="@NONE@"):
1259 loop = asyncio.get_running_loop()
1260 fut = loop.create_future()
1261 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1262 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1263 self.db_core_iface.message_send(to_jid, message, subject, mess_type, extra, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1264 return fut
1265
1266 def namespaces_get(self):
1267 loop = asyncio.get_running_loop()
1268 fut = loop.create_future()
1269 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1270 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1271 self.db_core_iface.namespaces_get(timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1272 return fut
1273
1274 def param_get_a(self, name, category, attribute="value", profile_key="@DEFAULT@"):
1275 loop = asyncio.get_running_loop()
1276 fut = loop.create_future()
1277 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1278 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1279 self.db_core_iface.param_get_a(name, category, attribute, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1280 return fut
1281
1282 def param_get_a_async(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@"):
1283 loop = asyncio.get_running_loop()
1284 fut = loop.create_future()
1285 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1286 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1287 self.db_core_iface.param_get_a_async(name, category, attribute, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1288 return fut
1289
1290 def param_set(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@"):
1291 loop = asyncio.get_running_loop()
1292 fut = loop.create_future()
1293 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1294 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1295 self.db_core_iface.param_set(name, value, category, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1296 return fut
1297
1298 def param_ui_get(self, security_limit=-1, app='', extra='', profile_key="@DEFAULT@"):
1299 loop = asyncio.get_running_loop()
1300 fut = loop.create_future()
1301 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1302 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1303 self.db_core_iface.param_ui_get(security_limit, app, extra, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1304 return fut
1305
1306 def params_categories_get(self):
1307 loop = asyncio.get_running_loop()
1308 fut = loop.create_future()
1309 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1310 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1311 self.db_core_iface.params_categories_get(timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1312 return fut
1313
1314 def params_register_app(self, xml, security_limit=-1, app=''):
1315 loop = asyncio.get_running_loop()
1316 fut = loop.create_future()
1317 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1318 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1319 self.db_core_iface.params_register_app(xml, security_limit, app, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1320 return fut
1321
1322 def params_template_load(self, filename):
1323 loop = asyncio.get_running_loop()
1324 fut = loop.create_future()
1325 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1326 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1327 self.db_core_iface.params_template_load(filename, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1328 return fut
1329
1330 def params_template_save(self, filename):
1331 loop = asyncio.get_running_loop()
1332 fut = loop.create_future()
1333 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1334 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1335 self.db_core_iface.params_template_save(filename, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1336 return fut
1337
1338 def params_values_from_category_get_async(self, category, security_limit=-1, app="", extra="", profile_key="@DEFAULT@"):
1339 loop = asyncio.get_running_loop()
1340 fut = loop.create_future()
1341 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1342 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1343 self.db_core_iface.params_values_from_category_get_async(category, security_limit, app, extra, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1344 return fut
1345
1346 def presence_set(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@"):
1347 loop = asyncio.get_running_loop()
1348 fut = loop.create_future()
1349 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1350 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1351 self.db_core_iface.presence_set(to_jid, show, statuses, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1352 return fut
1353
1354 def presence_statuses_get(self, profile_key="@DEFAULT@"):
1355 loop = asyncio.get_running_loop()
1356 fut = loop.create_future()
1357 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1358 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1359 self.db_core_iface.presence_statuses_get(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1360 return fut
1361
1362 def private_data_delete(self, namespace, key, arg_2):
1363 loop = asyncio.get_running_loop()
1364 fut = loop.create_future()
1365 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1366 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1367 self.db_core_iface.private_data_delete(namespace, key, arg_2, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1368 return fut
1369
1370 def private_data_get(self, namespace, key, profile_key):
1371 loop = asyncio.get_running_loop()
1372 fut = loop.create_future()
1373 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1374 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1375 self.db_core_iface.private_data_get(namespace, key, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1376 return fut
1377
1378 def private_data_set(self, namespace, key, data, profile_key):
1379 loop = asyncio.get_running_loop()
1380 fut = loop.create_future()
1381 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1382 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1383 self.db_core_iface.private_data_set(namespace, key, data, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1384 return fut
1385
1386 def profile_create(self, profile, password='', component=''):
1387 loop = asyncio.get_running_loop()
1388 fut = loop.create_future()
1389 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1390 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1391 self.db_core_iface.profile_create(profile, password, component, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1392 return fut
1393
1394 def profile_delete_async(self, profile):
1395 loop = asyncio.get_running_loop()
1396 fut = loop.create_future()
1397 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1398 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1399 self.db_core_iface.profile_delete_async(profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1400 return fut
1401
1402 def profile_is_session_started(self, profile_key="@DEFAULT@"):
1403 loop = asyncio.get_running_loop()
1404 fut = loop.create_future()
1405 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1406 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1407 self.db_core_iface.profile_is_session_started(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1408 return fut
1409
1410 def profile_name_get(self, profile_key="@DEFAULT@"):
1411 loop = asyncio.get_running_loop()
1412 fut = loop.create_future()
1413 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1414 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1415 self.db_core_iface.profile_name_get(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1416 return fut
1417
1418 def profile_set_default(self, profile):
1419 loop = asyncio.get_running_loop()
1420 fut = loop.create_future()
1421 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1422 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1423 self.db_core_iface.profile_set_default(profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1424 return fut
1425
1426 def profile_start_session(self, password='', profile_key="@DEFAULT@"):
1427 loop = asyncio.get_running_loop()
1428 fut = loop.create_future()
1429 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1430 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1431 self.db_core_iface.profile_start_session(password, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1432 return fut
1433
1434 def profiles_list_get(self, clients=True, components=False):
1435 loop = asyncio.get_running_loop()
1436 fut = loop.create_future()
1437 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1438 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1439 self.db_core_iface.profiles_list_get(clients, components, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1440 return fut
1441
1442 def progress_get(self, id, profile):
1443 loop = asyncio.get_running_loop()
1444 fut = loop.create_future()
1445 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1446 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1447 self.db_core_iface.progress_get(id, profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1448 return fut
1449
1450 def progress_get_all(self, profile):
1451 loop = asyncio.get_running_loop()
1452 fut = loop.create_future()
1453 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1454 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1455 self.db_core_iface.progress_get_all(profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1456 return fut
1457
1458 def progress_get_all_metadata(self, profile):
1459 loop = asyncio.get_running_loop()
1460 fut = loop.create_future()
1461 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1462 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1463 self.db_core_iface.progress_get_all_metadata(profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1464 return fut
1465
1466 def ready_get(self):
1467 loop = asyncio.get_running_loop()
1468 fut = loop.create_future()
1469 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1470 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1471 self.db_core_iface.ready_get(timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1472 return fut
1473
1474 def roster_resync(self, profile_key="@DEFAULT@"):
1475 loop = asyncio.get_running_loop()
1476 fut = loop.create_future()
1477 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1478 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1479 self.db_core_iface.roster_resync(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1480 return fut
1481
1482 def session_infos_get(self, profile_key):
1483 loop = asyncio.get_running_loop()
1484 fut = loop.create_future()
1485 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1486 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1487 self.db_core_iface.session_infos_get(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1488 return fut
1489
1490 def sub_waiting_get(self, profile_key="@DEFAULT@"):
1491 loop = asyncio.get_running_loop()
1492 fut = loop.create_future()
1493 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1494 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1495 self.db_core_iface.sub_waiting_get(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1496 return fut
1497
1498 def subscription(self, sub_type, entity, profile_key="@DEFAULT@"):
1499 loop = asyncio.get_running_loop()
1500 fut = loop.create_future()
1501 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1502 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1503 self.db_core_iface.subscription(sub_type, entity, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1504 return fut
1505
1506 def version_get(self):
1507 loop = asyncio.get_running_loop()
1508 fut = loop.create_future()
1509 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1510 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1511 self.db_core_iface.version_get(timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1512 return fut