Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2018-12-31 12:47:59 +0300
committerPhilipp Hörist <philipp@hoerist.com>2018-12-31 12:55:13 +0300
commit567841fdff9c3ea6cbe8d609d41052e35099aa13 (patch)
tree625062aaa59e1e8d024a0df7646a1aaa96378427 /omemo/modules/util.py
parent0bde0fbe4770cc80af52a2c9977ee92c17c77411 (diff)
[omemo] Add PEP devicelist module
Diffstat (limited to 'omemo/modules/util.py')
-rw-r--r--omemo/modules/util.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/omemo/modules/util.py b/omemo/modules/util.py
new file mode 100644
index 0000000..084aeb0
--- /dev/null
+++ b/omemo/modules/util.py
@@ -0,0 +1,46 @@
+# Copyright (C) 2018 Philipp Hörist <philipp AT hoerist.com>
+#
+# This file is part of OMEMO.
+#
+# OMEMO is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published
+# by the Free Software Foundation; version 3 only.
+#
+# OMEMO is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OMEMO. If not, see <http://www.gnu.org/licenses/>.
+
+# XEP-0384: OMEMO Encryption
+
+import logging
+
+import nbxmpp
+
+from gajim.common.exceptions import StanzaMalformed
+
+
+log = logging.getLogger('gajim.plugin_system.omemo')
+
+NS_OMEMO = 'eu.siacs.conversations.axolotl'
+NS_DEVICE_LIST = NS_OMEMO + '.devicelist'
+
+
+def unpack_devicelist(item):
+ list_ = item.getTag('list', namespace=NS_OMEMO)
+ if list_ is None:
+ raise StanzaMalformed('No list node')
+
+ device_list = list_.getTags('device')
+
+ devices = []
+ for device in device_list:
+ id_ = device.getAttr('id')
+ if id_ is None:
+ raise StanzaMalformed('No id for device found')
+
+ devices.append(int(id_))
+ return devices