diff --git a/src/common/config.py b/src/common/config.py index c3202afb0..a3c90176b 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -274,6 +274,7 @@ 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 ], diff --git a/src/gajim.py b/src/gajim.py index 173fdfef8..60ff0766b 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -2370,18 +2370,24 @@ class Interface: def autoconnect(self): '''auto connect at startup''' - ask_message = False + # dict of account that want to connect sorted by status + shows = {} for a in gajim.connections: if gajim.config.get_per('accounts', a, 'autoconnect'): - ask_message = True + 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) break - if ask_message: - message = self.roster.get_status_message('online') + for show in shows: + message = self.roster.get_status_message(show) if message == None: - return - for a in gajim.connections: - if gajim.config.get_per('accounts', a, 'autoconnect'): - self.roster.send_status(a, 'online', message) + continue + for a in shows[show]: + self.roster.send_status(a, show, message) return False def show_systray(self):