From 30a9202f9d663dcd402de9f2a3eae6fb3793ba9b Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Fri, 29 Jun 2007 09:39:13 +0000
Subject: [PATCH] automaticaly fill password entry in groupchat invitation
 dialog if we get it. fixes #3271

---
 src/dialogs.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/dialogs.py b/src/dialogs.py
index 597deb2650..19f04238c9 100644
--- a/src/dialogs.py
+++ b/src/dialogs.py
@@ -1209,7 +1209,8 @@ class SubscriptionRequestWindow:
 
 
 class JoinGroupchatWindow:
-	def __init__(self, account, room_jid = '', nick = '', automatic = False):
+	def __init__(self, account, room_jid = '', nick = '', password = '',
+	automatic = False):
 		'''automatic is a dict like {'invities': []}
 		If automatic is not empty, this means room must be automaticaly configured
 		and when done, invities must be automatically invited'''
@@ -1233,9 +1234,12 @@ class JoinGroupchatWindow:
 		self.window = self.xml.get_widget('join_groupchat_window')
 		self._room_jid_entry = self.xml.get_widget('room_jid_entry')
 		self._nickname_entry = self.xml.get_widget('nickname_entry')
+		self._password_entry = self.xml.get_widget('password_entry')
 
 		self._room_jid_entry.set_text(room_jid)
 		self._nickname_entry.set_text(nick)
+		if password:
+			self._password_entry.set_text(password)
 		self.xml.signal_autoconnect(self)
 		gajim.interface.instances[account]['join_gc'] = self #now add us to open windows
 		if len(gajim.connections) > 1:
@@ -1303,8 +1307,7 @@ class JoinGroupchatWindow:
 		'''When Join button is clicked'''
 		nickname = self._nickname_entry.get_text().decode('utf-8')
 		room_jid = self._room_jid_entry.get_text().decode('utf-8')
-		password = self.xml.get_widget('password_entry').get_text().decode(
-			'utf-8')
+		password = self._password_entry.get_text().decode('utf-8')
 		user, server, resource = helpers.decompose_jid(room_jid)
 		if not user or not server or resource:
 			ErrorDialog(_('Invalid group chat Jabber ID'),
@@ -2565,6 +2568,7 @@ class InvitationReceivedDialog:
 
 		self.room_jid = room_jid
 		self.account = account
+		self.password = password
 		xml = gtkgui_helpers.get_glade('invitation_received_dialog.glade')
 		self.dialog = xml.get_widget('invitation_received_dialog')
 
@@ -2598,7 +2602,8 @@ class InvitationReceivedDialog:
 	def on_accept_button_clicked(self, widget):
 		self.dialog.destroy()
 		try:
-			JoinGroupchatWindow(self.account, self.room_jid)
+			JoinGroupchatWindow(self.account, self.room_jid,
+				password=self.password)
 		except GajimGeneralException:
 			pass
 
-- 
GitLab