]> git.0d.be Git - empathy.git/commitdiff
Add api to create accounts, by cm and proto name
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Sun, 5 Jul 2009 15:19:59 +0000 (16:19 +0100)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Mon, 6 Jul 2009 09:49:04 +0000 (10:49 +0100)
libempathy/empathy-account-manager.c
libempathy/empathy-account-manager.h
tests/check-empathy-helpers.c

index fd8a21b1d5c95c9353e0c4bed622c0948ca6ed9f..0d09ec5f0819d80e3f029b687be91e6c0741d1d5 100644 (file)
@@ -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)
 {
index b04571ff81c8a3e5f4574b3d94f99f9e1f198eaf..2d77610fb73e6ef0ec2c8f5ddf113e0572f16c8e 100644 (file)
@@ -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
index c77cf9b75677888e9ac89540d9ad0e5126a020fa..fc6f04439ac8552f1e1a6a2efef7e9a233180305 100644 (file)
@@ -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
     {