add autoconnect_as feature to autoconnect as away or invisible

This commit is contained in:
Yann Leboulanger 2008-03-30 11:50:59 +00:00
parent 1c313ed242
commit a6e06b3bca
2 changed files with 15 additions and 8 deletions

View File

@ -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 ],

View File

@ -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):