summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-11-30 21:24:20 +0100
committermathieui <mathieui@mathieui.net>2020-12-02 19:17:33 +0100
commit350f85a8d193698dc8b9795fec1af4862f6d85be (patch)
tree8182d50fcda9596473a5270ab92eabd7cc4dc492
parentb62ea49de39f40a34fbde796a5b88419c133363c (diff)
downloadslixmpp-350f85a8d193698dc8b9795fec1af4862f6d85be.tar.gz
slixmpp-350f85a8d193698dc8b9795fec1af4862f6d85be.tar.bz2
slixmpp-350f85a8d193698dc8b9795fec1af4862f6d85be.tar.xz
slixmpp-350f85a8d193698dc8b9795fec1af4862f6d85be.zip
XEP-0403: MIX-Presence
-rw-r--r--slixmpp/plugins/__init__.py1
-rw-r--r--slixmpp/plugins/xep_0403/__init__.py13
-rw-r--r--slixmpp/plugins/xep_0403/mix_presence.py47
-rw-r--r--slixmpp/plugins/xep_0403/stanza.py37
4 files changed, 98 insertions, 0 deletions
diff --git a/slixmpp/plugins/__init__.py b/slixmpp/plugins/__init__.py
index df1e3150..91f062a3 100644
--- a/slixmpp/plugins/__init__.py
+++ b/slixmpp/plugins/__init__.py
@@ -87,6 +87,7 @@ __all__ = [
'xep_0332', # HTTP Over XMPP Transport
'xep_0369', # MIX-CORE
'xep_0377', # Spam reporting
+ 'xep_0403', # MIX-Presence
'xep_0404', # MIX-Anon
'xep_0405', # MIX-PAM
'xep_0421', # Anonymous unique occupant identifiers for MUCs
diff --git a/slixmpp/plugins/xep_0403/__init__.py b/slixmpp/plugins/xep_0403/__init__.py
new file mode 100644
index 00000000..0526276e
--- /dev/null
+++ b/slixmpp/plugins/xep_0403/__init__.py
@@ -0,0 +1,13 @@
+"""
+ Slixmpp: The Slick XMPP Library
+ Copyright (C) 2020 Mathieu Pasquet <mathieui@mathieui.net>
+ This file is part of Slixmpp.
+
+ See the file LICENSE for copying permission.
+"""
+
+from slixmpp.plugins.base import register_plugin
+from slixmpp.plugins.xep_0403.stanza import *
+from slixmpp.plugins.xep_0403.mix_presence import XEP_0403
+
+register_plugin(XEP_0403)
diff --git a/slixmpp/plugins/xep_0403/mix_presence.py b/slixmpp/plugins/xep_0403/mix_presence.py
new file mode 100644
index 00000000..995439b9
--- /dev/null
+++ b/slixmpp/plugins/xep_0403/mix_presence.py
@@ -0,0 +1,47 @@
+"""
+ Slixmpp: The Slick XMPP Library
+ Copyright (C) 2020 Mathieu Pasquet <mathieui@mathieui.net>
+ This file is part of Slixmpp.
+
+ See the file LICENSE for copying permission.
+"""
+from typing import (
+ Optional,
+ Set,
+)
+
+from slixmpp import JID, Iq
+from slixmpp.exceptions import IqError, IqTimeout
+from slixmpp.plugins import BasePlugin
+from slixmpp.plugins.xep_0403 import stanza
+from slixmpp.xmlstream.matcher import MatchXPath
+from slixmpp.xmlstream.handler import Callback
+
+
+NODES = [
+ 'urn:xmpp:mix:nodes:presence'
+]
+
+
+class XEP_0403(BasePlugin):
+ '''XEP-0403: MIX-Presence'''
+
+ name = 'xep_0403'
+ description = 'MIX-Presence'
+ dependencies = {'xep_0369'}
+ stanza = stanza
+ namespace = stanza.NS
+
+ def plugin_init(self) -> None:
+ stanza.register_plugins()
+
+ self.xmpp.register_handler(
+ Callback(
+ 'MIX Presence received',
+ MatchXPath('{%s}presence/{%s}mix' % (self.xmpp.default_ns, stanza.NS)),
+ self._handle_mix_presence,
+ )
+ )
+
+ def _handle_mix_presence(self, presence):
+ self.xmpp.event('mix_presence', presence)
diff --git a/slixmpp/plugins/xep_0403/stanza.py b/slixmpp/plugins/xep_0403/stanza.py
new file mode 100644
index 00000000..3e5b9cde
--- /dev/null
+++ b/slixmpp/plugins/xep_0403/stanza.py
@@ -0,0 +1,37 @@
+"""
+ Slixmpp: The Slick XMPP Library
+ Copyright (C) 2020 Mathieu Pasquet <mathieui@mathieui.net>
+ This file is part of Slixmpp.
+
+ See the file LICENSE for copying permissio
+"""
+
+from xml.etree import ElementTree as ET
+from slixmpp import JID
+from slixmpp.stanza import Presence
+from slixmpp.xmlstream import (
+ register_stanza_plugin,
+ ElementBase,
+)
+
+from slixmpp.plugins.xep_0060.stanza import (
+ Item,
+ EventItem,
+)
+
+
+NS = 'urn:xmpp:mix:presence:0'
+
+
+class MIXPresence(ElementBase):
+ namespace = NS
+ name = 'mix'
+ plugin_attrib = 'mix'
+ interfaces = {'jid', 'nick'}
+ sub_interfaces = {'jid', 'nick'}
+
+
+def register_plugins():
+ register_stanza_plugin(Presence, MIXPresence)
+ register_stanza_plugin(Item, Presence)
+ register_stanza_plugin(EventItem, Presence)