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:
parent
6637366b68
commit
015ee132ae
3 changed files with 16 additions and 10 deletions
|
@ -1741,7 +1741,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
jid = destroy.getAttr('jid')
|
jid = destroy.getAttr('jid')
|
||||||
if jid:
|
if jid:
|
||||||
reason += '\n' + _('You can join this room instead: %s') % jid
|
reason += '\n' + _('You can join this room instead: %s') % jid
|
||||||
statusCode = 'destroyed'
|
statusCode = ['destroyed']
|
||||||
else:
|
else:
|
||||||
reason = prs.getReason()
|
reason = prs.getReason()
|
||||||
statusCode = prs.getStatusCode()
|
statusCode = prs.getStatusCode()
|
||||||
|
|
|
@ -509,7 +509,11 @@ class Presence(Protocol):
|
||||||
return self._muc_getSubTagDataAttr('actor','jid')[1]
|
return self._muc_getSubTagDataAttr('actor','jid')[1]
|
||||||
def getStatusCode(self):
|
def getStatusCode(self):
|
||||||
"""Returns the status code of the presence (for groupchat)"""
|
"""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):
|
class Iq(Protocol):
|
||||||
""" XMPP Iq object - get/set dialog mechanism. """
|
""" XMPP Iq object - get/set dialog mechanism. """
|
||||||
|
|
|
@ -886,8 +886,10 @@ class GroupchatControl(ChatControlBase):
|
||||||
affiliation = 'none'
|
affiliation = 'none'
|
||||||
fake_jid = self.room_jid + '/' + nick
|
fake_jid = self.room_jid + '/' + nick
|
||||||
newly_created = False
|
newly_created = False
|
||||||
|
if '170' in statusCode:
|
||||||
|
self.print_conversation(_('Room logging is enabled'), 'info')
|
||||||
if show in ('offline', 'error'):
|
if show in ('offline', 'error'):
|
||||||
if statusCode == '307':
|
if '307' in statusCode:
|
||||||
if actor is None: # do not print 'kicked by None'
|
if actor is None: # do not print 'kicked by None'
|
||||||
s = _('%(nick)s has been kicked: %(reason)s') % {
|
s = _('%(nick)s has been kicked: %(reason)s') % {
|
||||||
'nick': nick,
|
'nick': nick,
|
||||||
|
@ -898,7 +900,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
'who': actor,
|
'who': actor,
|
||||||
'reason': reason }
|
'reason': reason }
|
||||||
self.print_conversation(s, 'info', tim = tim)
|
self.print_conversation(s, 'info', tim = tim)
|
||||||
elif statusCode == '301':
|
elif '301' in statusCode:
|
||||||
if actor is None: # do not print 'banned by None'
|
if actor is None: # do not print 'banned by None'
|
||||||
s = _('%(nick)s has been banned: %(reason)s') % {
|
s = _('%(nick)s has been banned: %(reason)s') % {
|
||||||
'nick': nick,
|
'nick': nick,
|
||||||
|
@ -909,7 +911,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
'who': actor,
|
'who': actor,
|
||||||
'reason': reason }
|
'reason': reason }
|
||||||
self.print_conversation(s, 'info', tim = tim)
|
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
|
if new_nick == self.nick: # We changed our nick
|
||||||
s = _('You are now known as %s') % new_nick
|
s = _('You are now known as %s') % new_nick
|
||||||
else:
|
else:
|
||||||
|
@ -945,7 +947,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
os.remove(files[old_file])
|
os.remove(files[old_file])
|
||||||
os.rename(old_file, files[old_file])
|
os.rename(old_file, files[old_file])
|
||||||
self.print_conversation(s, 'info', tim)
|
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)
|
self.print_conversation(reason, 'info', tim)
|
||||||
|
|
||||||
if len(gajim.events.get_events(self.account, fake_jid)) == 0:
|
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 = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
|
||||||
c.show = show
|
c.show = show
|
||||||
c.status = status
|
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()
|
self.got_disconnected()
|
||||||
contact = gajim.contacts.\
|
contact = gajim.contacts.\
|
||||||
get_contact_with_highest_priority(self.account, self.room_jid)
|
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,
|
iter = self.add_contact_to_roster(nick, show, role, affiliation,
|
||||||
status, jid)
|
status, jid)
|
||||||
newly_created = True
|
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)
|
gajim.connections[self.account].request_gc_config(self.room_jid)
|
||||||
else:
|
else:
|
||||||
gc_c = gajim.contacts.get_gc_contact(self.account, self.room_jid,
|
gc_c = gajim.contacts.get_gc_contact(self.account, self.room_jid,
|
||||||
|
@ -1021,7 +1023,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
if self.parent_win:
|
if self.parent_win:
|
||||||
self.parent_win.redraw_tab(self)
|
self.parent_win.redraw_tab(self)
|
||||||
if (time.time() - self.room_creation) > 30 and \
|
if (time.time() - self.room_creation) > 30 and \
|
||||||
nick != self.nick and statusCode != '303':
|
nick != self.nick and '303' not in statusCode:
|
||||||
st = ''
|
st = ''
|
||||||
print_status = None
|
print_status = None
|
||||||
for bookmark in gajim.connections[self.account].bookmarks:
|
for bookmark in gajim.connections[self.account].bookmarks:
|
||||||
|
@ -1039,7 +1041,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
if nick in self.attention_list:
|
if nick in self.attention_list:
|
||||||
self.attention_list.remove(nick)
|
self.attention_list.remove(nick)
|
||||||
if show == 'offline' and print_status in ('all', 'in_and_out') and \
|
if show == 'offline' and print_status in ('all', 'in_and_out') and \
|
||||||
statusCode != '307':
|
'307' not in statusCode:
|
||||||
st = _('%s has left') % nick_jid
|
st = _('%s has left') % nick_jid
|
||||||
if reason:
|
if reason:
|
||||||
st += ' [%s]' % reason
|
st += ' [%s]' % reason
|
||||||
|
|
Loading…
Add table
Reference in a new issue