summaryrefslogtreecommitdiff
path: root/slixmpp/plugins/xep_0045/__init__.py
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2020-05-29 17:25:18 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2020-05-29 17:25:18 +0200
commit03ee9bc4cc8d9ed92cd9c70fa6227d4c0355da73 (patch)
tree5aa5ed90d10c7720828220fd76fe59e96e530097 /slixmpp/plugins/xep_0045/__init__.py
parent4fad5c62cefdbc89ba1243fe52ceae9de0054dd2 (diff)
downloadslixmpp-03ee9bc4cc8d9ed92cd9c70fa6227d4c0355da73.tar.gz
slixmpp-03ee9bc4cc8d9ed92cd9c70fa6227d4c0355da73.tar.bz2
slixmpp-03ee9bc4cc8d9ed92cd9c70fa6227d4c0355da73.tar.xz
slixmpp-03ee9bc4cc8d9ed92cd9c70fa6227d4c0355da73.zip
XEP-0045: Split stanza into sub-module
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'slixmpp/plugins/xep_0045/__init__.py')
-rw-r--r--slixmpp/plugins/xep_0045/__init__.py89
1 files changed, 1 insertions, 88 deletions
diff --git a/slixmpp/plugins/xep_0045/__init__.py b/slixmpp/plugins/xep_0045/__init__.py
index f0433097..e3437b8f 100644
--- a/slixmpp/plugins/xep_0045/__init__.py
+++ b/slixmpp/plugins/xep_0045/__init__.py
@@ -15,99 +15,12 @@ from slixmpp.xmlstream.handler.callback import Callback
from slixmpp.xmlstream.matcher.xpath import MatchXPath
from slixmpp.xmlstream.matcher.xmlmask import MatchXMLMask
from slixmpp.exceptions import IqError, IqTimeout
+from slixmpp.plugins.xep_0045.stanza import MUCPresence
log = logging.getLogger(__name__)
-class MUCPresence(ElementBase):
- name = 'x'
- namespace = 'http://jabber.org/protocol/muc#user'
- plugin_attrib = 'muc'
- interfaces = {'affiliation', 'role', 'jid', 'nick', 'room'}
- affiliations = {'', }
- roles = {'', }
-
- def get_item_attr(self, attr, default):
- item = self.xml.find('{http://jabber.org/protocol/muc#user}item')
- if item is None:
- return default
- return item.get(attr)
-
- def set_item_attr(self, attr, value):
- item = self.xml.find('{http://jabber.org/protocol/muc#user}item')
- if item is None:
- item = ET.Element('{http://jabber.org/protocol/muc#user}item')
- self.xml.append(item)
- item.attrib[attr] = value
- return item
-
- def del_item_attr(self, attr):
- item = self.xml.find('{http://jabber.org/protocol/muc#user}item')
- if item is not None and attr in item.attrib:
- del item.attrib[attr]
-
- def get_affiliation(self):
- return self.get_item_attr('affiliation', '')
-
- def set_affiliation(self, value):
- self.set_item_attr('affiliation', value)
- return self
-
- def del_affiliation(self):
- # TODO: set default affiliation
- self.del_item_attr('affiliation')
- return self
-
- def get_jid(self):
- return JID(self.get_item_attr('jid', ''))
-
- def set_jid(self, value):
- if not isinstance(value, str):
- value = str(value)
- self.set_item_attr('jid', value)
- return self
-
- def del_jid(self):
- self.del_item_attr('jid')
- return self
-
- def get_role(self):
- return self.get_item_attr('role', '')
-
- def set_role(self, value):
- # TODO: check for valid role
- self.set_item_attr('role', value)
- return self
-
- def del_role(self):
- # TODO: set default role
- self.del_item_attr('role')
- return self
-
- def get_nick(self):
- return self.parent()['from'].resource
-
- def get_room(self):
- return self.parent()['from'].bare
-
- def set_nick(self, value):
- log.warning("Cannot set nick through mucpresence plugin.")
- return self
-
- def set_room(self, value):
- log.warning("Cannot set room through mucpresence plugin.")
- return self
-
- def del_nick(self):
- log.warning("Cannot delete nick through mucpresence plugin.")
- return self
-
- def del_room(self):
- log.warning("Cannot delete room through mucpresence plugin.")
- return self
-
-
class XEP_0045(BasePlugin):
"""