[empathy: 3/59] Add empathy_get_account_for_connection function.
- From: Jonny Lamb <jonnylamb src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [empathy: 3/59] Add empathy_get_account_for_connection function.
- Date: Mon, 2 Nov 2009 13:37:58 +0000 (UTC)
commit 25fe1de65572fecd8b369f4c01df32e47d5afc28
Author: Jonny Lamb <jonnylamb gnome org>
Date: Sat Oct 24 01:20:25 2009 +0100
Add empathy_get_account_for_connection function.
Signed-off-by: Jonny Lamb <jonnylamb gnome org>
libempathy/empathy-utils.c | 35 ++++++++++++++++++++++++++++++++++-
libempathy/empathy-utils.h | 2 ++
2 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index a0cb411..dacc1d8 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 d62e096..13093b8 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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]