diff options
author | Not Zed <NotZed@Ximian.com> | 2003-03-20 18:17:25 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2003-03-20 18:17:25 +0800 |
commit | 1dc4c5de39970316494ab17e2b50ae1a7ca6170e (patch) | |
tree | f474ee61d5e15306ca95f386223d91f1cb060761 /mail/importers/pine-importer.c | |
parent | 4ac5734af0ee578f5e769bf4bd5a420d379d2155 (diff) | |
download | gsoc2013-evolution-1dc4c5de39970316494ab17e2b50ae1a7ca6170e.tar.gz gsoc2013-evolution-1dc4c5de39970316494ab17e2b50ae1a7ca6170e.tar.zst gsoc2013-evolution-1dc4c5de39970316494ab17e2b50ae1a7ca6170e.zip |
** for mail part of bug #38461.
2003-03-21 Not Zed <NotZed@Ximian.com>
** for mail part of bug #38461.
* importers/evolution-outlook-importer.c (load_file_fn): dont pass
in create flag to uri_to_folder, the folder must already exist.
* importers/evolution-mbox-importer.c (folder_created_cb):
Removed, we now force the caller to create the destination folder
first.
(load_file_fn): Dont try and create a folder if it doesn't exist.
Also, use the uri directly as the destination uri, so we can
import into any folder.
(process_item_fn): If we dont have a folder, thats just an error,
return BAD_FILE.
* importers/netscape-importer.c (netscape_import_file): As below
for elm_import_file.
(import_next): similarly as for pine import_next.
(importer_cb): just record result.
(importer_timeout_fn): removed.
* importers/pine-importer.c (import_next): Similar to below for
the elm import_next.
(pine_import_file): As below for elm_import_file.
(importer_timeout_fn): removed.
(importer_cb): just record the result, and exit.
(import_next): change around to behave more like the elm importer,
cleaning up when we're done.
* importers/elm-importer.c (elm_import_file): Create the
destination folder ourselves, dont pass it onto the mbox importer.
Simplify logic, just do the import within a while loop, polling
the g main loop as necessary, remove need for idle callbacks and
other crap.
(import_next): If elm_import_file fails, then just go straight to
the next folder, stops it falling in a heap.
(import_item_idle): removed.
(importer_cb): just record result/exit.
* mail-importer.c (mail_importer_create_folder): removed.
(mail_importer_make_local_folder): new function to create a
local-only folder from a path. It runs synchronously by using a
recursive main loop.
(folder_created_cb): callback for make_local_folder.
svn path=/trunk/; revision=20379
Diffstat (limited to 'mail/importers/pine-importer.c')
-rw-r--r-- | mail/importers/pine-importer.c | 114 |
1 files changed, 50 insertions, 64 deletions
diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c index af4f8f783b..2368c0c12f 100644 --- a/mail/importers/pine-importer.c +++ b/mail/importers/pine-importer.c @@ -54,6 +54,8 @@ #include <importer/evolution-importer-client.h> #include <importer/GNOME_Evolution_Importer.h> +#include "mail/mail-importer.h" + #include <ebook/e-book.h> #include <ebook/e-card-simple.h> @@ -74,6 +76,8 @@ typedef struct { GList *dir_list; int progress_count; + int more; + EvolutionImporterResult result; GNOME_Evolution_Importer importer; EvolutionImporterListener *listener; @@ -85,9 +89,6 @@ typedef struct { EBook *book; - int timeout_id; - int more; - /* GUI */ GtkWidget *dialog; GtkWidget *label; @@ -258,33 +259,6 @@ import_addressbook (PineImporter *importer) g_free (uri); } -static gboolean -importer_timeout_fn (gpointer data) -{ - PineImporter *importer = (PineImporter *) data; - CORBA_Environment ev; - - importer->timeout_id = 0; - - if (importer->more) { - importer->progress_count++; - if ((importer->progress_count & 0xf) == 0) - gtk_progress_bar_pulse(GTK_PROGRESS_BAR(importer->progressbar)); - - CORBA_exception_init (&ev); - GNOME_Evolution_Importer_processItem (importer->importer, bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener)), &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_warning ("Exception: %s", CORBA_exception_id (&ev)); - CORBA_exception_free (&ev); - } else if (importer->dir_list) { - import_next (importer); - } else { - bonobo_object_unref (BONOBO_OBJECT (importer->ii)); - } - - return FALSE; -} - static void importer_cb (EvolutionImporterListener *listener, EvolutionImporterResult result, @@ -292,26 +266,9 @@ importer_cb (EvolutionImporterListener *listener, void *data) { PineImporter *importer = (PineImporter *) data; - - if (result == EVOLUTION_IMPORTER_NOT_READY || - result == EVOLUTION_IMPORTER_BUSY) { - importer->more = more_items; - importer->timeout_id = gtk_timeout_add (1000, importer_timeout_fn, data); - return; - } - - if (importer->timeout_id) { - /* we ignore multiple calls, we can get them if for - example we're waiting for a folder to open, yet we - tried to open the next. Uh, this shouldn't happen - anyway, but ... */ - return; - } + importer->result = result; importer->more = more_items; - - importer->timeout_id = g_idle_add(importer_timeout_fn, importer); - return; } static gboolean @@ -323,36 +280,59 @@ pine_import_file (PineImporter *importer, CORBA_boolean result; CORBA_Environment ev; CORBA_Object objref; - char *str; + char *str, *uri; + struct stat st; CORBA_exception_init (&ev); str = g_strdup_printf (_("Importing %s as %s"), path, folderpath); gtk_label_set_text (GTK_LABEL (importer->label), str); g_free (str); - while (gtk_events_pending ()) { - gtk_main_iteration (); + while (g_main_context_iteration(NULL, FALSE)) + ; + + uri = mail_importer_make_local_folder(folderpath); + if (!uri) + return FALSE; + + /* only create dirs, dont try to import them */ + if (lstat(path, &st) == 0 && S_ISDIR(st.st_mode)) { + g_free(uri); + /* this is ok, we return false to say we haven't launched an async task */ + return FALSE; } - result = GNOME_Evolution_Importer_loadFile (importer->importer, path, - folderpath, &ev); + result = GNOME_Evolution_Importer_loadFile (importer->importer, path, uri, &ev); + g_free(uri); if (ev._major != CORBA_NO_EXCEPTION || result == FALSE) { g_warning ("Exception here: %s\n%s, %s", CORBA_exception_id (&ev), path, folderpath); CORBA_exception_free (&ev); return FALSE; } - importer->listener = evolution_importer_listener_new (importer_cb, - importer); + /* process all items in a direct loop */ + importer->listener = evolution_importer_listener_new (importer_cb, importer); objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener)); - GNOME_Evolution_Importer_processItem (importer->importer, objref, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("Exception: %s", CORBA_exception_id (&ev)); - CORBA_exception_free (&ev); - } + do { + importer->progress_count++; + if ((importer->progress_count & 0xf) == 0) + gtk_progress_bar_pulse(GTK_PROGRESS_BAR(importer->progressbar)); + + importer->result = -1; + GNOME_Evolution_Importer_processItem (importer->importer, objref, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("Exception: %s", CORBA_exception_id (&ev)); + break; + } + + while (importer->result == -1 || g_main_context_pending(NULL)) + g_main_context_iteration(NULL, TRUE); + } while (importer->more); + bonobo_object_unref((BonoboObject *)importer->listener); + CORBA_exception_free (&ev); - return TRUE; + return FALSE; } static gboolean @@ -385,10 +365,12 @@ static void import_next (PineImporter *importer) { PineFolder *data; - + +trynext: if (importer->dir_list) { char *folder; GList *l; + int ok; l = importer->dir_list; data = l->data; @@ -396,14 +378,18 @@ import_next (PineImporter *importer) importer->dir_list = l->next; g_list_free_1(l); - pine_import_file (importer, data->path, folder, data->folder); + ok = pine_import_file (importer, data->path, folder, data->folder); + g_free (folder); g_free (data->parent); g_free (data->path); g_free (data->foldername); g_free (data); + if (!ok) + goto trynext; + } else { + bonobo_object_unref((BonoboObject *)importer->ii); } - } /* Pine uses sent-mail and saved-mail whereas Evolution uses Sent and Drafts */ |