Mercurial > libervia-backend
annotate src/bridge/DBus.py @ 517:59b32c04e105
plugin text commands: added /help command
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 20 Oct 2012 19:22:51 +0200 |
parents | 8ee9113d307b |
children | 2c4016921403 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 #-*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 SAT: a jabber client | |
459 | 6 Copyright (C) 2009, 2010, 2011, 2012 Jérôme Poisson (goffi@goffi.org) |
0 | 7 |
8 This program is free software: you can redistribute it and/or modify | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
9 it under the terms of the GNU Affero General Public License as published by |
0 | 10 the Free Software Foundation, either version 3 of the License, or |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
16 GNU Affero General Public License for more details. |
0 | 17 |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
18 You should have received a copy of the GNU Affero General Public License |
0 | 19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 """ | |
21 | |
22 | |
23 from bridge import Bridge | |
24 import dbus | |
25 import dbus.service | |
26 import dbus.mainloop.glib | |
468
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
27 import inspect |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
28 from logging import debug, info, error |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
29 from twisted.internet.defer import Deferred |
0 | 30 |
10 | 31 const_INT_PREFIX = "org.goffi.SAT" #Interface prefix |
419
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
32 const_ERROR_PREFIX = const_INT_PREFIX+".error" |
360 | 33 const_OBJ_PATH = '/org/goffi/SAT/bridge' |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
34 const_CORE_SUFFIX = ".core" |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
35 const_PLUGIN_SUFFIX = ".plugin" |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
36 |
477
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
469
diff
changeset
|
37 class ParseError(Exception): |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
469
diff
changeset
|
38 pass |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
469
diff
changeset
|
39 |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
40 class MethodNotRegistered(dbus.DBusException): |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
41 _dbus_error_name = const_ERROR_PREFIX + ".MethodNotRegistered" |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
42 |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
43 class InternalError(dbus.DBusException): |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
44 _dbus_error_name = const_ERROR_PREFIX + ".InternalError" |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
45 |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
46 class AsyncNotDeferred(dbus.DBusException): |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
47 _dbus_error_name = const_ERROR_PREFIX + ".AsyncNotDeferred" |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
48 |
424
72c13313b6d6
bridge: added check that synchronous method does not return a deferred
Goffi <goffi@goffi.org>
parents:
423
diff
changeset
|
49 class DeferredNotAsync(dbus.DBusException): |
72c13313b6d6
bridge: added check that synchronous method does not return a deferred
Goffi <goffi@goffi.org>
parents:
423
diff
changeset
|
50 _dbus_error_name = const_ERROR_PREFIX + ".DeferredNotAsync" |
72c13313b6d6
bridge: added check that synchronous method does not return a deferred
Goffi <goffi@goffi.org>
parents:
423
diff
changeset
|
51 |
419
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
52 class GenericException(dbus.DBusException): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
53 def __init__(self, twisted_error): |
419
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
54 super(GenericException,self).__init__() |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
55 mess = twisted_error.getErrorMessage() |
477
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
469
diff
changeset
|
56 self._dbus_error_name = const_ERROR_PREFIX+"."+ (mess or str(twisted_error.__class__)) |
419
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
57 |
0 | 58 class DbusObject(dbus.service.Object): |
59 | |
60 def __init__(self, bus, path): | |
61 dbus.service.Object.__init__(self, bus, path) | |
62 debug("Init DbusObject...") | |
63 self.cb={} | |
64 | |
65 def register(self, name, cb): | |
66 self.cb[name]=cb | |
67 | |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
68 def _callback(self, name, *args, **kwargs): |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
69 """call the callback if it exists, raise an exception else |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
70 if the callback return a deferred, use async methods""" |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
71 if not name in self.cb: |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
72 raise MethodNotRegistered |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
73 |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
74 if "callback" in kwargs: |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
75 #we must have errback too |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
76 if not "errback" in kwargs: |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
77 error("errback is missing in method call [%s]" % name) |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
78 raise InternalError |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
79 callback = kwargs.pop("callback") |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
80 errback = kwargs.pop("errback") |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
81 async = True |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
82 else: |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
83 async = False |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
84 result = self.cb[name](*args, **kwargs) |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
85 if async: |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
86 if not isinstance(result, Deferred): |
425
e4e9187e3b5b
backend, bridge: asynchronous history
Goffi <goffi@goffi.org>
parents:
424
diff
changeset
|
87 error("Asynchronous method [%s] does not return a Deferred." % name) |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
88 raise AsyncNotDeferred |
468
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
89 result.addCallback(lambda result: callback() if result==None else callback(result)) |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
90 result.addErrback(lambda err:errback(GenericException(err))) |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
91 else: |
424
72c13313b6d6
bridge: added check that synchronous method does not return a deferred
Goffi <goffi@goffi.org>
parents:
423
diff
changeset
|
92 if isinstance(result, Deferred): |
425
e4e9187e3b5b
backend, bridge: asynchronous history
Goffi <goffi@goffi.org>
parents:
424
diff
changeset
|
93 error("Synchronous method [%s] return a Deferred." % name) |
424
72c13313b6d6
bridge: added check that synchronous method does not return a deferred
Goffi <goffi@goffi.org>
parents:
423
diff
changeset
|
94 raise DeferredNotAsync |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
95 return result |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
96 |
0 | 97 ### signals ### |
98 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
99 @dbus.service.signal(const_INT_PREFIX+const_PLUGIN_SUFFIX, |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
100 signature='') |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
101 def dummySignal(self): |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
102 #FIXME: workaround for addSignal (doesn't work if one method doensn't |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
103 # already exist for plugins), probably missing some initialisation, need |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
104 # further investigations |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
105 pass |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
106 |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
107 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 108 signature='ssa{ss}') |
109 def actionResult(self, answer_type, id, data): | |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
110 pass |
267 | 111 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
112 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 113 signature='ssa{sa{ss}}') |
114 def actionResultExt(self, answer_type, id, data): | |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
115 pass |
267 | 116 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
117 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 118 signature='ssa{ss}') |
119 def askConfirmation(self, conf_type, id, data): | |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
120 pass |
267 | 121 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
122 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
123 signature='s') |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
124 def connected(self, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
125 pass |
267 | 126 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
127 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
262
af3d4f11fe43
Added management of connection error
Goffi <goffi@goffi.org>
parents:
260
diff
changeset
|
128 signature='ss') |
274
c1ad04586edf
Bridge: rename connection_error to connectionError for function name consistency
Goffi <goffi@goffi.org>
parents:
272
diff
changeset
|
129 def connectionError(self, error_type, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
130 pass |
0 | 131 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
132 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
49 | 133 signature='ss') |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
134 def contactDeleted(self, entity_jid, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
135 pass |
267 | 136 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
137 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 138 signature='s') |
139 def disconnected(self, profile): | |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
140 pass |
267 | 141 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
142 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 143 signature='ssss') |
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
|
144 def entityDataUpdated(self, jid, name, value, 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
|
145 pass |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
146 |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
147 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
148 signature='ssss') |
267 | 149 def newAlert(self, message, title, alert_type, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
150 pass |
267 | 151 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
152 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 153 signature='sa{ss}ass') |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
154 def newContact(self, contact_jid, attributes, groups, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
155 pass |
0 | 156 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
157 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
513
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
512
diff
changeset
|
158 signature='ssssa{ss}s') |
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
512
diff
changeset
|
159 def newMessage(self, from_jid, message, mess_type, to_jid, extra, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
160 pass |
267 | 161 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
162 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 163 signature='ssss') |
164 def paramUpdate(self, name, value, category, profile): | |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
165 pass |
0 | 166 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
167 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 168 signature='ssia{ss}s') |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
169 def presenceUpdate(self, entity_jid, show, priority, statuses, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
170 pass |
267 | 171 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
172 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 173 signature='sss') |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
174 def subscribe(self, sub_type, entity_jid, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
175 pass |
267 | 176 |
49 | 177 |
0 | 178 ### methods ### |
267 | 179 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
180 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
181 in_signature='ss', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
182 async_callbacks=None) |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
183 def addContact(self, entity_jid, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
184 return self._callback("addContact", unicode(entity_jid), unicode(profile_key)) |
0 | 185 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
186 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
187 in_signature='s', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
188 async_callbacks=('callback', 'errback')) |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
189 def asyncConnect(self, profile_key="@DEFAULT@", callback=None, errback=None): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
190 return self._callback("asyncConnect", unicode(profile_key), callback=callback, errback=errback) |
419
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
191 |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
192 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
193 in_signature='s', out_signature='', |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
194 async_callbacks=('callback', 'errback')) |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
195 def asyncCreateProfile(self, profile, callback=None, errback=None): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
196 return self._callback("asyncCreateProfile", unicode(profile), callback=callback, errback=errback) |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
197 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
198 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
199 in_signature='ssss', out_signature='s', |
413
dd4caab17008
core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents:
399
diff
changeset
|
200 async_callbacks=('callback', 'errback')) |
dd4caab17008
core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents:
399
diff
changeset
|
201 def asyncGetParamA(self, name, category, attribute="value", profile_key="@DEFAULT@", callback=None, errback=None): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
202 return self._callback("asyncGetParamA", unicode(name), unicode(category), unicode(attribute), unicode(profile_key), callback=callback, errback=errback) |
413
dd4caab17008
core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents:
399
diff
changeset
|
203 |
dd4caab17008
core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents:
399
diff
changeset
|
204 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
dd4caab17008
core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents:
399
diff
changeset
|
205 in_signature='ssss', out_signature='s', |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
206 async_callbacks=None) |
267 | 207 def callMenu(self, category, name, menu_type, profile_key): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
208 return self._callback("callMenu", unicode(category), unicode(name), unicode(menu_type), unicode(profile_key)) |
267 | 209 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
210 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
211 in_signature='sba{ss}', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
212 async_callbacks=None) |
267 | 213 def confirmationAnswer(self, id, accepted, data): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
214 return self._callback("confirmationAnswer", unicode(id), accepted, data) |
267 | 215 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
216 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
217 in_signature='s', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
218 async_callbacks=None) |
267 | 219 def connect(self, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
220 return self._callback("connect", unicode(profile_key)) |
267 | 221 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
222 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
223 in_signature='s', out_signature='i', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
224 async_callbacks=None) |
267 | 225 def createProfile(self, profile): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
226 return self._callback("createProfile", unicode(profile)) |
267 | 227 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
228 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
229 in_signature='ss', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
230 async_callbacks=None) |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
231 def delContact(self, entity_jid, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
232 return self._callback("delContact", unicode(entity_jid), unicode(profile_key)) |
267 | 233 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
234 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
235 in_signature='s', out_signature='i', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
236 async_callbacks=None) |
267 | 237 def deleteProfile(self, profile): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
238 return self._callback("deleteProfile", unicode(profile)) |
267 | 239 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
240 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
241 in_signature='s', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
242 async_callbacks=None) |
267 | 243 def disconnect(self, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
244 return self._callback("disconnect", unicode(profile_key)) |
267 | 245 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
246 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
365
efbfccfed623
core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents:
364
diff
changeset
|
247 in_signature='ss', out_signature='s', |
364 | 248 async_callbacks=None) |
365
efbfccfed623
core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents:
364
diff
changeset
|
249 def getConfig(self, section, name): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
250 return self._callback("getConfig", unicode(section), unicode(name)) |
364 | 251 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
252 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
253 in_signature='s', out_signature='a(sa{ss}as)', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
254 async_callbacks=None) |
267 | 255 def getContacts(self, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
256 return self._callback("getContacts", unicode(profile_key)) |
267 | 257 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
258 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
259 in_signature='ss', out_signature='as', |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
260 async_callbacks=None) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
261 def getContactsFromGroup(self, group, profile_key="@DEFAULT@"): |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
262 return self._callback("getContactsFromGroup", unicode(group), unicode(profile_key)) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
263 |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
264 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
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
|
265 in_signature='sass', out_signature='a{ss}', |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
266 async_callbacks=None) |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
267 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
|
268 return self._callback("getEntityData", unicode(jid), keys, unicode(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
|
269 |
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
270 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
512
862c0d6ab974
core, bridge, quick_frontend: MUC private messages history management:
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
271 in_signature='ssib', out_signature='a(dssss)', |
425
e4e9187e3b5b
backend, bridge: asynchronous history
Goffi <goffi@goffi.org>
parents:
424
diff
changeset
|
272 async_callbacks=('callback', 'errback')) |
e4e9187e3b5b
backend, bridge: asynchronous history
Goffi <goffi@goffi.org>
parents:
424
diff
changeset
|
273 def getHistory(self, from_jid, to_jid, limit, between=True, callback=None, errback=None): |
e4e9187e3b5b
backend, bridge: asynchronous history
Goffi <goffi@goffi.org>
parents:
424
diff
changeset
|
274 return self._callback("getHistory", unicode(from_jid), unicode(to_jid), limit, between, callback=callback, errback=errback) |
267 | 275 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
276 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
399 | 277 in_signature='ss', out_signature='s', |
278 async_callbacks=None) | |
279 def getLastResource(self, contact_jid, profile_key="@DEFAULT@"): | |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
280 return self._callback("getLastResource", unicode(contact_jid), unicode(profile_key)) |
399 | 281 |
282 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, | |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
283 in_signature='sss', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
284 async_callbacks=None) |
267 | 285 def getMenuHelp(self, category, name, menu_type): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
286 return self._callback("getMenuHelp", unicode(category), unicode(name), unicode(menu_type)) |
267 | 287 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
288 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
289 in_signature='', out_signature='a(sss)', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
290 async_callbacks=None) |
267 | 291 def getMenus(self, ): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
292 return self._callback("getMenus", ) |
267 | 293 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
294 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
295 in_signature='ssss', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
296 async_callbacks=None) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
297 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
298 return self._callback("getParamA", unicode(name), unicode(category), unicode(attribute), unicode(profile_key)) |
267 | 299 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
300 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
301 in_signature='s', out_signature='s', |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
302 async_callbacks=('callback', 'errback')) |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
303 def getParams(self, profile_key="@DEFAULT@", callback=None, errback=None): |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
304 return self._callback("getParams", unicode(profile_key), callback=callback, errback=errback) |
267 | 305 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
306 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
307 in_signature='', out_signature='as', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
308 async_callbacks=None) |
267 | 309 def getParamsCategories(self, ): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
310 return self._callback("getParamsCategories", ) |
267 | 311 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
312 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
313 in_signature='ss', out_signature='s', |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
314 async_callbacks=('callback', 'errback')) |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
315 def getParamsForCategory(self, category, profile_key="@DEFAULT@", callback=None, errback=None): |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
316 return self._callback("getParamsForCategory", unicode(category), unicode(profile_key), callback=callback, errback=errback) |
267 | 317 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
318 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
319 in_signature='s', out_signature='s', |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
320 async_callbacks=('callback', 'errback')) |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
321 def getParamsUI(self, profile_key="@DEFAULT@", callback=None, errback=None): |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
322 return self._callback("getParamsUI", unicode(profile_key), callback=callback, errback=errback) |
267 | 323 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
324 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
325 in_signature='s', out_signature='a{sa{s(sia{ss})}}', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
326 async_callbacks=None) |
267 | 327 def getPresenceStatus(self, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
328 return self._callback("getPresenceStatus", unicode(profile_key)) |
267 | 329 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
330 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
331 in_signature='s', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
332 async_callbacks=None) |
267 | 333 def getProfileName(self, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
334 return self._callback("getProfileName", unicode(profile_key)) |
267 | 335 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
336 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
337 in_signature='', out_signature='as', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
338 async_callbacks=None) |
267 | 339 def getProfilesList(self, ): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
340 return self._callback("getProfilesList", ) |
60
9764e027ecc0
SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
341 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
342 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
343 in_signature='s', out_signature='a{ss}', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
344 async_callbacks=None) |
267 | 345 def getProgress(self, id): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
346 return self._callback("getProgress", unicode(id)) |
68 | 347 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
348 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
349 in_signature='', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
350 async_callbacks=None) |
267 | 351 def getVersion(self, ): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
352 return self._callback("getVersion", ) |
267 | 353 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
354 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
355 in_signature='s', out_signature='a{ss}', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
356 async_callbacks=None) |
267 | 357 def getWaitingSub(self, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
358 return self._callback("getWaitingSub", unicode(profile_key)) |
267 | 359 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
360 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
361 in_signature='s', out_signature='b', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
362 async_callbacks=None) |
267 | 363 def isConnected(self, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
364 return self._callback("isConnected", unicode(profile_key)) |
267 | 365 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
366 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
367 in_signature='sa{ss}s', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
368 async_callbacks=None) |
267 | 369 def launchAction(self, action_type, data, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
370 return self._callback("launchAction", unicode(action_type), data, unicode(profile_key)) |
60
9764e027ecc0
SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
371 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
372 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
373 in_signature='ssssi', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
374 async_callbacks=None) |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
375 def registerNewAccount(self, login, password, email, host, port=5222): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
376 return self._callback("registerNewAccount", unicode(login), unicode(password), unicode(email), unicode(host), port) |
0 | 377 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
378 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
379 in_signature='sssss', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
380 async_callbacks=None) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
381 def sendMessage(self, to_jid, message, subject='', mess_type="auto", profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
382 return self._callback("sendMessage", unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), unicode(profile_key)) |
65
d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents:
61
diff
changeset
|
383 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
384 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
385 in_signature='ssss', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
386 async_callbacks=None) |
267 | 387 def setParam(self, name, value, category, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
388 return self._callback("setParam", unicode(name), unicode(value), unicode(category), unicode(profile_key)) |
105 | 389 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
390 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
391 in_signature='ssia{ss}s', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
392 async_callbacks=None) |
267 | 393 def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
394 return self._callback("setPresence", unicode(to_jid), unicode(show), priority, statuses, unicode(profile_key)) |
0 | 395 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
396 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
397 in_signature='sss', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
398 async_callbacks=None) |
267 | 399 def subscription(self, sub_type, entity, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
400 return self._callback("subscription", unicode(sub_type), unicode(entity), unicode(profile_key)) |
0 | 401 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
402 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
345 | 403 in_signature='ssass', out_signature='', |
404 async_callbacks=None) | |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
405 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@"): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
419
diff
changeset
|
406 return self._callback("updateContact", unicode(entity_jid), unicode(name), groups, unicode(profile_key)) |
345 | 407 |
101 | 408 |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
409 def __attributes(self, in_sign): |
267 | 410 """Return arguments to user given a in_sign |
411 @param in_sign: in_sign in the short form (using s,a,i,b etc) | |
412 @return: list of arguments that correspond to a in_sign (e.g.: "sss" return "arg1, arg2, arg3")""" | |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
413 i=0 |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
414 idx=0 |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
415 attr=[] |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
416 while i<len(in_sign): |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
417 if in_sign[i] not in ['b','y','n','i','x','q','u','t','d','s','a']: |
267 | 418 raise ParseError("Unmanaged attribute type [%c]" % in_sign[i]) |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
419 |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
420 attr.append("arg_%i" % idx) |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
421 idx+=1 |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
422 |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
423 if in_sign[i] == 'a': |
73 | 424 i+=1 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
135
diff
changeset
|
425 if in_sign[i]!='{' and in_sign[i]!='(': #FIXME: must manage tuples out of arrays |
73 | 426 i+=1 |
427 continue #we have a simple type for the array | |
267 | 428 opening_car = in_sign[i] |
429 assert(opening_car in ['{','(']) | |
430 closing_car = '}' if opening_car == '{' else ')' | |
431 opening_count = 1 | |
73 | 432 while (True): #we have a dict or a list of tuples |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
433 i+=1 |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
434 if i>=len(in_sign): |
267 | 435 raise ParseError("missing }") |
436 if in_sign[i] == opening_car: | |
437 opening_count+=1 | |
438 if in_sign[i] == closing_car: | |
439 opening_count-=1 | |
440 if opening_count == 0: | |
441 break | |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
442 i+=1 |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
443 return attr |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
444 |
468
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
445 def addMethod(self, name, int_suffix, in_sign, out_sign, method, async=False): |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
446 """Dynamically add a method to Dbus Bridge""" |
468
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
447 inspect_args = inspect.getargspec(method) |
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
448 |
469
db4c2b82bab6
D-Bus bridge: fixed getRoomsSubjects call + fixed dynamic addition of methods + added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
468
diff
changeset
|
449 _arguments = inspect_args.args |
468
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
450 _defaults = list(inspect_args.defaults or []) |
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
451 |
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
452 if inspect.ismethod(method): |
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
453 #if we have a method, we don't want the first argument (usually 'self') |
469
db4c2b82bab6
D-Bus bridge: fixed getRoomsSubjects call + fixed dynamic addition of methods + added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
468
diff
changeset
|
454 del(_arguments[0]) |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
455 |
469
db4c2b82bab6
D-Bus bridge: fixed getRoomsSubjects call + fixed dynamic addition of methods + added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
468
diff
changeset
|
456 #first arguments are for the _callback method |
db4c2b82bab6
D-Bus bridge: fixed getRoomsSubjects call + fixed dynamic addition of methods + added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
468
diff
changeset
|
457 arguments_callback = ', '.join([repr(name)] + ((_arguments + ['callback=callback','errback=errback']) if async else _arguments)) |
db4c2b82bab6
D-Bus bridge: fixed getRoomsSubjects call + fixed dynamic addition of methods + added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
468
diff
changeset
|
458 |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
459 if async: |
469
db4c2b82bab6
D-Bus bridge: fixed getRoomsSubjects call + fixed dynamic addition of methods + added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
468
diff
changeset
|
460 _arguments.extend(['callback','errback']) |
db4c2b82bab6
D-Bus bridge: fixed getRoomsSubjects call + fixed dynamic addition of methods + added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
468
diff
changeset
|
461 _defaults.extend([None, None]) |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
462 |
468
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
463 |
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
464 #now we create a second list with default values |
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
465 for i in range(1, len(_defaults)+1): |
469
db4c2b82bab6
D-Bus bridge: fixed getRoomsSubjects call + fixed dynamic addition of methods + added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
468
diff
changeset
|
466 _arguments[-i] = "%s = %s" % (_arguments[-i], repr(_defaults[-i])) |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
467 |
469
db4c2b82bab6
D-Bus bridge: fixed getRoomsSubjects call + fixed dynamic addition of methods + added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
468
diff
changeset
|
468 arguments_defaults = ', '.join(_arguments) |
468
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
469 |
469
db4c2b82bab6
D-Bus bridge: fixed getRoomsSubjects call + fixed dynamic addition of methods + added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
468
diff
changeset
|
470 code = compile ('def %(name)s (self,%(arguments_defaults)s): return self._callback(%(arguments_callback)s)' % |
db4c2b82bab6
D-Bus bridge: fixed getRoomsSubjects call + fixed dynamic addition of methods + added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
468
diff
changeset
|
471 {'name':name, 'arguments_defaults':arguments_defaults, 'arguments_callback':arguments_callback}, '<DBus bridge>','exec') |
468
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
472 exec (code) #FIXME: to the same thing in a cleaner way, without compile/exec |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
473 method = locals()[name] |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
474 async_callbacks = ('callback', 'errback') if async else None |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
475 setattr(DbusObject, name, dbus.service.method( |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
476 const_INT_PREFIX+int_suffix, in_signature=in_sign, out_signature=out_sign, |
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
477 async_callbacks=async_callbacks)(method)) |
284
c25371424090
dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents:
274
diff
changeset
|
478 function = getattr(self, name) |
c25371424090
dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents:
274
diff
changeset
|
479 func_table = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__][function._dbus_interface] |
c25371424090
dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents:
274
diff
changeset
|
480 func_table[function.__name__] = function #Needed for introspection |
73 | 481 |
298
15c8916317d0
dbus bridge: added doc parameter, unmanaged yet
Goffi <goffi@goffi.org>
parents:
284
diff
changeset
|
482 def addSignal(self, name, int_suffix, signature, doc={}): |
73 | 483 """Dynamically add a signal to Dbus Bridge""" |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
484 attributes = ', '.join(self.__attributes(signature)) |
468
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
485 #TODO: use doc parameter to name attributes |
73 | 486 |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
487 #code = compile ('def '+name+' (self,'+attributes+'): debug ("'+name+' signal")', '<DBus bridge>','exec') #XXX: the debug is too annoying with xmllog |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
488 code = compile ('def '+name+' (self,'+attributes+'): pass', '<DBus bridge>','exec') |
73 | 489 exec (code) |
490 signal = locals()[name] | |
491 setattr(DbusObject, name, dbus.service.signal( | |
492 const_INT_PREFIX+int_suffix, signature=signature)(signal)) | |
284
c25371424090
dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents:
274
diff
changeset
|
493 function = getattr(self, name) |
c25371424090
dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents:
274
diff
changeset
|
494 func_table = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__][function._dbus_interface] |
c25371424090
dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents:
274
diff
changeset
|
495 func_table[function.__name__] = function #Needed for introspection |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
496 |
0 | 497 class DBusBridge(Bridge): |
498 def __init__(self): | |
499 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) | |
500 Bridge.__init__(self) | |
501 info ("Init DBus...") | |
502 self.session_bus = dbus.SessionBus() | |
10 | 503 self.dbus_name = dbus.service.BusName(const_INT_PREFIX, self.session_bus) |
360 | 504 self.dbus_bridge = DbusObject(self.session_bus, const_OBJ_PATH) |
0 | 505 |
267 | 506 def actionResult(self, answer_type, id, data): |
507 self.dbus_bridge.actionResult(answer_type, id, data) | |
508 | |
509 def actionResultExt(self, answer_type, id, data): | |
510 self.dbus_bridge.actionResultExt(answer_type, id, data) | |
511 | |
512 def askConfirmation(self, conf_type, id, data): | |
513 self.dbus_bridge.askConfirmation(conf_type, id, data) | |
514 | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
515 def connected(self, profile): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
516 self.dbus_bridge.connected(profile) |
267 | 517 |
274
c1ad04586edf
Bridge: rename connection_error to connectionError for function name consistency
Goffi <goffi@goffi.org>
parents:
272
diff
changeset
|
518 def connectionError(self, error_type, profile): |
c1ad04586edf
Bridge: rename connection_error to connectionError for function name consistency
Goffi <goffi@goffi.org>
parents:
272
diff
changeset
|
519 self.dbus_bridge.connectionError(error_type, profile) |
267 | 520 |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
521 def contactDeleted(self, entity_jid, profile): |
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
522 self.dbus_bridge.contactDeleted(entity_jid, profile) |
267 | 523 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
524 def disconnected(self, profile): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
525 self.dbus_bridge.disconnected(profile) |
267 | 526 |
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
|
527 def entityDataUpdated(self, jid, name, value, 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
|
528 self.dbus_bridge.entityDataUpdated(jid, name, value, 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
|
529 |
267 | 530 def newAlert(self, message, title, alert_type, profile): |
531 self.dbus_bridge.newAlert(message, title, alert_type, profile) | |
532 | |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
533 def newContact(self, contact_jid, attributes, groups, profile): |
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
534 self.dbus_bridge.newContact(contact_jid, attributes, groups, profile) |
0 | 535 |
513
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
512
diff
changeset
|
536 def newMessage(self, from_jid, message, mess_type, to_jid, extra, profile): |
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
512
diff
changeset
|
537 self.dbus_bridge.newMessage(from_jid, message, mess_type, to_jid, extra, profile) |
0 | 538 |
267 | 539 def paramUpdate(self, name, value, category, profile): |
540 self.dbus_bridge.paramUpdate(name, value, category, profile) | |
541 | |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
542 def presenceUpdate(self, entity_jid, show, priority, statuses, profile): |
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
543 self.dbus_bridge.presenceUpdate(entity_jid, show, priority, statuses, profile) |
49 | 544 |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
545 def subscribe(self, sub_type, entity_jid, profile): |
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
546 self.dbus_bridge.subscribe(sub_type, entity_jid, profile) |
0 | 547 |
267 | 548 |
0 | 549 def register(self, name, callback): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
550 debug("registering DBus bridge method [%s]", name) |
0 | 551 self.dbus_bridge.register(name, callback) |
552 | |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
553 def addMethod(self, name, int_suffix, in_sign, out_sign, method, async=False, doc={}): |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
554 """Dynamically add a method to Dbus Bridge""" |
468
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
555 #FIXME: doc parameter is kept only temporary, the time to remove it from calls |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
556 print ("Adding method [%s] to DBus bridge" % name) |
468
c97640c90a94
D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
557 self.dbus_bridge.addMethod(name, int_suffix, in_sign, out_sign, method, async) |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
558 self.register(name, method) |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
559 |
298
15c8916317d0
dbus bridge: added doc parameter, unmanaged yet
Goffi <goffi@goffi.org>
parents:
284
diff
changeset
|
560 def addSignal(self, name, int_suffix, signature, doc={}): |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
561 self.dbus_bridge.addSignal(name, int_suffix, signature, doc) |
74
6e3a06b4dd36
plugin xep-0045: added roomUserJoined and roomUserLeft signals
Goffi <goffi@goffi.org>
parents:
73
diff
changeset
|
562 setattr(DBusBridge, name, getattr(self.dbus_bridge, name)) |