improve function name; move it to where we keep those

This commit is contained in:
Nikos Kouremenos 2006-04-08 10:28:53 +00:00
parent c220fed809
commit 9e35ac7aeb
4 changed files with 18 additions and 15 deletions

View File

@ -190,8 +190,23 @@ def get_resource_from_jid(jid):
'''
def get_number_of_accounts():
'''returns the number of ALL accounts'''
return len(connections.keys())
def get_number_of_connected_accounts(accounts_list = None):
'''returns the number of CONNECTED accounts
you can optionally pass an accounts_list
and if you do those will be checked, else all will be checked'''
connected_accounts = 0
if accounts_list is None:
accounts = connections.keys()
else:
accounts = accounts_list
for acct in accounts:
if gajim.connections[acct].connected > 1:
connected_accounts = connected_accounts + 1
return connected_accounts
def get_transport_name_from_jid(jid, use_config_setting = True):
'''returns 'aim', 'gg', 'irc' etc
if JID is not from transport returns None'''

View File

@ -460,18 +460,6 @@ def get_xmpp_show(show):
return None
return show
def connected_accounts(account_list = None):
'''returns the number of connected accounts'''
connected_accounts = 0
if account_list is None:
accounts = gajim.connections.keys()
else:
accounts = account_list
for acct in accounts:
if gajim.connections[acct].connected > 1:
connected_accounts = connected_accounts + 1
return connected_accounts
def get_output_of_command(command):
try:
child_stdin, child_stdout = os.popen2(command)

View File

@ -667,7 +667,7 @@ class RosterWindow:
gc_sub_menu = gtk.Menu() # gc is always a submenu
join_gc_menuitem.set_submenu(gc_sub_menu)
connected_accounts = helpers.connected_accounts()
connected_accounts = gajim.get_number_of_connected_accounts()
if connected_accounts > 1: # 2 or more accounts? make submenus
add_sub_menu = gtk.Menu()
disco_sub_menu = gtk.Menu()
@ -1969,7 +1969,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
for acct in accounts:
if gajim.config.get_per('accounts', acct, 'sync_with_global_status'):
global_sync_accounts.append(acct)
global_sync_connected_accounts = helpers.connected_accounts(
global_sync_connected_accounts = gajim.get_number_of_connected_accounts(
global_sync_accounts)
for acct in accounts:
if not gajim.config.get_per('accounts', acct, 'sync_with_global_status'):

View File

@ -155,7 +155,7 @@ class Systray:
item.set_image(img)
sub_menu.append(item)
item.connect('activate', self.on_change_status_message_activate)
connected_accounts = helpers.connected_accounts()
connected_accounts = gajim.get_number_of_connected_accounts()
if connected_accounts < 1:
item.set_sensitive(False)