changeset 586991e434e6 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=586991e434e6
description: implement XEP-0306 : status conditions for MUC
diffstat:
src/common/connection_handlers_events.py | 41 ++++++++++++++++++++++++++++++-
src/common/xmpp/protocol.py | 12 +++++++++
2 files changed, 51 insertions(+), 2 deletions(-)
diffs (94 lines):
diff -r 02bac92365c1 -r 586991e434e6 src/common/connection_handlers_events.py
--- a/src/common/connection_handlers_events.py Sun Oct 30 13:26:41 2011 +0100
+++ b/src/common/connection_handlers_events.py Sun Oct 30 13:27:32 2011 +0100
@@ -42,6 +42,28 @@
import logging
log = logging.getLogger('gajim.c.connection_handlers_events')
+CONDITION_TO_CODE = {
+ 'realjid-public': 100,
+ 'affiliation-changed': 101,
+ 'unavailable-shown': 102,
+ 'unavailable-not-shown': 103,
+ 'configuration-changed': 104,
+ 'self-presence': 110,
+ 'logging-enabled': 170,
+ 'logging-disabled': 171,
+ 'non-anonymous': 172,
+ 'semi-anonymous': 173,
+ 'fully-anonymous': 174,
+ 'room-created': 201,
+ 'nick-assigned': 210,
+ 'banned': 301,
+ 'new-nick': 303,
+ 'kicked': 307,
+ 'removed-affiliation': 321,
+ 'removed-membership': 322,
+ 'removed-shutdown': 332,
+}
+
class HelperEvent:
def get_jid_resource(self, check_fake_jid=False):
if check_fake_jid and hasattr(self, 'id_') and \
@@ -898,7 +920,15 @@
self.status_code = ['destroyed']
else:
self.reason = self.stanza.getReason()
- self.status_code = self.stanza.getStatusCode()
+ conditions = self.stanza.getStatusConditions()
+ if conditions:
+ self.status_code = []
+ for condition in conditions:
+ if condition in CONDITION_TO_CODE:
+ self.status_code.append(CONDITION_TO_CODE[condition])
+ else:
+ self.status_code = self.stanza.getStatusCode()
+
self.role = self.stanza.getRole()
self.affiliation = self.stanza.getAffiliation()
self.real_jid = self.stanza.getJid()
@@ -1198,7 +1228,14 @@
conn=self.conn, msg_event=self))
return
- self.status_code = self.stanza.getStatusCode()
+ conditions = self.stanza.getStatusConditions()
+ if conditions:
+ self.status_code = []
+ for condition in conditions:
+ if condition in CONDITION_TO_CODE:
+ self.status_code.append(CONDITION_TO_CODE[condition])
+ else:
+ self.status_code = self.stanza.getStatusCode()
if not self.stanza.getTag('body'): # no <body>
# It could be a config change. See
diff -r 02bac92365c1 -r 586991e434e6 src/common/xmpp/protocol.py
--- a/src/common/xmpp/protocol.py Sun Oct 30 13:26:41 2011 +0100
+++ b/src/common/xmpp/protocol.py Sun Oct 30 13:27:32 2011 +0100
@@ -53,6 +53,7 @@
NS_CHATSTATES = 'http://jabber.org/protocol/chatstates' #
JEP-0085
NS_CHATTING = 'http://jabber.org/protocol/chatting' #
XEP-0194
NS_CLIENT = 'jabber:client'
+NS_CONDITIONS = 'urn:xmpp:muc:conditions:0' #
XEP-0306
NS_COMMANDS = 'http://jabber.org/protocol/commands'
NS_COMPONENT_ACCEPT = 'jabber:component:accept'
NS_COMPONENT_1 = 'http://jabberd.jabberstudio.org/ns/component/1.0'
@@ -625,6 +626,17 @@
"""
return self.getTagAttr('error', 'code')
+ def getStatusConditions(self):
+ """
+ Return the status conditions list as defined in XEP-0306.
+ """
+ conds = []
+ condtag = self.getTag('conditions', namespace=NS_CONDITIONS)
+ if condtag:
+ for tag in condtag.getChildren():
+ conds.append(tag.getName())
+ return conds
+
def setError(self, error, code=None):
"""
Set the error code. Obsolete. Use error-conditions instead
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits