aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-07-05 23:19:59 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-07-06 17:49:04 +0800
commit7445fd6d08294399972dd0c2c808d9aabfc11b20 (patch)
tree697f76c9a250d631a55a888bd3ff1290032fa818
parent2d517a8bf5f8048a83d753fb0977d4949cbdeb7a (diff)
downloadgsoc2013-empathy-7445fd6d08294399972dd0c2c808d9aabfc11b20.tar
gsoc2013-empathy-7445fd6d08294399972dd0c2c808d9aabfc11b20.tar.gz
gsoc2013-empathy-7445fd6d08294399972dd0c2c808d9aabfc11b20.tar.bz2
gsoc2013-empathy-7445fd6d08294399972dd0c2c808d9aabfc11b20.tar.lz
gsoc2013-empathy-7445fd6d08294399972dd0c2c808d9aabfc11b20.tar.xz
gsoc2013-empathy-7445fd6d08294399972dd0c2c808d9aabfc11b20.tar.zst
gsoc2013-empathy-7445fd6d08294399972dd0c2c808d9aabfc11b20.zip
Add api to create accounts, by cm and proto name
-rw-r--r--libempathy/empathy-account-manager.c42
-rw-r--r--libempathy/empathy-account-manager.h8
-rw-r--r--tests/check-empathy-helpers.c3
3 files changed, 50 insertions, 3 deletions
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c
index fd8a21b1d..0d09ec5f0 100644
--- a/libempathy/empathy-account-manager.c
+++ b/libempathy/empathy-account-manager.c
@@ -22,6 +22,7 @@
#include "config.h"
#include <libmissioncontrol/mc-account-monitor.h>
+#include <telepathy-glib/util.h>
#include "empathy-account-manager.h"
#include "empathy-account-priv.h"
@@ -582,7 +583,7 @@ empathy_account_manager_dup_singleton (void)
}
EmpathyAccount *
-empathy_account_manager_create (EmpathyAccountManager *manager,
+empathy_account_manager_create_by_profile (EmpathyAccountManager *manager,
McProfile *profile)
{
McAccount *mc_account = mc_account_create (profile);
@@ -591,6 +592,45 @@ empathy_account_manager_create (EmpathyAccountManager *manager,
mc_account));
}
+EmpathyAccount *
+empathy_account_manager_create (EmpathyAccountManager *manager,
+ const gchar *connection_manager,
+ const gchar *protocol,
+ const gchar *display_name)
+{
+ McProfile *profile;
+ gboolean found;
+ GList *profiles, *l;
+ EmpathyAccount *result = NULL;
+
+ profiles = mc_profiles_list_by_protocol (protocol);
+
+ for (l = profiles; l != NULL; l = g_list_next (l)) {
+ McProtocol *protocol;
+ McManager *cm;
+
+ profile = MC_PROFILE (l->data);
+
+ protocol = mc_profile_get_protocol (profile);
+ cm = mc_protocol_get_manager (protocol);
+ found = !tp_strdiff (mc_manager_get_unique_name (cm),
+ connection_manager);
+
+ g_object_unref (protocol);
+ g_object_unref (manager);
+
+ if (found) {
+ result = empathy_account_manager_create_by_profile (manager, profile);
+ empathy_account_set_display_name (result, display_name);
+ break;
+ }
+ }
+
+ mc_profiles_free_list (profiles);
+
+ return result;
+}
+
int
empathy_account_manager_get_connected_accounts (EmpathyAccountManager *manager)
{
diff --git a/libempathy/empathy-account-manager.h b/libempathy/empathy-account-manager.h
index b04571ff8..2d77610fb 100644
--- a/libempathy/empathy-account-manager.h
+++ b/libempathy/empathy-account-manager.h
@@ -52,7 +52,13 @@ GType empathy_account_manager_get_type (void);
/* public methods */
EmpathyAccountManager * empathy_account_manager_dup_singleton (void);
-EmpathyAccount * empathy_account_manager_create
+EmpathyAccount * empathy_account_manager_create (
+ EmpathyAccountManager *manager,
+ const gchar *connection_manager,
+ const gchar *protocol,
+ const gchar *display_name);
+
+EmpathyAccount * empathy_account_manager_create_by_profile
(EmpathyAccountManager *manager,
McProfile *profile);
int empathy_account_manager_get_connected_accounts
diff --git a/tests/check-empathy-helpers.c b/tests/check-empathy-helpers.c
index c77cf9b75..fc6f04439 100644
--- a/tests/check-empathy-helpers.c
+++ b/tests/check-empathy-helpers.c
@@ -79,7 +79,8 @@ get_test_account (void)
if (g_list_length (accounts) == 0)
{
/* need to create a test account */
- account = empathy_account_manager_create (account_manager, profile);
+ account = empathy_account_manager_create_by_profile (account_manager,
+ profile);
}
else
{