aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--importers/ChangeLog6
-rw-r--r--importers/pine-importer.c92
-rw-r--r--mail/ChangeLog15
-rw-r--r--mail/component-factory.c7
-rw-r--r--mail/importers/evolution-mbox-importer.c51
-rw-r--r--mail/mail-importer.c2
-rw-r--r--shell/ChangeLog18
-rw-r--r--shell/e-local-storage.c53
-rw-r--r--shell/evolution-storage.c58
9 files changed, 249 insertions, 53 deletions
diff --git a/importers/ChangeLog b/importers/ChangeLog
index f97bf62473..4b660e2152 100644
--- a/importers/ChangeLog
+++ b/importers/ChangeLog
@@ -1,3 +1,9 @@
+2001-08-30 Iain Holmes <iain@ximian.com>
+
+ * pine-importer.c (create_importer_gui): Add a messagebox.
+ (importer_cb): Update GUI
+ (pine_import_file): Upidate gui.
+
2001-08-29 Iain Holmes <iain@ximian.com>
* netscape-importer.c (importer_cb): Handle the case if the importer
diff --git a/importers/pine-importer.c b/importers/pine-importer.c
index a6ca9a4f17..31ba29e02c 100644
--- a/importers/pine-importer.c
+++ b/importers/pine-importer.c
@@ -76,16 +76,40 @@ typedef struct {
EBook *book;
Bonobo_ConfigDatabase db;
+
+ /* GUI */
+ GtkWidget *dialog;
+ GtkWidget *label;
+ GtkWidget *progressbar;
} PineImporter;
typedef struct {
char *parent;
char *foldername;
char *path;
+ gboolean folder;
} PineFolder;
static void import_next (PineImporter *importer);
+static GtkWidget *
+create_importer_gui (PineImporter *importer)
+{
+ GtkWidget *dialog;
+
+ dialog = gnome_message_box_new (_("Evolution is importer your old Pine data"), GNOME_MESSAGE_BOX_INFO, NULL);
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Importing..."));
+
+ importer->label = gtk_label_new (_("Please wait"));
+ importer->progressbar = gtk_progress_bar_new ();
+ gtk_progress_set_activity_mode (GTK_PROGRESS (importer->progressbar), TRUE);
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
+ importer->label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
+ importer->progressbar, FALSE, FALSE, 0);
+ return dialog;
+}
+
static void
pine_store_settings (PineImporter *importer)
{
@@ -364,6 +388,16 @@ importer_cb (EvolutionImporterListener *listener,
}
if (more_items) {
+ GtkAdjustment *adj;
+ float newval;
+
+ adj = GTK_PROGRESS (importer->progressbar)->adjustment;
+ newval = adj->value + 1;
+ if (newval > adj->upper) {
+ newval = adj->lower;
+ }
+
+ gtk_progress_set_value (GTK_PROGRESS (importer->progressbar), newval);
CORBA_exception_init (&ev);
objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener));
GNOME_Evolution_Importer_processItem (importer->importer,
@@ -391,13 +425,22 @@ importer_cb (EvolutionImporterListener *listener,
static gboolean
pine_import_file (PineImporter *importer,
const char *path,
- const char *folderpath)
+ const char *folderpath,
+ gboolean folder)
{
CORBA_boolean result;
CORBA_Environment ev;
CORBA_Object objref;
+ char *str;
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 ();
+ }
result = GNOME_Evolution_Importer_loadFile (importer->importer, path,
folderpath, &ev);
if (ev._major != CORBA_NO_EXCEPTION || result == FALSE) {
@@ -467,7 +510,24 @@ import_next (PineImporter *importer)
data = importer->dir_list->data;
folder = g_concat_dir_and_file (data->parent, data->foldername);
- pine_import_file (importer, data->path, folder);
+#if 0
+ while (pine_import_file (importer, data->path, folder, data->folder) == FALSE) {
+ g_free (folder);
+ g_free (data->parent);
+ g_free (data->path);
+ g_free (data->foldername);
+ g_free (data);
+ importer->dir_list = importer->dir_list->next;
+
+ if (importer->dir_list == NULL) {
+ break;
+ }
+
+ data = importer->dir_list->data;
+ folder = g_concat_dir_and_file (data->parent, data->foldername);
+ }
+#endif
+ pine_import_file (importer, data->path, folder, data->folder);
g_free (folder);
g_free (data->parent);
g_free (data->path);
@@ -499,6 +559,7 @@ scan_dir (PineImporter *importer,
DIR *maildir;
struct stat buf;
struct dirent *current;
+ char *str;
maildir = opendir (dirname);
if (maildir == NULL) {
@@ -507,6 +568,14 @@ scan_dir (PineImporter *importer,
return;
}
+ str = g_strdup_printf (_("Scanning %s"), dirname);
+ gtk_label_set_text (GTK_LABEL (importer->label), str);
+ g_free (str);
+
+ while (gtk_events_pending ()) {
+ gtk_main_iteration ();
+ }
+
current = readdir (maildir);
while (current) {
PineFolder *pf;
@@ -541,15 +610,17 @@ scan_dir (PineImporter *importer,
pf->path = g_strdup (fullname);
pf->parent = g_strdup (orig_parent);
pf->foldername = g_strdup (foldername);
+ pf->folder = FALSE;
importer->dir_list = g_list_append (importer->dir_list, pf);
} else if (S_ISDIR (buf.st_mode)) {
char *subdir;
pf = g_new (PineFolder, 1);
- pf->path = NULL;
+ pf->path = g_strdup (fullname);
pf->parent = g_strdup (orig_parent);
pf->foldername = g_strdup (foldername);
-/* importer->dir_list = g_list_append (importer->dir_list, pf); */
+ pf->folder = TRUE;
+ importer->dir_list = g_list_append (importer->dir_list, pf);
subdir = g_concat_dir_and_file (orig_parent, foldername);
scan_dir (importer, fullname, subdir);
@@ -573,6 +644,13 @@ pine_create_structure (EvolutionIntelligentImporter *ii,
bonobo_object_ref (BONOBO_OBJECT (ii));
pine_store_settings (importer);
+ /* Create a dialog */
+ importer->dialog = create_importer_gui (importer);
+ gtk_widget_show_all (importer->dialog);
+ while (gtk_events_pending ()) {
+ gtk_main_iteration ();
+ }
+
if (importer->do_address == TRUE) {
bonobo_config_set_boolean (importer->db,
"/Importer/Pine/address-imported", TRUE, NULL);
@@ -585,6 +663,12 @@ pine_create_structure (EvolutionIntelligentImporter *ii,
"/Importer/Pine/mail-imported", TRUE, NULL);
maildir = gnome_util_prepend_user_home ("mail");
+ gtk_label_set_text (GTK_LABEL (importer->label),
+ _("Scanning directory"));
+ while (gtk_events_pending ()) {
+ gtk_main_iteration ();
+ }
+
scan_dir (importer, maildir, "/");
g_free (maildir);
diff --git a/mail/ChangeLog b/mail/ChangeLog
index ea685e762a..5614aa12ff 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,18 @@
+2001-08-30 Iain Holmes <iain@ximian.com>
+
+ * importer/evolution-mbox-importer.c: (load_file_fn): Check if it's a
+ folder, if so, create a folder.
+ (process_item_fn): If it was a folder created, just finish up importing
+
+2001-08-29 Iain Holmes <iain@ximian.com>
+
+ * importers/evolution-mbox-importer.c: Turn off debugging, remove
+ spewage.
+ (process_item_fn): Notify the importer if the folder isn't opened or
+ created yet.
+ (load_file_fn): Allow the function to continue if the folder is being
+ created.
+
2001-08-30 Peter Williams <peterw@ximian.com>
Due to the introduction of mail_folder_cache_remove(), we can no
diff --git a/mail/component-factory.c b/mail/component-factory.c
index d828757ee3..778e6b2be3 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -183,11 +183,12 @@ create_folder_done (char *uri, CamelFolder *folder, void *data)
GNOME_Evolution_ShellComponentListener_Result result;
CORBA_Environment ev;
- if (folder)
+ if (folder) {
result = GNOME_Evolution_ShellComponentListener_OK;
- else
+ } else {
result = GNOME_Evolution_ShellComponentListener_INVALID_URI;
-
+ }
+
CORBA_exception_init (&ev);
GNOME_Evolution_ShellComponentListener_notifyResult (listener, result, &ev);
CORBA_Object_release (listener, &ev);
diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c
index 28d1ca5e31..07dc4b7eb1 100644
--- a/mail/importers/evolution-mbox-importer.c
+++ b/mail/importers/evolution-mbox-importer.c
@@ -43,7 +43,7 @@
#include "e-util/e-path.h"
-#define IMPORTER_DEBUG
+/* #define IMPORTER_DEBUG */
#ifdef IMPORTER_DEBUG
#define IN g_print ("=====> %s (%d)\n", __FUNCTION__, __LINE__)
#define OUT g_print ("<==== %s (%d)\n", __FUNCTION__, __LINE__)
@@ -60,6 +60,7 @@ typedef struct {
char *filename;
int num;
CamelMimeParser *mp;
+ gboolean is_folder;
} MboxImporter;
void mail_importer_module_init (void);
@@ -77,6 +78,20 @@ process_item_fn (EvolutionImporter *eimporter,
gboolean done = FALSE;
CamelException *ex;
+ if (importer->folder == NULL) {
+ GNOME_Evolution_ImporterListener_notifyResult (listener,
+ GNOME_Evolution_ImporterListener_NOT_READY,
+ TRUE, ev);
+ return;
+ }
+
+ if (mbi->is_folder == TRUE) {
+ GNOME_Evolution_ImporterListener_notifyResult (listener,
+ GNOME_Evolution_ImporterListener_OK,
+ FALSE, ev);
+ return;
+ }
+
ex = camel_exception_new ();
if (camel_mime_parser_step (mbi->mp, 0, 0) == HSCAN_FROM) {
/* Import the next message */
@@ -117,7 +132,6 @@ process_item_fn (EvolutionImporter *eimporter,
}
camel_exception_free (ex);
- g_print ("Notifying...\n");
GNOME_Evolution_ImporterListener_notifyResult (listener,
GNOME_Evolution_ImporterListener_OK,
!done, ev);
@@ -200,7 +214,6 @@ folder_created_cb (BonoboListener *listener,
return;
}
- g_warning ("%s created", fullpath);
g_free (fullpath);
bonobo_object_unref (BONOBO_OBJECT (listener));
}
@@ -213,9 +226,10 @@ load_file_fn (EvolutionImporter *eimporter,
{
MboxImporter *mbi;
MailImporter *importer;
+ gboolean delayed = FALSE;
+ struct stat buf;
int fd;
- g_warning ("%s", __FUNCTION__);
mbi = (MboxImporter *) closure;
importer = (MailImporter *) mbi;
@@ -227,11 +241,17 @@ load_file_fn (EvolutionImporter *eimporter,
return FALSE;
}
- mbi->mp = camel_mime_parser_new ();
- camel_mime_parser_scan_from (mbi->mp, TRUE);
- if (camel_mime_parser_init_with_fd (mbi->mp, fd) == -1) {
- g_warning ("Unable to process spool folder");
- goto fail;
+ fstat (fd, &buf);
+ if (S_ISREG (buf.st_mode)) {
+ mbi->mp = camel_mime_parser_new ();
+ camel_mime_parser_scan_from (mbi->mp, TRUE);
+ if (camel_mime_parser_init_with_fd (mbi->mp, fd) == -1) {
+ g_warning ("Unable to process spool folder");
+ goto fail;
+ }
+ mbi->is_folder = FALSE;
+ } else {
+ mbi->is_folder = TRUE;
}
importer->mstream = NULL;
@@ -268,21 +288,26 @@ load_file_fn (EvolutionImporter *eimporter,
importer);
mail_importer_create_folder (parent, name, NULL, listener);
+ camel_exception_free (ex);
+ ex = camel_exception_new ();
+ importer->folder = mail_tool_uri_to_folder (fullpath, ex);
+ delayed = TRUE;
g_free (parent);
}
camel_exception_free (ex);
g_free (fullpath);
}
- if (importer->folder == NULL){
+ if (importer->folder == NULL && delayed == FALSE){
g_print ("Bad folder\n");
goto fail;
}
- camel_folder_freeze (importer->folder);
- importer->frozen = TRUE;
+ if (importer->folder != NULL) {
+ camel_folder_freeze (importer->folder);
+ importer->frozen = TRUE;
+ }
- g_warning ("Okay, so everything is now ready to import that mbox file!");
return TRUE;
fail:
diff --git a/mail/mail-importer.c b/mail/mail-importer.c
index d32a2d0f12..cfe7476ef2 100644
--- a/mail/mail-importer.c
+++ b/mail/mail-importer.c
@@ -84,8 +84,10 @@ mail_importer_create_folder (const char *parent_path,
parent_path);
corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
+
/* Darn CORBA wanting non-NULL values for strings */
real_description = CORBA_string_dup (description ? description : "");
+
CORBA_exception_init (&ev);
GNOME_Evolution_Storage_asyncCreateFolder (local_storage,
diff --git a/shell/ChangeLog b/shell/ChangeLog
index a736d59c11..61b4d54dcc 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,21 @@
+2001-08-29 Iain Holmes <iain@ximian.com>
+
+ * e-local-storage.c (notify_listener): Function to create CORBAany
+ and notify listeners.
+ (component_async_create_folder_callback): Notify the listener again.
+ (create_folder): Handle the Bonobo_Listener again and make it async.
+ (impl_async_create_folder): Pass CORBA_OBJECT_NIL as the listener.
+ (bonobo_interface_create_folder_cb): Make async.
+
+ * evolution-storage.c (notify_bonobo_listener): Removed this broken
+ broken function.
+ (impl_Storage_async_create_folder): Make async, duplicate the listener
+ instead of notifying it.
+ (impl_Storage_async_remove_folder): Notify listener by hand.
+ (e_marshal_NONE__POINTER_POINTER_POINTER_POINTER_POINTER): Return of the
+ worst signal marshaller in Scotland.
+ (class_init): Use the above marshaller for the create_folder signal.
+
2001-08-30 Jeffrey Stedfast <fejj@ximian.com>
* e-shell-folder-creation-dialog.c (entry_name_is_valid): Check
diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c
index 275b9be88e..0006be090d 100644
--- a/shell/e-local-storage.c
+++ b/shell/e-local-storage.c
@@ -55,6 +55,7 @@
#include "e-local-storage.h"
+#include <bonobo/bonobo-exception.h>
#define PARENT_TYPE E_TYPE_STORAGE
static EStorageClass *parent_class = NULL;
@@ -215,8 +216,33 @@ load_all_folders (ELocalStorage *local_storage)
/* Callbacks for the async methods invoked on the `Evolution::ShellComponent's. */
+static void
+notify_listener (const Bonobo_Listener listener,
+ EStorageResult result,
+ const char *physical_path)
+{
+ CORBA_any any;
+ GNOME_Evolution_Storage_FolderResult folder_result;
+ CORBA_Environment ev;
+
+ folder_result.result = result;
+ folder_result.path = CORBA_string_dup (physical_path ? physical_path : "");
+ any._type = TC_GNOME_Evolution_Storage_FolderResult;
+ any._value = &folder_result;
+
+ CORBA_exception_init (&ev);
+ Bonobo_Listener_event (listener, "evolution-shell:folder_created",
+ &any, &ev);
+ if (BONOBO_EX (&ev)) {
+ g_warning ("Exception notifing listener: %s\n",
+ CORBA_exception_id (&ev));
+ }
+ CORBA_exception_free (&ev);
+}
+
struct _AsyncCreateFolderCallbackData {
EStorage *storage;
+ Bonobo_Listener listener;
char *path;
char *display_name;
@@ -266,6 +292,10 @@ component_async_create_folder_callback (EvolutionShellComponentClient *shell_com
bonobo_object_unref (BONOBO_OBJECT (shell_component_client));
+ if (callback_data->listener != CORBA_OBJECT_NIL)
+ notify_listener (callback_data->listener, storage_result,
+ callback_data->physical_path);
+
if (callback_data->callback != NULL)
(* callback_data->callback) (callback_data->storage,
storage_result,
@@ -334,8 +364,9 @@ create_folder_directory (ELocalStorage *local_storage,
return E_STORAGE_OK;
}
-static EStorageResult
+static void
create_folder (ELocalStorage *local_storage,
+ const Bonobo_Listener listener,
const char *path,
const char *type,
const char *description,
@@ -356,20 +387,24 @@ create_folder (ELocalStorage *local_storage,
component_client = e_folder_type_registry_get_handler_for_type (priv->folder_type_registry,
type);
if (component_client == NULL) {
+ if (listener != CORBA_OBJECT_NIL)
+ notify_listener (listener, E_STORAGE_INVALIDTYPE, NULL);
if (callback != NULL)
(* callback) (storage, E_STORAGE_INVALIDTYPE, data);
- return E_STORAGE_INVALIDTYPE;
+ return;
}
g_assert (g_path_is_absolute (path));
result = create_folder_directory (local_storage, path, type, description, &physical_path);
if (result != E_STORAGE_OK) {
- g_warning ("physical_path: %s", physical_path);
if (callback != NULL)
(* callback) (storage, result, data);
+ if (listener != CORBA_OBJECT_NIL)
+ notify_listener (listener, result, NULL);
+
g_free (physical_path);
- return result;
+ return;
}
folder_name = g_basename (path);
@@ -389,6 +424,7 @@ create_folder (ELocalStorage *local_storage,
callback_data->description = g_strdup (description);
callback_data->physical_uri = physical_uri;
callback_data->physical_path = physical_path;
+ callback_data->listener = listener;
callback_data->callback = callback;
callback_data->callback_data = data;
@@ -399,8 +435,6 @@ create_folder (ELocalStorage *local_storage,
type,
component_async_create_folder_callback,
callback_data);
-
- return result;
}
struct _AsyncRemoveFolderCallbackData {
@@ -607,7 +641,7 @@ impl_async_create_folder (EStorage *storage,
local_storage = E_LOCAL_STORAGE (storage);
- create_folder (local_storage, path, type, description, callback, data);
+ create_folder (local_storage, CORBA_OBJECT_NIL, path, type, description, callback, data);
}
@@ -887,8 +921,9 @@ impl_async_xfer_folder (EStorage *storage,
/* Callbacks for the `Evolution::Storage' interface we are exposing to the outside world. */
-static int
+static void
bonobo_interface_create_folder_cb (EvolutionStorage *storage,
+ const Bonobo_Listener listener,
const char *path,
const char *type,
const char *description,
@@ -899,7 +934,7 @@ bonobo_interface_create_folder_cb (EvolutionStorage *storage,
local_storage = E_LOCAL_STORAGE (data);
- return create_folder (local_storage, path, type, description, NULL, NULL);
+ create_folder (local_storage, listener, path, type, description, NULL, NULL);
}
static int
diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c
index da76c619ee..45d999c93b 100644
--- a/shell/evolution-storage.c
+++ b/shell/evolution-storage.c
@@ -291,23 +291,6 @@ storage_gtk_to_corba_result (EvolutionStorageResult result)
}
static void
-notify_bonobo_listener (const Bonobo_Listener listener,
- EvolutionStorageResult result,
- const char *physical_path,
- CORBA_Environment *ev)
-{
- CORBA_any any;
- GNOME_Evolution_Storage_FolderResult folder_result;
-
- folder_result.result = storage_gtk_to_corba_result (result);
- folder_result.path = CORBA_string_dup (physical_path ? physical_path : "");
- any._type = TC_GNOME_Evolution_Storage_FolderResult;
- any._value = &folder_result;
-
- Bonobo_Listener_event (listener, "result", &any, ev);
-}
-
-static void
impl_Storage_async_create_folder (PortableServer_Servant servant,
const CORBA_char *path,
const CORBA_char *type,
@@ -317,17 +300,15 @@ impl_Storage_async_create_folder (PortableServer_Servant servant,
CORBA_Environment *ev)
{
BonoboObject *bonobo_object;
+ CORBA_Object obj_dup;
EvolutionStorage *storage;
- int int_result;
bonobo_object = bonobo_object_from_servant (servant);
storage = EVOLUTION_STORAGE (bonobo_object);
- int_result = GNOME_Evolution_Storage_UNSUPPORTED_OPERATION;
+ obj_dup = CORBA_Object_duplicate (listener, ev);
gtk_signal_emit (GTK_OBJECT (storage), signals[CREATE_FOLDER],
- path, type, description, parent_physical_uri, &int_result);
-
- notify_bonobo_listener (listener, int_result, path, ev);
+ obj_dup, path, type, description, parent_physical_uri);
}
@@ -341,6 +322,8 @@ impl_Storage_async_remove_folder (PortableServer_Servant servant,
BonoboObject *bonobo_object;
EvolutionStorage *storage;
int int_result;
+ CORBA_any any;
+ GNOME_Evolution_Storage_Result corba_result;
bonobo_object = bonobo_object_from_servant (servant);
storage = EVOLUTION_STORAGE (bonobo_object);
@@ -349,7 +332,11 @@ impl_Storage_async_remove_folder (PortableServer_Servant servant,
gtk_signal_emit (GTK_OBJECT (storage), signals[REMOVE_FOLDER],
path, physical_uri, &int_result);
- notify_bonobo_listener (listener, int_result, path, ev);
+ corba_result = storage_gtk_to_corba_result (int_result);
+ any._type = TC_GNOME_Evolution_Storage_Result;
+ any._value = &corba_result;
+
+ Bonobo_Listener_event (listener, "result", &any, ev);
}
static void
@@ -511,6 +498,29 @@ corba_class_init (void)
vepv->GNOME_Evolution_Storage_epv = evolution_storage_get_epv ();
}
+/* The worst signal marshaller in Scotland */
+typedef void (*GtkSignal_NONE__POINTER_POINTER_POINTER_POINTER_POINTER) (GtkObject *,
+ gpointer, gpointer, gpointer, gpointer, gpointer,
+ gpointer user_data);
+
+static void
+e_marshal_NONE__POINTER_POINTER_POINTER_POINTER_POINTER (GtkObject *object,
+ GtkSignalFunc func,
+ gpointer func_data,
+ GtkArg *args)
+{
+ GtkSignal_NONE__POINTER_POINTER_POINTER_POINTER_POINTER rfunc;
+
+ rfunc = (GtkSignal_NONE__POINTER_POINTER_POINTER_POINTER_POINTER) func;
+ (*rfunc) (object,
+ GTK_VALUE_POINTER (args[0]),
+ GTK_VALUE_POINTER (args[1]),
+ GTK_VALUE_POINTER (args[2]),
+ GTK_VALUE_POINTER (args[3]),
+ GTK_VALUE_POINTER (args[4]),
+ func_data);
+}
+
static void
class_init (EvolutionStorageClass *klass)
{
@@ -526,7 +536,7 @@ class_init (EvolutionStorageClass *klass)
object_class->type,
GTK_SIGNAL_OFFSET (EvolutionStorageClass,
create_folder),
- e_marshal_INT__POINTER_POINTER_POINTER_POINTER,
+ e_marshal_INT__POINTER_POINTER_POINTER_POINTER_POINTER,
GTK_TYPE_INT, 4,
GTK_TYPE_STRING,
GTK_TYPE_STRING,