aboutsummaryrefslogtreecommitdiffstats
path: root/mail/importers
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2003-03-20 18:17:25 +0800
committerMichael Zucci <zucchi@src.gnome.org>2003-03-20 18:17:25 +0800
commit1dc4c5de39970316494ab17e2b50ae1a7ca6170e (patch)
treef474ee61d5e15306ca95f386223d91f1cb060761 /mail/importers
parent4ac5734af0ee578f5e769bf4bd5a420d379d2155 (diff)
downloadgsoc2013-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')
-rw-r--r--mail/importers/elm-importer.c105
-rw-r--r--mail/importers/evolution-mbox-importer.c105
-rw-r--r--mail/importers/evolution-outlook-importer.c6
-rw-r--r--mail/importers/netscape-importer.c101
-rw-r--r--mail/importers/pine-importer.c114
5 files changed, 156 insertions, 275 deletions
diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c
index 0314952b94..730167243f 100644
--- a/mail/importers/elm-importer.c
+++ b/mail/importers/elm-importer.c
@@ -52,6 +52,8 @@
#include <importer/evolution-importer-client.h>
#include <importer/GNOME_Evolution_Importer.h>
+#include "mail/mail-importer.h"
+
#define ELM_INTELLIGENT_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Elm_Intelligent_Importer_Factory"
#define MBOX_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Mbox_Importer"
#define KEY "elm-mail-imported"
@@ -68,13 +70,13 @@ typedef struct {
GList *dir_list;
- int num;
int progress_count;
- int import_id;
+ int more;
+ EvolutionImporterResult result;
GNOME_Evolution_Importer importer;
EvolutionImporterListener *listener;
-
+
GtkWidget *mail;
gboolean do_mail;
@@ -129,26 +131,6 @@ elm_restore_settings (ElmImporter *importer)
importer->do_mail = gconf_client_get_bool (gconf, "/apps/evolution/importer/elm/mail", NULL);
}
-static gboolean
-import_item_idle(void *data)
-{
- ElmImporter *importer = data;
- CORBA_Environment ev;
-
- importer->import_id = 0;
-
- 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);
-
- return FALSE;
-}
-
static void
importer_cb (EvolutionImporterListener *listener,
EvolutionImporterResult result,
@@ -156,16 +138,9 @@ importer_cb (EvolutionImporterListener *listener,
void *data)
{
ElmImporter *importer = (ElmImporter *) data;
-
- if (more_items) {
- g_assert(importer->import_id == 0);
- importer->progress_count++;
- if ((importer->progress_count & 0xf) == 0)
- gtk_progress_bar_pulse(GTK_PROGRESS_BAR(importer->progressbar));
- importer->import_id = g_idle_add(import_item_idle, importer);
- } else {
- import_next (importer);
- }
+
+ importer->result = result;
+ importer->more = more_items;
}
static gboolean
@@ -176,37 +151,60 @@ elm_import_file (ElmImporter *importer,
CORBA_boolean result;
CORBA_Environment ev;
CORBA_Object objref;
- char *str;
-
- CORBA_exception_init (&ev);
+ char *str, *uri;
+ struct stat st;
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;
+
+ /* if its a dir, we just create it, but dont add anything */
+ 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);
+ CORBA_exception_init(&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", CORBA_exception_id (&ev));
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);
- return FALSE;
- }
+ 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 void
@@ -346,9 +344,11 @@ import_next (ElmImporter *importer)
{
ElmFolder *data;
+trynext:
if (importer->dir_list) {
char *folder;
GList *l;
+ int ok;
l = importer->dir_list;
data = l->data;
@@ -357,13 +357,16 @@ import_next (ElmImporter *importer)
importer->dir_list = l->next;
g_list_free_1(l);
-
- elm_import_file (importer, data->path, folder);
+
+ ok = elm_import_file (importer, data->path, folder);
g_free (folder);
g_free (data->parent);
g_free (data->path);
g_free (data->foldername);
g_free (data);
+ /* its ugly, but so is everything else in this file */
+ if (!ok)
+ goto trynext;
} else {
bonobo_object_unref((BonoboObject *)importer->ii);
}
diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c
index 31d3d4c6a2..9cbcdeb9de 100644
--- a/mail/importers/evolution-mbox-importer.c
+++ b/mail/importers/evolution-mbox-importer.c
@@ -120,19 +120,9 @@ process_item_fn (EvolutionImporter *eimporter,
const char *mozilla_status;
if (importer->folder == NULL) {
- /* if it failed, need to say it failed ... */
- /* the create_folder callback needs to store the create result */
- /* here we need to pass FALSE for more items */
- printf("not ready\n");
- if (mbi->create_result == GNOME_Evolution_Storage_OK)
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_NOT_READY,
- TRUE, ev);
- else
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_BAD_FILE,
- FALSE, ev);
- return;
+ GNOME_Evolution_ImporterListener_notifyResult (listener,
+ GNOME_Evolution_ImporterListener_BAD_FILE,
+ FALSE, ev);
}
if (mbi->is_folder == TRUE) {
@@ -247,59 +237,14 @@ importer_destroy_cb (void *data, GObject *object)
g_free (mbi);
}
-static void
-folder_created_cb (BonoboListener *listener,
- const char *event_name,
- const BonoboArg *event_data,
- CORBA_Environment *ev,
- MailImporter *importer)
-{
- char *fullpath;
- GNOME_Evolution_Storage_FolderResult *result;
- CamelException *ex;
-
- if (strcmp (event_name, "evolution-shell:folder_created") != 0) {
- return; /* Unknown event */
- }
-
- result = event_data->_value;
-
- printf("folder created cb, result = %d\n", result->result);
- ((MboxImporter *)importer)->create_result = result->result;
-
- if (result->result != GNOME_Evolution_Storage_OK)
- return;
-
- fullpath = g_strconcat ("file://", result->path, NULL);
-
- ex = camel_exception_new ();
- importer->folder = mail_tool_uri_to_folder (fullpath, CAMEL_STORE_FOLDER_CREATE, ex);
- if (camel_exception_is_set (ex)) {
- g_warning ("Error opening %s", fullpath);
- camel_exception_free (ex);
-
- g_free (fullpath);
- ((MboxImporter *)importer)->create_result = GNOME_Evolution_Storage_GENERIC_ERROR;
-
- return;
- }
-
- camel_folder_freeze (importer->folder);
- importer->frozen = TRUE;
-
- g_free (fullpath);
- bonobo_object_unref (BONOBO_OBJECT (listener));
-}
-
static gboolean
load_file_fn (EvolutionImporter *eimporter,
const char *filename,
- const char *folderpath,
+ const char *uri,
void *closure)
{
MboxImporter *mbi;
MailImporter *importer;
- gboolean delayed = FALSE;
struct stat buf;
int fd;
@@ -328,46 +273,12 @@ load_file_fn (EvolutionImporter *eimporter,
}
importer->mstream = NULL;
- if (folderpath == NULL || *folderpath == '\0') {
+ if (uri == NULL || *uri == '\0')
importer->folder = mail_tool_get_local_inbox (NULL);
- } else {
- char *parent, *fullpath, *homedir;
- const char *name;
- BonoboListener *listener;
- CamelException *ex;
-
- homedir = g_strdup_printf("file://%s/evolution/local", g_get_home_dir());
+ else
+ importer->folder = mail_tool_uri_to_folder(uri, 0, NULL);
- fullpath = e_path_to_physical (homedir, folderpath);
- ex = camel_exception_new ();
- importer->folder = mail_tool_uri_to_folder (fullpath, 0, ex);
- g_free (homedir);
-
- if (camel_exception_is_set (ex) || importer->folder == NULL) {
- /* Make a new directory */
- name = strrchr (folderpath, '/');
- if (name == NULL) {
- parent = g_strdup ("/");
- name = folderpath;
- } else {
- name += 1;
- parent = g_path_get_dirname (folderpath);
- }
-
- listener = bonobo_listener_new (NULL, NULL);
- g_signal_connect((listener), "event-notify",
- G_CALLBACK (folder_created_cb),
- importer);
- mbi->create_result = GNOME_Evolution_Storage_OK;
- mail_importer_create_folder (parent, name, NULL, listener);
- delayed = importer->folder == NULL;
- g_free (parent);
- }
- camel_exception_free (ex);
- g_free (fullpath);
- }
-
- if (importer->folder == NULL && delayed == FALSE){
+ if (importer->folder == NULL) {
g_warning ("Bad folder\n");
goto fail;
}
diff --git a/mail/importers/evolution-outlook-importer.c b/mail/importers/evolution-outlook-importer.c
index 2737aa592a..f0c697c6b6 100644
--- a/mail/importers/evolution-outlook-importer.c
+++ b/mail/importers/evolution-outlook-importer.c
@@ -224,7 +224,7 @@ importer_destroy_cb (void *data, GObject *object)
static gboolean
load_file_fn (EvolutionImporter *eimporter,
const char *filename,
- const char *folderpath,
+ const char *uri,
void *closure)
{
OutlookImporter *oli;
@@ -263,10 +263,10 @@ load_file_fn (EvolutionImporter *eimporter,
importer->mstream = NULL;
- if (folderpath == NULL || *folderpath == '\0')
+ if (uri == NULL || *uri == 0)
importer->folder = mail_tool_get_local_inbox (NULL);
else
- importer->folder = mail_tool_uri_to_folder (folderpath, CAMEL_STORE_FOLDER_CREATE, NULL);
+ importer->folder = mail_tool_uri_to_folder (uri, 0, NULL);
if (importer->folder == NULL){
g_warning ("Bad folder");
diff --git a/mail/importers/netscape-importer.c b/mail/importers/netscape-importer.c
index b08c1f7e00..cb0f430299 100644
--- a/mail/importers/netscape-importer.c
+++ b/mail/importers/netscape-importer.c
@@ -64,6 +64,7 @@
#include <shell/evolution-shell-client.h>
#include "Mailer.h"
+#include "mail/mail-importer.h"
static char *nsmail_dir = NULL;
static GHashTable *user_prefs = NULL;
@@ -94,8 +95,8 @@ typedef struct {
GList *dir_list;
int progress_count;
- int num;
- guint import_id;
+ int more;
+ EvolutionImporterResult result;
GNOME_Evolution_Importer importer;
EvolutionImporterListener *listener;
@@ -1728,26 +1729,6 @@ netscape_can_import (EvolutionIntelligentImporter *ii,
}
}
-static gboolean
-importer_timeout_fn (gpointer data)
-{
- NsImporter *importer = (NsImporter *) data;
- CORBA_Object objref;
- CORBA_Environment ev;
-
- importer->import_id = 0;
-
- CORBA_exception_init (&ev);
- objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener));
- GNOME_Evolution_Importer_processItem (importer->importer, objref, &ev);
- CORBA_exception_free (&ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_warning ("Exception: %s", CORBA_exception_id (&ev));
-
- return FALSE;
-}
-
static void
importer_cb (EvolutionImporterListener *listener,
EvolutionImporterResult result,
@@ -1755,25 +1736,9 @@ importer_cb (EvolutionImporterListener *listener,
void *data)
{
NsImporter *importer = (NsImporter *) data;
-
- if (result == EVOLUTION_IMPORTER_NOT_READY ||
- result == EVOLUTION_IMPORTER_BUSY) {
- g_timeout_add (1000, importer_timeout_fn, data);
- return;
- }
-
- if (more_items) {
- importer->progress_count++;
- if ((importer->progress_count & 0xf) == 0)
- gtk_progress_bar_pulse(GTK_PROGRESS_BAR(importer->progressbar));
- importer->import_id = g_idle_add(importer_timeout_fn, importer);
- return;
- }
- if (importer->dir_list)
- import_next (importer);
- else
- bonobo_object_unref((BonoboObject *)importer->ii);
+ importer->result = result;
+ importer->more = more_items;
}
static gboolean
@@ -1784,9 +1749,9 @@ netscape_import_file (NsImporter *importer,
CORBA_boolean result;
CORBA_Environment ev;
CORBA_Object objref;
- char *str;
+ char *str, *uri;
- /* Do import */
+ /* Do import of mail folder */
d(g_warning ("Importing %s as %s", path, folderpath));
CORBA_exception_init (&ev);
@@ -1794,33 +1759,43 @@ netscape_import_file (NsImporter *importer,
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;
- 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", CORBA_exception_id (&ev));
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));
- d(g_print ("%s:Processing...\n", G_GNUC_FUNCTION));
- CORBA_exception_init (&ev);
- 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);
- return FALSE;
- }
+ 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;
}
typedef struct {
@@ -1835,9 +1810,11 @@ import_next (NsImporter *importer)
{
NetscapeCreateDirectoryData *data;
+trynext:
if (importer->dir_list) {
char *folder;
GList *l;
+ int ok;
l = importer->dir_list;
data = l->data;
@@ -1847,12 +1824,16 @@ import_next (NsImporter *importer)
importer->dir_list = l->next;
g_list_free_1(l);
- netscape_import_file (importer, data->path, folder);
+ ok = netscape_import_file (importer, data->path, 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);
}
}
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 */