[empathy: 4/59] Add empathy_account_manager_get_accounts_connected function.



commit bb173d8e042303ab7a0d9ec15c7a07f752cde200
Author: Jonny Lamb <jonnylamb gnome org>
Date:   Sat Oct 24 14:47:04 2009 +0100

    Add empathy_account_manager_get_accounts_connected function.
    
    Signed-off-by: Jonny Lamb <jonnylamb gnome org>

 libempathy/empathy-utils.c |   34 ++++++++++++++++++++++++++++++++++
 libempathy/empathy-utils.h |    2 ++
 2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index dacc1d8..eb080c2 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -523,3 +523,37 @@ empathy_get_account_for_connection (TpConnection *connection)
 
   return account;
 }
+
+gboolean
+empathy_account_manager_get_accounts_connected (gboolean *connecting)
+{
+  TpAccountManager *manager;
+  GList *accounts, *l;
+  gboolean out_connecting = FALSE;
+  gboolean out_connected = FALSE;
+
+  manager = tp_account_manager_dup ();
+  accounts = tp_account_manager_get_valid_accounts (manager);
+
+  for (l = accounts; l != NULL; l = l->next)
+    {
+      TpConnectionStatus s = tp_account_get_connection_status (
+          TP_ACCOUNT (l->data), NULL);
+
+      if (s == TP_CONNECTION_STATUS_CONNECTING)
+        out_connecting = TRUE;
+      else if (s == TP_CONNECTION_STATUS_CONNECTED)
+        out_connected = TRUE;
+
+      if (out_connecting && out_connected)
+        break;
+    }
+
+  g_list_free (accounts);
+  g_object_unref (manager);
+
+  if (connecting != NULL)
+    *connecting = out_connecting;
+
+  return out_connected;
+}
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index 13093b8..97e5e85 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -87,6 +87,8 @@ void empathy_signal_connect_weak (gpointer instance,
 
 TpAccount * empathy_get_account_for_connection (TpConnection *connection);
 
+gboolean empathy_account_manager_get_accounts_connected (gboolean *connecting);
+
 G_END_DECLS
 
 #endif /*  __EMPATHY_UTILS_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]