[evolution] evolution-addressbook-export: Remove --async option.



commit b31f2ad72010e397fa7514b4d61f2adf716f1038
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Feb 25 15:03:11 2013 -0500

    evolution-addressbook-export: Remove --async option.
    
    Pointless option, does the same as "evolution-addressbook-export &".

 .../evolution-addressbook-export-list-cards.c      |  107 +++-----------------
 addressbook/tools/evolution-addressbook-export.c   |   33 +------
 addressbook/tools/evolution-addressbook-export.h   |    2 -
 3 files changed, 15 insertions(+), 127 deletions(-)
---
diff --git a/addressbook/tools/evolution-addressbook-export-list-cards.c 
b/addressbook/tools/evolution-addressbook-export-list-cards.c
index eee2fe9..89fd758 100644
--- a/addressbook/tools/evolution-addressbook-export-list-cards.c
+++ b/addressbook/tools/evolution-addressbook-export-list-cards.c
@@ -244,7 +244,6 @@ gchar *delivery_address_get_sub_field (const EContactAddress * delivery_address,
 gchar *check_null_pointer (gchar * orig);
 gchar *escape_string (gchar * orig);
 gint output_n_cards_file (FILE * outputfile, GSList *contacts, gint size, gint begin_no, CARD_FORMAT format);
-static void fork_to_background (void);
 void set_pre_defined_field (GSList ** pre_defined_fields);
 
 /* function declarations*/
@@ -603,37 +602,12 @@ output_n_cards_file (FILE *outputfile,
 }
 
 static void
-fork_to_background (void)
-{
-#ifndef G_OS_WIN32
-       pid_t pid;
-       pid = fork ();
-       if (pid == -1) {
-               /* ouch, fork() failed */
-               perror ("fork");
-               exit (-1);
-       } else if (pid == 0) {
-               /* child */
-               /*contunue */
-
-       } else {
-               /* parent exit,  note the use of _exit() instead of exit() */
-               _exit (-1);
-       }
-#endif
-}
-
-static void
 action_list_cards (GSList *contacts,
                    ActionContext *p_actctx)
 {
        FILE *outputfile;
        long length;
-       gint IsFirstOne;
-       gint series_no;
-       gchar *file_series_name;
        CARD_FORMAT format;
-       gint size;
 
        length = g_slist_length (contacts);
 
@@ -643,78 +617,25 @@ action_list_cards (GSList *contacts,
                exit (-1);
        }
 
-       if (p_actctx->action_list_cards.async_mode == FALSE) {  /* normal mode */
-
-               if (p_actctx->action_list_cards.output_file == NULL) {
-                       outputfile = stdout;
-               } else {
-                       /* fopen output file */
-                       if (!(outputfile = g_fopen (p_actctx->action_list_cards.output_file, "w"))) {
-                               g_warning (_("Can not open file"));
-                               exit (-1);
-                       }
-               }
-
-               if (p_actctx->action_list_cards.IsVCard == TRUE)
-                       format = CARD_FORMAT_VCARD;
-               else
-                       format = CARD_FORMAT_CSV;
-
-               output_n_cards_file (outputfile, contacts, length, 0, format);
-
-               if (p_actctx->action_list_cards.output_file != NULL) {
-                       fclose (outputfile);
+       if (p_actctx->action_list_cards.output_file == NULL) {
+               outputfile = stdout;
+       } else {
+               /* fopen output file */
+               if (!(outputfile = g_fopen (p_actctx->action_list_cards.output_file, "w"))) {
+                       g_warning (_("Can not open file"));
+                       exit (-1);
                }
        }
 
-       /*async mode */
-       else {
-
-               size = p_actctx->action_list_cards.file_size;
-               IsFirstOne = TRUE;
-               series_no = 0;
-
-               do {
-                       /* whether it is the last file */
-                       if ((series_no + 1) * size >= length) { /*last one */
-                               file_series_name = g_strdup_printf ("%s.end", 
p_actctx->action_list_cards.output_file);
-
-                       } else {        /*next one */
-                               file_series_name =
-                                       g_strdup_printf ("%s.%04d", p_actctx->action_list_cards.output_file, 
series_no);
-                       }
-
-                       if (!(outputfile = g_fopen (file_series_name, "w"))) {
-                               g_warning (_("Can not open file"));
-                               exit (-1);
-                       }
-
-                       if (p_actctx->action_list_cards.IsVCard == TRUE)
-                               format = CARD_FORMAT_VCARD;
-                       else
-                               format = CARD_FORMAT_CSV;
-                       output_n_cards_file (outputfile, contacts, size, series_no * size, format);
-
-                       fclose (outputfile);
+       if (p_actctx->action_list_cards.IsVCard == TRUE)
+               format = CARD_FORMAT_VCARD;
+       else
+               format = CARD_FORMAT_CSV;
 
-                       series_no++;
+       output_n_cards_file (outputfile, contacts, length, 0, format);
 
-                       if (IsFirstOne == TRUE) {
-                               fork_to_background ();
-                               IsFirstOne = FALSE;
-                       }
-
-               }
-               while (series_no * size < length);
-               g_free (file_series_name);
-#ifdef G_OS_WIN32
-               /* On Unix the parent exits already in
-                * fork_to_background(), but without fork() exit only
-                * after doing the job. XXX Is this correct?
-                */
-               if (IsFirstOne == FALSE)
-                       _exit (-1);
-#endif
+       if (p_actctx->action_list_cards.output_file != NULL) {
+               fclose (outputfile);
        }
 }
 
diff --git a/addressbook/tools/evolution-addressbook-export.c 
b/addressbook/tools/evolution-addressbook-export.c
index 47b2671..0b83036 100644
--- a/addressbook/tools/evolution-addressbook-export.c
+++ b/addressbook/tools/evolution-addressbook-export.c
@@ -51,8 +51,6 @@ static gchar *opt_output_file = NULL;
 static gboolean opt_list_folders_mode = FALSE;
 static gchar *opt_output_format = NULL;
 static gchar *opt_addressbook_source_uid = NULL;
-static gboolean opt_async_mode = FALSE;
-static gint opt_file_size = 0;
 static gchar **opt_remaining = NULL;
 
 static GOptionEntry entries[] = {
@@ -67,14 +65,6 @@ static GOptionEntry entries[] = {
          G_OPTION_ARG_STRING, &opt_output_format,
          N_("Show cards as vcard or csv file"),
          N_("[vcard|csv]") },
-       { "async", 'a', 0,
-         G_OPTION_ARG_NONE, &opt_async_mode,
-         N_("Export in asynchronous mode") },
-       { "size", '\0', 0,
-         G_OPTION_ARG_INT, &opt_file_size,
-         N_("The number of cards in one output file in asynchronous mode, "
-            "default size 100."),
-         N_("NUMBER") },
        { G_OPTION_REMAINING, '\0', 0,
          G_OPTION_ARG_STRING_ARRAY, &opt_remaining },
        { NULL }
@@ -143,9 +133,7 @@ main (gint argc,
 
        if (opt_list_folders_mode != FALSE) {
                current_action = ACTION_LIST_FOLDERS;
-               /* check there should not be addressbook-source-uid,
-                * and async and size, output_format */
-               if (opt_addressbook_source_uid != NULL || opt_async_mode != FALSE || opt_output_format != 
NULL || opt_file_size != 0) {
+               if (opt_addressbook_source_uid != NULL || opt_output_format != NULL) {
                        g_warning (_("Command line arguments error, please use --help option to see the 
usage."));
                        exit (-1);
                }
@@ -164,23 +152,6 @@ main (gint argc,
                                exit (-1);
                        }
                }
-
-               /*check async and output file */
-               if (opt_async_mode == TRUE) {
-                       /* check have to output file , set default file_size */
-                       if (opt_output_file == NULL) {
-                               g_warning (_("In async mode, output must be file."));
-                               exit (-1);
-                       }
-                       if (opt_file_size == 0)
-                               opt_file_size = DEFAULT_SIZE_NUMBER;
-               } else {
-                       /*check no file_size */
-                       if (opt_file_size != 0) {
-                               g_warning (_("In normal mode, there is no need for the size option."));
-                               exit (-1);
-                       }
-               }
        }
 
        /* do actions */
@@ -204,8 +175,6 @@ main (gint argc,
                actctx.action_list_cards.IsVCard = IsVCard;
                actctx.action_list_cards.addressbook_source_uid =
                        g_strdup (opt_addressbook_source_uid);
-               actctx.action_list_cards.async_mode = opt_async_mode;
-               actctx.action_list_cards.file_size = opt_file_size;
 
                action_list_cards_init (registry, &actctx);
 
diff --git a/addressbook/tools/evolution-addressbook-export.h 
b/addressbook/tools/evolution-addressbook-export.h
index b059252..090446b 100644
--- a/addressbook/tools/evolution-addressbook-export.h
+++ b/addressbook/tools/evolution-addressbook-export.h
@@ -56,8 +56,6 @@ union _ActionContext
                gint IsCSV;
                gint IsVCard;
                gchar *addressbook_source_uid;
-               gint async_mode;
-               gint file_size;
        }
        action_list_cards;
 };


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