diff --git a/src/common/gajim.py b/src/common/gajim.py index f76addcf6..92789f711 100644 --- a/src/common/gajim.py +++ b/src/common/gajim.py @@ -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''' diff --git a/src/common/helpers.py b/src/common/helpers.py index d8bbec5fe..a50b4c25f 100644 --- a/src/common/helpers.py +++ b/src/common/helpers.py @@ -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) diff --git a/src/roster_window.py b/src/roster_window.py index 4719bb08d..181370b1f 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -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'): diff --git a/src/systray.py b/src/systray.py index 0abc13cc1..1da35d2b9 100644 --- a/src/systray.py +++ b/src/systray.py @@ -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)