comparison sat_frontends/bridge/pb.py @ 3243:f2e30aa031e9

bridge (pb): fixed conversions of Failure to BridgeException in non-AIO bridge
author Goffi <goffi@goffi.org>
date Wed, 01 Apr 2020 15:40:29 +0200
parents ae09989e9feb
children 6cf4bd6972c2
comparison
equal deleted inserted replaced
3242:6d0137022df2 3243:f2e30aa031e9
62 def __getattr__(self, name): 62 def __getattr__(self, name):
63 return partial(self.call, name) 63 return partial(self.call, name)
64 64
65 def _generic_errback(self, err): 65 def _generic_errback(self, err):
66 log.error(f"bridge error: {err}") 66 log.error(f"bridge error: {err}")
67
68 def _errback(self, failure_, ori_errback):
69 """Convert Failure to BridgeException"""
70 ori_errback(
71 BridgeException(
72 name=failure_.type.decode('utf-8'),
73 message=str(failure_.value)
74 )
75 )
67 76
68 def remoteCallback(self, result, callback): 77 def remoteCallback(self, result, callback):
69 """call callback with argument or None 78 """call callback with argument or None
70 79
71 if result is not None not argument is used, 80 if result is not None not argument is used,
146 def actionsGet(self, profile_key="@DEFAULT@", callback=None, errback=None): 155 def actionsGet(self, profile_key="@DEFAULT@", callback=None, errback=None):
147 d = self.root.callRemote("actionsGet", profile_key) 156 d = self.root.callRemote("actionsGet", profile_key)
148 if callback is not None: 157 if callback is not None:
149 d.addCallback(callback) 158 d.addCallback(callback)
150 if errback is None: 159 if errback is None:
151 errback = self._generic_errback 160 d.addErrback(self._generic_errback)
152 d.addErrback(errback) 161 else:
162 d.addErrback(self._errback, ori_errback=errback)
153 163
154 def addContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None): 164 def addContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None):
155 d = self.root.callRemote("addContact", entity_jid, profile_key) 165 d = self.root.callRemote("addContact", entity_jid, profile_key)
156 if callback is not None: 166 if callback is not None:
157 d.addCallback(lambda __: callback()) 167 d.addCallback(lambda __: callback())
158 if errback is None: 168 if errback is None:
159 errback = self._generic_errback 169 d.addErrback(self._generic_errback)
160 d.addErrback(errback) 170 else:
171 d.addErrback(self._errback, ori_errback=errback)
161 172
162 def asyncDeleteProfile(self, profile, callback=None, errback=None): 173 def asyncDeleteProfile(self, profile, callback=None, errback=None):
163 d = self.root.callRemote("asyncDeleteProfile", profile) 174 d = self.root.callRemote("asyncDeleteProfile", profile)
164 if callback is not None: 175 if callback is not None:
165 d.addCallback(lambda __: callback()) 176 d.addCallback(lambda __: callback())
166 if errback is None: 177 if errback is None:
167 errback = self._generic_errback 178 d.addErrback(self._generic_errback)
168 d.addErrback(errback) 179 else:
180 d.addErrback(self._errback, ori_errback=errback)
169 181
170 def asyncGetParamA(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None): 182 def asyncGetParamA(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None):
171 d = self.root.callRemote("asyncGetParamA", name, category, attribute, security_limit, profile_key) 183 d = self.root.callRemote("asyncGetParamA", name, category, attribute, security_limit, profile_key)
172 if callback is not None: 184 if callback is not None:
173 d.addCallback(callback) 185 d.addCallback(callback)
174 if errback is None: 186 if errback is None:
175 errback = self._generic_errback 187 d.addErrback(self._generic_errback)
176 d.addErrback(errback) 188 else:
189 d.addErrback(self._errback, ori_errback=errback)
177 190
178 def asyncGetParamsValuesFromCategory(self, category, security_limit=-1, app="", extra="", profile_key="@DEFAULT@", callback=None, errback=None): 191 def asyncGetParamsValuesFromCategory(self, category, security_limit=-1, app="", extra="", profile_key="@DEFAULT@", callback=None, errback=None):
179 d = self.root.callRemote("asyncGetParamsValuesFromCategory", category, security_limit, app, extra, profile_key) 192 d = self.root.callRemote("asyncGetParamsValuesFromCategory", category, security_limit, app, extra, profile_key)
180 if callback is not None: 193 if callback is not None:
181 d.addCallback(callback) 194 d.addCallback(callback)
182 if errback is None: 195 if errback is None:
183 errback = self._generic_errback 196 d.addErrback(self._generic_errback)
184 d.addErrback(errback) 197 else:
198 d.addErrback(self._errback, ori_errback=errback)
185 199
186 def connect(self, profile_key="@DEFAULT@", password='', options={}, callback=None, errback=None): 200 def connect(self, profile_key="@DEFAULT@", password='', options={}, callback=None, errback=None):
187 d = self.root.callRemote("connect", profile_key, password, options) 201 d = self.root.callRemote("connect", profile_key, password, options)
188 if callback is not None: 202 if callback is not None:
189 d.addCallback(callback) 203 d.addCallback(callback)
190 if errback is None: 204 if errback is None:
191 errback = self._generic_errback 205 d.addErrback(self._generic_errback)
192 d.addErrback(errback) 206 else:
207 d.addErrback(self._errback, ori_errback=errback)
193 208
194 def delContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None): 209 def delContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None):
195 d = self.root.callRemote("delContact", entity_jid, profile_key) 210 d = self.root.callRemote("delContact", entity_jid, profile_key)
196 if callback is not None: 211 if callback is not None:
197 d.addCallback(lambda __: callback()) 212 d.addCallback(lambda __: callback())
198 if errback is None: 213 if errback is None:
199 errback = self._generic_errback 214 d.addErrback(self._generic_errback)
200 d.addErrback(errback) 215 else:
216 d.addErrback(self._errback, ori_errback=errback)
201 217
202 def devicesInfosGet(self, bare_jid, profile_key, callback=None, errback=None): 218 def devicesInfosGet(self, bare_jid, profile_key, callback=None, errback=None):
203 d = self.root.callRemote("devicesInfosGet", bare_jid, profile_key) 219 d = self.root.callRemote("devicesInfosGet", bare_jid, profile_key)
204 if callback is not None: 220 if callback is not None:
205 d.addCallback(callback) 221 d.addCallback(callback)
206 if errback is None: 222 if errback is None:
207 errback = self._generic_errback 223 d.addErrback(self._generic_errback)
208 d.addErrback(errback) 224 else:
225 d.addErrback(self._errback, ori_errback=errback)
209 226
210 def discoFindByFeatures(self, namespaces, identities, bare_jid=False, service=True, roster=True, own_jid=True, local_device=False, profile_key="@DEFAULT@", callback=None, errback=None): 227 def discoFindByFeatures(self, namespaces, identities, bare_jid=False, service=True, roster=True, own_jid=True, local_device=False, profile_key="@DEFAULT@", callback=None, errback=None):
211 d = self.root.callRemote("discoFindByFeatures", namespaces, identities, bare_jid, service, roster, own_jid, local_device, profile_key) 228 d = self.root.callRemote("discoFindByFeatures", namespaces, identities, bare_jid, service, roster, own_jid, local_device, profile_key)
212 if callback is not None: 229 if callback is not None:
213 d.addCallback(callback) 230 d.addCallback(callback)
214 if errback is None: 231 if errback is None:
215 errback = self._generic_errback 232 d.addErrback(self._generic_errback)
216 d.addErrback(errback) 233 else:
234 d.addErrback(self._errback, ori_errback=errback)
217 235
218 def discoInfos(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@", callback=None, errback=None): 236 def discoInfos(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@", callback=None, errback=None):
219 d = self.root.callRemote("discoInfos", entity_jid, node, use_cache, profile_key) 237 d = self.root.callRemote("discoInfos", entity_jid, node, use_cache, profile_key)
220 if callback is not None: 238 if callback is not None:
221 d.addCallback(callback) 239 d.addCallback(callback)
222 if errback is None: 240 if errback is None:
223 errback = self._generic_errback 241 d.addErrback(self._generic_errback)
224 d.addErrback(errback) 242 else:
243 d.addErrback(self._errback, ori_errback=errback)
225 244
226 def discoItems(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@", callback=None, errback=None): 245 def discoItems(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@", callback=None, errback=None):
227 d = self.root.callRemote("discoItems", entity_jid, node, use_cache, profile_key) 246 d = self.root.callRemote("discoItems", entity_jid, node, use_cache, profile_key)
228 if callback is not None: 247 if callback is not None:
229 d.addCallback(callback) 248 d.addCallback(callback)
230 if errback is None: 249 if errback is None:
231 errback = self._generic_errback 250 d.addErrback(self._generic_errback)
232 d.addErrback(errback) 251 else:
252 d.addErrback(self._errback, ori_errback=errback)
233 253
234 def disconnect(self, profile_key="@DEFAULT@", callback=None, errback=None): 254 def disconnect(self, profile_key="@DEFAULT@", callback=None, errback=None):
235 d = self.root.callRemote("disconnect", profile_key) 255 d = self.root.callRemote("disconnect", profile_key)
236 if callback is not None: 256 if callback is not None:
237 d.addCallback(lambda __: callback()) 257 d.addCallback(lambda __: callback())
238 if errback is None: 258 if errback is None:
239 errback = self._generic_errback 259 d.addErrback(self._generic_errback)
240 d.addErrback(errback) 260 else:
261 d.addErrback(self._errback, ori_errback=errback)
241 262
242 def encryptionNamespaceGet(self, arg_0, callback=None, errback=None): 263 def encryptionNamespaceGet(self, arg_0, callback=None, errback=None):
243 d = self.root.callRemote("encryptionNamespaceGet", arg_0) 264 d = self.root.callRemote("encryptionNamespaceGet", arg_0)
244 if callback is not None: 265 if callback is not None:
245 d.addCallback(callback) 266 d.addCallback(callback)
246 if errback is None: 267 if errback is None:
247 errback = self._generic_errback 268 d.addErrback(self._generic_errback)
248 d.addErrback(errback) 269 else:
270 d.addErrback(self._errback, ori_errback=errback)
249 271
250 def encryptionPluginsGet(self, callback=None, errback=None): 272 def encryptionPluginsGet(self, callback=None, errback=None):
251 d = self.root.callRemote("encryptionPluginsGet") 273 d = self.root.callRemote("encryptionPluginsGet")
252 if callback is not None: 274 if callback is not None:
253 d.addCallback(callback) 275 d.addCallback(callback)
254 if errback is None: 276 if errback is None:
255 errback = self._generic_errback 277 d.addErrback(self._generic_errback)
256 d.addErrback(errback) 278 else:
279 d.addErrback(self._errback, ori_errback=errback)
257 280
258 def encryptionTrustUIGet(self, to_jid, namespace, profile_key, callback=None, errback=None): 281 def encryptionTrustUIGet(self, to_jid, namespace, profile_key, callback=None, errback=None):
259 d = self.root.callRemote("encryptionTrustUIGet", to_jid, namespace, profile_key) 282 d = self.root.callRemote("encryptionTrustUIGet", to_jid, namespace, profile_key)
260 if callback is not None: 283 if callback is not None:
261 d.addCallback(callback) 284 d.addCallback(callback)
262 if errback is None: 285 if errback is None:
263 errback = self._generic_errback 286 d.addErrback(self._generic_errback)
264 d.addErrback(errback) 287 else:
288 d.addErrback(self._errback, ori_errback=errback)
265 289
266 def getConfig(self, section, name, callback=None, errback=None): 290 def getConfig(self, section, name, callback=None, errback=None):
267 d = self.root.callRemote("getConfig", section, name) 291 d = self.root.callRemote("getConfig", section, name)
268 if callback is not None: 292 if callback is not None:
269 d.addCallback(callback) 293 d.addCallback(callback)
270 if errback is None: 294 if errback is None:
271 errback = self._generic_errback 295 d.addErrback(self._generic_errback)
272 d.addErrback(errback) 296 else:
297 d.addErrback(self._errback, ori_errback=errback)
273 298
274 def getContacts(self, profile_key="@DEFAULT@", callback=None, errback=None): 299 def getContacts(self, profile_key="@DEFAULT@", callback=None, errback=None):
275 d = self.root.callRemote("getContacts", profile_key) 300 d = self.root.callRemote("getContacts", profile_key)
276 if callback is not None: 301 if callback is not None:
277 d.addCallback(callback) 302 d.addCallback(callback)
278 if errback is None: 303 if errback is None:
279 errback = self._generic_errback 304 d.addErrback(self._generic_errback)
280 d.addErrback(errback) 305 else:
306 d.addErrback(self._errback, ori_errback=errback)
281 307
282 def getContactsFromGroup(self, group, profile_key="@DEFAULT@", callback=None, errback=None): 308 def getContactsFromGroup(self, group, profile_key="@DEFAULT@", callback=None, errback=None):
283 d = self.root.callRemote("getContactsFromGroup", group, profile_key) 309 d = self.root.callRemote("getContactsFromGroup", group, profile_key)
284 if callback is not None: 310 if callback is not None:
285 d.addCallback(callback) 311 d.addCallback(callback)
286 if errback is None: 312 if errback is None:
287 errback = self._generic_errback 313 d.addErrback(self._generic_errback)
288 d.addErrback(errback) 314 else:
315 d.addErrback(self._errback, ori_errback=errback)
289 316
290 def getEntitiesData(self, jids, keys, profile, callback=None, errback=None): 317 def getEntitiesData(self, jids, keys, profile, callback=None, errback=None):
291 d = self.root.callRemote("getEntitiesData", jids, keys, profile) 318 d = self.root.callRemote("getEntitiesData", jids, keys, profile)
292 if callback is not None: 319 if callback is not None:
293 d.addCallback(callback) 320 d.addCallback(callback)
294 if errback is None: 321 if errback is None:
295 errback = self._generic_errback 322 d.addErrback(self._generic_errback)
296 d.addErrback(errback) 323 else:
324 d.addErrback(self._errback, ori_errback=errback)
297 325
298 def getEntityData(self, jid, keys, profile, callback=None, errback=None): 326 def getEntityData(self, jid, keys, profile, callback=None, errback=None):
299 d = self.root.callRemote("getEntityData", jid, keys, profile) 327 d = self.root.callRemote("getEntityData", jid, keys, profile)
300 if callback is not None: 328 if callback is not None:
301 d.addCallback(callback) 329 d.addCallback(callback)
302 if errback is None: 330 if errback is None:
303 errback = self._generic_errback 331 d.addErrback(self._generic_errback)
304 d.addErrback(errback) 332 else:
333 d.addErrback(self._errback, ori_errback=errback)
305 334
306 def getFeatures(self, profile_key, callback=None, errback=None): 335 def getFeatures(self, profile_key, callback=None, errback=None):
307 d = self.root.callRemote("getFeatures", profile_key) 336 d = self.root.callRemote("getFeatures", profile_key)
308 if callback is not None: 337 if callback is not None:
309 d.addCallback(callback) 338 d.addCallback(callback)
310 if errback is None: 339 if errback is None:
311 errback = self._generic_errback 340 d.addErrback(self._generic_errback)
312 d.addErrback(errback) 341 else:
342 d.addErrback(self._errback, ori_errback=errback)
313 343
314 def getMainResource(self, contact_jid, profile_key="@DEFAULT@", callback=None, errback=None): 344 def getMainResource(self, contact_jid, profile_key="@DEFAULT@", callback=None, errback=None):
315 d = self.root.callRemote("getMainResource", contact_jid, profile_key) 345 d = self.root.callRemote("getMainResource", contact_jid, profile_key)
316 if callback is not None: 346 if callback is not None:
317 d.addCallback(callback) 347 d.addCallback(callback)
318 if errback is None: 348 if errback is None:
319 errback = self._generic_errback 349 d.addErrback(self._generic_errback)
320 d.addErrback(errback) 350 else:
351 d.addErrback(self._errback, ori_errback=errback)
321 352
322 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@", callback=None, errback=None): 353 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@", callback=None, errback=None):
323 d = self.root.callRemote("getParamA", name, category, attribute, profile_key) 354 d = self.root.callRemote("getParamA", name, category, attribute, profile_key)
324 if callback is not None: 355 if callback is not None:
325 d.addCallback(callback) 356 d.addCallback(callback)
326 if errback is None: 357 if errback is None:
327 errback = self._generic_errback 358 d.addErrback(self._generic_errback)
328 d.addErrback(errback) 359 else:
360 d.addErrback(self._errback, ori_errback=errback)
329 361
330 def getParamsCategories(self, callback=None, errback=None): 362 def getParamsCategories(self, callback=None, errback=None):
331 d = self.root.callRemote("getParamsCategories") 363 d = self.root.callRemote("getParamsCategories")
332 if callback is not None: 364 if callback is not None:
333 d.addCallback(callback) 365 d.addCallback(callback)
334 if errback is None: 366 if errback is None:
335 errback = self._generic_errback 367 d.addErrback(self._generic_errback)
336 d.addErrback(errback) 368 else:
369 d.addErrback(self._errback, ori_errback=errback)
337 370
338 def getParamsUI(self, security_limit=-1, app='', extra='', profile_key="@DEFAULT@", callback=None, errback=None): 371 def getParamsUI(self, security_limit=-1, app='', extra='', profile_key="@DEFAULT@", callback=None, errback=None):
339 d = self.root.callRemote("getParamsUI", security_limit, app, extra, profile_key) 372 d = self.root.callRemote("getParamsUI", security_limit, app, extra, profile_key)
340 if callback is not None: 373 if callback is not None:
341 d.addCallback(callback) 374 d.addCallback(callback)
342 if errback is None: 375 if errback is None:
343 errback = self._generic_errback 376 d.addErrback(self._generic_errback)
344 d.addErrback(errback) 377 else:
378 d.addErrback(self._errback, ori_errback=errback)
345 379
346 def getPresenceStatuses(self, profile_key="@DEFAULT@", callback=None, errback=None): 380 def getPresenceStatuses(self, profile_key="@DEFAULT@", callback=None, errback=None):
347 d = self.root.callRemote("getPresenceStatuses", profile_key) 381 d = self.root.callRemote("getPresenceStatuses", profile_key)
348 if callback is not None: 382 if callback is not None:
349 d.addCallback(callback) 383 d.addCallback(callback)
350 if errback is None: 384 if errback is None:
351 errback = self._generic_errback 385 d.addErrback(self._generic_errback)
352 d.addErrback(errback) 386 else:
387 d.addErrback(self._errback, ori_errback=errback)
353 388
354 def getReady(self, callback=None, errback=None): 389 def getReady(self, callback=None, errback=None):
355 d = self.root.callRemote("getReady") 390 d = self.root.callRemote("getReady")
356 if callback is not None: 391 if callback is not None:
357 d.addCallback(lambda __: callback()) 392 d.addCallback(lambda __: callback())
358 if errback is None: 393 if errback is None:
359 errback = self._generic_errback 394 d.addErrback(self._generic_errback)
360 d.addErrback(errback) 395 else:
396 d.addErrback(self._errback, ori_errback=errback)
361 397
362 def getVersion(self, callback=None, errback=None): 398 def getVersion(self, callback=None, errback=None):
363 d = self.root.callRemote("getVersion") 399 d = self.root.callRemote("getVersion")
364 if callback is not None: 400 if callback is not None:
365 d.addCallback(callback) 401 d.addCallback(callback)
366 if errback is None: 402 if errback is None:
367 errback = self._generic_errback 403 d.addErrback(self._generic_errback)
368 d.addErrback(errback) 404 else:
405 d.addErrback(self._errback, ori_errback=errback)
369 406
370 def getWaitingSub(self, profile_key="@DEFAULT@", callback=None, errback=None): 407 def getWaitingSub(self, profile_key="@DEFAULT@", callback=None, errback=None):
371 d = self.root.callRemote("getWaitingSub", profile_key) 408 d = self.root.callRemote("getWaitingSub", profile_key)
372 if callback is not None: 409 if callback is not None:
373 d.addCallback(callback) 410 d.addCallback(callback)
374 if errback is None: 411 if errback is None:
375 errback = self._generic_errback 412 d.addErrback(self._generic_errback)
376 d.addErrback(errback) 413 else:
414 d.addErrback(self._errback, ori_errback=errback)
377 415
378 def historyGet(self, from_jid, to_jid, limit, between=True, filters='', profile="@NONE@", callback=None, errback=None): 416 def historyGet(self, from_jid, to_jid, limit, between=True, filters='', profile="@NONE@", callback=None, errback=None):
379 d = self.root.callRemote("historyGet", from_jid, to_jid, limit, between, filters, profile) 417 d = self.root.callRemote("historyGet", from_jid, to_jid, limit, between, filters, profile)
380 if callback is not None: 418 if callback is not None:
381 d.addCallback(callback) 419 d.addCallback(callback)
382 if errback is None: 420 if errback is None:
383 errback = self._generic_errback 421 d.addErrback(self._generic_errback)
384 d.addErrback(errback) 422 else:
423 d.addErrback(self._errback, ori_errback=errback)
385 424
386 def imageCheck(self, arg_0, callback=None, errback=None): 425 def imageCheck(self, arg_0, callback=None, errback=None):
387 d = self.root.callRemote("imageCheck", arg_0) 426 d = self.root.callRemote("imageCheck", arg_0)
388 if callback is not None: 427 if callback is not None:
389 d.addCallback(callback) 428 d.addCallback(callback)
390 if errback is None: 429 if errback is None:
391 errback = self._generic_errback 430 d.addErrback(self._generic_errback)
392 d.addErrback(errback) 431 else:
432 d.addErrback(self._errback, ori_errback=errback)
393 433
394 def imageGeneratePreview(self, image_path, profile_key, callback=None, errback=None): 434 def imageGeneratePreview(self, image_path, profile_key, callback=None, errback=None):
395 d = self.root.callRemote("imageGeneratePreview", image_path, profile_key) 435 d = self.root.callRemote("imageGeneratePreview", image_path, profile_key)
396 if callback is not None: 436 if callback is not None:
397 d.addCallback(callback) 437 d.addCallback(callback)
398 if errback is None: 438 if errback is None:
399 errback = self._generic_errback 439 d.addErrback(self._generic_errback)
400 d.addErrback(errback) 440 else:
441 d.addErrback(self._errback, ori_errback=errback)
401 442
402 def imageResize(self, image_path, width, height, callback=None, errback=None): 443 def imageResize(self, image_path, width, height, callback=None, errback=None):
403 d = self.root.callRemote("imageResize", image_path, width, height) 444 d = self.root.callRemote("imageResize", image_path, width, height)
404 if callback is not None: 445 if callback is not None:
405 d.addCallback(callback) 446 d.addCallback(callback)
406 if errback is None: 447 if errback is None:
407 errback = self._generic_errback 448 d.addErrback(self._generic_errback)
408 d.addErrback(errback) 449 else:
450 d.addErrback(self._errback, ori_errback=errback)
409 451
410 def isConnected(self, profile_key="@DEFAULT@", callback=None, errback=None): 452 def isConnected(self, profile_key="@DEFAULT@", callback=None, errback=None):
411 d = self.root.callRemote("isConnected", profile_key) 453 d = self.root.callRemote("isConnected", profile_key)
412 if callback is not None: 454 if callback is not None:
413 d.addCallback(callback) 455 d.addCallback(callback)
414 if errback is None: 456 if errback is None:
415 errback = self._generic_errback 457 d.addErrback(self._generic_errback)
416 d.addErrback(errback) 458 else:
459 d.addErrback(self._errback, ori_errback=errback)
417 460
418 def launchAction(self, callback_id, data, profile_key="@DEFAULT@", callback=None, errback=None): 461 def launchAction(self, callback_id, data, profile_key="@DEFAULT@", callback=None, errback=None):
419 d = self.root.callRemote("launchAction", callback_id, data, profile_key) 462 d = self.root.callRemote("launchAction", callback_id, data, profile_key)
420 if callback is not None: 463 if callback is not None:
421 d.addCallback(callback) 464 d.addCallback(callback)
422 if errback is None: 465 if errback is None:
423 errback = self._generic_errback 466 d.addErrback(self._generic_errback)
424 d.addErrback(errback) 467 else:
468 d.addErrback(self._errback, ori_errback=errback)
425 469
426 def loadParamsTemplate(self, filename, callback=None, errback=None): 470 def loadParamsTemplate(self, filename, callback=None, errback=None):
427 d = self.root.callRemote("loadParamsTemplate", filename) 471 d = self.root.callRemote("loadParamsTemplate", filename)
428 if callback is not None: 472 if callback is not None:
429 d.addCallback(callback) 473 d.addCallback(callback)
430 if errback is None: 474 if errback is None:
431 errback = self._generic_errback 475 d.addErrback(self._generic_errback)
432 d.addErrback(errback) 476 else:
477 d.addErrback(self._errback, ori_errback=errback)
433 478
434 def menuHelpGet(self, menu_id, language, callback=None, errback=None): 479 def menuHelpGet(self, menu_id, language, callback=None, errback=None):
435 d = self.root.callRemote("menuHelpGet", menu_id, language) 480 d = self.root.callRemote("menuHelpGet", menu_id, language)
436 if callback is not None: 481 if callback is not None:
437 d.addCallback(callback) 482 d.addCallback(callback)
438 if errback is None: 483 if errback is None:
439 errback = self._generic_errback 484 d.addErrback(self._generic_errback)
440 d.addErrback(errback) 485 else:
486 d.addErrback(self._errback, ori_errback=errback)
441 487
442 def menuLaunch(self, menu_type, path, data, security_limit, profile_key, callback=None, errback=None): 488 def menuLaunch(self, menu_type, path, data, security_limit, profile_key, callback=None, errback=None):
443 d = self.root.callRemote("menuLaunch", menu_type, path, data, security_limit, profile_key) 489 d = self.root.callRemote("menuLaunch", menu_type, path, data, security_limit, profile_key)
444 if callback is not None: 490 if callback is not None:
445 d.addCallback(callback) 491 d.addCallback(callback)
446 if errback is None: 492 if errback is None:
447 errback = self._generic_errback 493 d.addErrback(self._generic_errback)
448 d.addErrback(errback) 494 else:
495 d.addErrback(self._errback, ori_errback=errback)
449 496
450 def menusGet(self, language, security_limit, callback=None, errback=None): 497 def menusGet(self, language, security_limit, callback=None, errback=None):
451 d = self.root.callRemote("menusGet", language, security_limit) 498 d = self.root.callRemote("menusGet", language, security_limit)
452 if callback is not None: 499 if callback is not None:
453 d.addCallback(callback) 500 d.addCallback(callback)
454 if errback is None: 501 if errback is None:
455 errback = self._generic_errback 502 d.addErrback(self._generic_errback)
456 d.addErrback(errback) 503 else:
504 d.addErrback(self._errback, ori_errback=errback)
457 505
458 def messageEncryptionGet(self, to_jid, profile_key, callback=None, errback=None): 506 def messageEncryptionGet(self, to_jid, profile_key, callback=None, errback=None):
459 d = self.root.callRemote("messageEncryptionGet", to_jid, profile_key) 507 d = self.root.callRemote("messageEncryptionGet", to_jid, profile_key)
460 if callback is not None: 508 if callback is not None:
461 d.addCallback(callback) 509 d.addCallback(callback)
462 if errback is None: 510 if errback is None:
463 errback = self._generic_errback 511 d.addErrback(self._generic_errback)
464 d.addErrback(errback) 512 else:
513 d.addErrback(self._errback, ori_errback=errback)
465 514
466 def messageEncryptionStart(self, to_jid, namespace='', replace=False, profile_key="@NONE@", callback=None, errback=None): 515 def messageEncryptionStart(self, to_jid, namespace='', replace=False, profile_key="@NONE@", callback=None, errback=None):
467 d = self.root.callRemote("messageEncryptionStart", to_jid, namespace, replace, profile_key) 516 d = self.root.callRemote("messageEncryptionStart", to_jid, namespace, replace, profile_key)
468 if callback is not None: 517 if callback is not None:
469 d.addCallback(lambda __: callback()) 518 d.addCallback(lambda __: callback())
470 if errback is None: 519 if errback is None:
471 errback = self._generic_errback 520 d.addErrback(self._generic_errback)
472 d.addErrback(errback) 521 else:
522 d.addErrback(self._errback, ori_errback=errback)
473 523
474 def messageEncryptionStop(self, to_jid, profile_key, callback=None, errback=None): 524 def messageEncryptionStop(self, to_jid, profile_key, callback=None, errback=None):
475 d = self.root.callRemote("messageEncryptionStop", to_jid, profile_key) 525 d = self.root.callRemote("messageEncryptionStop", to_jid, profile_key)
476 if callback is not None: 526 if callback is not None:
477 d.addCallback(lambda __: callback()) 527 d.addCallback(lambda __: callback())
478 if errback is None: 528 if errback is None:
479 errback = self._generic_errback 529 d.addErrback(self._generic_errback)
480 d.addErrback(errback) 530 else:
531 d.addErrback(self._errback, ori_errback=errback)
481 532
482 def messageSend(self, to_jid, message, subject={}, mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None): 533 def messageSend(self, to_jid, message, subject={}, mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None):
483 d = self.root.callRemote("messageSend", to_jid, message, subject, mess_type, extra, profile_key) 534 d = self.root.callRemote("messageSend", to_jid, message, subject, mess_type, extra, profile_key)
484 if callback is not None: 535 if callback is not None:
485 d.addCallback(lambda __: callback()) 536 d.addCallback(lambda __: callback())
486 if errback is None: 537 if errback is None:
487 errback = self._generic_errback 538 d.addErrback(self._generic_errback)
488 d.addErrback(errback) 539 else:
540 d.addErrback(self._errback, ori_errback=errback)
489 541
490 def namespacesGet(self, callback=None, errback=None): 542 def namespacesGet(self, callback=None, errback=None):
491 d = self.root.callRemote("namespacesGet") 543 d = self.root.callRemote("namespacesGet")
492 if callback is not None: 544 if callback is not None:
493 d.addCallback(callback) 545 d.addCallback(callback)
494 if errback is None: 546 if errback is None:
495 errback = self._generic_errback 547 d.addErrback(self._generic_errback)
496 d.addErrback(errback) 548 else:
549 d.addErrback(self._errback, ori_errback=errback)
497 550
498 def paramsRegisterApp(self, xml, security_limit=-1, app='', callback=None, errback=None): 551 def paramsRegisterApp(self, xml, security_limit=-1, app='', callback=None, errback=None):
499 d = self.root.callRemote("paramsRegisterApp", xml, security_limit, app) 552 d = self.root.callRemote("paramsRegisterApp", xml, security_limit, app)
500 if callback is not None: 553 if callback is not None:
501 d.addCallback(lambda __: callback()) 554 d.addCallback(lambda __: callback())
502 if errback is None: 555 if errback is None:
503 errback = self._generic_errback 556 d.addErrback(self._generic_errback)
504 d.addErrback(errback) 557 else:
558 d.addErrback(self._errback, ori_errback=errback)
505 559
506 def privateDataDelete(self, namespace, key, arg_2, callback=None, errback=None): 560 def privateDataDelete(self, namespace, key, arg_2, callback=None, errback=None):
507 d = self.root.callRemote("privateDataDelete", namespace, key, arg_2) 561 d = self.root.callRemote("privateDataDelete", namespace, key, arg_2)
508 if callback is not None: 562 if callback is not None:
509 d.addCallback(lambda __: callback()) 563 d.addCallback(lambda __: callback())
510 if errback is None: 564 if errback is None:
511 errback = self._generic_errback 565 d.addErrback(self._generic_errback)
512 d.addErrback(errback) 566 else:
567 d.addErrback(self._errback, ori_errback=errback)
513 568
514 def privateDataGet(self, namespace, key, profile_key, callback=None, errback=None): 569 def privateDataGet(self, namespace, key, profile_key, callback=None, errback=None):
515 d = self.root.callRemote("privateDataGet", namespace, key, profile_key) 570 d = self.root.callRemote("privateDataGet", namespace, key, profile_key)
516 if callback is not None: 571 if callback is not None:
517 d.addCallback(callback) 572 d.addCallback(callback)
518 if errback is None: 573 if errback is None:
519 errback = self._generic_errback 574 d.addErrback(self._generic_errback)
520 d.addErrback(errback) 575 else:
576 d.addErrback(self._errback, ori_errback=errback)
521 577
522 def privateDataSet(self, namespace, key, data, profile_key, callback=None, errback=None): 578 def privateDataSet(self, namespace, key, data, profile_key, callback=None, errback=None):
523 d = self.root.callRemote("privateDataSet", namespace, key, data, profile_key) 579 d = self.root.callRemote("privateDataSet", namespace, key, data, profile_key)
524 if callback is not None: 580 if callback is not None:
525 d.addCallback(lambda __: callback()) 581 d.addCallback(lambda __: callback())
526 if errback is None: 582 if errback is None:
527 errback = self._generic_errback 583 d.addErrback(self._generic_errback)
528 d.addErrback(errback) 584 else:
585 d.addErrback(self._errback, ori_errback=errback)
529 586
530 def profileCreate(self, profile, password='', component='', callback=None, errback=None): 587 def profileCreate(self, profile, password='', component='', callback=None, errback=None):
531 d = self.root.callRemote("profileCreate", profile, password, component) 588 d = self.root.callRemote("profileCreate", profile, password, component)
532 if callback is not None: 589 if callback is not None:
533 d.addCallback(lambda __: callback()) 590 d.addCallback(lambda __: callback())
534 if errback is None: 591 if errback is None:
535 errback = self._generic_errback 592 d.addErrback(self._generic_errback)
536 d.addErrback(errback) 593 else:
594 d.addErrback(self._errback, ori_errback=errback)
537 595
538 def profileIsSessionStarted(self, profile_key="@DEFAULT@", callback=None, errback=None): 596 def profileIsSessionStarted(self, profile_key="@DEFAULT@", callback=None, errback=None):
539 d = self.root.callRemote("profileIsSessionStarted", profile_key) 597 d = self.root.callRemote("profileIsSessionStarted", profile_key)
540 if callback is not None: 598 if callback is not None:
541 d.addCallback(callback) 599 d.addCallback(callback)
542 if errback is None: 600 if errback is None:
543 errback = self._generic_errback 601 d.addErrback(self._generic_errback)
544 d.addErrback(errback) 602 else:
603 d.addErrback(self._errback, ori_errback=errback)
545 604
546 def profileNameGet(self, profile_key="@DEFAULT@", callback=None, errback=None): 605 def profileNameGet(self, profile_key="@DEFAULT@", callback=None, errback=None):
547 d = self.root.callRemote("profileNameGet", profile_key) 606 d = self.root.callRemote("profileNameGet", profile_key)
548 if callback is not None: 607 if callback is not None:
549 d.addCallback(callback) 608 d.addCallback(callback)
550 if errback is None: 609 if errback is None:
551 errback = self._generic_errback 610 d.addErrback(self._generic_errback)
552 d.addErrback(errback) 611 else:
612 d.addErrback(self._errback, ori_errback=errback)
553 613
554 def profileSetDefault(self, profile, callback=None, errback=None): 614 def profileSetDefault(self, profile, callback=None, errback=None):
555 d = self.root.callRemote("profileSetDefault", profile) 615 d = self.root.callRemote("profileSetDefault", profile)
556 if callback is not None: 616 if callback is not None:
557 d.addCallback(lambda __: callback()) 617 d.addCallback(lambda __: callback())
558 if errback is None: 618 if errback is None:
559 errback = self._generic_errback 619 d.addErrback(self._generic_errback)
560 d.addErrback(errback) 620 else:
621 d.addErrback(self._errback, ori_errback=errback)
561 622
562 def profileStartSession(self, password='', profile_key="@DEFAULT@", callback=None, errback=None): 623 def profileStartSession(self, password='', profile_key="@DEFAULT@", callback=None, errback=None):
563 d = self.root.callRemote("profileStartSession", password, profile_key) 624 d = self.root.callRemote("profileStartSession", password, profile_key)
564 if callback is not None: 625 if callback is not None:
565 d.addCallback(callback) 626 d.addCallback(callback)
566 if errback is None: 627 if errback is None:
567 errback = self._generic_errback 628 d.addErrback(self._generic_errback)
568 d.addErrback(errback) 629 else:
630 d.addErrback(self._errback, ori_errback=errback)
569 631
570 def profilesListGet(self, clients=True, components=False, callback=None, errback=None): 632 def profilesListGet(self, clients=True, components=False, callback=None, errback=None):
571 d = self.root.callRemote("profilesListGet", clients, components) 633 d = self.root.callRemote("profilesListGet", clients, components)
572 if callback is not None: 634 if callback is not None:
573 d.addCallback(callback) 635 d.addCallback(callback)
574 if errback is None: 636 if errback is None:
575 errback = self._generic_errback 637 d.addErrback(self._generic_errback)
576 d.addErrback(errback) 638 else:
639 d.addErrback(self._errback, ori_errback=errback)
577 640
578 def progressGet(self, id, profile, callback=None, errback=None): 641 def progressGet(self, id, profile, callback=None, errback=None):
579 d = self.root.callRemote("progressGet", id, profile) 642 d = self.root.callRemote("progressGet", id, profile)
580 if callback is not None: 643 if callback is not None:
581 d.addCallback(callback) 644 d.addCallback(callback)
582 if errback is None: 645 if errback is None:
583 errback = self._generic_errback 646 d.addErrback(self._generic_errback)
584 d.addErrback(errback) 647 else:
648 d.addErrback(self._errback, ori_errback=errback)
585 649
586 def progressGetAll(self, profile, callback=None, errback=None): 650 def progressGetAll(self, profile, callback=None, errback=None):
587 d = self.root.callRemote("progressGetAll", profile) 651 d = self.root.callRemote("progressGetAll", profile)
588 if callback is not None: 652 if callback is not None:
589 d.addCallback(callback) 653 d.addCallback(callback)
590 if errback is None: 654 if errback is None:
591 errback = self._generic_errback 655 d.addErrback(self._generic_errback)
592 d.addErrback(errback) 656 else:
657 d.addErrback(self._errback, ori_errback=errback)
593 658
594 def progressGetAllMetadata(self, profile, callback=None, errback=None): 659 def progressGetAllMetadata(self, profile, callback=None, errback=None):
595 d = self.root.callRemote("progressGetAllMetadata", profile) 660 d = self.root.callRemote("progressGetAllMetadata", profile)
596 if callback is not None: 661 if callback is not None:
597 d.addCallback(callback) 662 d.addCallback(callback)
598 if errback is None: 663 if errback is None:
599 errback = self._generic_errback 664 d.addErrback(self._generic_errback)
600 d.addErrback(errback) 665 else:
666 d.addErrback(self._errback, ori_errback=errback)
601 667
602 def rosterResync(self, profile_key="@DEFAULT@", callback=None, errback=None): 668 def rosterResync(self, profile_key="@DEFAULT@", callback=None, errback=None):
603 d = self.root.callRemote("rosterResync", profile_key) 669 d = self.root.callRemote("rosterResync", profile_key)
604 if callback is not None: 670 if callback is not None:
605 d.addCallback(lambda __: callback()) 671 d.addCallback(lambda __: callback())
606 if errback is None: 672 if errback is None:
607 errback = self._generic_errback 673 d.addErrback(self._generic_errback)
608 d.addErrback(errback) 674 else:
675 d.addErrback(self._errback, ori_errback=errback)
609 676
610 def saveParamsTemplate(self, filename, callback=None, errback=None): 677 def saveParamsTemplate(self, filename, callback=None, errback=None):
611 d = self.root.callRemote("saveParamsTemplate", filename) 678 d = self.root.callRemote("saveParamsTemplate", filename)
612 if callback is not None: 679 if callback is not None:
613 d.addCallback(callback) 680 d.addCallback(callback)
614 if errback is None: 681 if errback is None:
615 errback = self._generic_errback 682 d.addErrback(self._generic_errback)
616 d.addErrback(errback) 683 else:
684 d.addErrback(self._errback, ori_errback=errback)
617 685
618 def sessionInfosGet(self, profile_key, callback=None, errback=None): 686 def sessionInfosGet(self, profile_key, callback=None, errback=None):
619 d = self.root.callRemote("sessionInfosGet", profile_key) 687 d = self.root.callRemote("sessionInfosGet", profile_key)
620 if callback is not None: 688 if callback is not None:
621 d.addCallback(callback) 689 d.addCallback(callback)
622 if errback is None: 690 if errback is None:
623 errback = self._generic_errback 691 d.addErrback(self._generic_errback)
624 d.addErrback(errback) 692 else:
693 d.addErrback(self._errback, ori_errback=errback)
625 694
626 def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None): 695 def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None):
627 d = self.root.callRemote("setParam", name, value, category, security_limit, profile_key) 696 d = self.root.callRemote("setParam", name, value, category, security_limit, profile_key)
628 if callback is not None: 697 if callback is not None:
629 d.addCallback(lambda __: callback()) 698 d.addCallback(lambda __: callback())
630 if errback is None: 699 if errback is None:
631 errback = self._generic_errback 700 d.addErrback(self._generic_errback)
632 d.addErrback(errback) 701 else:
702 d.addErrback(self._errback, ori_errback=errback)
633 703
634 def setPresence(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@", callback=None, errback=None): 704 def setPresence(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@", callback=None, errback=None):
635 d = self.root.callRemote("setPresence", to_jid, show, statuses, profile_key) 705 d = self.root.callRemote("setPresence", to_jid, show, statuses, profile_key)
636 if callback is not None: 706 if callback is not None:
637 d.addCallback(lambda __: callback()) 707 d.addCallback(lambda __: callback())
638 if errback is None: 708 if errback is None:
639 errback = self._generic_errback 709 d.addErrback(self._generic_errback)
640 d.addErrback(errback) 710 else:
711 d.addErrback(self._errback, ori_errback=errback)
641 712
642 def subscription(self, sub_type, entity, profile_key="@DEFAULT@", callback=None, errback=None): 713 def subscription(self, sub_type, entity, profile_key="@DEFAULT@", callback=None, errback=None):
643 d = self.root.callRemote("subscription", sub_type, entity, profile_key) 714 d = self.root.callRemote("subscription", sub_type, entity, profile_key)
644 if callback is not None: 715 if callback is not None:
645 d.addCallback(lambda __: callback()) 716 d.addCallback(lambda __: callback())
646 if errback is None: 717 if errback is None:
647 errback = self._generic_errback 718 d.addErrback(self._generic_errback)
648 d.addErrback(errback) 719 else:
720 d.addErrback(self._errback, ori_errback=errback)
649 721
650 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@", callback=None, errback=None): 722 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@", callback=None, errback=None):
651 d = self.root.callRemote("updateContact", entity_jid, name, groups, profile_key) 723 d = self.root.callRemote("updateContact", entity_jid, name, groups, profile_key)
652 if callback is not None: 724 if callback is not None:
653 d.addCallback(lambda __: callback()) 725 d.addCallback(lambda __: callback())
654 if errback is None: 726 if errback is None:
655 errback = self._generic_errback 727 d.addErrback(self._generic_errback)
656 d.addErrback(errback) 728 else:
729 d.addErrback(self._errback, ori_errback=errback)
657 730
658 731
659 class AIOSignalsHandler(SignalsHandler): 732 class AIOSignalsHandler(SignalsHandler):
660 733
661 def register_signal(self, name, handler, iface="core"): 734 def register_signal(self, name, handler, iface="core"):
668 741
669 def __init__(self): 742 def __init__(self):
670 self.signals_handler = AIOSignalsHandler() 743 self.signals_handler = AIOSignalsHandler()
671 744
672 def _errback(self, failure_): 745 def _errback(self, failure_):
746 """Convert Failure to BridgeException"""
673 raise BridgeException( 747 raise BridgeException(
674 name=failure_.type.decode('utf-8'), 748 name=failure_.type.decode('utf-8'),
675 message=str(failure_.value) 749 message=str(failure_.value)
676 ) 750 )
677 751