[empathy/mc5] Return TRUE if we imported any mc4 accounts



commit afd7de0052654752aa60edc8dddfd628eaa49ce6
Author: Sjoerd Simons <sjoerd simons collabora co uk>
Date:   Sun Aug 23 18:24:46 2009 +0100

    Return TRUE if we imported any mc4 accounts

 src/empathy-import-mc4-accounts.c |   30 +++++++++++++++++++-----------
 src/empathy-import-mc4-accounts.h |    2 +-
 2 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c
index 614c5cb..5425b35 100644
--- a/src/empathy-import-mc4-accounts.c
+++ b/src/empathy-import-mc4-accounts.c
@@ -283,7 +283,7 @@ _recurse_account (GSList *entries, EmpathyAccountSettings *settings,
     }
 }
 
-static void
+static gboolean
 import_one_account (const char *path,
   EmpathyConnectionManagers *managers,
   GConfClient *client)
@@ -298,6 +298,7 @@ import_one_account (const char *path,
   gchar *display_name;
   gchar *key;
   gboolean enabled = FALSE;
+  gboolean ret = FALSE;
 
   DEBUG ("Starting import of %s (%s)", path, account_name);
 
@@ -350,12 +351,15 @@ import_one_account (const char *path,
   g_free (key);
   empathy_account_settings_apply_async (settings,
           _create_account_cb, GINT_TO_POINTER (enabled));
+  ret = TRUE;
+
 out:
   g_free (protocol);
   g_free (profile);
   g_slist_free (entries);
   g_free (account_name);
-  return;
+
+  return ret;
 
 failed:
   DEBUG ("Failed to import %s", path);
@@ -364,15 +368,17 @@ failed:
   goto out;
 }
 
-void
+gboolean
 empathy_import_mc4_accounts (EmpathyConnectionManagers *managers)
 {
   GConfClient *client;
   GError *error = NULL;
-  GSList *dir, *dirs;
+  GSList *dir, *dirs = NULL;
   gboolean imported_mc4_accounts;
+  gboolean imported = FALSE;
 
-  g_return_if_fail (empathy_connection_managers_is_ready (managers));
+  g_return_val_if_fail (empathy_connection_managers_is_ready (managers),
+    FALSE);
 
   client = gconf_client_get_default ();
 
@@ -384,14 +390,13 @@ empathy_import_mc4_accounts (EmpathyConnectionManagers *managers)
       DEBUG ("Failed to get import_mc4_accounts key: %s\n", error->message);
       g_clear_error (&error);
       g_object_unref (client);
-      return;
+      goto out;
     }
 
   if (imported_mc4_accounts)
     {
       DEBUG ("Mc4 accounts already imported");
-      g_object_unref (client);
-      return;
+      goto out;
     }
 
   DEBUG ("MC 4 accounts are going to be imported\n");
@@ -404,15 +409,15 @@ empathy_import_mc4_accounts (EmpathyConnectionManagers *managers)
           error->message);
       g_clear_error (&error);
       g_object_unref (client);
-      return;
+      goto out;
     }
 
   for (dir = dirs; NULL != dir; dir = dir->next)
     {
-      import_one_account ((gchar *)dir->data, managers, client);
+      if (import_one_account ((gchar *)dir->data, managers, client))
+        imported = TRUE;
       g_free (dir->data);
     }
-  g_slist_free (dirs);
 
   gconf_client_set_bool (client,
       IMPORTED_MC4_ACCOUNTS, TRUE, &error);
@@ -423,5 +428,8 @@ empathy_import_mc4_accounts (EmpathyConnectionManagers *managers)
       g_clear_error (&error);
     }
 
+out:
+  g_slist_free (dirs);
   g_object_unref (client);
+  return imported;
 }
diff --git a/src/empathy-import-mc4-accounts.h b/src/empathy-import-mc4-accounts.h
index e5392db..c30b4e5 100644
--- a/src/empathy-import-mc4-accounts.h
+++ b/src/empathy-import-mc4-accounts.h
@@ -26,7 +26,7 @@ G_BEGIN_DECLS
 
 #include <libempathy/empathy-connection-managers.h>
 
-void empathy_import_mc4_accounts (EmpathyConnectionManagers *managers);
+gboolean empathy_import_mc4_accounts (EmpathyConnectionManagers *managers);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]