aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-utils.c
diff options
context:
space:
mode:
authorJonny Lamb <jonnylamb@gnome.org>2009-10-24 08:20:25 +0800
committerJonny Lamb <jonnylamb@gnome.org>2009-10-24 21:46:39 +0800
commit25fe1de65572fecd8b369f4c01df32e47d5afc28 (patch)
tree1db82cd834c4dd4a916c05a41e220da05be06aa4 /libempathy/empathy-utils.c
parent1d66bb9bffcb1e9d6eb034be4bf7c5eaea839a5d (diff)
downloadgsoc2013-empathy-25fe1de65572fecd8b369f4c01df32e47d5afc28.tar.gz
gsoc2013-empathy-25fe1de65572fecd8b369f4c01df32e47d5afc28.tar.zst
gsoc2013-empathy-25fe1de65572fecd8b369f4c01df32e47d5afc28.zip
Add empathy_get_account_for_connection function.
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
Diffstat (limited to 'libempathy/empathy-utils.c')
-rw-r--r--libempathy/empathy-utils.c35
1 files changed, 34 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;
+}