diff --git a/src/common/connection.py b/src/common/connection.py index a163cddd4..18a6c1aae 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -313,7 +313,7 @@ class Connection: self.dispatch('NOTIFY', ( account, show, status, resource, prio, keyID, prs.getRole(), prs.getAffiliation(), prs.getJid(), prs.getReason(), - prs.getActor(), prs.getStatusCode())) + prs.getActor(), prs.getStatusCode(), prs.getNewNick())) # END presenceCB def _disconnectedCB(self): @@ -1041,6 +1041,12 @@ class Connection: iq = common.xmpp.Iq(typ = 'get', queryNS = common.xmpp.NS_MUC_OWNER, to = room_jid) self.connection.send(iq) + + def change_gc_nick(self, nick, room_jid): + if not self.connection: + return + self.connection.send(common.xmpp.Presence(to = '%s/%s' % (room_jid, + nick))) def send_gc_status(self, nick, jid, show, status): if not self.connection: diff --git a/src/common/xmpp/protocol.py b/src/common/xmpp/protocol.py index c4a175738..65490a7fb 100644 --- a/src/common/xmpp/protocol.py +++ b/src/common/xmpp/protocol.py @@ -425,6 +425,9 @@ class Presence(Protocol): def getAffiliation(self): """Returns the presence affiliation (for groupchat)""" return self._muc_getItemAttr('item','affiliation') + def getNewNick(self): + """Returns the status code of the presence (for groupchat)""" + return self._muc_getItemAttr('item','nick') def getJid(self): """Returns the presence jid (for groupchat)""" return self._muc_getItemAttr('item','jid') diff --git a/src/gajim.py b/src/gajim.py index b5a99ecdf..902b9ed99 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -217,7 +217,7 @@ class Interface: def handle_event_notify(self, account, array): #('NOTIFY', account, (jid, status, message, resource, priority, keyID, - # role, affiliation, real_jid, reason, actor, statusCode)) + # role, affiliation, real_jid, reason, actor, statusCode, new_nick)) statuss = ['offline', 'error', 'online', 'chat', 'away', 'xa', 'dnd', 'invisible'] old_show = 0 new_show = statuss.index(array[1]) @@ -335,7 +335,7 @@ class Interface: fjid = array[0] + '/' + array[3] self.windows[account]['gc'][ji].chg_user_status(ji, resource, array[1], array[2], array[6], array[7], array[8], array[9], - array[10], array[11], account) + array[10], array[11], array[12], account) def handle_event_msg(self, account, array): #('MSG', account, (user, msg, time, encrypted)) diff --git a/src/groupchat_window.py b/src/groupchat_window.py index 7139aeccc..1f3f37af8 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -262,7 +262,7 @@ class GroupchatWindow(chat.Chat): role_iter = model.iter_next(role_iter) def chg_user_status(self, room_jid, nick, show, status, role, affiliation, \ - jid, reason, actor, statusCode, account): + jid, reason, actor, statusCode, new_nick, account): """When a user changes his status""" if not role: role = 'visitor' @@ -271,8 +271,13 @@ class GroupchatWindow(chat.Chat): if statusCode == '307': self.print_conversation(_('%s has been kicked by %s: %s') % (nick, actor, reason), room_jid) + elif statusCode == '303': # Someone changed his nick + self.print_conversation(_('%s is now known as %s') % (nick, + new_nick), room_jid) + if nick == self.nicks[room_jid]: # We changed out nick + self.nicks[room_jid] = new_nick self.remove_user(room_jid, nick) - if nick == self.nicks[room_jid]: # We became offline + if nick == self.nicks[room_jid] and statusCode != '303': # We became offline model.clear() else: iter = self.get_user_iter(room_jid, nick) @@ -293,7 +298,7 @@ class GroupchatWindow(chat.Chat): model.set_value(iter, 0, image) model.set_value(iter, 3, show) if (time.time() - self.room_creation[room_jid]) > 30 and \ - nick != self.nicks[room_jid]: + nick != self.nicks[room_jid] and statusCode != '303': if show == 'offline': st = _('%s has left') % nick else: @@ -323,6 +328,17 @@ class GroupchatWindow(chat.Chat): subject = instance.input_entry.get_text() gajim.connections[self.account].send_gc_subject(room_jid, subject) + def on_change_nick_menuitem_activate(self, widget): + room_jid = self.get_active_jid() + nick = self.nicks[room_jid] + instance = dialogs.InputDialog(_('Changing out Nickname'), + _('Please specify the new nickname you want to use:'), nick) + response = instance.dialog.run() + instance.dialog.destroy() + if response == gtk.RESPONSE_OK: + nick = instance.input_entry.get_text() + gajim.connections[self.account].change_gc_nick(nick, room_jid) + def on_configure_room_menuitem_activate(self, widget): room_jid = self.get_active_jid() gajim.connections[self.account].request_gc_config(room_jid) @@ -345,7 +361,7 @@ class GroupchatWindow(chat.Chat): gajim.connections[self.account].bookmarks.append(bm) gajim.connections[self.account].store_bookmarks() - + self.plugin.roster.make_menu() dialogs.InformationDialog( diff --git a/src/gtkgui.glade b/src/gtkgui.glade index efe60465c..932fb306c 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -15253,7 +15253,7 @@ the Jabber network. - + True gtk-properties 1 @@ -15274,7 +15274,7 @@ the Jabber network. - + True gtk-edit 1 @@ -15287,6 +15287,27 @@ the Jabber network. + + + True + Change _Nick + True + + + + + True + gtk-media-next + 1 + 0.5 + 0.5 + 0 + 0 + + + + + True @@ -15295,7 +15316,7 @@ the Jabber network. - + True gtk-add 1