Mercurial > libervia-backend
annotate frontends/src/bridge/DBus.py @ 1113:edd3fc4b4aaf
core (constants): minor comment change
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 20 Aug 2014 23:07:59 +0200 |
parents | f094583732de |
children | bf2927e6a0f5 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 #-*- coding: utf-8 -*- | |
3 | |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
595
diff
changeset
|
4 # SAT communication bridge |
811 | 5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org) |
0 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
595
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
595
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
595
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
595
diff
changeset
|
10 # (at your option) any later version. |
0 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
595
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
595
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
595
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
595
diff
changeset
|
15 # GNU Affero General Public License for more details. |
0 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
595
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
595
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
0 | 19 |
771 | 20 from sat.core.i18n import _ |
1062
95758ef3faa8
bridge: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1059
diff
changeset
|
21 from bridge_frontend import BridgeFrontend, BridgeException |
535
790be337cc41
bridge: fixed D-Bus warning in frontend side of bridge
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
22 import dbus |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
23 from sat.core.log import getLogger |
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
24 log = getLogger(__name__) |
627
d207c2186519
core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
25 from sat.core.exceptions import BridgeExceptionNoService, BridgeInitError |
0 | 26 |
535
790be337cc41
bridge: fixed D-Bus warning in frontend side of bridge
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
27 from dbus.mainloop.glib import DBusGMainLoop |
790be337cc41
bridge: fixed D-Bus warning in frontend side of bridge
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
28 DBusGMainLoop(set_as_default=True) |
790be337cc41
bridge: fixed D-Bus warning in frontend side of bridge
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
29 |
1073
f094583732de
bridge: DBusException also transports the twisted failure condition
souliane <souliane@mailoo.org>
parents:
1072
diff
changeset
|
30 import ast |
f094583732de
bridge: DBusException also transports the twisted failure condition
souliane <souliane@mailoo.org>
parents:
1072
diff
changeset
|
31 |
595
1f160467f5de
Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
32 const_INT_PREFIX = "org.goffi.SAT" # Interface prefix |
1f160467f5de
Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
33 const_ERROR_PREFIX = const_INT_PREFIX + ".error" |
360 | 34 const_OBJ_PATH = '/org/goffi/SAT/bridge' |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
35 const_CORE_SUFFIX = ".core" |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
36 const_PLUGIN_SUFFIX = ".plugin" |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
37 const_TIMEOUT = 120 |
360 | 38 |
595
1f160467f5de
Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
39 |
1062
95758ef3faa8
bridge: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1059
diff
changeset
|
40 def dbus_to_bridge_exception(dbus_e): |
95758ef3faa8
bridge: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1059
diff
changeset
|
41 """Convert a DBusException to a BridgeException. |
95758ef3faa8
bridge: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1059
diff
changeset
|
42 |
95758ef3faa8
bridge: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1059
diff
changeset
|
43 @param dbus_e (DBusException) |
95758ef3faa8
bridge: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1059
diff
changeset
|
44 @return: BridgeException |
95758ef3faa8
bridge: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1059
diff
changeset
|
45 """ |
95758ef3faa8
bridge: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1059
diff
changeset
|
46 name = dbus_e.get_dbus_name()[len(const_ERROR_PREFIX) + 1:] |
1073
f094583732de
bridge: DBusException also transports the twisted failure condition
souliane <souliane@mailoo.org>
parents:
1072
diff
changeset
|
47 # XXX: dbus_e.args doesn't contain the original DBusException args, but we |
f094583732de
bridge: DBusException also transports the twisted failure condition
souliane <souliane@mailoo.org>
parents:
1072
diff
changeset
|
48 # receive its serialized form in dbus_e.args[0]. From that we can rebuild |
f094583732de
bridge: DBusException also transports the twisted failure condition
souliane <souliane@mailoo.org>
parents:
1072
diff
changeset
|
49 # the original arguments list thanks to ast.literal_eval (secure eval). |
f094583732de
bridge: DBusException also transports the twisted failure condition
souliane <souliane@mailoo.org>
parents:
1072
diff
changeset
|
50 message = dbus_e.get_dbus_message() # similar to dbus_e.args[0] |
f094583732de
bridge: DBusException also transports the twisted failure condition
souliane <souliane@mailoo.org>
parents:
1072
diff
changeset
|
51 try: |
f094583732de
bridge: DBusException also transports the twisted failure condition
souliane <souliane@mailoo.org>
parents:
1072
diff
changeset
|
52 message, condition = ast.literal_eval(message) |
f094583732de
bridge: DBusException also transports the twisted failure condition
souliane <souliane@mailoo.org>
parents:
1072
diff
changeset
|
53 except (SyntaxError, ValueError, TypeError): |
f094583732de
bridge: DBusException also transports the twisted failure condition
souliane <souliane@mailoo.org>
parents:
1072
diff
changeset
|
54 condition = '' |
f094583732de
bridge: DBusException also transports the twisted failure condition
souliane <souliane@mailoo.org>
parents:
1072
diff
changeset
|
55 return BridgeException(name, message, condition) |
1062
95758ef3faa8
bridge: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1059
diff
changeset
|
56 |
95758ef3faa8
bridge: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1059
diff
changeset
|
57 |
0 | 58 class DBusBridgeFrontend(BridgeFrontend): |
59 def __init__(self): | |
165
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
136
diff
changeset
|
60 try: |
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
136
diff
changeset
|
61 self.sessions_bus = dbus.SessionBus() |
360 | 62 self.db_object = self.sessions_bus.get_object(const_INT_PREFIX, |
595
1f160467f5de
Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
63 const_OBJ_PATH) |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
64 self.db_core_iface = dbus.Interface(self.db_object, |
595
1f160467f5de
Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
65 dbus_interface=const_INT_PREFIX + const_CORE_SUFFIX) |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
66 self.db_plugin_iface = dbus.Interface(self.db_object, |
595
1f160467f5de
Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
67 dbus_interface=const_INT_PREFIX + const_PLUGIN_SUFFIX) |
1f160467f5de
Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
68 except dbus.exceptions.DBusException, e: |
1f160467f5de
Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
69 if e._dbus_error_name == 'org.freedesktop.DBus.Error.ServiceUnknown': |
165
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
136
diff
changeset
|
70 raise BridgeExceptionNoService |
627
d207c2186519
core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
71 elif e._dbus_error_name == 'org.freedesktop.DBus.Error.NotSupported': |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
72 log.error(_(u"D-Bus is not launched, please see README to see instructions on how to launch it")) |
627
d207c2186519
core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
73 raise BridgeInitError |
165
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
136
diff
changeset
|
74 else: |
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
136
diff
changeset
|
75 raise e |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
76 #props = self.db_core_iface.getProperties() |
0 | 77 |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
78 def register(self, functionName, handler, iface="core"): |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
79 if iface == "core": |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
80 self.db_core_iface.connect_to_signal(functionName, handler) |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
81 elif iface == "plugin": |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
82 self.db_plugin_iface.connect_to_signal(functionName, handler) |
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
83 else: |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
963
diff
changeset
|
84 log.error(_('Unknown interface')) |
0 | 85 |
568
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
86 def __getattribute__(self, name): |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
87 """ usual __getattribute__ if the method exists, else try to find a plugin method """ |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
88 try: |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
89 return object.__getattribute__(self, name) |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
90 except AttributeError: |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
91 # The attribute is not found, we try the plugin proxy to find the requested method |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
92 |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
93 def getPluginMethod(*args, **kwargs): |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
94 # We first check if we have an async call. We detect this in two ways: |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
95 # - if we have the 'callback' and 'errback' keyword arguments |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
96 # - or if the last two arguments are callable |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
97 |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
98 async = False |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
99 |
568
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
100 if kwargs: |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
101 if 'callback' in kwargs and 'errback' in kwargs: |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
102 async = True |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
103 _callback = kwargs.pop('callback') |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
104 _errback = kwargs.pop('errback') |
595
1f160467f5de
Fix pep8 support in src/bridge.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
105 elif len(args) >= 2 and callable(args[-1]) and callable(args[-2]): |
568
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
106 async = True |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
107 args = list(args) |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
108 _errback = args.pop() |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
109 _callback = args.pop() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
110 |
568
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
111 method = getattr(self.db_plugin_iface, name) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
112 |
568
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
113 if async: |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
114 kwargs['timeout'] = const_TIMEOUT |
568
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
115 kwargs['reply_handler'] = _callback |
1062
95758ef3faa8
bridge: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1059
diff
changeset
|
116 kwargs['error_handler'] = lambda err: _errback(dbus_to_bridge_exception(err)) |
568
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
117 |
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
118 return method(*args, **kwargs) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
119 |
568
239abc5484c9
bridge: generic plugin methods handling for frontend side in D-Bus Bridge \o/
Goffi <goffi@goffi.org>
parents:
562
diff
changeset
|
120 return getPluginMethod |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
372
diff
changeset
|
121 def addContact(self, entity_jid, profile_key="@DEFAULT@"): |
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
372
diff
changeset
|
122 return self.db_core_iface.addContact(entity_jid, profile_key) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
123 |
1030
15f43b54d697
core, memory, bridge: added profile password + password encryption:
souliane <souliane@mailoo.org>
parents:
1024
diff
changeset
|
124 def asyncConnect(self, profile_key="@DEFAULT@", password='', callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
125 return self.db_core_iface.asyncConnect(profile_key, password, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))) |
421
28e4299d4553
primitivus: profile manager updated to use new asynchronous profile creation
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
126 |
1030
15f43b54d697
core, memory, bridge: added profile password + password encryption:
souliane <souliane@mailoo.org>
parents:
1024
diff
changeset
|
127 def asyncCreateProfile(self, profile, password='', callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
128 return self.db_core_iface.asyncCreateProfile(profile, password, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))) |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
129 |
893
308a96bc7c1b
core, frontends: add method asyncDeleteProfile, remove synchronous methods createProfile and deleteProfile
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
130 def asyncDeleteProfile(self, profile, callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
131 return self.db_core_iface.asyncDeleteProfile(profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))) |
893
308a96bc7c1b
core, frontends: add method asyncDeleteProfile, remove synchronous methods createProfile and deleteProfile
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
132 |
656
7d6e5807504a
bridge, memory: added the parameter security_limit to asyncGetParamA so it can be used from libervia. refactorization in memory.py are related to that.
souliane <souliane@mailoo.org>
parents:
641
diff
changeset
|
133 def asyncGetParamA(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
134 return unicode(self.db_core_iface.asyncGetParamA(name, category, attribute, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))) |
413
dd4caab17008
core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
135 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
535
diff
changeset
|
136 def confirmationAnswer(self, id, accepted, data, profile): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
535
diff
changeset
|
137 return self.db_core_iface.confirmationAnswer(id, accepted, data, profile) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
138 |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
372
diff
changeset
|
139 def delContact(self, entity_jid, profile_key="@DEFAULT@"): |
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
372
diff
changeset
|
140 return self.db_core_iface.delContact(entity_jid, profile_key) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
141 |
963
723f28cd15c7
core (disco): added discoInfos and discoItems bridge methods
Goffi <goffi@goffi.org>
parents:
943
diff
changeset
|
142 def discoInfos(self, entity_jid, profile_key, callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
143 return self.db_core_iface.discoInfos(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))) |
963
723f28cd15c7
core (disco): added discoInfos and discoItems bridge methods
Goffi <goffi@goffi.org>
parents:
943
diff
changeset
|
144 |
723f28cd15c7
core (disco): added discoInfos and discoItems bridge methods
Goffi <goffi@goffi.org>
parents:
943
diff
changeset
|
145 def discoItems(self, entity_jid, profile_key, callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
146 return self.db_core_iface.discoItems(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))) |
963
723f28cd15c7
core (disco): added discoInfos and discoItems bridge methods
Goffi <goffi@goffi.org>
parents:
943
diff
changeset
|
147 |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
148 def disconnect(self, profile_key="@DEFAULT@"): |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
149 return self.db_core_iface.disconnect(profile_key) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
150 |
365
efbfccfed623
core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents:
364
diff
changeset
|
151 def getConfig(self, section, name): |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
152 return unicode(self.db_core_iface.getConfig(section, name)) |
364 | 153 |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
154 def getContacts(self, profile_key="@DEFAULT@"): |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
155 return self.db_core_iface.getContacts(profile_key) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
156 |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
492
diff
changeset
|
157 def getContactsFromGroup(self, group, profile_key="@DEFAULT@"): |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
492
diff
changeset
|
158 return self.db_core_iface.getContactsFromGroup(group, profile_key) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
492
diff
changeset
|
159 |
504
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
160 def getEntityData(self, jid, keys, profile): |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
161 return self.db_core_iface.getEntityData(jid, keys, profile) |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
162 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
535
diff
changeset
|
163 def getHistory(self, from_jid, to_jid, limit, between=True, profile="@NONE@", callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
164 return self.db_core_iface.getHistory(from_jid, to_jid, limit, between, profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
165 |
399 | 166 def getLastResource(self, contact_jid, profile_key="@DEFAULT@"): |
167 return unicode(self.db_core_iface.getLastResource(contact_jid, profile_key)) | |
168 | |
773 | 169 def getMenuHelp(self, menu_id, language): |
170 return unicode(self.db_core_iface.getMenuHelp(menu_id, language)) | |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
171 |
773 | 172 def getMenus(self, language, security_limit): |
173 return self.db_core_iface.getMenus(language, security_limit) | |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
174 |
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
175 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"): |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
176 return unicode(self.db_core_iface.getParamA(name, category, attribute, profile_key)) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
177 |
777
5642939d254e
core, bridge: new method paramsRegisterApp to register frontend's specific parameters
souliane <souliane@mailoo.org>
parents:
773
diff
changeset
|
178 def getParams(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
179 return unicode(self.db_core_iface.getParams(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
180 |
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
181 def getParamsCategories(self, ): |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
182 return self.db_core_iface.getParamsCategories() |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
183 |
777
5642939d254e
core, bridge: new method paramsRegisterApp to register frontend's specific parameters
souliane <souliane@mailoo.org>
parents:
773
diff
changeset
|
184 def getParamsForCategory(self, category, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
185 return unicode(self.db_core_iface.getParamsForCategory(category, security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
186 |
777
5642939d254e
core, bridge: new method paramsRegisterApp to register frontend's specific parameters
souliane <souliane@mailoo.org>
parents:
773
diff
changeset
|
187 def getParamsUI(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
188 return unicode(self.db_core_iface.getParamsUI(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err)))) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
189 |
943
71926ec2114d
core (memory): entities cache improvments:
Goffi <goffi@goffi.org>
parents:
917
diff
changeset
|
190 def getPresenceStatuses(self, profile_key="@DEFAULT@"): |
71926ec2114d
core (memory): entities cache improvments:
Goffi <goffi@goffi.org>
parents:
917
diff
changeset
|
191 return self.db_core_iface.getPresenceStatuses(profile_key) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
192 |
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
193 def getProfileName(self, profile_key="@DEFAULT@"): |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
194 return unicode(self.db_core_iface.getProfileName(profile_key)) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
195 |
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
196 def getProfilesList(self, ): |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
197 return self.db_core_iface.getProfilesList() |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
198 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
535
diff
changeset
|
199 def getProgress(self, id, profile): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
535
diff
changeset
|
200 return self.db_core_iface.getProgress(id, profile) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
201 |
1024
7e43ea75cce8
bridge (constructor): fixed D-Bus frontend generator for async method without sig_in + fixed --debug option + regenerated bridge to fix bad frontend D-Bus bridge.
Goffi <goffi@goffi.org>
parents:
1023
diff
changeset
|
202 def getReady(self, callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
203 return self.db_core_iface.getReady(timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))) |
1023
8bae81e254a2
core: added a getReady method which can be called by frontends to ensure that backend is fully initialised before doing anything + this ckeck is automatically done in asyncConnect
Goffi <goffi@goffi.org>
parents:
1015
diff
changeset
|
204 |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
205 def getVersion(self, ): |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
206 return unicode(self.db_core_iface.getVersion()) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
207 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
208 def getWaitingConf(self, profile_key): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
209 return self.db_core_iface.getWaitingConf(profile_key) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
210 |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
211 def getWaitingSub(self, profile_key="@DEFAULT@"): |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
212 return self.db_core_iface.getWaitingSub(profile_key) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
213 |
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
214 def isConnected(self, profile_key="@DEFAULT@"): |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
215 return self.db_core_iface.isConnected(profile_key) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
216 |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
217 def launchAction(self, callback_id, data, profile_key="@DEFAULT@", callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
218 return self.db_core_iface.launchAction(callback_id, data, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
219 |
1015
fee00f2e11c2
memory, jp: added jp commands to load/save parameters template
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
220 def loadParamsTemplate(self, filename): |
fee00f2e11c2
memory, jp: added jp commands to load/save parameters template
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
221 return self.db_core_iface.loadParamsTemplate(filename) |
fee00f2e11c2
memory, jp: added jp commands to load/save parameters template
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
222 |
777
5642939d254e
core, bridge: new method paramsRegisterApp to register frontend's specific parameters
souliane <souliane@mailoo.org>
parents:
773
diff
changeset
|
223 def paramsRegisterApp(self, xml, security_limit=-1, app=''): |
5642939d254e
core, bridge: new method paramsRegisterApp to register frontend's specific parameters
souliane <souliane@mailoo.org>
parents:
773
diff
changeset
|
224 return self.db_core_iface.paramsRegisterApp(xml, security_limit, app) |
5642939d254e
core, bridge: new method paramsRegisterApp to register frontend's specific parameters
souliane <souliane@mailoo.org>
parents:
773
diff
changeset
|
225 |
1015
fee00f2e11c2
memory, jp: added jp commands to load/save parameters template
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
226 def saveParamsTemplate(self, filename): |
fee00f2e11c2
memory, jp: added jp commands to load/save parameters template
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
227 return self.db_core_iface.saveParamsTemplate(filename) |
fee00f2e11c2
memory, jp: added jp commands to load/save parameters template
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
228 |
752
f49945d728de
core,bridge: sendMessage bridge method is now async
Goffi <goffi@goffi.org>
parents:
709
diff
changeset
|
229 def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None): |
1072
d123d61976c8
bridge (D-Bus): frontend side now use a 120 s timeout for async calls
Goffi <goffi@goffi.org>
parents:
1062
diff
changeset
|
230 return self.db_core_iface.sendMessage(to_jid, message, subject, mess_type, extra, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=lambda err:errback(dbus_to_bridge_exception(err))) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
231 |
641
49587e170f53
core: added the security_limit to setParam
souliane <souliane@mailoo.org>
parents:
636
diff
changeset
|
232 def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@"): |
49587e170f53
core: added the security_limit to setParam
souliane <souliane@mailoo.org>
parents:
636
diff
changeset
|
233 return self.db_core_iface.setParam(name, value, category, security_limit, profile_key) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
234 |
917
a9401694d2dc
bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents:
893
diff
changeset
|
235 def setPresence(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@"): |
a9401694d2dc
bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents:
893
diff
changeset
|
236 return self.db_core_iface.setPresence(to_jid, show, statuses, profile_key) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
237 |
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
238 def subscription(self, sub_type, entity, profile_key="@DEFAULT@"): |
372
f964dcec1611
core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
239 return self.db_core_iface.subscription(sub_type, entity, profile_key) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
240 |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
372
diff
changeset
|
241 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@"): |
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
372
diff
changeset
|
242 return self.db_core_iface.updateContact(entity_jid, name, groups, profile_key) |