XEP-0045: Multi-User Chat

* Handle Multiple status code in MUC.
 * Warn the user if room logging is enabled (
http://www.xmpp.org/extensions/xep-0045.html#enter-logging ). Fix #3270.
This commit is contained in:
Julien Pivotto 2007-07-19 09:27:33 +00:00
parent 6637366b68
commit 015ee132ae
3 changed files with 16 additions and 10 deletions

View File

@ -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()

View File

@ -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. """

View File

@ -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