From fc153017ec8d9d5c7d70443c77159afb8c81f17a Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sun, 24 Jun 2007 21:19:41 +0000 Subject: [PATCH] ask password to user when we try to connect to a password protected room. fixes #2890 --- src/common/connection_handlers.py | 4 ++-- src/gajim.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 13af916e8..ea469b219 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1658,8 +1658,8 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, self.dispatch('NOTIFY', (jid_stripped, 'error', errmsg, resource, prio, keyID, timestamp, None)) elif errcode == '401': # password required to join - self.dispatch('ERROR', (_('Unable to join group chat'), - _('A password is required to join this group chat.'))) + room_jid, nick = gajim.get_room_and_nick_from_fjid(who) + self.dispatch('GC_PASSWORD_REQUIRED', (room_jid, nick)) elif errcode == '403': # we are banned self.dispatch('ERROR', (_('Unable to join group chat'), _('You are banned from this group chat.'))) diff --git a/src/gajim.py b/src/gajim.py index c68c022f7..f14c0f15a 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1212,6 +1212,27 @@ class Interface: self.instances[account]['gc_config'][room_jid].\ affiliation_list_received(array[1], array[2]) + def handle_event_gc_password_required(self, account, array): + #('GC_PASSWORD_REQUIRED', account, (room_jid, nick)) + room_jid = array[0] + nick = array[1] + dlg = dialogs.InputDialog(_('Password Required'), + _('A Password is required to join the room %s. Please type it') % \ + room_jid, is_modal = True) + response = dlg.get_response() + if response == gtk.RESPONSE_OK: + password = dlg.input_entry.get_text() + gajim.connections[account].join_gc(nick, room_jid, password) + gajim.gc_passwords[room_jid] = password + else: + # get and destroy window + if room_jid in gajim.interface.minimized_controls[account]: + self.roster.on_disconnect(None, room_jid, account) + else: + win = self.msg_win_mgr.get_window(room_jid, account) + ctrl = win.get_control(room_jid, account) + win.remove_tab(ctrl, 3) + def handle_event_gc_invitation(self, account, array): #('GC_INVITATION', (room_jid, jid_from, reason, password)) jid = gajim.get_jid_without_resource(array[1]) @@ -2086,6 +2107,7 @@ class Interface: 'GC_CONFIG': self.handle_event_gc_config, 'GC_INVITATION': self.handle_event_gc_invitation, 'GC_AFFILIATION': self.handle_event_gc_affiliation, + 'GC_PASSWORD_REQUIRED': self.handle_event_gc_password_required, 'BAD_PASSPHRASE': self.handle_event_bad_passphrase, 'ROSTER_INFO': self.handle_event_roster_info, 'BOOKMARKS': self.handle_event_bookmarks,