[evolution] evolution-addressbook-export: Add ESourceRegistry to ActionContext.



commit 361dd78922ab2332a576bb7695466387b021c97a
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Feb 25 15:28:18 2013 -0500

    evolution-addressbook-export: Add ESourceRegistry to ActionContext.

 .../evolution-addressbook-export-list-cards.c      |    7 +++----
 .../evolution-addressbook-export-list-folders.c    |    6 +++---
 addressbook/tools/evolution-addressbook-export.c   |    9 +++++----
 addressbook/tools/evolution-addressbook-export.h   |    8 ++++----
 4 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/addressbook/tools/evolution-addressbook-export-list-cards.c 
b/addressbook/tools/evolution-addressbook-export-list-cards.c
index a884e6e..86c5cb3 100644
--- a/addressbook/tools/evolution-addressbook-export-list-cards.c
+++ b/addressbook/tools/evolution-addressbook-export-list-cards.c
@@ -689,9 +689,9 @@ set_pre_defined_field (GSList **pre_defined_fields)
 }
 
 guint
-action_list_cards_init (ESourceRegistry *registry,
-                        ActionContext *p_actctx)
+action_list_cards_init (ActionContext *p_actctx)
 {
+       ESourceRegistry *registry;
        EClient *client;
        EBookClient *book_client;
        EBookQuery *query;
@@ -701,8 +701,7 @@ action_list_cards_init (ESourceRegistry *registry,
        gchar *query_str;
        GError *error = NULL;
 
-       g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FAILED);
-
+       registry = p_actctx->registry;
        uid = p_actctx->addressbook_source_uid;
 
        if (uid != NULL)
diff --git a/addressbook/tools/evolution-addressbook-export-list-folders.c 
b/addressbook/tools/evolution-addressbook-export-list-folders.c
index c1d2b41..946deb6 100644
--- a/addressbook/tools/evolution-addressbook-export-list-folders.c
+++ b/addressbook/tools/evolution-addressbook-export-list-folders.c
@@ -32,14 +32,14 @@
 #include "evolution-addressbook-export.h"
 
 guint
-action_list_folders_init (ESourceRegistry *registry,
-                          ActionContext *p_actctx)
+action_list_folders_init (ActionContext *p_actctx)
 {
+       ESourceRegistry *registry;
        GList *list, *iter;
        FILE *outputfile = NULL;
        const gchar *extension_name;
 
-       g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FAILED);
+       registry = p_actctx->registry;
 
        if (p_actctx->output_file != NULL) {
                if (!(outputfile = g_fopen (p_actctx->output_file, "w"))) {
diff --git a/addressbook/tools/evolution-addressbook-export.c 
b/addressbook/tools/evolution-addressbook-export.c
index 428877b..685fab2 100644
--- a/addressbook/tools/evolution-addressbook-export.c
+++ b/addressbook/tools/evolution-addressbook-export.c
@@ -74,7 +74,6 @@ gint
 main (gint argc,
       gchar **argv)
 {
-       ESourceRegistry *registry;
        ActionContext actctx;
        GOptionContext *context;
        GError *error = NULL;
@@ -120,7 +119,7 @@ main (gint argc,
                exit (-1);
        }
 
-       registry = e_source_registry_new_sync (NULL, &error);
+       actctx.registry = e_source_registry_new_sync (NULL, &error);
        if (error != NULL) {
                g_printerr ("%s\n", error->message);
                g_error_free (error);
@@ -162,7 +161,7 @@ main (gint argc,
                } else {
                        actctx.output_file = g_strdup (opt_output_file);
                }
-               action_list_folders_init (registry, &actctx);
+               action_list_folders_init (&actctx);
 
        } else if (current_action == ACTION_LIST_CARDS) {
                actctx.action_type = current_action;
@@ -176,13 +175,15 @@ main (gint argc,
                actctx.addressbook_source_uid =
                        g_strdup (opt_addressbook_source_uid);
 
-               action_list_cards_init (registry, &actctx);
+               action_list_cards_init (&actctx);
 
        } else {
                g_warning (_("Unhandled error"));
                exit (-1);
        }
 
+       g_object_unref (actctx.registry);
+
        /*FIXME:should free actctx's some gchar * field, such as output_file! but since the program will end, 
so that will not cause mem leak.  */
 
        return 0;
diff --git a/addressbook/tools/evolution-addressbook-export.h 
b/addressbook/tools/evolution-addressbook-export.h
index ca78eb8..28168c4 100644
--- a/addressbook/tools/evolution-addressbook-export.h
+++ b/addressbook/tools/evolution-addressbook-export.h
@@ -40,6 +40,8 @@ G_BEGIN_DECLS
 struct _ActionContext {
 
        guint action_type;
+
+       ESourceRegistry *registry;
        gchar *output_file;
 
        /* for cards only */
@@ -51,12 +53,10 @@ struct _ActionContext {
 typedef struct _ActionContext ActionContext;
 
 /* action_list_folders */
-guint          action_list_folders_init        (ESourceRegistry *registry,
-                                                ActionContext *p_actctx);
+guint          action_list_folders_init        (ActionContext *p_actctx);
 
 /*action list cards*/
-guint          action_list_cards_init          (ESourceRegistry *registry,
-                                                ActionContext *p_actctx);
+guint          action_list_cards_init          (ActionContext *p_actctx);
 
 G_END_DECLS
 


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