comparison sat_frontends/bridge/dbus_bridge.py @ 2658:4e130cc9bfc0

core (memore/encryption): new methods and checks: Following methods are now available though bridge: - messageEncryptionStop - messageEncryptionGet: retrieve encryption data for a message session - encryptionPluginsGet: retrieve all registered encryption plugin Following methods are available for internal use: - getPlugins: retrieve registerd plugins - getNSFromName: retrieve namespace from plugin name - getBridgeData: serialise session data (to be used with bridge) - markAsEncrypted: mark message data as encrypted (to be set by encryption plugin in MessageReceived trigger) Behaviours improvments: - start and stop send messageEncryptionStarted and messageEncryptionStopped signals, and a message feedback - new "replace" arguments in start allows to replace a plugin if one is already running (instead of raising a ConflictError) - plugins declare themselves as "directed" (i.e. working with only one device at a time) or not. This is checked while dealing with jids, an exception is raised when a full jid is received for a non directed encryption. - use of new data_format (de)serialise
author Goffi <goffi@goffi.org>
date Sat, 11 Aug 2018 18:24:55 +0200
parents 712cb4ff3e13
children e347e32aa07f
comparison
equal deleted inserted replaced
2657:9190874a8ac5 2658:4e130cc9bfc0
243 if errback is None: 243 if errback is None:
244 errback = log.error 244 errback = log.error
245 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) 245 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
246 return self.db_core_iface.disconnect(profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) 246 return self.db_core_iface.disconnect(profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
247 247
248 def encryptionPluginsGet(self, callback=None, errback=None):
249 if callback is None:
250 error_handler = None
251 else:
252 if errback is None:
253 errback = log.error
254 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
255 kwargs={}
256 if callback is not None:
257 kwargs['timeout'] = const_TIMEOUT
258 kwargs['reply_handler'] = callback
259 kwargs['error_handler'] = error_handler
260 return self.db_core_iface.encryptionPluginsGet(**kwargs)
261
248 def getConfig(self, section, name, callback=None, errback=None): 262 def getConfig(self, section, name, callback=None, errback=None):
249 if callback is None: 263 if callback is None:
250 error_handler = None 264 error_handler = None
251 else: 265 else:
252 if errback is None: 266 if errback is None:
502 kwargs['timeout'] = const_TIMEOUT 516 kwargs['timeout'] = const_TIMEOUT
503 kwargs['reply_handler'] = callback 517 kwargs['reply_handler'] = callback
504 kwargs['error_handler'] = error_handler 518 kwargs['error_handler'] = error_handler
505 return self.db_core_iface.menusGet(language, security_limit, **kwargs) 519 return self.db_core_iface.menusGet(language, security_limit, **kwargs)
506 520
507 def messageEncryptionStart(self, to_jid, encryption_ns='', profile_key="@NONE@", callback=None, errback=None): 521 def messageEncryptionGet(self, to_jid, profile_key, callback=None, errback=None):
508 if callback is None: 522 if callback is None:
509 error_handler = None 523 error_handler = None
510 else: 524 else:
511 if errback is None: 525 if errback is None:
512 errback = log.error 526 errback = log.error
513 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) 527 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
514 kwargs={} 528 kwargs={}
515 if callback is not None: 529 if callback is not None:
516 kwargs['timeout'] = const_TIMEOUT 530 kwargs['timeout'] = const_TIMEOUT
517 kwargs['reply_handler'] = callback 531 kwargs['reply_handler'] = callback
518 kwargs['error_handler'] = error_handler 532 kwargs['error_handler'] = error_handler
519 return self.db_core_iface.messageEncryptionStart(to_jid, encryption_ns, profile_key, **kwargs) 533 return unicode(self.db_core_iface.messageEncryptionGet(to_jid, profile_key, **kwargs))
534
535 def messageEncryptionStart(self, to_jid, encryption_ns='', replace=False, profile_key="@NONE@", callback=None, errback=None):
536 if callback is None:
537 error_handler = None
538 else:
539 if errback is None:
540 errback = log.error
541 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
542 kwargs={}
543 if callback is not None:
544 kwargs['timeout'] = const_TIMEOUT
545 kwargs['reply_handler'] = callback
546 kwargs['error_handler'] = error_handler
547 return self.db_core_iface.messageEncryptionStart(to_jid, encryption_ns, replace, profile_key, **kwargs)
548
549 def messageEncryptionStop(self, to_jid, profile_key, callback=None, errback=None):
550 if callback is None:
551 error_handler = None
552 else:
553 if errback is None:
554 errback = log.error
555 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
556 kwargs={}
557 if callback is not None:
558 kwargs['timeout'] = const_TIMEOUT
559 kwargs['reply_handler'] = callback
560 kwargs['error_handler'] = error_handler
561 return self.db_core_iface.messageEncryptionStop(to_jid, profile_key, **kwargs)
520 562
521 def messageSend(self, to_jid, message, subject={}, mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None): 563 def messageSend(self, to_jid, message, subject={}, mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None):
522 if callback is None: 564 if callback is None:
523 error_handler = None 565 error_handler = None
524 else: 566 else: