]> git.0d.be Git - empathy.git/commitdiff
Add empathy_get_account_for_connection function.
authorJonny Lamb <jonnylamb@gnome.org>
Sat, 24 Oct 2009 00:20:25 +0000 (01:20 +0100)
committerJonny Lamb <jonnylamb@gnome.org>
Sat, 24 Oct 2009 13:46:39 +0000 (14:46 +0100)
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
libempathy/empathy-utils.c
libempathy/empathy-utils.h

index a0cb4111e0d24bc0ce11f895db723b5d61fd5ff8..dacc1d88c883b53af7a3c06c65e1b396ac5f4495 100644 (file)
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * Copyright (C) 2003-2007 Imendio AB
  * Copyright (C) 2007-2008 Collabora Ltd.
@@ -32,6 +31,8 @@
 #include <glib/gi18n-lib.h>
 
 #include <libxml/uri.h>
+
+#include <telepathy-glib/account-manager.h>
 #include <telepathy-glib/connection.h>
 #include <telepathy-glib/channel.h>
 #include <telepathy-glib/dbus.h>
@@ -490,3 +491,35 @@ empathy_signal_connect_weak (gpointer instance,
   g_object_weak_ref (instance_obj, instance_destroyed_cb, ctx);
   g_object_weak_ref (user_data, user_data_destroyed_cb, ctx);
 }
+
+/* Note: this function depends on the account manager having its core feature
+ * prepared. */
+TpAccount *
+empathy_get_account_for_connection (TpConnection *connection)
+{
+  TpAccountManager *manager;
+  TpAccount *account = NULL;
+  GList *accounts, *l;
+
+  manager = tp_account_manager_dup ();
+
+  /* FIXME: assumes account manager is prepared */
+
+  accounts = tp_account_manager_get_valid_accounts (manager);
+
+  for (l = accounts; l != NULL; l = l->next)
+    {
+      TpAccount *a = l->data;
+
+      if (tp_account_get_connection (a) == connection)
+        {
+          account = a;
+          break;
+        }
+    }
+
+  g_list_free (accounts);
+  g_object_unref (manager);
+
+  return account;
+}
index d62e096ae4f13c6871014d657573355122522cb8..13093b8a1df1256ed0fa9407ca2965b054079b98 100644 (file)
@@ -85,6 +85,8 @@ void empathy_signal_connect_weak (gpointer instance,
     GCallback c_handler,
     GObject *user_data);
 
+TpAccount * empathy_get_account_for_connection (TpConnection *connection);
+
 G_END_DECLS
 
 #endif /*  __EMPATHY_UTILS_H__ */