Mercurial > libervia-backend
comparison frontends/src/bridge/DBus.py @ 1367:f71a0fc26886
merged branch frontends_multi_profiles
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 18 Mar 2015 10:52:28 +0100 |
parents | bb9c32249778 |
children | 069ad98b360d |
comparison
equal
deleted
inserted
replaced
1295:1e3b1f9ad6e2 | 1367:f71a0fc26886 |
---|---|
100 # - or if the last two arguments are callable | 100 # - or if the last two arguments are callable |
101 | 101 |
102 async = False | 102 async = False |
103 | 103 |
104 if kwargs: | 104 if kwargs: |
105 if 'callback' in kwargs and 'errback' in kwargs: | 105 if 'callback' in kwargs: |
106 async = True | 106 async = True |
107 _callback = kwargs.pop('callback') | 107 _callback = kwargs.pop('callback') |
108 _errback = kwargs.pop('errback') | 108 _errback = kwargs.pop('errback', lambda failure: log.error(unicode(failure))) |
109 elif len(args) >= 2 and callable(args[-1]) and callable(args[-2]): | 109 elif len(args) >= 2 and callable(args[-1]) and callable(args[-2]): |
110 async = True | 110 async = True |
111 args = list(args) | 111 args = list(args) |
112 _errback = args.pop() | 112 _errback = args.pop() |
113 _callback = args.pop() | 113 _callback = args.pop() |
120 kwargs['error_handler'] = lambda err: _errback(dbus_to_bridge_exception(err)) | 120 kwargs['error_handler'] = lambda err: _errback(dbus_to_bridge_exception(err)) |
121 | 121 |
122 return method(*args, **kwargs) | 122 return method(*args, **kwargs) |
123 | 123 |
124 return getPluginMethod | 124 return getPluginMethod |
125 def addContact(self, entity_jid, profile_key="@DEFAULT@"): | 125 |
126 return self.db_core_iface.addContact(entity_jid, profile_key) | 126 def addContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None): |
127 if callback is None: | |
128 error_handler = None | |
129 else: | |
130 if errback is None: | |
131 errback = log.error | |
132 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
133 kwargs={} | |
134 if callback is not None: | |
135 kwargs['timeout'] = const_TIMEOUT | |
136 kwargs['reply_handler'] = callback | |
137 kwargs['error_handler'] = error_handler | |
138 return self.db_core_iface.addContact(entity_jid, profile_key, **kwargs) | |
127 | 139 |
128 def asyncConnect(self, profile_key="@DEFAULT@", password='', callback=None, errback=None): | 140 def asyncConnect(self, profile_key="@DEFAULT@", password='', callback=None, errback=None): |
129 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 141 if callback is None: |
142 error_handler = None | |
143 else: | |
144 if errback is None: | |
145 errback = log.error | |
146 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
130 return self.db_core_iface.asyncConnect(profile_key, password, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 147 return self.db_core_iface.asyncConnect(profile_key, password, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
131 | 148 |
132 def asyncCreateProfile(self, profile, password='', callback=None, errback=None): | 149 def asyncCreateProfile(self, profile, password='', callback=None, errback=None): |
133 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 150 if callback is None: |
151 error_handler = None | |
152 else: | |
153 if errback is None: | |
154 errback = log.error | |
155 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
134 return self.db_core_iface.asyncCreateProfile(profile, password, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 156 return self.db_core_iface.asyncCreateProfile(profile, password, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
135 | 157 |
136 def asyncDeleteProfile(self, profile, callback=None, errback=None): | 158 def asyncDeleteProfile(self, profile, callback=None, errback=None): |
137 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 159 if callback is None: |
160 error_handler = None | |
161 else: | |
162 if errback is None: | |
163 errback = log.error | |
164 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
138 return self.db_core_iface.asyncDeleteProfile(profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 165 return self.db_core_iface.asyncDeleteProfile(profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
139 | 166 |
140 def asyncGetParamA(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None): | 167 def asyncGetParamA(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None): |
141 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 168 if callback is None: |
169 error_handler = None | |
170 else: | |
171 if errback is None: | |
172 errback = log.error | |
173 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
142 return unicode(self.db_core_iface.asyncGetParamA(name, category, attribute, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) | 174 return unicode(self.db_core_iface.asyncGetParamA(name, category, attribute, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) |
143 | 175 |
144 def confirmationAnswer(self, id, accepted, data, profile): | 176 def confirmationAnswer(self, id, accepted, data, profile, callback=None, errback=None): |
145 return self.db_core_iface.confirmationAnswer(id, accepted, data, profile) | 177 if callback is None: |
146 | 178 error_handler = None |
147 def delContact(self, entity_jid, profile_key="@DEFAULT@"): | 179 else: |
148 return self.db_core_iface.delContact(entity_jid, profile_key) | 180 if errback is None: |
181 errback = log.error | |
182 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
183 kwargs={} | |
184 if callback is not None: | |
185 kwargs['timeout'] = const_TIMEOUT | |
186 kwargs['reply_handler'] = callback | |
187 kwargs['error_handler'] = error_handler | |
188 return self.db_core_iface.confirmationAnswer(id, accepted, data, profile, **kwargs) | |
189 | |
190 def delContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None): | |
191 if callback is None: | |
192 error_handler = None | |
193 else: | |
194 if errback is None: | |
195 errback = log.error | |
196 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
197 return self.db_core_iface.delContact(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | |
149 | 198 |
150 def discoInfos(self, entity_jid, profile_key, callback=None, errback=None): | 199 def discoInfos(self, entity_jid, profile_key, callback=None, errback=None): |
151 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 200 if callback is None: |
201 error_handler = None | |
202 else: | |
203 if errback is None: | |
204 errback = log.error | |
205 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
152 return self.db_core_iface.discoInfos(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 206 return self.db_core_iface.discoInfos(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
153 | 207 |
154 def discoItems(self, entity_jid, profile_key, callback=None, errback=None): | 208 def discoItems(self, entity_jid, profile_key, callback=None, errback=None): |
155 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 209 if callback is None: |
210 error_handler = None | |
211 else: | |
212 if errback is None: | |
213 errback = log.error | |
214 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
156 return self.db_core_iface.discoItems(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 215 return self.db_core_iface.discoItems(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
157 | 216 |
158 def disconnect(self, profile_key="@DEFAULT@"): | 217 def disconnect(self, profile_key="@DEFAULT@", callback=None, errback=None): |
159 return self.db_core_iface.disconnect(profile_key) | 218 if callback is None: |
160 | 219 error_handler = None |
161 def getConfig(self, section, name): | 220 else: |
162 return unicode(self.db_core_iface.getConfig(section, name)) | 221 if errback is None: |
163 | 222 errback = log.error |
164 def getContacts(self, profile_key="@DEFAULT@"): | 223 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
165 return self.db_core_iface.getContacts(profile_key) | 224 kwargs={} |
166 | 225 if callback is not None: |
167 def getContactsFromGroup(self, group, profile_key="@DEFAULT@"): | 226 kwargs['timeout'] = const_TIMEOUT |
168 return self.db_core_iface.getContactsFromGroup(group, profile_key) | 227 kwargs['reply_handler'] = callback |
169 | 228 kwargs['error_handler'] = error_handler |
170 def getEntityData(self, jid, keys, profile): | 229 return self.db_core_iface.disconnect(profile_key, **kwargs) |
171 return self.db_core_iface.getEntityData(jid, keys, profile) | 230 |
231 def getConfig(self, section, name, callback=None, errback=None): | |
232 if callback is None: | |
233 error_handler = None | |
234 else: | |
235 if errback is None: | |
236 errback = log.error | |
237 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
238 kwargs={} | |
239 if callback is not None: | |
240 kwargs['timeout'] = const_TIMEOUT | |
241 kwargs['reply_handler'] = callback | |
242 kwargs['error_handler'] = error_handler | |
243 return unicode(self.db_core_iface.getConfig(section, name, **kwargs)) | |
244 | |
245 def getContacts(self, profile_key="@DEFAULT@", callback=None, errback=None): | |
246 if callback is None: | |
247 error_handler = None | |
248 else: | |
249 if errback is None: | |
250 errback = log.error | |
251 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
252 return self.db_core_iface.getContacts(profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | |
253 | |
254 def getContactsFromGroup(self, group, profile_key="@DEFAULT@", callback=None, errback=None): | |
255 if callback is None: | |
256 error_handler = None | |
257 else: | |
258 if errback is None: | |
259 errback = log.error | |
260 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
261 kwargs={} | |
262 if callback is not None: | |
263 kwargs['timeout'] = const_TIMEOUT | |
264 kwargs['reply_handler'] = callback | |
265 kwargs['error_handler'] = error_handler | |
266 return self.db_core_iface.getContactsFromGroup(group, profile_key, **kwargs) | |
267 | |
268 def getEntitiesData(self, jids, keys, profile, callback=None, errback=None): | |
269 if callback is None: | |
270 error_handler = None | |
271 else: | |
272 if errback is None: | |
273 errback = log.error | |
274 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
275 kwargs={} | |
276 if callback is not None: | |
277 kwargs['timeout'] = const_TIMEOUT | |
278 kwargs['reply_handler'] = callback | |
279 kwargs['error_handler'] = error_handler | |
280 return self.db_core_iface.getEntitiesData(jids, keys, profile, **kwargs) | |
281 | |
282 def getEntityData(self, jid, keys, profile, callback=None, errback=None): | |
283 if callback is None: | |
284 error_handler = None | |
285 else: | |
286 if errback is None: | |
287 errback = log.error | |
288 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
289 kwargs={} | |
290 if callback is not None: | |
291 kwargs['timeout'] = const_TIMEOUT | |
292 kwargs['reply_handler'] = callback | |
293 kwargs['error_handler'] = error_handler | |
294 return self.db_core_iface.getEntityData(jid, keys, profile, **kwargs) | |
172 | 295 |
173 def getHistory(self, from_jid, to_jid, limit, between=True, search='', profile="@NONE@", callback=None, errback=None): | 296 def getHistory(self, from_jid, to_jid, limit, between=True, search='', profile="@NONE@", callback=None, errback=None): |
174 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 297 if callback is None: |
298 error_handler = None | |
299 else: | |
300 if errback is None: | |
301 errback = log.error | |
302 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
175 return self.db_core_iface.getHistory(from_jid, to_jid, limit, between, search, profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 303 return self.db_core_iface.getHistory(from_jid, to_jid, limit, between, search, profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
176 | 304 |
177 def getLastResource(self, contact_jid, profile_key="@DEFAULT@"): | 305 def getMainResource(self, contact_jid, profile_key="@DEFAULT@", callback=None, errback=None): |
178 return unicode(self.db_core_iface.getLastResource(contact_jid, profile_key)) | 306 if callback is None: |
179 | 307 error_handler = None |
180 def getMenuHelp(self, menu_id, language): | 308 else: |
181 return unicode(self.db_core_iface.getMenuHelp(menu_id, language)) | 309 if errback is None: |
182 | 310 errback = log.error |
183 def getMenus(self, language, security_limit): | 311 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
184 return self.db_core_iface.getMenus(language, security_limit) | 312 kwargs={} |
185 | 313 if callback is not None: |
186 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"): | 314 kwargs['timeout'] = const_TIMEOUT |
187 return unicode(self.db_core_iface.getParamA(name, category, attribute, profile_key)) | 315 kwargs['reply_handler'] = callback |
316 kwargs['error_handler'] = error_handler | |
317 return unicode(self.db_core_iface.getMainResource(contact_jid, profile_key, **kwargs)) | |
318 | |
319 def getMenuHelp(self, menu_id, language, callback=None, errback=None): | |
320 if callback is None: | |
321 error_handler = None | |
322 else: | |
323 if errback is None: | |
324 errback = log.error | |
325 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
326 kwargs={} | |
327 if callback is not None: | |
328 kwargs['timeout'] = const_TIMEOUT | |
329 kwargs['reply_handler'] = callback | |
330 kwargs['error_handler'] = error_handler | |
331 return unicode(self.db_core_iface.getMenuHelp(menu_id, language, **kwargs)) | |
332 | |
333 def getMenus(self, language, security_limit, callback=None, errback=None): | |
334 if callback is None: | |
335 error_handler = None | |
336 else: | |
337 if errback is None: | |
338 errback = log.error | |
339 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
340 kwargs={} | |
341 if callback is not None: | |
342 kwargs['timeout'] = const_TIMEOUT | |
343 kwargs['reply_handler'] = callback | |
344 kwargs['error_handler'] = error_handler | |
345 return self.db_core_iface.getMenus(language, security_limit, **kwargs) | |
346 | |
347 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@", callback=None, errback=None): | |
348 if callback is None: | |
349 error_handler = None | |
350 else: | |
351 if errback is None: | |
352 errback = log.error | |
353 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
354 kwargs={} | |
355 if callback is not None: | |
356 kwargs['timeout'] = const_TIMEOUT | |
357 kwargs['reply_handler'] = callback | |
358 kwargs['error_handler'] = error_handler | |
359 return unicode(self.db_core_iface.getParamA(name, category, attribute, profile_key, **kwargs)) | |
188 | 360 |
189 def getParams(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): | 361 def getParams(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): |
190 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 362 if callback is None: |
363 error_handler = None | |
364 else: | |
365 if errback is None: | |
366 errback = log.error | |
367 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
191 return unicode(self.db_core_iface.getParams(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) | 368 return unicode(self.db_core_iface.getParams(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) |
192 | 369 |
193 def getParamsCategories(self, ): | 370 def getParamsCategories(self, callback=None, errback=None): |
194 return self.db_core_iface.getParamsCategories() | 371 if callback is None: |
372 error_handler = None | |
373 else: | |
374 if errback is None: | |
375 errback = log.error | |
376 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
377 kwargs={} | |
378 if callback is not None: | |
379 kwargs['timeout'] = const_TIMEOUT | |
380 kwargs['reply_handler'] = callback | |
381 kwargs['error_handler'] = error_handler | |
382 return self.db_core_iface.getParamsCategories(**kwargs) | |
195 | 383 |
196 def getParamsForCategory(self, category, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): | 384 def getParamsForCategory(self, category, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): |
197 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 385 if callback is None: |
386 error_handler = None | |
387 else: | |
388 if errback is None: | |
389 errback = log.error | |
390 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
198 return unicode(self.db_core_iface.getParamsForCategory(category, security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) | 391 return unicode(self.db_core_iface.getParamsForCategory(category, security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) |
199 | 392 |
200 def getParamsUI(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): | 393 def getParamsUI(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): |
201 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 394 if callback is None: |
395 error_handler = None | |
396 else: | |
397 if errback is None: | |
398 errback = log.error | |
399 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
202 return unicode(self.db_core_iface.getParamsUI(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) | 400 return unicode(self.db_core_iface.getParamsUI(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) |
203 | 401 |
204 def getPresenceStatuses(self, profile_key="@DEFAULT@"): | 402 def getPresenceStatuses(self, profile_key="@DEFAULT@", callback=None, errback=None): |
205 return self.db_core_iface.getPresenceStatuses(profile_key) | 403 if callback is None: |
206 | 404 error_handler = None |
207 def getProfileName(self, profile_key="@DEFAULT@"): | 405 else: |
208 return unicode(self.db_core_iface.getProfileName(profile_key)) | 406 if errback is None: |
209 | 407 errback = log.error |
210 def getProfilesList(self, ): | 408 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
211 return self.db_core_iface.getProfilesList() | 409 kwargs={} |
212 | 410 if callback is not None: |
213 def getProgress(self, id, profile): | 411 kwargs['timeout'] = const_TIMEOUT |
214 return self.db_core_iface.getProgress(id, profile) | 412 kwargs['reply_handler'] = callback |
413 kwargs['error_handler'] = error_handler | |
414 return self.db_core_iface.getPresenceStatuses(profile_key, **kwargs) | |
415 | |
416 def getProfileName(self, profile_key="@DEFAULT@", callback=None, errback=None): | |
417 if callback is None: | |
418 error_handler = None | |
419 else: | |
420 if errback is None: | |
421 errback = log.error | |
422 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
423 kwargs={} | |
424 if callback is not None: | |
425 kwargs['timeout'] = const_TIMEOUT | |
426 kwargs['reply_handler'] = callback | |
427 kwargs['error_handler'] = error_handler | |
428 return unicode(self.db_core_iface.getProfileName(profile_key, **kwargs)) | |
429 | |
430 def getProfilesList(self, callback=None, errback=None): | |
431 if callback is None: | |
432 error_handler = None | |
433 else: | |
434 if errback is None: | |
435 errback = log.error | |
436 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
437 kwargs={} | |
438 if callback is not None: | |
439 kwargs['timeout'] = const_TIMEOUT | |
440 kwargs['reply_handler'] = callback | |
441 kwargs['error_handler'] = error_handler | |
442 return self.db_core_iface.getProfilesList(**kwargs) | |
443 | |
444 def getProgress(self, id, profile, callback=None, errback=None): | |
445 if callback is None: | |
446 error_handler = None | |
447 else: | |
448 if errback is None: | |
449 errback = log.error | |
450 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
451 kwargs={} | |
452 if callback is not None: | |
453 kwargs['timeout'] = const_TIMEOUT | |
454 kwargs['reply_handler'] = callback | |
455 kwargs['error_handler'] = error_handler | |
456 return self.db_core_iface.getProgress(id, profile, **kwargs) | |
215 | 457 |
216 def getReady(self, callback=None, errback=None): | 458 def getReady(self, callback=None, errback=None): |
217 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 459 if callback is None: |
460 error_handler = None | |
461 else: | |
462 if errback is None: | |
463 errback = log.error | |
464 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
218 return self.db_core_iface.getReady(timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 465 return self.db_core_iface.getReady(timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
219 | 466 |
220 def getVersion(self, ): | 467 def getVersion(self, callback=None, errback=None): |
221 return unicode(self.db_core_iface.getVersion()) | 468 if callback is None: |
222 | 469 error_handler = None |
223 def getWaitingConf(self, profile_key): | 470 else: |
224 return self.db_core_iface.getWaitingConf(profile_key) | 471 if errback is None: |
225 | 472 errback = log.error |
226 def getWaitingSub(self, profile_key="@DEFAULT@"): | 473 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
227 return self.db_core_iface.getWaitingSub(profile_key) | 474 kwargs={} |
228 | 475 if callback is not None: |
229 def isConnected(self, profile_key="@DEFAULT@"): | 476 kwargs['timeout'] = const_TIMEOUT |
230 return self.db_core_iface.isConnected(profile_key) | 477 kwargs['reply_handler'] = callback |
478 kwargs['error_handler'] = error_handler | |
479 return unicode(self.db_core_iface.getVersion(**kwargs)) | |
480 | |
481 def getWaitingConf(self, profile_key, callback=None, errback=None): | |
482 if callback is None: | |
483 error_handler = None | |
484 else: | |
485 if errback is None: | |
486 errback = log.error | |
487 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
488 kwargs={} | |
489 if callback is not None: | |
490 kwargs['timeout'] = const_TIMEOUT | |
491 kwargs['reply_handler'] = callback | |
492 kwargs['error_handler'] = error_handler | |
493 return self.db_core_iface.getWaitingConf(profile_key, **kwargs) | |
494 | |
495 def getWaitingSub(self, profile_key="@DEFAULT@", callback=None, errback=None): | |
496 if callback is None: | |
497 error_handler = None | |
498 else: | |
499 if errback is None: | |
500 errback = log.error | |
501 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
502 kwargs={} | |
503 if callback is not None: | |
504 kwargs['timeout'] = const_TIMEOUT | |
505 kwargs['reply_handler'] = callback | |
506 kwargs['error_handler'] = error_handler | |
507 return self.db_core_iface.getWaitingSub(profile_key, **kwargs) | |
508 | |
509 def isConnected(self, profile_key="@DEFAULT@", callback=None, errback=None): | |
510 if callback is None: | |
511 error_handler = None | |
512 else: | |
513 if errback is None: | |
514 errback = log.error | |
515 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
516 kwargs={} | |
517 if callback is not None: | |
518 kwargs['timeout'] = const_TIMEOUT | |
519 kwargs['reply_handler'] = callback | |
520 kwargs['error_handler'] = error_handler | |
521 return self.db_core_iface.isConnected(profile_key, **kwargs) | |
231 | 522 |
232 def launchAction(self, callback_id, data, profile_key="@DEFAULT@", callback=None, errback=None): | 523 def launchAction(self, callback_id, data, profile_key="@DEFAULT@", callback=None, errback=None): |
233 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 524 if callback is None: |
525 error_handler = None | |
526 else: | |
527 if errback is None: | |
528 errback = log.error | |
529 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
234 return self.db_core_iface.launchAction(callback_id, data, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 530 return self.db_core_iface.launchAction(callback_id, data, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
235 | 531 |
236 def loadParamsTemplate(self, filename): | 532 def loadParamsTemplate(self, filename, callback=None, errback=None): |
237 return self.db_core_iface.loadParamsTemplate(filename) | 533 if callback is None: |
238 | 534 error_handler = None |
239 def paramsRegisterApp(self, xml, security_limit=-1, app=''): | 535 else: |
240 return self.db_core_iface.paramsRegisterApp(xml, security_limit, app) | 536 if errback is None: |
241 | 537 errback = log.error |
242 def saveParamsTemplate(self, filename): | 538 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
243 return self.db_core_iface.saveParamsTemplate(filename) | 539 kwargs={} |
540 if callback is not None: | |
541 kwargs['timeout'] = const_TIMEOUT | |
542 kwargs['reply_handler'] = callback | |
543 kwargs['error_handler'] = error_handler | |
544 return self.db_core_iface.loadParamsTemplate(filename, **kwargs) | |
545 | |
546 def paramsRegisterApp(self, xml, security_limit=-1, app='', callback=None, errback=None): | |
547 if callback is None: | |
548 error_handler = None | |
549 else: | |
550 if errback is None: | |
551 errback = log.error | |
552 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
553 kwargs={} | |
554 if callback is not None: | |
555 kwargs['timeout'] = const_TIMEOUT | |
556 kwargs['reply_handler'] = callback | |
557 kwargs['error_handler'] = error_handler | |
558 return self.db_core_iface.paramsRegisterApp(xml, security_limit, app, **kwargs) | |
559 | |
560 def saveParamsTemplate(self, filename, callback=None, errback=None): | |
561 if callback is None: | |
562 error_handler = None | |
563 else: | |
564 if errback is None: | |
565 errback = log.error | |
566 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
567 kwargs={} | |
568 if callback is not None: | |
569 kwargs['timeout'] = const_TIMEOUT | |
570 kwargs['reply_handler'] = callback | |
571 kwargs['error_handler'] = error_handler | |
572 return self.db_core_iface.saveParamsTemplate(filename, **kwargs) | |
244 | 573 |
245 def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None): | 574 def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None): |
246 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) | 575 if callback is None: |
576 error_handler = None | |
577 else: | |
578 if errback is None: | |
579 errback = log.error | |
580 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
247 return self.db_core_iface.sendMessage(to_jid, message, subject, mess_type, extra, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 581 return self.db_core_iface.sendMessage(to_jid, message, subject, mess_type, extra, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
248 | 582 |
249 def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@"): | 583 def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None): |
250 return self.db_core_iface.setParam(name, value, category, security_limit, profile_key) | 584 if callback is None: |
251 | 585 error_handler = None |
252 def setPresence(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@"): | 586 else: |
253 return self.db_core_iface.setPresence(to_jid, show, statuses, profile_key) | 587 if errback is None: |
254 | 588 errback = log.error |
255 def subscription(self, sub_type, entity, profile_key="@DEFAULT@"): | 589 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
256 return self.db_core_iface.subscription(sub_type, entity, profile_key) | 590 kwargs={} |
257 | 591 if callback is not None: |
258 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@"): | 592 kwargs['timeout'] = const_TIMEOUT |
259 return self.db_core_iface.updateContact(entity_jid, name, groups, profile_key) | 593 kwargs['reply_handler'] = callback |
594 kwargs['error_handler'] = error_handler | |
595 return self.db_core_iface.setParam(name, value, category, security_limit, profile_key, **kwargs) | |
596 | |
597 def setPresence(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@", callback=None, errback=None): | |
598 if callback is None: | |
599 error_handler = None | |
600 else: | |
601 if errback is None: | |
602 errback = log.error | |
603 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
604 kwargs={} | |
605 if callback is not None: | |
606 kwargs['timeout'] = const_TIMEOUT | |
607 kwargs['reply_handler'] = callback | |
608 kwargs['error_handler'] = error_handler | |
609 return self.db_core_iface.setPresence(to_jid, show, statuses, profile_key, **kwargs) | |
610 | |
611 def subscription(self, sub_type, entity, profile_key="@DEFAULT@", callback=None, errback=None): | |
612 if callback is None: | |
613 error_handler = None | |
614 else: | |
615 if errback is None: | |
616 errback = log.error | |
617 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
618 kwargs={} | |
619 if callback is not None: | |
620 kwargs['timeout'] = const_TIMEOUT | |
621 kwargs['reply_handler'] = callback | |
622 kwargs['error_handler'] = error_handler | |
623 return self.db_core_iface.subscription(sub_type, entity, profile_key, **kwargs) | |
624 | |
625 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@", callback=None, errback=None): | |
626 if callback is None: | |
627 error_handler = None | |
628 else: | |
629 if errback is None: | |
630 errback = log.error | |
631 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
632 return self.db_core_iface.updateContact(entity_jid, name, groups, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |