@@ -16,8 +16,8 @@ from gajim.common.connection_handlers_events import MessageNotSentEvent
|
||||
from gajim.plugins.plugins_i18n import _
|
||||
|
||||
from omemo.xmpp import (
|
||||
NS_NOTIFY, NS_OMEMO, NS_EME, NS_HINTS, BundleInformationAnnouncement,
|
||||
BundleInformationQuery, DevicelistQuery,
|
||||
NS_NOTIFY, NS_OMEMO, NS_EME, NS_HINTS, NS_BUNDLES,
|
||||
BundleInformationQuery, DevicelistQuery, make_bundle,
|
||||
OmemoMessage, successful, unpack_device_bundle,
|
||||
unpack_device_list_update, unpack_encrypted, NS_DEVICE_LIST)
|
||||
from omemo.omemo.state import OmemoState
|
||||
@@ -811,12 +811,16 @@ class OMEMOConnection:
|
||||
def publish_bundle(self):
|
||||
""" Publish our bundle information to the PEP node """
|
||||
|
||||
bundle_announce = BundleInformationAnnouncement(
|
||||
self.omemo.bundle, self.omemo.own_device_id)
|
||||
log.info('%s => Publishing bundle ...', self.account)
|
||||
self.send_with_callback(bundle_announce, self.handle_publish_result)
|
||||
bundle = make_bundle(self.omemo.bundle)
|
||||
node = '%s%s' % (NS_BUNDLES, self.omemo.own_device_id)
|
||||
|
||||
def handle_publish_result(self, stanza):
|
||||
log.info('%s => Publishing bundle ...', self.account)
|
||||
|
||||
con = app.connections[self.account]
|
||||
con.get_module('PubSub').send_pb_publish(
|
||||
'', node, bundle, 'current', cb=self.handle_publish_result)
|
||||
|
||||
def handle_publish_result(self, _con, stanza):
|
||||
""" Log if publishing our bundle was successful
|
||||
|
||||
Parameters
|
||||
|
||||
@@ -43,13 +43,6 @@ NS_HINTS = 'urn:xmpp:hints'
|
||||
log = logging.getLogger('gajim.plugin_system.omemo')
|
||||
|
||||
|
||||
class PublishNode(Node):
|
||||
def __init__(self, node_str, data):
|
||||
assert node_str is not None and isinstance(data, Node)
|
||||
Node.__init__(self, tag='publish', attrs={'node': node_str})
|
||||
self.addChild('item').addChild(node=data)
|
||||
|
||||
|
||||
class PubsubNode(Node):
|
||||
def __init__(self, data):
|
||||
assert isinstance(data, Node)
|
||||
@@ -88,17 +81,25 @@ class BundleInformationQuery(Iq):
|
||||
self.addChild(node=pubsub)
|
||||
|
||||
|
||||
class BundleInformationAnnouncement(Iq):
|
||||
def __init__(self, state_bundle, device_id):
|
||||
class DevicelistQuery(Iq):
|
||||
def __init__(self, contact_jid):
|
||||
id_ = app.get_an_id()
|
||||
attrs = {'id': id_}
|
||||
Iq.__init__(self, typ='set', attrs=attrs)
|
||||
bundle_node = self.make_bundle_node(state_bundle)
|
||||
publish = PublishNode(NS_BUNDLES + str(device_id), bundle_node)
|
||||
pubsub = PubsubNode(publish)
|
||||
Iq.__init__(self, typ='get', attrs=attrs, to=contact_jid)
|
||||
items = Node('items', attrs={'node': NS_DEVICE_LIST, 'max_items': 1})
|
||||
pubsub = PubsubNode(items)
|
||||
self.addChild(node=pubsub)
|
||||
|
||||
def make_bundle_node(self, state_bundle):
|
||||
|
||||
class DevicelistPEP(AbstractPEP):
|
||||
type_ = 'omemo-devicelist'
|
||||
namespace = NS_DEVICE_LIST
|
||||
|
||||
def _extract_info(self, items):
|
||||
return ({}, [])
|
||||
|
||||
|
||||
def make_bundle(state_bundle):
|
||||
result = Node('bundle', attrs={'xmlns': NS_OMEMO})
|
||||
prekey_pub_node = result.addChild(
|
||||
'signedPreKeyPublic',
|
||||
@@ -121,24 +122,6 @@ class BundleInformationAnnouncement(Iq):
|
||||
return result
|
||||
|
||||
|
||||
class DevicelistQuery(Iq):
|
||||
def __init__(self, contact_jid):
|
||||
id_ = app.get_an_id()
|
||||
attrs = {'id': id_}
|
||||
Iq.__init__(self, typ='get', attrs=attrs, to=contact_jid)
|
||||
items = Node('items', attrs={'node': NS_DEVICE_LIST, 'max_items': 1})
|
||||
pubsub = PubsubNode(items)
|
||||
self.addChild(node=pubsub)
|
||||
|
||||
|
||||
class DevicelistPEP(AbstractPEP):
|
||||
type_ = 'omemo-devicelist'
|
||||
namespace = NS_DEVICE_LIST
|
||||
|
||||
def _extract_info(self, items):
|
||||
return ({}, [])
|
||||
|
||||
|
||||
@log_calls('OmemoPlugin')
|
||||
def unpack_device_bundle(bundle, device_id):
|
||||
pubsub = bundle.getTag('pubsub', namespace=NS_PUBSUB)
|
||||
|
||||
Reference in New Issue
Block a user