[omemo] Use nbxmpp.namespaces

This commit is contained in:
lovetox
2020-04-19 22:12:13 +02:00
parent 7097f86834
commit fcaa83e3d2
3 changed files with 20 additions and 19 deletions

View File

@@ -20,6 +20,7 @@ import os
import time import time
import nbxmpp import nbxmpp
from nbxmpp.namespaces import Namespace
from nbxmpp.protocol import NodeProcessed from nbxmpp.protocol import NodeProcessed
from nbxmpp.protocol import JID from nbxmpp.protocol import JID
from nbxmpp.util import is_error_result from nbxmpp.util import is_error_result
@@ -50,19 +51,19 @@ from omemo.modules.util import prepare_stanza
ALLOWED_TAGS = [ ALLOWED_TAGS = [
('request', nbxmpp.NS_RECEIPTS), ('request', Namespace.RECEIPTS),
('active', nbxmpp.NS_CHATSTATES), ('active', Namespace.CHATSTATES),
('gone', nbxmpp.NS_CHATSTATES), ('gone', Namespace.CHATSTATES),
('inactive', nbxmpp.NS_CHATSTATES), ('inactive', Namespace.CHATSTATES),
('paused', nbxmpp.NS_CHATSTATES), ('paused', Namespace.CHATSTATES),
('composing', nbxmpp.NS_CHATSTATES), ('composing', Namespace.CHATSTATES),
('no-store', nbxmpp.NS_MSG_HINTS), ('no-store', Namespace.HINTS),
('store', nbxmpp.NS_MSG_HINTS), ('store', Namespace.HINTS),
('no-copy', nbxmpp.NS_MSG_HINTS), ('no-copy', Namespace.HINTS),
('no-permanent-store', nbxmpp.NS_MSG_HINTS), ('no-permanent-store', Namespace.HINTS),
('replace', nbxmpp.NS_CORRECT), ('replace', Namespace.CORRECT),
('thread', None), ('thread', None),
('origin-id', nbxmpp.NS_SID), ('origin-id', Namespace.SID),
] ]
ENCRYPTION_NAME = 'OMEMO' ENCRYPTION_NAME = 'OMEMO'
@@ -88,11 +89,11 @@ class OMEMO(BaseModule):
self.handlers = [ self.handlers = [
StanzaHandler(name='message', StanzaHandler(name='message',
callback=self._message_received, callback=self._message_received,
ns=nbxmpp.NS_OMEMO_TEMP, ns=Namespace.OMEMO_TEMP,
priority=9), priority=9),
StanzaHandler(name='presence', StanzaHandler(name='presence',
callback=self._on_muc_user_presence, callback=self._on_muc_user_presence,
ns=nbxmpp.NS_MUC_USER, ns=Namespace.MUC_USER,
priority=48), priority=48),
] ]
@@ -470,7 +471,7 @@ class OMEMO(BaseModule):
self._process_devicelist_update(jid, devicelist) self._process_devicelist_update(jid, devicelist)
@event_node(nbxmpp.NS_OMEMO_TEMP_DL) @event_node(Namespace.OMEMO_TEMP_DL)
def _devicelist_notification_received(self, _con, _stanza, properties): def _devicelist_notification_received(self, _con, _stanza, properties):
if properties.pubsub_event.retracted: if properties.pubsub_event.retracted:
return return

View File

@@ -15,11 +15,11 @@
# along with OMEMO Gajim Plugin. If not, see <http://www.gnu.org/licenses/>. # along with OMEMO Gajim Plugin. If not, see <http://www.gnu.org/licenses/>.
import nbxmpp from nbxmpp.namespaces import Namespace
def prepare_stanza(stanza, plaintext): def prepare_stanza(stanza, plaintext):
delete_nodes(stanza, 'encrypted', nbxmpp.NS_OMEMO_TEMP) delete_nodes(stanza, 'encrypted', Namespace.OMEMO_TEMP)
delete_nodes(stanza, 'body') delete_nodes(stanza, 'body')
stanza.setBody(plaintext) stanza.setBody(plaintext)

View File

@@ -26,7 +26,7 @@ from gi.repository import GLib
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import Gdk from gi.repository import Gdk
import nbxmpp from nbxmpp.namespaces import Namespace
from gajim import dialogs from gajim import dialogs
from gajim.common import app, ged from gajim.common import app, ged
@@ -193,7 +193,7 @@ class OmemoPlugin(GajimPlugin):
def _update_caps(self, account, features): def _update_caps(self, account, features):
if not self._is_enabled_account(account): if not self._is_enabled_account(account):
return return
features.append('%s+notify' % nbxmpp.NS_OMEMO_TEMP_DL) features.append('%s+notify' % Namespace.OMEMO_TEMP_DL)
@staticmethod @staticmethod
def activate_encryption(chat_control): def activate_encryption(chat_control):