Fix a bug with my last commits
This commit is contained in:
parent
3a1b83228d
commit
3087a66ccb
1 changed files with 92 additions and 88 deletions
|
@ -889,94 +889,96 @@ class GroupchatControl(ChatControlBase):
|
||||||
|
|
||||||
# statusCode
|
# statusCode
|
||||||
# http://www.xmpp.org/extensions/xep-0045.html#registrar-statuscodes-init
|
# http://www.xmpp.org/extensions/xep-0045.html#registrar-statuscodes-init
|
||||||
if '100' in statusCode:
|
if statusCode:
|
||||||
# Can be a message (see handle_event_gc_config_change in gajim.py)
|
if '100' in statusCode:
|
||||||
self.print_conversation(\
|
# Can be a message (see handle_event_gc_config_change in gajim.py)
|
||||||
_('Any occupant is allowed to see your full JID'))
|
self.print_conversation(\
|
||||||
if '170' in statusCode:
|
_('Any occupant is allowed to see your full JID'))
|
||||||
# Can be a message (see handle_event_gc_config_change in gajim.py)
|
if '170' in statusCode:
|
||||||
self.print_conversation(_('Room logging is enabled'))
|
# Can be a message (see handle_event_gc_config_change in gajim.py)
|
||||||
if '201' in statusCode:
|
self.print_conversation(_('Room logging is enabled'))
|
||||||
self.print_conversation(_('A new room has been created'))
|
if '201' in statusCode:
|
||||||
if '210' in statusCode:
|
self.print_conversation(_('A new room has been created'))
|
||||||
self.print_conversation(\
|
if '210' in statusCode:
|
||||||
_('The server has assigned or modified your roomnick'))
|
self.print_conversation(\
|
||||||
|
_('The server has assigned or modified your roomnick'))
|
||||||
|
|
||||||
if show in ('offline', 'error'):
|
if show in ('offline', 'error'):
|
||||||
if '307' in statusCode:
|
if statusCode:
|
||||||
if actor is None: # do not print 'kicked by None'
|
if statuscode '307' in statusCode:
|
||||||
s = _('%(nick)s has been kicked: %(reason)s') % {
|
if actor is None: # do not print 'kicked by None'
|
||||||
|
s = _('%(nick)s has been kicked: %(reason)s') % {
|
||||||
|
'nick': nick,
|
||||||
|
'reason': reason }
|
||||||
|
else:
|
||||||
|
s = _('%(nick)s has been kicked by %(who)s: %(reason)s') % {
|
||||||
|
'nick': nick,
|
||||||
|
'who': actor,
|
||||||
|
'reason': reason }
|
||||||
|
self.print_conversation(s, 'info', tim = tim)
|
||||||
|
elif '301' in statusCode:
|
||||||
|
if actor is None: # do not print 'banned by None'
|
||||||
|
s = _('%(nick)s has been banned: %(reason)s') % {
|
||||||
|
'nick': nick,
|
||||||
|
'reason': reason }
|
||||||
|
else:
|
||||||
|
s = _('%(nick)s has been banned by %(who)s: %(reason)s') % {
|
||||||
|
'nick': nick,
|
||||||
|
'who': actor,
|
||||||
|
'reason': reason }
|
||||||
|
self.print_conversation(s, 'info', tim = tim)
|
||||||
|
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:
|
||||||
|
s = _('%s is now known as %s') % (nick, new_nick)
|
||||||
|
# We add new nick to muc roster here, so we don't see
|
||||||
|
# that "new_nick has joined the room" when he just changed nick.
|
||||||
|
# add_contact_to_roster will be called a second time
|
||||||
|
# after that, but that doesn't hurt
|
||||||
|
self.add_contact_to_roster(new_nick, show, role, affiliation,
|
||||||
|
status, jid)
|
||||||
|
if nick in self.attention_list:
|
||||||
|
self.attention_list.remove(nick)
|
||||||
|
# keep nickname color
|
||||||
|
if nick in self.gc_custom_colors:
|
||||||
|
self.gc_custom_colors[new_nick] = self.gc_custom_colors[nick]
|
||||||
|
# rename vcard / avatar
|
||||||
|
puny_jid = helpers.sanitize_filename(self.room_jid)
|
||||||
|
puny_nick = helpers.sanitize_filename(nick)
|
||||||
|
puny_new_nick = helpers.sanitize_filename(new_nick)
|
||||||
|
old_path = os.path.join(gajim.VCARD_PATH, puny_jid, puny_nick)
|
||||||
|
new_path = os.path.join(gajim.VCARD_PATH, puny_jid, puny_new_nick)
|
||||||
|
files = {old_path: new_path}
|
||||||
|
path = os.path.join(gajim.AVATAR_PATH, puny_jid)
|
||||||
|
# possible extensions
|
||||||
|
for ext in ('.png', '.jpeg', '_notif_size_bw.png',
|
||||||
|
'_notif_size_colored.png'):
|
||||||
|
files[os.path.join(path, puny_nick + ext)] = \
|
||||||
|
os.path.join(path, puny_new_nick + ext)
|
||||||
|
for old_file in files:
|
||||||
|
if os.path.exists(old_file):
|
||||||
|
if os.path.exists(files[old_file]):
|
||||||
|
# Windows require this
|
||||||
|
os.remove(files[old_file])
|
||||||
|
os.rename(old_file, files[old_file])
|
||||||
|
self.print_conversation(s, 'info', tim)
|
||||||
|
elif '321' in statusCode:
|
||||||
|
s = _('%(nick)s has been removed from the room (%(reason)s)') % {
|
||||||
|
'nick': nick, 'reason': _('affiliation changed') }
|
||||||
|
self.print_conversation(s, 'info', tim = tim)
|
||||||
|
elif '322' in statusCode:
|
||||||
|
s = _('%(nick)s has been removed from the room (%(reason)s)') % {
|
||||||
'nick': nick,
|
'nick': nick,
|
||||||
'reason': reason }
|
'reason': _('room configuration changed to members-only') }
|
||||||
else:
|
self.print_conversation(s, 'info', tim = tim)
|
||||||
s = _('%(nick)s has been kicked by %(who)s: %(reason)s') % {
|
elif '332' in statusCode:
|
||||||
|
s = _('%(nick)s has been removed from the room (%(reason)s)') % {
|
||||||
'nick': nick,
|
'nick': nick,
|
||||||
'who': actor,
|
'reason': _('system shutdown') }
|
||||||
'reason': reason }
|
self.print_conversation(s, 'info', tim = tim)
|
||||||
self.print_conversation(s, 'info', tim = tim)
|
elif 'destroyed' in statusCode: # Room has been destroyed
|
||||||
elif '301' in statusCode:
|
self.print_conversation(reason, 'info', tim)
|
||||||
if actor is None: # do not print 'banned by None'
|
|
||||||
s = _('%(nick)s has been banned: %(reason)s') % {
|
|
||||||
'nick': nick,
|
|
||||||
'reason': reason }
|
|
||||||
else:
|
|
||||||
s = _('%(nick)s has been banned by %(who)s: %(reason)s') % {
|
|
||||||
'nick': nick,
|
|
||||||
'who': actor,
|
|
||||||
'reason': reason }
|
|
||||||
self.print_conversation(s, 'info', tim = tim)
|
|
||||||
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:
|
|
||||||
s = _('%s is now known as %s') % (nick, new_nick)
|
|
||||||
# We add new nick to muc roster here, so we don't see
|
|
||||||
# that "new_nick has joined the room" when he just changed nick.
|
|
||||||
# add_contact_to_roster will be called a second time
|
|
||||||
# after that, but that doesn't hurt
|
|
||||||
self.add_contact_to_roster(new_nick, show, role, affiliation,
|
|
||||||
status, jid)
|
|
||||||
if nick in self.attention_list:
|
|
||||||
self.attention_list.remove(nick)
|
|
||||||
# keep nickname color
|
|
||||||
if nick in self.gc_custom_colors:
|
|
||||||
self.gc_custom_colors[new_nick] = self.gc_custom_colors[nick]
|
|
||||||
# rename vcard / avatar
|
|
||||||
puny_jid = helpers.sanitize_filename(self.room_jid)
|
|
||||||
puny_nick = helpers.sanitize_filename(nick)
|
|
||||||
puny_new_nick = helpers.sanitize_filename(new_nick)
|
|
||||||
old_path = os.path.join(gajim.VCARD_PATH, puny_jid, puny_nick)
|
|
||||||
new_path = os.path.join(gajim.VCARD_PATH, puny_jid, puny_new_nick)
|
|
||||||
files = {old_path: new_path}
|
|
||||||
path = os.path.join(gajim.AVATAR_PATH, puny_jid)
|
|
||||||
# possible extensions
|
|
||||||
for ext in ('.png', '.jpeg', '_notif_size_bw.png',
|
|
||||||
'_notif_size_colored.png'):
|
|
||||||
files[os.path.join(path, puny_nick + ext)] = \
|
|
||||||
os.path.join(path, puny_new_nick + ext)
|
|
||||||
for old_file in files:
|
|
||||||
if os.path.exists(old_file):
|
|
||||||
if os.path.exists(files[old_file]):
|
|
||||||
# Windows require this
|
|
||||||
os.remove(files[old_file])
|
|
||||||
os.rename(old_file, files[old_file])
|
|
||||||
self.print_conversation(s, 'info', tim)
|
|
||||||
elif '321' in statusCode:
|
|
||||||
s = _('%(nick)s has been removed from the room (%(reason)s)') % {
|
|
||||||
'nick': nick, 'reason': _('affiliation changed') }
|
|
||||||
self.print_conversation(s, 'info', tim = tim)
|
|
||||||
elif '322' in statusCode:
|
|
||||||
s = _('%(nick)s has been removed from the room (%(reason)s)') % {
|
|
||||||
'nick': nick,
|
|
||||||
'reason': _('room configuration changed to members-only') }
|
|
||||||
self.print_conversation(s, 'info', tim = tim)
|
|
||||||
elif '332' in statusCode:
|
|
||||||
s = _('%(nick)s has been removed from the room (%(reason)s)') % {
|
|
||||||
'nick': nick,
|
|
||||||
'reason': _('system shutdown') }
|
|
||||||
self.print_conversation(s, 'info', tim = tim)
|
|
||||||
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:
|
if len(gajim.events.get_events(self.account, fake_jid)) == 0:
|
||||||
self.remove_contact(nick)
|
self.remove_contact(nick)
|
||||||
|
@ -984,7 +986,8 @@ 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 '303' not in statusCode: # We became offline
|
if nick == self.nick and (not statusCode or \
|
||||||
|
'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)
|
||||||
|
@ -998,7 +1001,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 '201' in statusCode: # We just created the room
|
if statusCode and '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,
|
||||||
|
@ -1051,7 +1054,8 @@ 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 '303' not in statusCode:
|
nick != self.nick and (not statusCode or \
|
||||||
|
'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:
|
||||||
|
@ -1069,7 +1073,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 \
|
||||||
'307' not in statusCode:
|
(not statusCode or '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