Add notification of Configuration Changes in MUC. See #3270.
http://www.xmpp.org/extensions/xep-0045.html#roomconfig-notify
This commit is contained in:
parent
015ee132ae
commit
0314f23aa4
|
@ -1529,6 +1529,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
self.dispatch('GC_SUBJECT', (frm, subject, msgtxt, has_timestamp))
|
self.dispatch('GC_SUBJECT', (frm, subject, msgtxt, has_timestamp))
|
||||||
else:
|
else:
|
||||||
if not msg.getTag('body'): #no <body>
|
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
|
return
|
||||||
# Ignore message from room in which we are not
|
# Ignore message from room in which we are not
|
||||||
if not self.last_history_line.has_key(jid):
|
if not self.last_history_line.has_key(jid):
|
||||||
|
|
|
@ -449,6 +449,14 @@ class Message(Protocol):
|
||||||
th=self.getThread()
|
th=self.getThread()
|
||||||
if th: m.setThread(th)
|
if th: m.setThread(th)
|
||||||
return m
|
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):
|
class Presence(Protocol):
|
||||||
""" XMPP Presence object."""
|
""" XMPP Presence object."""
|
||||||
|
|
31
src/gajim.py
31
src/gajim.py
|
@ -1210,6 +1210,36 @@ class Interface:
|
||||||
self.instances[account]['gc_config'][room_jid] = \
|
self.instances[account]['gc_config'][room_jid] = \
|
||||||
config.GroupchatConfigWindow(account, room_jid, array[1])
|
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):
|
def handle_event_gc_affiliation(self, account, array):
|
||||||
#('GC_AFFILIATION', account, (room_jid, affiliation, list)) list is list
|
#('GC_AFFILIATION', account, (room_jid, affiliation, list)) list is list
|
||||||
room_jid = array[0]
|
room_jid = array[0]
|
||||||
|
@ -2113,6 +2143,7 @@ class Interface:
|
||||||
'GC_MSG': self.handle_event_gc_msg,
|
'GC_MSG': self.handle_event_gc_msg,
|
||||||
'GC_SUBJECT': self.handle_event_gc_subject,
|
'GC_SUBJECT': self.handle_event_gc_subject,
|
||||||
'GC_CONFIG': self.handle_event_gc_config,
|
'GC_CONFIG': self.handle_event_gc_config,
|
||||||
|
'GC_CONFIG_CHANGE': self.handle_event_gc_config_change,
|
||||||
'GC_INVITATION': self.handle_event_gc_invitation,
|
'GC_INVITATION': self.handle_event_gc_invitation,
|
||||||
'GC_AFFILIATION': self.handle_event_gc_affiliation,
|
'GC_AFFILIATION': self.handle_event_gc_affiliation,
|
||||||
'GC_PASSWORD_REQUIRED': self.handle_event_gc_password_required,
|
'GC_PASSWORD_REQUIRED': self.handle_event_gc_password_required,
|
||||||
|
|
|
@ -887,7 +887,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
fake_jid = self.room_jid + '/' + nick
|
fake_jid = self.room_jid + '/' + nick
|
||||||
newly_created = False
|
newly_created = False
|
||||||
if '170' in statusCode:
|
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 show in ('offline', 'error'):
|
||||||
if '307' in statusCode:
|
if '307' in statusCode:
|
||||||
if actor is None: # do not print 'kicked by None'
|
if actor is None: # do not print 'kicked by None'
|
||||||
|
|
Loading…
Reference in New Issue