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

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2019-10-13 12:57:29 +0300
committerPhilipp Hörist <philipp@hoerist.com>2019-10-13 12:57:29 +0300
commitaf360130ec8655f9c947fc97bee2c033d62d2798 (patch)
treecba8cb1211733d5dd09408f4daec32dbd135d390 /nbxmpp/modules
parenta15b98aec870e0e6c8fac08f102b5da182aa0470 (diff)
Add OOB (XEP-0066) support
Diffstat (limited to 'nbxmpp/modules')
-rw-r--r--nbxmpp/modules/oob.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/nbxmpp/modules/oob.py b/nbxmpp/modules/oob.py
new file mode 100644
index 0000000..c0de07f
--- /dev/null
+++ b/nbxmpp/modules/oob.py
@@ -0,0 +1,49 @@
+# Copyright (C) 2018 Philipp Hörist <philipp AT hoerist.com>
+#
+# This file is part of nbxmpp.
+#
+# This program 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; either version 3
+# of the License, or (at your option) any later version.
+#
+# This program 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 this program; If not, see <http://www.gnu.org/licenses/>.
+
+import logging
+
+from nbxmpp.protocol import NS_X_OOB
+from nbxmpp.structs import StanzaHandler
+from nbxmpp.structs import OOBData
+
+log = logging.getLogger('nbxmpp.m.oob')
+
+
+class OOB:
+ def __init__(self, client):
+ self._client = client
+ self.handlers = [
+ StanzaHandler(name='message',
+ callback=self._process_message_oob,
+ ns=NS_X_OOB,
+ priority=15),
+ ]
+
+ def _process_message_oob(self, _con, stanza, properties):
+ oob = stanza.getTag('x', namespace=NS_X_OOB)
+ if oob is None:
+ return
+
+ url = oob.getTagData('url')
+ if url is None:
+ log.warning('OOB data without url')
+ log.warning(stanza)
+ return
+
+ desc = oob.getTagData('desc')
+ properties.oob = OOBData(url, desc)