comparison frontends/src/bridge/DBus.py @ 1290:faa1129559b8 frontends_multi_profiles

core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit): /!\ not finished, everything is still instable ! - bridge: DBus bridge has been modified to allow blocking call to be called in the same way as asynchronous calls - bridge: calls with a callback and no errback are now possible, default errback log the error - constants: removed hack to manage presence without OrderedDict, as an OrderedDict like class has been implemented in Libervia - core: getLastResource has been removed and replaced by getMainResource (there is a global better management of resources) - various style improvments: use of constants when possible, fixed variable overlaps, import of module instead of direct class import - frontends: printInfo and printMessage methods in (Quick)Chat are more generic (use of extra instead of timestamp) - frontends: bridge creation and option parsing (command line arguments) are now specified by the frontend in QuickApp __init__ - frontends: ProfileManager manage a more complete plug sequence (some stuff formerly manage in contact_list have moved to ProfileManager) - quick_frontend (quick_widgets): QuickWidgetsManager is now iterable (all widgets are then returned), or can return an iterator on a specific class (return all widgets of this class) with getWidgets - frontends: tools.jid can now be used in Pyjamas, with some care - frontends (XMLUI): profile is now managed - core (memory): big improvment on entities cache management (and specially resource management) - core (params/exceptions): added PermissionError - various fixes and improvments, check diff for more details
author Goffi <goffi@goffi.org>
date Sat, 24 Jan 2015 01:00:29 +0100
parents e3a9ea76de35
children bb9c32249778
comparison
equal deleted inserted replaced
1289:653f2e2eea31 1290:faa1129559b8
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:
178 error_handler = None
179 else:
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)
146 189
147 def delContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None): 190 def delContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None):
148 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) 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))
149 return self.db_core_iface.delContact(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) 197 return self.db_core_iface.delContact(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
150 198
151 def discoInfos(self, entity_jid, profile_key, callback=None, errback=None): 199 def discoInfos(self, entity_jid, profile_key, callback=None, errback=None):
152 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))
153 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)
154 207
155 def discoItems(self, entity_jid, profile_key, callback=None, errback=None): 208 def discoItems(self, entity_jid, profile_key, callback=None, errback=None):
156 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))
157 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)
158 216
159 def disconnect(self, profile_key="@DEFAULT@"): 217 def disconnect(self, profile_key="@DEFAULT@", callback=None, errback=None):
160 return self.db_core_iface.disconnect(profile_key) 218 if callback is None:
161 219 error_handler = None
162 def getConfig(self, section, name): 220 else:
163 return unicode(self.db_core_iface.getConfig(section, name)) 221 if errback is None:
222 errback = log.error
223 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
224 kwargs={}
225 if callback is not None:
226 kwargs['timeout'] = const_TIMEOUT
227 kwargs['reply_handler'] = callback
228 kwargs['error_handler'] = error_handler
229 return self.db_core_iface.disconnect(profile_key, **kwargs)
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))
164 244
165 def getContacts(self, profile_key="@DEFAULT@", callback=None, errback=None): 245 def getContacts(self, profile_key="@DEFAULT@", callback=None, errback=None):
166 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) 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))
167 return self.db_core_iface.getContacts(profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) 252 return self.db_core_iface.getContacts(profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
168 253
169 def getContactsFromGroup(self, group, profile_key="@DEFAULT@"): 254 def getContactsFromGroup(self, group, profile_key="@DEFAULT@", callback=None, errback=None):
170 return self.db_core_iface.getContactsFromGroup(group, profile_key) 255 if callback is None:
171 256 error_handler = None
172 def getEntityData(self, jid, keys, profile): 257 else:
173 return self.db_core_iface.getEntityData(jid, keys, profile) 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 getEntityData(self, jid, 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.getEntityData(jid, keys, profile, **kwargs)
174 281
175 def getHistory(self, from_jid, to_jid, limit, between=True, search='', profile="@NONE@", callback=None, errback=None): 282 def getHistory(self, from_jid, to_jid, limit, between=True, search='', profile="@NONE@", callback=None, errback=None):
176 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) 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))
177 return self.db_core_iface.getHistory(from_jid, to_jid, limit, between, search, profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) 289 return self.db_core_iface.getHistory(from_jid, to_jid, limit, between, search, profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
178 290
179 def getLastResource(self, contact_jid, profile_key="@DEFAULT@"): 291 def getMainResource(self, contact_jid, profile_key="@DEFAULT@", callback=None, errback=None):
180 return unicode(self.db_core_iface.getLastResource(contact_jid, profile_key)) 292 if callback is None:
181 293 error_handler = None
182 def getMenuHelp(self, menu_id, language): 294 else:
183 return unicode(self.db_core_iface.getMenuHelp(menu_id, language)) 295 if errback is None:
184 296 errback = log.error
185 def getMenus(self, language, security_limit): 297 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
186 return self.db_core_iface.getMenus(language, security_limit) 298 kwargs={}
187 299 if callback is not None:
188 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"): 300 kwargs['timeout'] = const_TIMEOUT
189 return unicode(self.db_core_iface.getParamA(name, category, attribute, profile_key)) 301 kwargs['reply_handler'] = callback
302 kwargs['error_handler'] = error_handler
303 return unicode(self.db_core_iface.getMainResource(contact_jid, profile_key, **kwargs))
304
305 def getMenuHelp(self, menu_id, language, callback=None, errback=None):
306 if callback is None:
307 error_handler = None
308 else:
309 if errback is None:
310 errback = log.error
311 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
312 kwargs={}
313 if callback is not None:
314 kwargs['timeout'] = const_TIMEOUT
315 kwargs['reply_handler'] = callback
316 kwargs['error_handler'] = error_handler
317 return unicode(self.db_core_iface.getMenuHelp(menu_id, language, **kwargs))
318
319 def getMenus(self, language, security_limit, 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 self.db_core_iface.getMenus(language, security_limit, **kwargs)
332
333 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@", 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 unicode(self.db_core_iface.getParamA(name, category, attribute, profile_key, **kwargs))
190 346
191 def getParams(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): 347 def getParams(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None):
192 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) 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))
193 return unicode(self.db_core_iface.getParams(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) 354 return unicode(self.db_core_iface.getParams(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
194 355
195 def getParamsCategories(self, ): 356 def getParamsCategories(self, callback=None, errback=None):
196 return self.db_core_iface.getParamsCategories() 357 if callback is None:
358 error_handler = None
359 else:
360 if errback is None:
361 errback = log.error
362 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
363 kwargs={}
364 if callback is not None:
365 kwargs['timeout'] = const_TIMEOUT
366 kwargs['reply_handler'] = callback
367 kwargs['error_handler'] = error_handler
368 return self.db_core_iface.getParamsCategories(**kwargs)
197 369
198 def getParamsForCategory(self, category, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): 370 def getParamsForCategory(self, category, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None):
199 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) 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))
200 return unicode(self.db_core_iface.getParamsForCategory(category, security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) 377 return unicode(self.db_core_iface.getParamsForCategory(category, security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
201 378
202 def getParamsUI(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): 379 def getParamsUI(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None):
203 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) 380 if callback is None:
381 error_handler = None
382 else:
383 if errback is None:
384 errback = log.error
385 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
204 return unicode(self.db_core_iface.getParamsUI(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) 386 return unicode(self.db_core_iface.getParamsUI(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
205 387
206 def getPresenceStatuses(self, profile_key="@DEFAULT@"): 388 def getPresenceStatuses(self, profile_key="@DEFAULT@", callback=None, errback=None):
207 return self.db_core_iface.getPresenceStatuses(profile_key) 389 if callback is None:
208 390 error_handler = None
209 def getProfileName(self, profile_key="@DEFAULT@"): 391 else:
210 return unicode(self.db_core_iface.getProfileName(profile_key)) 392 if errback is None:
211 393 errback = log.error
212 def getProfilesList(self, ): 394 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
213 return self.db_core_iface.getProfilesList() 395 kwargs={}
214 396 if callback is not None:
215 def getProgress(self, id, profile): 397 kwargs['timeout'] = const_TIMEOUT
216 return self.db_core_iface.getProgress(id, profile) 398 kwargs['reply_handler'] = callback
399 kwargs['error_handler'] = error_handler
400 return self.db_core_iface.getPresenceStatuses(profile_key, **kwargs)
401
402 def getProfileName(self, profile_key="@DEFAULT@", callback=None, errback=None):
403 if callback is None:
404 error_handler = None
405 else:
406 if errback is None:
407 errback = log.error
408 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
409 kwargs={}
410 if callback is not None:
411 kwargs['timeout'] = const_TIMEOUT
412 kwargs['reply_handler'] = callback
413 kwargs['error_handler'] = error_handler
414 return unicode(self.db_core_iface.getProfileName(profile_key, **kwargs))
415
416 def getProfilesList(self, 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 self.db_core_iface.getProfilesList(**kwargs)
429
430 def getProgress(self, id, profile, 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.getProgress(id, profile, **kwargs)
217 443
218 def getReady(self, callback=None, errback=None): 444 def getReady(self, callback=None, errback=None):
219 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) 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))
220 return self.db_core_iface.getReady(timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) 451 return self.db_core_iface.getReady(timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
221 452
222 def getVersion(self, ): 453 def getVersion(self, callback=None, errback=None):
223 return unicode(self.db_core_iface.getVersion()) 454 if callback is None:
224 455 error_handler = None
225 def getWaitingConf(self, profile_key): 456 else:
226 return self.db_core_iface.getWaitingConf(profile_key) 457 if errback is None:
227 458 errback = log.error
228 def getWaitingSub(self, profile_key="@DEFAULT@"): 459 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
229 return self.db_core_iface.getWaitingSub(profile_key) 460 kwargs={}
230 461 if callback is not None:
231 def isConnected(self, profile_key="@DEFAULT@"): 462 kwargs['timeout'] = const_TIMEOUT
232 return self.db_core_iface.isConnected(profile_key) 463 kwargs['reply_handler'] = callback
464 kwargs['error_handler'] = error_handler
465 return unicode(self.db_core_iface.getVersion(**kwargs))
466
467 def getWaitingConf(self, profile_key, callback=None, errback=None):
468 if callback is None:
469 error_handler = None
470 else:
471 if errback is None:
472 errback = log.error
473 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
474 kwargs={}
475 if callback is not None:
476 kwargs['timeout'] = const_TIMEOUT
477 kwargs['reply_handler'] = callback
478 kwargs['error_handler'] = error_handler
479 return self.db_core_iface.getWaitingConf(profile_key, **kwargs)
480
481 def getWaitingSub(self, profile_key="@DEFAULT@", 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.getWaitingSub(profile_key, **kwargs)
494
495 def isConnected(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.isConnected(profile_key, **kwargs)
233 508
234 def launchAction(self, callback_id, data, profile_key="@DEFAULT@", callback=None, errback=None): 509 def launchAction(self, callback_id, data, profile_key="@DEFAULT@", callback=None, errback=None):
235 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) 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))
236 return self.db_core_iface.launchAction(callback_id, data, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) 516 return self.db_core_iface.launchAction(callback_id, data, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
237 517
238 def loadParamsTemplate(self, filename): 518 def loadParamsTemplate(self, filename, callback=None, errback=None):
239 return self.db_core_iface.loadParamsTemplate(filename) 519 if callback is None:
240 520 error_handler = None
241 def paramsRegisterApp(self, xml, security_limit=-1, app=''): 521 else:
242 return self.db_core_iface.paramsRegisterApp(xml, security_limit, app) 522 if errback is None:
243 523 errback = log.error
244 def saveParamsTemplate(self, filename): 524 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
245 return self.db_core_iface.saveParamsTemplate(filename) 525 kwargs={}
526 if callback is not None:
527 kwargs['timeout'] = const_TIMEOUT
528 kwargs['reply_handler'] = callback
529 kwargs['error_handler'] = error_handler
530 return self.db_core_iface.loadParamsTemplate(filename, **kwargs)
531
532 def paramsRegisterApp(self, xml, security_limit=-1, app='', callback=None, errback=None):
533 if callback is None:
534 error_handler = None
535 else:
536 if errback is None:
537 errback = log.error
538 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
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.paramsRegisterApp(xml, security_limit, app, **kwargs)
545
546 def saveParamsTemplate(self, filename, 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.saveParamsTemplate(filename, **kwargs)
246 559
247 def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None): 560 def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None):
248 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) 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))
249 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) 567 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)
250 568
251 def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@"): 569 def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None):
252 return self.db_core_iface.setParam(name, value, category, security_limit, profile_key) 570 if callback is None:
253 571 error_handler = None
254 def setPresence(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@"): 572 else:
255 return self.db_core_iface.setPresence(to_jid, show, statuses, profile_key) 573 if errback is None:
256 574 errback = log.error
257 def subscription(self, sub_type, entity, profile_key="@DEFAULT@"): 575 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
258 return self.db_core_iface.subscription(sub_type, entity, profile_key) 576 kwargs={}
577 if callback is not None:
578 kwargs['timeout'] = const_TIMEOUT
579 kwargs['reply_handler'] = callback
580 kwargs['error_handler'] = error_handler
581 return self.db_core_iface.setParam(name, value, category, security_limit, profile_key, **kwargs)
582
583 def setPresence(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@", callback=None, errback=None):
584 if callback is None:
585 error_handler = None
586 else:
587 if errback is None:
588 errback = log.error
589 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
590 kwargs={}
591 if callback is not None:
592 kwargs['timeout'] = const_TIMEOUT
593 kwargs['reply_handler'] = callback
594 kwargs['error_handler'] = error_handler
595 return self.db_core_iface.setPresence(to_jid, show, statuses, profile_key, **kwargs)
596
597 def subscription(self, sub_type, entity, 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.subscription(sub_type, entity, profile_key, **kwargs)
259 610
260 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@", callback=None, errback=None): 611 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@", callback=None, errback=None):
261 error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err)) 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))
262 return self.db_core_iface.updateContact(entity_jid, name, groups, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) 618 return self.db_core_iface.updateContact(entity_jid, name, groups, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)