diff --git a/src/common/config.py b/src/common/config.py index fcdb5d236..12a3684fc 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -277,7 +277,8 @@ class Config: 'autopriority_dnd': [ opt_int, 20], 'autopriority_invisible': [ opt_int, 10], 'autoconnect': [ opt_bool, False, '', True ], - 'dont_restore_last_status': [ opt_bool, False, _('If enabled, don\'t restore the last status that was used.') ], + 'autoconnect_as': [ opt_str, 'online', _('Status used to autoconnect as. Can be online, chat, away, xa, dnd, invisible. NOTE: this option is used only if restore_last_status is disabled'), True ], + 'restore_last_status': [ opt_bool, False, _('If enabled, restore the last status that was used.') ], 'autoreconnect': [ opt_bool, True ], 'active': [ opt_bool, True], 'proxy': [ opt_str, '', '', True ], diff --git a/src/gajim.py b/src/gajim.py index bbe968e41..c1d00f390 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -2775,18 +2775,27 @@ 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'): - if not gajim.config.get_per('accounts', a, - 'dont_restore_last_status'): - self.roster.send_status(a, - gajim.config.get_per('accounts', - a, 'last_status'), - helpers.from_one_line( - gajim.config.get_per('accounts', - a, 'last_status_msg'))) + if gajim.config.get_per('accounts', a, 'restore_last_status'): + self.roster.send_status(a, gajim.config.get_per('accounts', a, + 'last_status'), helpers.from_one_line(gajim.config.get_per( + 'accounts', a, 'last_status_msg'))) + continue + 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: - self.roster.send_status(a, 'online', '') + 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) return False def show_systray(self): diff --git a/src/roster_window.py b/src/roster_window.py index 225738df5..9aa993c37 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -1936,10 +1936,8 @@ class RosterWindow: 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', + gajim.config.set_per('accounts', account, 'last_status', status) + gajim.config.set_per('accounts', account, 'last_status_msg', helpers.to_one_line(txt)) if gajim.connections[account].connected < 2: self.set_connecting_state(account)