diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index b2cd1a66b..9fa71bb1b 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1741,7 +1741,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, jid = destroy.getAttr('jid') if jid: reason += '\n' + _('You can join this room instead: %s') % jid - statusCode = 'destroyed' + statusCode = ['destroyed'] else: reason = prs.getReason() statusCode = prs.getStatusCode() diff --git a/src/common/xmpp/protocol.py b/src/common/xmpp/protocol.py index 0b549bd5b..8409483d8 100644 --- a/src/common/xmpp/protocol.py +++ b/src/common/xmpp/protocol.py @@ -509,7 +509,11 @@ class Presence(Protocol): return self._muc_getSubTagDataAttr('actor','jid')[1] def getStatusCode(self): """Returns the status code of the presence (for groupchat)""" - return self._muc_getItemAttr('status','code') + attrs = [] + for xtag in self.getTags('x'): + for child in xtag.getTags('status'): + attrs.append(child.getAttr('code')) + return attrs class Iq(Protocol): """ XMPP Iq object - get/set dialog mechanism. """ diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 6d22288d3..1c560f555 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -886,8 +886,10 @@ class GroupchatControl(ChatControlBase): affiliation = 'none' fake_jid = self.room_jid + '/' + nick newly_created = False + if '170' in statusCode: + self.print_conversation(_('Room logging is enabled'), 'info') if show in ('offline', 'error'): - if statusCode == '307': + if '307' in statusCode: if actor is None: # do not print 'kicked by None' s = _('%(nick)s has been kicked: %(reason)s') % { 'nick': nick, @@ -898,7 +900,7 @@ class GroupchatControl(ChatControlBase): 'who': actor, 'reason': reason } self.print_conversation(s, 'info', tim = tim) - elif statusCode == '301': + elif '301' in statusCode: if actor is None: # do not print 'banned by None' s = _('%(nick)s has been banned: %(reason)s') % { 'nick': nick, @@ -909,7 +911,7 @@ class GroupchatControl(ChatControlBase): 'who': actor, 'reason': reason } self.print_conversation(s, 'info', tim = tim) - elif statusCode == '303': # Someone changed his or her nick + elif '303' in statusCode: # Someone changed his or her nick if new_nick == self.nick: # We changed our nick s = _('You are now known as %s') % new_nick else: @@ -945,7 +947,7 @@ class GroupchatControl(ChatControlBase): os.remove(files[old_file]) os.rename(old_file, files[old_file]) self.print_conversation(s, 'info', tim) - elif statusCode == 'destroyed': # Room has been destroyed + elif 'destroyed' in statusCode: # Room has been destroyed self.print_conversation(reason, 'info', tim) if len(gajim.events.get_events(self.account, fake_jid)) == 0: @@ -954,7 +956,7 @@ class GroupchatControl(ChatControlBase): c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick) c.show = show c.status = status - if nick == self.nick and statusCode != '303': # We became offline + if nick == self.nick and '303' not in statusCode: # We became offline self.got_disconnected() contact = gajim.contacts.\ get_contact_with_highest_priority(self.account, self.room_jid) @@ -968,7 +970,7 @@ class GroupchatControl(ChatControlBase): iter = self.add_contact_to_roster(nick, show, role, affiliation, status, jid) newly_created = True - if statusCode == '201': # We just created the room + if '201' in statusCode: # We just created the room gajim.connections[self.account].request_gc_config(self.room_jid) else: gc_c = gajim.contacts.get_gc_contact(self.account, self.room_jid, @@ -1021,7 +1023,7 @@ class GroupchatControl(ChatControlBase): if self.parent_win: self.parent_win.redraw_tab(self) if (time.time() - self.room_creation) > 30 and \ - nick != self.nick and statusCode != '303': + nick != self.nick and '303' not in statusCode: st = '' print_status = None for bookmark in gajim.connections[self.account].bookmarks: @@ -1039,7 +1041,7 @@ class GroupchatControl(ChatControlBase): if nick in self.attention_list: self.attention_list.remove(nick) if show == 'offline' and print_status in ('all', 'in_and_out') and \ - statusCode != '307': + '307' not in statusCode: st = _('%s has left') % nick_jid if reason: st += ' [%s]' % reason