From 1fabaa884493752cb99fc92a92b6da652811c130 Mon Sep 17 00:00:00 2001 From: js Date: Wed, 16 Jul 2008 15:50:51 +0000 Subject: [PATCH] Keep last status on autoconnect. --- src/common/config.py | 3 ++- src/gajim.py | 19 +++++-------------- src/roster_window.py | 5 +++++ 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/common/config.py b/src/common/config.py index fd84606ef..eba219f93 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -270,7 +270,6 @@ class Config: 'autopriority_dnd': [ opt_int, 20], 'autopriority_invisible': [ opt_int, 10], 'autoconnect': [ opt_bool, False, '', True ], - 'autoconnect_as': [ opt_str, 'online', _('Status used to autoconnect as. Can be online, chat, away, xa, dnd, invisible.'), True ], 'autoreconnect': [ opt_bool, True ], 'active': [ opt_bool, True], 'proxy': [ opt_str, '', '', True ], @@ -308,6 +307,8 @@ class Config: 'msgwin-height': [opt_int, 440], 'listen_to_network_manager' : [opt_bool, True], 'is_zeroconf': [opt_bool, False], + 'last_status': [opt_str, 'online'], + 'last_status_msg': [opt_str, ''], 'zeroconf_first_name': [ opt_str, '', '', True ], 'zeroconf_last_name': [ opt_str, '', '', True ], 'zeroconf_jabber_id': [ opt_str, '', '', True ], diff --git a/src/gajim.py b/src/gajim.py index 2cc86e481..f6f9d6f9c 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -2706,22 +2706,13 @@ class Interface: def autoconnect(self): '''auto connect at startup''' # dict of account that want to connect sorted by status - shows = {} for a in gajim.connections: if gajim.config.get_per('accounts', a, 'autoconnect'): - show = gajim.config.get_per('accounts', a, 'autoconnect_as') - if not show in gajim.SHOW_LIST: - continue - if not show in shows: - shows[show] = [a] - else: - shows[show].append(a) - for show in shows: - message = self.roster.get_status_message(show) - if message is None: - continue - for a in shows[show]: - self.roster.send_status(a, show, message) + self.roster.send_status(a, + gajim.config.get_per('accounts', a, + 'last_status'), + gajim.config.get_per('accounts', a, + 'last_status_msg')) return False def show_systray(self): diff --git a/src/roster_window.py b/src/roster_window.py index 7d12086fc..3a65f2fd6 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -1726,6 +1726,11 @@ class RosterWindow: def send_status(self, account, status, txt, auto = False, to = None): child_iterA = self._get_account_iter(account, self.model) if status != 'offline': + if to is None: + gajim.config.set_per('accounts', account, + 'last_status', status) + gajim.config.set_per('accounts', account, + 'last_status_msg', txt) if gajim.connections[account].connected < 2: self.set_connecting_state(account)