aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2001-03-23 10:09:29 +0800
committerIain Holmes <iain@src.gnome.org>2001-03-23 10:09:29 +0800
commit35c7cc901818b753634113241f1d85231d4624c3 (patch)
tree36c225a7d4a2ed0f4f4ba6931fda38827134e1fe /shell
parent01e19198a88f491251dd2c3d824bd771eebc3e3e (diff)
downloadgsoc2013-evolution-35c7cc901818b753634113241f1d85231d4624c3.tar
gsoc2013-evolution-35c7cc901818b753634113241f1d85231d4624c3.tar.gz
gsoc2013-evolution-35c7cc901818b753634113241f1d85231d4624c3.tar.bz2
gsoc2013-evolution-35c7cc901818b753634113241f1d85231d4624c3.tar.lz
gsoc2013-evolution-35c7cc901818b753634113241f1d85231d4624c3.tar.xz
gsoc2013-evolution-35c7cc901818b753634113241f1d85231d4624c3.tar.zst
gsoc2013-evolution-35c7cc901818b753634113241f1d85231d4624c3.zip
Fix some warnings, Allow the importers to import into any folder. Update
Fix some warnings, Allow the importers to import into any folder. Update all importers for this change. Don't emit the create_folder callback if the folder to be created already exists. This should fix the libibex crash when importing. svn path=/trunk/; revision=8912
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog19
-rw-r--r--shell/e-local-storage.c79
-rw-r--r--shell/e-storage.h3
-rw-r--r--shell/importer/GNOME_Evolution_Importer.idl4
-rw-r--r--shell/importer/evolution-importer-client.c6
-rw-r--r--shell/importer/evolution-importer-client.h3
-rw-r--r--shell/importer/evolution-importer-listener.c8
-rw-r--r--shell/importer/evolution-importer.c4
-rw-r--r--shell/importer/evolution-importer.h1
-rw-r--r--shell/importer/importer.c20
10 files changed, 110 insertions, 37 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 001b047f4f..ccee247b77 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,22 @@
+2001-03-22 Iain Holmes <iain@ximian.com>
+
+ * importer/evolution-importer-listener.c (evolution_importer_listener_new):
+ Remove the usage of the corba_object thing.
+ (evolution_importer_listener_construct): Ditto.
+
+ * e-local-storage.c (real_do_folder_create): Revert the e_mkdir_hier call
+ to two seperate calls to mkdir. If the directory exists, just call the
+ callback and notify the listener.
+
+ * importer/GNOME_Evolution_Importer.idl: Add a folderpath paramater to the
+ loadFile method.
+
+ * importer/evolution-importer.[ch]: Update for the new folderpath param.
+
+ * importer/evolution-importer-client.[ch]: Ditto.
+
+ * importer/importer.c: Ditto.
+
2001-03-22 Ettore Perazzoli <ettore@ximian.com>
* e-storage-set-view.c (motion_notify_event): Unref the target
diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c
index 15247295e0..3417776731 100644
--- a/shell/e-local-storage.c
+++ b/shell/e-local-storage.c
@@ -449,6 +449,28 @@ impl_get_name (EStorage *storage)
return E_LOCAL_STORAGE_NAME;
}
+const char *invalid_names[6] = {
+ "Calendar",
+ "Contacts",
+ "Trash",
+ "Executive-Summary",
+ "Tasks",
+ NULL};
+/* Checks that @foldername isn't an invalid name like Trash, Calendar etc */
+static gboolean
+check_valid_name (const char *foldername)
+{
+ int i;
+
+ g_return_val_if_fail (foldername != NULL, FALSE);
+ for (i = 0; invalid_names[i] != NULL; i++) {
+ if (strcmp (invalid_names[i], foldername) == 0)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
real_do_folder_create (ELocalStorage *local_storage,
Bonobo_Listener listener,
@@ -476,11 +498,21 @@ real_do_folder_create (ELocalStorage *local_storage,
(* callback) (storage, E_STORAGE_INVALIDTYPE, data);
notify_listener (listener, E_STORAGE_INVALIDTYPE, NULL);
+ return;
}
g_assert (g_path_is_absolute (path));
folder_name = g_basename (path);
+ /* Some validity checks */
+ if (!check_valid_name (folder_name)) {
+ if (callback != NULL)
+ (*callback) (storage, E_STORAGE_INVALIDNAME, data);
+
+ notify_listener (listener, E_STORAGE_INVALIDNAME, NULL);
+ return;
+ }
+
if (folder_name == path + 1) {
/* We want a direct child of the root, so we don't need to create a
`subfolders' directory. */
@@ -496,20 +528,24 @@ real_do_folder_create (ELocalStorage *local_storage,
parent_physical_path = get_physical_path (local_storage, parent_path);
subfolders_directory_physical_path = g_concat_dir_and_file (parent_physical_path,
SUBFOLDER_DIR_NAME);
-
-#if 0
- if (! g_file_exists (subfolders_directory_physical_path)
+ if (! g_file_exists (subfolders_directory_physical_path)
&& mkdir (subfolders_directory_physical_path, 0700) == -1) {
- g_free (parent_path);
- g_free (subfolders_directory_physical_path);
- g_free (parent_physical_path);
- if (callback != NULL)
- (* callback) (storage,
- errno_to_storage_result (), data);
- return errno_to_storage_result ();
+ if (errno != EEXIST) {
+ /* Really bad error which we can't recover from */
+ g_free (parent_path);
+ g_free (subfolders_directory_physical_path);
+ g_free (parent_physical_path);
+ if (callback != NULL)
+ (* callback) (storage,
+ errno_to_storage_result (),
+ data);
+
+ notify_listener (listener,
+ errno_to_storage_result (), NULL);
+ return;
+ }
}
-#endif
-
+
physical_path = g_concat_dir_and_file (subfolders_directory_physical_path,
folder_name);
g_free (subfolders_directory_physical_path);
@@ -518,17 +554,14 @@ real_do_folder_create (ELocalStorage *local_storage,
/* Create the directory that holds the folder. */
- if (e_mkdir_hier (physical_path, 0700) == -1) {
-
- /* Bad error which we can't recover from */
- if (errno != EEXIST) {
- notify_listener (listener, errno_to_storage_result (),
- physical_path);
- g_free (physical_path);
- if (callback != NULL)
- (* callback) (storage,
- errno_to_storage_result (), data);
- }
+ if (mkdir (physical_path, 0700) == -1) {
+ notify_listener (listener, errno_to_storage_result (),
+ physical_path);
+ g_free (physical_path);
+ if (callback != NULL)
+ (* callback) (storage,
+ errno_to_storage_result (), data);
+ return;
}
/* Finally tell the component to do the job of creating the physical files in
diff --git a/shell/e-storage.h b/shell/e-storage.h
index 5a986a5b1a..bd3ef5a61c 100644
--- a/shell/e-storage.h
+++ b/shell/e-storage.h
@@ -55,7 +55,8 @@ enum _EStorageResult {
E_STORAGE_NOTIMPLEMENTED,
E_STORAGE_PERMISSIONDENIED,
E_STORAGE_UNSUPPORTEDOPERATION,
- E_STORAGE_UNSUPPORTEDTYPE
+ E_STORAGE_UNSUPPORTEDTYPE,
+ E_STORAGE_INVALIDNAME
};
typedef enum _EStorageResult EStorageResult;
diff --git a/shell/importer/GNOME_Evolution_Importer.idl b/shell/importer/GNOME_Evolution_Importer.idl
index 7dec5e7e0c..adeb900dde 100644
--- a/shell/importer/GNOME_Evolution_Importer.idl
+++ b/shell/importer/GNOME_Evolution_Importer.idl
@@ -71,13 +71,15 @@ module Evolution {
/**
* loadFile:
* @filename: The filename of the file.
+ * @folderpath: The full pathname to the folder.
*
* Loads the file and prepares an Importer object that can
* process files of this type.
*
* Returns: An Importer object.
*/
- boolean loadFile (in string filename);
+ boolean loadFile (in string filename,
+ in string folderpath);
};
interface IntelligentImporter : Bonobo::Unknown {
diff --git a/shell/importer/evolution-importer-client.c b/shell/importer/evolution-importer-client.c
index 9b3bc3490f..34598227a1 100644
--- a/shell/importer/evolution-importer-client.c
+++ b/shell/importer/evolution-importer-client.c
@@ -162,6 +162,7 @@ evolution_importer_client_support_format (EvolutionImporterClient *client,
* evolution_importer_client_load_file:
* @client: The EvolutionImporterClient.
* @filename: The file to load.
+ * @folderpath: The full path to the folder, or NULL for Inbox.
*
* Loads and initialises the importer.
*
@@ -169,7 +170,8 @@ evolution_importer_client_support_format (EvolutionImporterClient *client,
*/
gboolean
evolution_importer_client_load_file (EvolutionImporterClient *client,
- const char *filename)
+ const char *filename,
+ const char *folderpath)
{
GNOME_Evolution_Importer corba_importer;
gboolean result;
@@ -182,7 +184,7 @@ evolution_importer_client_load_file (EvolutionImporterClient *client,
CORBA_exception_init (&ev);
corba_importer = bonobo_object_corba_objref (BONOBO_OBJECT (client));
result = GNOME_Evolution_Importer_loadFile (corba_importer,
- filename, &ev);
+ filename, folderpath, &ev);
CORBA_exception_free (&ev);
return result;
diff --git a/shell/importer/evolution-importer-client.h b/shell/importer/evolution-importer-client.h
index 178d20254f..e9a343dc80 100644
--- a/shell/importer/evolution-importer-client.h
+++ b/shell/importer/evolution-importer-client.h
@@ -59,7 +59,8 @@ EvolutionImporterClient *evolution_importer_client_new_from_id (const char *id);
gboolean evolution_importer_client_support_format (EvolutionImporterClient *client,
const char *filename);
gboolean evolution_importer_client_load_file (EvolutionImporterClient *client,
- const char *filename);
+ const char *filename,
+ const char *folderpath);
void evolution_importer_client_process_item (EvolutionImporterClient *client,
EvolutionImporterListener *listener);
const char *evolution_importer_client_get_error (EvolutionImporterClient *client);
diff --git a/shell/importer/evolution-importer-listener.c b/shell/importer/evolution-importer-listener.c
index 62dc35b19c..84d6ad22b3 100644
--- a/shell/importer/evolution-importer-listener.c
+++ b/shell/importer/evolution-importer-listener.c
@@ -185,7 +185,6 @@ evolution_importer_listener_init (EvolutionImporterListener *listener)
static void
evolution_importer_listener_construct (EvolutionImporterListener *listener,
- GNOME_Evolution_ImporterListener corba_object,
EvolutionImporterListenerCallback callback,
void *closure)
{
@@ -193,14 +192,11 @@ evolution_importer_listener_construct (EvolutionImporterListener *listener,
g_return_if_fail (listener != NULL);
g_return_if_fail (EVOLUTION_IS_IMPORTER_LISTENER (listener));
- g_return_if_fail (corba_object != CORBA_OBJECT_NIL);
g_return_if_fail (callback != NULL);
priv = listener->priv;
priv->callback = callback;
priv->closure = closure;
-
- bonobo_object_construct (BONOBO_OBJECT (listener), corba_object);
}
/**
@@ -217,12 +213,10 @@ evolution_importer_listener_new (EvolutionImporterListenerCallback callback,
void *closure)
{
EvolutionImporterListener *listener;
- GNOME_Evolution_ImporterListener corba_object;
listener = gtk_type_new (evolution_importer_listener_get_type ());
- evolution_importer_listener_construct (listener, corba_object,
- callback, closure);
+ evolution_importer_listener_construct (listener, callback, closure);
return listener;
}
diff --git a/shell/importer/evolution-importer.c b/shell/importer/evolution-importer.c
index c48390c9e5..af3acf487b 100644
--- a/shell/importer/evolution-importer.c
+++ b/shell/importer/evolution-importer.c
@@ -72,6 +72,7 @@ impl_GNOME_Evolution_Importer_supportFormat (PortableServer_Servant servant,
static CORBA_boolean
impl_GNOME_Evolution_Importer_loadFile (PortableServer_Servant servant,
const CORBA_char *filename,
+ const CORBA_char *folderpath,
CORBA_Environment *ev)
{
EvolutionImporter *importer;
@@ -81,7 +82,8 @@ impl_GNOME_Evolution_Importer_loadFile (PortableServer_Servant servant,
priv = importer->priv;
if (priv->load_file_fn != NULL)
- return (priv->load_file_fn) (importer, filename, priv->closure);
+ return (priv->load_file_fn) (importer, filename,
+ folderpath, priv->closure);
else
return FALSE;
}
diff --git a/shell/importer/evolution-importer.h b/shell/importer/evolution-importer.h
index a5f6e07e87..3df870bbf3 100644
--- a/shell/importer/evolution-importer.h
+++ b/shell/importer/evolution-importer.h
@@ -47,6 +47,7 @@ typedef gboolean (* EvolutionImporterSupportFormatFn) (EvolutionImporter *import
void *closure);
typedef gboolean (* EvolutionImporterLoadFileFn) (EvolutionImporter *importer,
const char *filename,
+ const char *folderpath,
void *closure);
typedef void (* EvolutionImporterProcessItemFn) (EvolutionImporter *importer,
CORBA_Object listener,
diff --git a/shell/importer/importer.c b/shell/importer/importer.c
index 5286a1b04d..a82bf72db2 100644
--- a/shell/importer/importer.c
+++ b/shell/importer/importer.c
@@ -60,6 +60,15 @@ typedef struct _ImportData {
char *choosen_iid;
} ImportData;
+#define IMPORTER_DEBUG
+#ifdef IMPORTER_DEBUG
+#define IN g_print ("=====> %s (%d)\n", __FUNCTION__, __LINE__)
+#define OUT g_print ("<==== %s (%d)\n", __FUNCTION__, __LINE__)
+#else
+#define IN
+#define OUT
+#endif
+
/* Some HTML helper functions from mail/mail-config-gui.c */
static void
html_size_req (GtkWidget *widget,
@@ -149,6 +158,7 @@ import_cb (EvolutionImporterListener *listener,
ImporterComponentData *icd = (ImporterComponentData *) data;
char *label;
+ IN;
if (icd->stop != TRUE) {
if (result == EVOLUTION_IMPORTER_NOT_READY) {
/* Importer isn't ready yet.
@@ -163,11 +173,13 @@ import_cb (EvolutionImporterListener *listener,
gtk_main_iteration ();
gtk_timeout_add (5000, importer_timeout_fn, data);
+ OUT;
return;
}
if (result == EVOLUTION_IMPORTER_BUSY) {
gtk_timeout_add (5000, importer_timeout_fn, data);
+ OUT;
return;
}
@@ -181,6 +193,7 @@ import_cb (EvolutionImporterListener *listener,
g_idle_add_full (G_PRIORITY_LOW, importer_timeout_fn,
data, NULL);
+ OUT;
return;
}
}
@@ -191,6 +204,8 @@ import_cb (EvolutionImporterListener *listener,
bonobo_object_unref (BONOBO_OBJECT (icd->listener));
bonobo_object_unref (BONOBO_OBJECT (icd->client));
g_free (icd);
+
+ OUT;
}
static gboolean
@@ -199,6 +214,7 @@ importer_timeout_fn (gpointer data)
ImporterComponentData *icd = (ImporterComponentData *) data;
char *label;
+ IN;
label = g_strdup_printf (_("Importing %s\nImporting item %d."),
icd->filename, icd->item);
gtk_label_set_text (GTK_LABEL (icd->contents), label);
@@ -207,6 +223,7 @@ importer_timeout_fn (gpointer data)
gtk_main_iteration ();
evolution_importer_client_process_item (icd->client, icd->listener);
+ OUT;
return FALSE;
}
@@ -338,7 +355,8 @@ start_import (const char *filename,
icd->client = evolution_importer_client_new_from_id (real_iid);
g_free (real_iid);
- if (evolution_importer_client_load_file (icd->client, filename) == FALSE) {
+ /* NULL for folderpath means use Inbox */
+ if (evolution_importer_client_load_file (icd->client, filename, NULL) == FALSE) {
label = g_strdup_printf (_("Error loading %s"), filename);
gtk_label_set_text (GTK_LABEL (icd->contents), label);
g_free (label);