encrytion state is keeped even if we close the chat window

This commit is contained in:
Yann Leboulanger 2005-07-02 11:06:02 +00:00
parent 004094b10f
commit 210d989525
4 changed files with 15 additions and 5 deletions

View File

@ -40,3 +40,5 @@ if LANG:
LANG = LANG[:2] # en, fr, el etc..
else:
LANG = 'en'
encrypted_chats = {} # list of encrypted chats {acct1: [jid1, jid2], ..}

View File

@ -1163,6 +1163,7 @@ _('To change the account name, it must be disconnected.')).get_response()
self.plugin.roster.to_be_removed[self.account]
self.plugin.sleeper_state[name] = \
self.plugin.sleeper_state[self.account]
gajim.encrypted_chats[name] = gajim.encrypted_chats[self.account]
#upgrade account variable in opened windows
for kind in ['infos', 'chats', 'gc', 'gc_config']:
for j in self.plugin.windows[name][kind]:
@ -1178,6 +1179,7 @@ _('To change the account name, it must be disconnected.')).get_response()
del self.plugin.roster.groups[self.account]
del self.plugin.roster.contacts[self.account]
del self.plugin.sleeper_state[self.account]
del gajim.encrypted_chats[self.account]
gajim.connections[self.account].name = name
gajim.connections[name] = gajim.connections[self.account]
del gajim.connections[self.account]
@ -1227,6 +1229,7 @@ _('To change the account name, it must be disconnected.')).get_response()
self.plugin.nicks[name] = config['name']
self.plugin.allow_notifications[name] = False
self.plugin.sleeper_state[name] = 0
gajim.encrypted_chats[name] = []
#refresh accounts window
if self.plugin.windows.has_key('accounts'):
self.plugin.windows['accounts'].init_accounts()

View File

@ -508,6 +508,7 @@ class Interface:
self.roster.newly_added[name] = []
self.roster.to_be_removed[name] = []
self.sleeper_state[name] = 0
gajim.encrypted_chats[name] = []
if self.windows.has_key('accounts'):
self.windows['accounts'].init_accounts()
self.roster.draw_roster()
@ -844,6 +845,7 @@ class Interface:
#1:online and use sleeper
#2:autoaway and use sleeper
#3:autoxa and use sleeper
gajim.encrypted_chats[a] = []
self.roster = roster_window.RosterWindow(self)
path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png')

View File

@ -44,7 +44,6 @@ class TabbedChatWindow(chat.Chat):
def __init__(self, user, plugin, account):
chat.Chat.__init__(self, plugin, account, 'tabbed_chat_window')
self.users = {}
self.encrypted = {}
self.new_user(user)
self.show_title()
self.xml.signal_connect('on_tabbed_chat_window_destroy',
@ -238,7 +237,9 @@ class TabbedChatWindow(chat.Chat):
self.xmls[user.jid] = gtk.glade.XML(GTKGUI_GLADE, 'chats_vbox', APP)
self.childs[user.jid] = self.xmls[user.jid].get_widget('chats_vbox')
self.users[user.jid] = user
self.encrypted[user.jid] = False
if user.jid in gajim.encrypted_chats[self.account]:
self.xmls[user.jid].get_widget('gpg_togglebutton').set_active(True)
xm = gtk.glade.XML(GTKGUI_GLADE, 'tabbed_chat_popup_menu', APP)
xm.signal_autoconnect(self)
@ -378,13 +379,15 @@ class TabbedChatWindow(chat.Chat):
kind = 'status'
name = ''
else:
if encrypted and not self.encrypted[jid]:
ec = gajim.encrypted_chats[self.account]
if encrypted and jid not in ec:
chat.Chat.print_conversation_line(self, 'Encryption enabled', jid,
'status', '', tim)
if not encrypted and self.encrypted[jid]:
ec.append(jid)
if not encrypted and jid in ec:
chat.Chat.print_conversation_line(self, 'Encryption disabled', jid,
'status', '', tim)
self.encrypted[jid] = encrypted
ec.remove(jid)
self.xmls[jid].get_widget('gpg_togglebutton').set_active(encrypted)
if contact:
kind = 'outgoing'