aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy/empathy-utils.c35
-rw-r--r--libempathy/empathy-utils.h2
2 files changed, 36 insertions, 1 deletions
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index a0cb4111e..dacc1d88c 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -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;
+}
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index d62e096ae..13093b8a1 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -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__ */