From 02749057938465e16744b0c45c642c1547adb0e0 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 22 Jul 2005 21:27:04 +0000 Subject: [PATCH] when we go autoaway, we save our status message so we restore it when we come back online --- src/common/gajim.py | 1 + src/config.py | 5 +++++ src/gajim.py | 8 +++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common/gajim.py b/src/common/gajim.py index d821e6f72..f330ddf28 100644 --- a/src/common/gajim.py +++ b/src/common/gajim.py @@ -59,6 +59,7 @@ sleeper_state = {} # whether we pass auto away / xa or not #'online': online and use sleeper #'autoaway': autoaway and use sleeper #'autoxa': autoxa and use sleeper +status_before_autoaway = {} def get_fjid_from_nick(room_jid, nick): diff --git a/src/config.py b/src/config.py index 8611be6f0..f3a4c23fd 100644 --- a/src/config.py +++ b/src/config.py @@ -1175,6 +1175,8 @@ _('To change the account name, you must be disconnected.')).get_response() gajim.encrypted_chats[name] = gajim.encrypted_chats[self.account] gajim.last_message_time[name] = \ gajim.last_message_time[self.account] + gajim.status_before_autoaway[name] = \ + gajim.status_before_autoaway[self.account] #upgrade account variable in opened windows for kind in ['infos', 'chats', 'gc', 'gc_config']: @@ -1198,6 +1200,7 @@ _('To change the account name, you must be disconnected.')).get_response() del gajim.sleeper_state[self.account] del gajim.encrypted_chats[self.account] del gajim.last_message_time[self.account] + del gajim.status_before_autoaway[self.account] gajim.connections[self.account].name = name gajim.connections[name] = gajim.connections[self.account] del gajim.connections[self.account] @@ -1249,6 +1252,7 @@ _('To change the account name, you must be disconnected.')).get_response() gajim.sleeper_state[name] = 'off' gajim.encrypted_chats[name] = [] gajim.last_message_time[name] = {} + gajim.status_before_autoaway[name] = '' #refresh accounts window if self.plugin.windows.has_key('accounts'): self.plugin.windows['accounts'].init_accounts() @@ -2344,6 +2348,7 @@ class RemoveAccountWindow: del gajim.sleeper_state[self.account] del gajim.encrypted_chats[self.account] del gajim.last_message_time[self.account] + del gajim.status_before_autoaway[self.account] self.plugin.roster.draw_roster() if self.plugin.windows.has_key('accounts'): self.plugin.windows['accounts'].init_accounts() diff --git a/src/gajim.py b/src/gajim.py index e4fa39f57..919b1697a 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -566,6 +566,7 @@ class Interface: gajim.sleeper_state[name] = 'off' gajim.encrypted_chats[name] = [] gajim.last_message_time[name] = {} + gajim.status_before_autoaway[name] = {} if self.windows.has_key('accounts'): self.windows['accounts'].init_accounts() self.roster.draw_roster() @@ -704,11 +705,15 @@ class Interface: gajim.sleeper_state[account] == 'autoaway' or \ gajim.sleeper_state[account] == 'autoxa': #we go online - self.roster.send_status(account, 'online', 'Online') + self.roster.send_status(account, 'online', + gajim.status_before_autoaway[account]) gajim.sleeper_state[account] = 'online' elif state == common.sleepy.STATE_AWAY and \ gajim.sleeper_state[account] == 'online' and \ gajim.config.get('autoaway'): + #we save out online status + gajim.status_before_autoaway[account] = \ + gajim.connections[account].status #we go away self.roster.send_status(account, 'away', 'auto away (idle)') gajim.sleeper_state[account] = 'autoaway' @@ -953,6 +958,7 @@ class Interface: gajim.sleeper_state[a] = 0 gajim.encrypted_chats[a] = [] gajim.last_message_time[a] = {} + gajim.status_before_autoaway[a] = '' self.roster = roster_window.RosterWindow(self) if gajim.config.get('use_dbus'):