Add notification of Configuration Changes in MUC. See #3270.

http://www.xmpp.org/extensions/xep-0045.html#roomconfig-notify
This commit is contained in:
Julien Pivotto 2007-07-19 10:06:59 +00:00
parent 015ee132ae
commit 0314f23aa4
4 changed files with 46 additions and 1 deletions

View File

@ -1529,6 +1529,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
self.dispatch('GC_SUBJECT', (frm, subject, msgtxt, has_timestamp))
else:
if not msg.getTag('body'): #no <body>
# It could be a config change. See
# http://www.xmpp.org/extensions/xep-0045.html#roomconfig-notify
if msg.getTag('x'):
statusCode = msg.getStatusCode()
if statusCode != []:
self.dispatch('GC_CONFIG_CHANGE', (jid, statusCode))
return
# Ignore message from room in which we are not
if not self.last_history_line.has_key(jid):

View File

@ -449,6 +449,14 @@ class Message(Protocol):
th=self.getThread()
if th: m.setThread(th)
return m
def getStatusCode(self):
"""Returns the status code of the message (for groupchat config
change)"""
attrs = []
for xtag in self.getTags('x'):
for child in xtag.getTags('status'):
attrs.append(child.getAttr('code'))
return attrs
class Presence(Protocol):
""" XMPP Presence object."""

View File

@ -1210,6 +1210,36 @@ class Interface:
self.instances[account]['gc_config'][room_jid] = \
config.GroupchatConfigWindow(account, room_jid, array[1])
def handle_event_gc_config_change(self, account, array):
#('GC_CONFIG_CHANGE', account, (jid, statusCode)) statuscode is a list
# http://www.xmpp.org/extensions/xep-0045.html#roomconfig-notify
jid = array[0]
statusCode = array[1]
gc_control = self.msg_win_mgr.get_control(jid, account)
if not gc_control and \
jid in self.minimized_controls[account]:
gc_control = self.minimized_controls[account][jid]
if not gc_control:
return
changes = []
if '170' in statusCode:
changes.append(_('Room logging is now enabled'))
if '171' in statusCode:
changes.append(_('Room logging is now disabled'))
if '172' in statusCode:
changes.append(_('Room is now non-anonymous'))
if '173' in statusCode:
changes.append(_('Room is now semi-anonymous'))
if '174' in statusCode:
changes.append(_('Room is now fully-anonymous'))
if '104' in statusCode:
changes.append(_('Room configuration has changed'))
for change in changes:
gc_control.print_conversation(change)
def handle_event_gc_affiliation(self, account, array):
#('GC_AFFILIATION', account, (room_jid, affiliation, list)) list is list
room_jid = array[0]
@ -2113,6 +2143,7 @@ class Interface:
'GC_MSG': self.handle_event_gc_msg,
'GC_SUBJECT': self.handle_event_gc_subject,
'GC_CONFIG': self.handle_event_gc_config,
'GC_CONFIG_CHANGE': self.handle_event_gc_config_change,
'GC_INVITATION': self.handle_event_gc_invitation,
'GC_AFFILIATION': self.handle_event_gc_affiliation,
'GC_PASSWORD_REQUIRED': self.handle_event_gc_password_required,

View File

@ -887,7 +887,7 @@ class GroupchatControl(ChatControlBase):
fake_jid = self.room_jid + '/' + nick
newly_created = False
if '170' in statusCode:
self.print_conversation(_('Room logging is enabled'), 'info')
self.print_conversation(_('Room logging is enabled'))
if show in ('offline', 'error'):
if '307' in statusCode:
if actor is None: # do not print 'kicked by None'