Mercurial > libervia-backend
annotate src/bridge/DBus.py @ 419:6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 02 Nov 2011 22:47:59 +0100 |
parents | dd4caab17008 |
children | 6c20c76abdcc |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 #-*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 SAT: a jabber client | |
228 | 6 Copyright (C) 2009, 2010, 2011 Jérôme Poisson (goffi@goffi.org) |
0 | 7 |
8 This program is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
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 | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
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 | |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
27 from logging import debug, info |
0 | 28 |
10 | 29 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
|
30 const_ERROR_PREFIX = const_INT_PREFIX+".error" |
360 | 31 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
|
32 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
|
33 const_PLUGIN_SUFFIX = ".plugin" |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
34 |
419
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
35 class GenericException(dbus.DBusException): |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
36 def __init__(self, name): |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
37 super(GenericException,self).__init__() |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
38 self._dbus_error_name = const_ERROR_PREFIX+"."+name |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
39 |
0 | 40 class DbusObject(dbus.service.Object): |
41 | |
42 def __init__(self, bus, path): | |
43 dbus.service.Object.__init__(self, bus, path) | |
44 debug("Init DbusObject...") | |
45 self.cb={} | |
46 | |
47 def register(self, name, cb): | |
48 self.cb[name]=cb | |
49 | |
50 ### signals ### | |
51 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
52 @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
|
53 signature='') |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
54 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
|
55 #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
|
56 # 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
|
57 # further investigations |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
58 pass |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
59 |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
60 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 61 signature='ssa{ss}') |
62 def actionResult(self, answer_type, id, data): | |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
63 pass |
267 | 64 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
65 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 66 signature='ssa{sa{ss}}') |
67 def actionResultExt(self, answer_type, id, data): | |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
68 pass |
267 | 69 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
70 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 71 signature='ssa{ss}') |
72 def askConfirmation(self, conf_type, id, data): | |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
73 pass |
267 | 74 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
75 @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
|
76 signature='s') |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
77 def connected(self, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
78 pass |
267 | 79 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
80 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
262
af3d4f11fe43
Added management of connection error
Goffi <goffi@goffi.org>
parents:
260
diff
changeset
|
81 signature='ss') |
274
c1ad04586edf
Bridge: rename connection_error to connectionError for function name consistency
Goffi <goffi@goffi.org>
parents:
272
diff
changeset
|
82 def connectionError(self, error_type, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
83 pass |
0 | 84 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
85 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
49 | 86 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
|
87 def contactDeleted(self, entity_jid, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
88 pass |
267 | 89 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
90 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 91 signature='s') |
92 def disconnected(self, profile): | |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
93 pass |
267 | 94 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
95 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 96 signature='ssss') |
97 def newAlert(self, message, title, alert_type, profile): | |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
98 pass |
267 | 99 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
100 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 101 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
|
102 def newContact(self, contact_jid, attributes, groups, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
103 pass |
0 | 104 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
105 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 106 signature='sssss') |
107 def newMessage(self, from_jid, message, mess_type, to_jid, profile): | |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
108 pass |
267 | 109 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
110 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 111 signature='ssss') |
112 def paramUpdate(self, name, value, category, profile): | |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
113 pass |
0 | 114 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
115 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 116 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
|
117 def presenceUpdate(self, entity_jid, show, priority, statuses, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
118 pass |
267 | 119 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
120 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
267 | 121 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
|
122 def subscribe(self, sub_type, entity_jid, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
123 pass |
267 | 124 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
125 @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX, |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
126 signature='sa{ss}s') |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
127 def updatedValue(self, name, value, profile): |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
128 pass |
267 | 129 |
49 | 130 |
0 | 131 ### methods ### |
267 | 132 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
133 @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
|
134 in_signature='ss', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
135 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
|
136 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:
371
diff
changeset
|
137 return self.cb["addContact"](unicode(entity_jid), unicode(profile_key)) |
0 | 138 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
139 @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
|
140 in_signature='s', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
141 async_callbacks=('callback', 'errback')) |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
142 def asyncConnect(self, profile_key="@DEFAULT@", callback=None, errback=None): |
419
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
143 return self.cb["asyncConnect"](unicode(profile_key), callback, lambda arg:errback(GenericException(arg))) |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
144 |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
145 @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
|
146 in_signature='s', out_signature='', |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
147 async_callbacks=('callback', 'errback')) |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
148 def asyncCreateProfile(self, profile, callback=None, errback=None): |
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
149 return self.cb["asyncCreateProfile"](unicode(profile), callback, lambda arg:errback(GenericException(arg))) |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
150 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
151 @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
|
152 in_signature='ssss', out_signature='s', |
413
dd4caab17008
core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents:
399
diff
changeset
|
153 async_callbacks=('callback', 'errback')) |
dd4caab17008
core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents:
399
diff
changeset
|
154 def asyncGetParamA(self, name, category, attribute="value", profile_key="@DEFAULT@", callback=None, errback=None): |
419
6c167a2e04b8
bridge: added generic D-Bus exception management + asyncCreateProfile method
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
155 return self.cb["asyncGetParamA"](unicode(name), unicode(category), unicode(attribute), unicode(profile_key), callback, lambda arg:errback(GenericException(arg))) |
413
dd4caab17008
core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents:
399
diff
changeset
|
156 |
dd4caab17008
core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents:
399
diff
changeset
|
157 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
dd4caab17008
core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents:
399
diff
changeset
|
158 in_signature='ssss', out_signature='s', |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
159 async_callbacks=None) |
267 | 160 def callMenu(self, category, name, menu_type, profile_key): |
161 return self.cb["callMenu"](unicode(category), unicode(name), unicode(menu_type), unicode(profile_key)) | |
162 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
163 @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
|
164 in_signature='sba{ss}', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
165 async_callbacks=None) |
267 | 166 def confirmationAnswer(self, id, accepted, data): |
167 return self.cb["confirmationAnswer"](unicode(id), accepted, data) | |
168 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
169 @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
|
170 in_signature='s', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
171 async_callbacks=None) |
267 | 172 def connect(self, profile_key="@DEFAULT@"): |
173 return self.cb["connect"](unicode(profile_key)) | |
174 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
175 @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
|
176 in_signature='s', out_signature='i', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
177 async_callbacks=None) |
267 | 178 def createProfile(self, profile): |
179 return self.cb["createProfile"](unicode(profile)) | |
180 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
181 @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
|
182 in_signature='ss', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
183 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
|
184 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:
371
diff
changeset
|
185 return self.cb["delContact"](unicode(entity_jid), unicode(profile_key)) |
267 | 186 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
187 @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
|
188 in_signature='s', out_signature='i', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
189 async_callbacks=None) |
267 | 190 def deleteProfile(self, profile): |
191 return self.cb["deleteProfile"](unicode(profile)) | |
192 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
193 @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
|
194 in_signature='s', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
195 async_callbacks=None) |
267 | 196 def disconnect(self, profile_key="@DEFAULT@"): |
197 return self.cb["disconnect"](unicode(profile_key)) | |
198 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
199 @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
|
200 in_signature='ss', out_signature='s', |
364 | 201 async_callbacks=None) |
365
efbfccfed623
core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents:
364
diff
changeset
|
202 def getConfig(self, section, name): |
efbfccfed623
core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents:
364
diff
changeset
|
203 return self.cb["getConfig"](unicode(section), unicode(name)) |
364 | 204 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
205 @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
|
206 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
|
207 async_callbacks=None) |
267 | 208 def getContacts(self, profile_key="@DEFAULT@"): |
209 return self.cb["getContacts"](unicode(profile_key)) | |
210 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
211 @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
|
212 in_signature='ssi', out_signature='a{i(ss)}', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
213 async_callbacks=None) |
267 | 214 def getHistory(self, from_jid, to_jid, size): |
215 return self.cb["getHistory"](unicode(from_jid), unicode(to_jid), size) | |
216 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
217 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
399 | 218 in_signature='ss', out_signature='s', |
219 async_callbacks=None) | |
220 def getLastResource(self, contact_jid, profile_key="@DEFAULT@"): | |
221 return self.cb["getLastResource"](unicode(contact_jid), unicode(profile_key)) | |
222 | |
223 @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
|
224 in_signature='sss', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
225 async_callbacks=None) |
267 | 226 def getMenuHelp(self, category, name, menu_type): |
227 return self.cb["getMenuHelp"](unicode(category), unicode(name), unicode(menu_type)) | |
228 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
229 @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
|
230 in_signature='', out_signature='a(sss)', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
231 async_callbacks=None) |
267 | 232 def getMenus(self, ): |
233 return self.cb["getMenus"]() | |
234 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
235 @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
|
236 in_signature='ssss', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
237 async_callbacks=None) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
238 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"): |
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
239 return self.cb["getParamA"](unicode(name), unicode(category), unicode(attribute), unicode(profile_key)) |
267 | 240 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
241 @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
|
242 in_signature='s', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
243 async_callbacks=None) |
267 | 244 def getParams(self, profile_key="@DEFAULT@"): |
245 return self.cb["getParams"](unicode(profile_key)) | |
246 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
247 @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
|
248 in_signature='', out_signature='as', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
249 async_callbacks=None) |
267 | 250 def getParamsCategories(self, ): |
251 return self.cb["getParamsCategories"]() | |
252 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
253 @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
|
254 in_signature='ss', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
255 async_callbacks=None) |
267 | 256 def getParamsForCategory(self, category, profile_key="@DEFAULT@"): |
257 return self.cb["getParamsForCategory"](unicode(category), unicode(profile_key)) | |
258 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
259 @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
|
260 in_signature='s', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
261 async_callbacks=None) |
267 | 262 def getParamsUI(self, profile_key="@DEFAULT@"): |
263 return self.cb["getParamsUI"](unicode(profile_key)) | |
264 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
265 @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
|
266 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
|
267 async_callbacks=None) |
267 | 268 def getPresenceStatus(self, profile_key="@DEFAULT@"): |
269 return self.cb["getPresenceStatus"](unicode(profile_key)) | |
270 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
271 @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
|
272 in_signature='s', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
273 async_callbacks=None) |
267 | 274 def getProfileName(self, profile_key="@DEFAULT@"): |
275 return self.cb["getProfileName"](unicode(profile_key)) | |
276 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
277 @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
|
278 in_signature='', out_signature='as', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
279 async_callbacks=None) |
267 | 280 def getProfilesList(self, ): |
60
9764e027ecc0
SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
281 return self.cb["getProfilesList"]() |
9764e027ecc0
SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
282 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
283 @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
|
284 in_signature='s', out_signature='a{ss}', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
285 async_callbacks=None) |
267 | 286 def getProgress(self, id): |
287 return self.cb["getProgress"](unicode(id)) | |
68 | 288 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
289 @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
|
290 in_signature='', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
291 async_callbacks=None) |
267 | 292 def getVersion(self, ): |
293 return self.cb["getVersion"]() | |
294 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
295 @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
|
296 in_signature='s', out_signature='a{ss}', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
297 async_callbacks=None) |
267 | 298 def getWaitingSub(self, profile_key="@DEFAULT@"): |
299 return self.cb["getWaitingSub"](unicode(profile_key)) | |
300 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
301 @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
|
302 in_signature='s', out_signature='b', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
303 async_callbacks=None) |
267 | 304 def isConnected(self, profile_key="@DEFAULT@"): |
305 return self.cb["isConnected"](unicode(profile_key)) | |
306 | |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
307 @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
|
308 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
|
309 async_callbacks=None) |
267 | 310 def launchAction(self, action_type, data, profile_key="@DEFAULT@"): |
311 return self.cb["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
|
312 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
313 @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
|
314 in_signature='ssssi', out_signature='s', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
315 async_callbacks=None) |
336
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
316 def registerNewAccount(self, login, password, email, host, port=5222): |
953536246d9d
core: added email in registerNewAccount
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
317 return self.cb["registerNewAccount"](unicode(login), unicode(password), unicode(email), unicode(host), port) |
0 | 318 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
319 @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
|
320 in_signature='sssss', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
321 async_callbacks=None) |
272
1d2e0dfe7114
bridge: core & frontend sides of bridge are now generated
Goffi <goffi@goffi.org>
parents:
267
diff
changeset
|
322 def sendMessage(self, to_jid, message, subject='', mess_type="chat", profile_key="@DEFAULT@"): |
267 | 323 return self.cb["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
|
324 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
325 @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
|
326 in_signature='ssss', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
327 async_callbacks=None) |
267 | 328 def setParam(self, name, value, category, profile_key="@DEFAULT@"): |
329 return self.cb["setParam"](unicode(name), unicode(value), unicode(category), unicode(profile_key)) | |
105 | 330 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
331 @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
|
332 in_signature='ssia{ss}s', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
333 async_callbacks=None) |
267 | 334 def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"): |
335 return self.cb["setPresence"](unicode(to_jid), unicode(show), priority, statuses, unicode(profile_key)) | |
0 | 336 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
337 @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
|
338 in_signature='sss', out_signature='', |
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
339 async_callbacks=None) |
267 | 340 def subscription(self, sub_type, entity, profile_key="@DEFAULT@"): |
341 return self.cb["subscription"](unicode(sub_type), unicode(entity), unicode(profile_key)) | |
0 | 342 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
343 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
345 | 344 in_signature='ssass', out_signature='', |
345 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
|
346 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:
371
diff
changeset
|
347 return self.cb["updateContact"](unicode(entity_jid), unicode(name), groups, unicode(profile_key)) |
345 | 348 |
101 | 349 |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
350 def __attributes(self, in_sign): |
267 | 351 """Return arguments to user given a in_sign |
352 @param in_sign: in_sign in the short form (using s,a,i,b etc) | |
353 @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
|
354 i=0 |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
355 idx=0 |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
356 attr=[] |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
357 while i<len(in_sign): |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
358 if in_sign[i] not in ['b','y','n','i','x','q','u','t','d','s','a']: |
267 | 359 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
|
360 |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
361 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
|
362 idx+=1 |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
363 |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
364 if in_sign[i] == 'a': |
73 | 365 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
|
366 if in_sign[i]!='{' and in_sign[i]!='(': #FIXME: must manage tuples out of arrays |
73 | 367 i+=1 |
368 continue #we have a simple type for the array | |
267 | 369 opening_car = in_sign[i] |
370 assert(opening_car in ['{','(']) | |
371 closing_car = '}' if opening_car == '{' else ')' | |
372 opening_count = 1 | |
73 | 373 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
|
374 i+=1 |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
375 if i>=len(in_sign): |
267 | 376 raise ParseError("missing }") |
377 if in_sign[i] == opening_car: | |
378 opening_count+=1 | |
379 if in_sign[i] == closing_car: | |
380 opening_count-=1 | |
381 if opening_count == 0: | |
382 break | |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
383 i+=1 |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
384 return attr |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
385 |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
386 def addMethod(self, name, int_suffix, in_sign, out_sign, async=False, doc={}): |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
387 """Dynamically add a method to Dbus Bridge""" |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
388 _attributes = self.__attributes(in_sign) |
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
389 |
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
390 if async: |
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
391 _attributes.extend(['callback','errback']) |
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
392 |
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
393 attributes = ', '.join(_attributes) |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
394 |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
395 code = compile ('def '+name+' (self,'+attributes+'): return self.cb["'+name+'"]('+attributes+')', '<DBus bridge>','exec') |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
396 exec (code) |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
397 method = locals()[name] |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
398 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
|
399 setattr(DbusObject, name, dbus.service.method( |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
400 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
|
401 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
|
402 function = getattr(self, name) |
c25371424090
dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents:
274
diff
changeset
|
403 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
|
404 func_table[function.__name__] = function #Needed for introspection |
73 | 405 |
298
15c8916317d0
dbus bridge: added doc parameter, unmanaged yet
Goffi <goffi@goffi.org>
parents:
284
diff
changeset
|
406 def addSignal(self, name, int_suffix, signature, doc={}): |
73 | 407 """Dynamically add a signal to Dbus Bridge""" |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
408 attributes = ', '.join(self.__attributes(signature)) |
73 | 409 |
337
4402ac630712
bridge: async callback managed in bridge_constructor + misc
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
410 #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
|
411 code = compile ('def '+name+' (self,'+attributes+'): pass', '<DBus bridge>','exec') |
73 | 412 exec (code) |
413 signal = locals()[name] | |
414 setattr(DbusObject, name, dbus.service.signal( | |
415 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
|
416 function = getattr(self, name) |
c25371424090
dbus bridge: fixed introspection for dynamically added methods and signals
Goffi <goffi@goffi.org>
parents:
274
diff
changeset
|
417 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
|
418 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
|
419 |
0 | 420 class DBusBridge(Bridge): |
421 def __init__(self): | |
422 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) | |
423 Bridge.__init__(self) | |
424 info ("Init DBus...") | |
425 self.session_bus = dbus.SessionBus() | |
10 | 426 self.dbus_name = dbus.service.BusName(const_INT_PREFIX, self.session_bus) |
360 | 427 self.dbus_bridge = DbusObject(self.session_bus, const_OBJ_PATH) |
0 | 428 |
267 | 429 def actionResult(self, answer_type, id, data): |
430 self.dbus_bridge.actionResult(answer_type, id, data) | |
431 | |
432 def actionResultExt(self, answer_type, id, data): | |
433 self.dbus_bridge.actionResultExt(answer_type, id, data) | |
434 | |
435 def askConfirmation(self, conf_type, id, data): | |
436 self.dbus_bridge.askConfirmation(conf_type, id, data) | |
437 | |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
438 def connected(self, profile): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
439 self.dbus_bridge.connected(profile) |
267 | 440 |
274
c1ad04586edf
Bridge: rename connection_error to connectionError for function name consistency
Goffi <goffi@goffi.org>
parents:
272
diff
changeset
|
441 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
|
442 self.dbus_bridge.connectionError(error_type, profile) |
267 | 443 |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
444 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
|
445 self.dbus_bridge.contactDeleted(entity_jid, profile) |
267 | 446 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
447 def disconnected(self, profile): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
65
diff
changeset
|
448 self.dbus_bridge.disconnected(profile) |
267 | 449 |
450 def newAlert(self, message, title, alert_type, profile): | |
451 self.dbus_bridge.newAlert(message, title, alert_type, profile) | |
452 | |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
453 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
|
454 self.dbus_bridge.newContact(contact_jid, attributes, groups, profile) |
0 | 455 |
267 | 456 def newMessage(self, from_jid, message, mess_type, to_jid, profile): |
457 self.dbus_bridge.newMessage(from_jid, message, mess_type, to_jid, profile) | |
0 | 458 |
267 | 459 def paramUpdate(self, name, value, category, profile): |
460 self.dbus_bridge.paramUpdate(name, value, category, profile) | |
461 | |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
462 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
|
463 self.dbus_bridge.presenceUpdate(entity_jid, show, priority, statuses, profile) |
49 | 464 |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
371
diff
changeset
|
465 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
|
466 self.dbus_bridge.subscribe(sub_type, entity_jid, profile) |
0 | 467 |
371
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
468 def updatedValue(self, name, value, profile): |
3ea41a199b36
bridge refactoring: categories are now core and plugin instead of communication and request
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
469 self.dbus_bridge.updatedValue(name, value, profile) |
49 | 470 |
267 | 471 |
0 | 472 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
|
473 debug("registering DBus bridge method [%s]", name) |
0 | 474 self.dbus_bridge.register(name, callback) |
475 | |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
476 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
|
477 """Dynamically add a method to Dbus Bridge""" |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
478 print ("Adding method [%s] to DBus bridge" % name) |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
479 self.dbus_bridge.addMethod(name, int_suffix, in_sign, out_sign, async, doc) |
7
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
480 self.register(name, method) |
c14a3a7018a5
added dynamic exportation of Dbus bridge method (usefull for plugins)
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
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={}): |
300
233e6fce0b49
DBus bridge: using new generated bridge
Goffi <goffi@goffi.org>
parents:
298
diff
changeset
|
483 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
|
484 setattr(DBusBridge, name, getattr(self.dbus_bridge, name)) |