aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2001-02-24 03:12:02 +0800
committerIain Holmes <iain@src.gnome.org>2001-02-24 03:12:02 +0800
commit48fb58e530564d082e6538aeb3a160096262d602 (patch)
treeecc4a31c037ce53868cb01bb907902ac064eecb9
parent3d49037634f91984ec0558b46de1d249f02eab8d (diff)
downloadgsoc2013-evolution-48fb58e530564d082e6538aeb3a160096262d602.tar
gsoc2013-evolution-48fb58e530564d082e6538aeb3a160096262d602.tar.gz
gsoc2013-evolution-48fb58e530564d082e6538aeb3a160096262d602.tar.bz2
gsoc2013-evolution-48fb58e530564d082e6538aeb3a160096262d602.tar.lz
gsoc2013-evolution-48fb58e530564d082e6538aeb3a160096262d602.tar.xz
gsoc2013-evolution-48fb58e530564d082e6538aeb3a160096262d602.tar.zst
gsoc2013-evolution-48fb58e530564d082e6538aeb3a160096262d602.zip
Changes to allow folders to be created from a callback.
svn path=/trunk/; revision=8371
-rw-r--r--shell/ChangeLog8
-rw-r--r--shell/e-local-storage.c114
-rw-r--r--shell/evolution-storage.c1
3 files changed, 87 insertions, 36 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index f3ee7bbb28..4204dd8fb8 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,11 @@
+2001-02-23 Iain Holmes <iain@ximian.com>
+
+ * e-local-storage.c (construct): Connect to the create-folder signal.
+ (impl_async_create_folder): Move this into the real_do_folder_create
+ function.
+ (real_do_folder_create): Function that creates the folder.
+ (create_folder_cb): Creates the folder form a callback.
+
2001-02-21 Michael Meeks <michael@ximian.com>
* importer/importer.c: add include.
diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c
index 5c3317fdb8..b669701be9 100644
--- a/shell/e-local-storage.c
+++ b/shell/e-local-storage.c
@@ -367,10 +367,11 @@ component_async_create_folder_callback (EvolutionShellComponentClient *shell_com
bonobo_object_unref (BONOBO_OBJECT (shell_component_client));
- (* callback_data->callback) (callback_data->storage,
- shell_component_result_to_storage_result (result),
- callback_data->callback_data);
-
+ if (callback_data->callback != NULL)
+ (* callback_data->callback) (callback_data->storage,
+ shell_component_result_to_storage_result (result),
+ callback_data->callback_data);
+
g_free (callback_data->path);
g_free (callback_data->display_name);
g_free (callback_data->type);
@@ -419,35 +420,36 @@ impl_get_name (EStorage *storage)
return E_LOCAL_STORAGE_NAME;
}
-static void
-impl_async_create_folder (EStorage *storage,
- const char *path,
- const char *type,
- const char *description,
- EStorageResultCallback callback,
- void *data)
+static int
+real_do_folder_create (ELocalStorage *local_storage,
+ const char *path,
+ const char *type,
+ const char *description,
+ EStorageResultCallback callback,
+ void *data)
{
- ELocalStorage *local_storage;
+ EStorage *storage;
ELocalStoragePrivate *priv;
EvolutionShellComponentClient *component_client;
- const char *folder_name;
AsyncCreateFolderCallbackData *callback_data;
+ const char *folder_name;
char *physical_path;
char *physical_uri;
char *parent_path;
-
- local_storage = E_LOCAL_STORAGE (storage);
+
+ storage = E_STORAGE (local_storage);
priv = local_storage->priv;
-
component_client = e_folder_type_registry_get_handler_for_type (priv->folder_type_registry,
type);
if (component_client == NULL) {
- (* callback) (storage, E_STORAGE_INVALIDTYPE, data);
- return;
- }
+ if (callback != NULL)
+ (* callback) (storage, E_STORAGE_INVALIDTYPE, data);
+ return E_STORAGE_INVALIDTYPE;
+ }
+
g_assert (g_path_is_absolute (path));
-
+
folder_name = g_basename (path);
if (folder_name == path + 1) {
/* We want a direct child of the root, so we don't need to create a
@@ -457,47 +459,51 @@ impl_async_create_folder (EStorage *storage,
} else {
char *parent_physical_path;
char *subfolders_directory_physical_path;
-
+
/* Create the `subfolders' subdirectory under the parent. */
-
+
parent_path = g_strndup (path, folder_name - path - 1);
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 (! 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);
-
- (* callback) (storage, errno_to_storage_result (), data);
- return;
+ if (callback != NULL)
+ (* callback) (storage,
+ errno_to_storage_result (), data);
+ return errno_to_storage_result ();
}
-
+
physical_path = g_concat_dir_and_file (subfolders_directory_physical_path,
folder_name);
g_free (subfolders_directory_physical_path);
g_free (parent_physical_path);
}
-
+
/* Create the directory that holds the folder. */
-
+
if (mkdir (physical_path, 0700) == -1) {
g_free (physical_path);
- (* callback) (storage, errno_to_storage_result (), data);
- return;
+ if (callback != NULL)
+ (* callback) (storage,
+ errno_to_storage_result (), data);
+
+ return errno_to_storage_result ();
}
/* Finally tell the component to do the job of creating the physical files in
it. */
/* FIXME: We should put the operations on a queue so that we can cancel them when
the ELocalStorage is destroyed. */
-
+
physical_uri = g_strconcat ("file://", physical_path, NULL);
-
+
callback_data = g_new (AsyncCreateFolderCallbackData, 1);
- callback_data->storage = storage;
+ callback_data->storage = E_STORAGE (local_storage);
callback_data->path = g_strdup (path);
callback_data->display_name = g_strdup (folder_name);
callback_data->type = g_strdup (type);
@@ -506,14 +512,48 @@ impl_async_create_folder (EStorage *storage,
callback_data->physical_path = physical_path;
callback_data->callback = callback;
callback_data->callback_data = data;
-
+
bonobo_object_ref (BONOBO_OBJECT (component_client));
-
+
evolution_shell_component_client_async_create_folder (component_client,
physical_path,
type,
component_async_create_folder_callback,
callback_data);
+ return EVOLUTION_STORAGE_OK;
+}
+
+static int
+create_folder_cb (EvolutionStorage *estorage,
+ const char *path,
+ const char *type,
+ const char *description,
+ const char *parent_p_path,
+ void *data)
+{
+ ELocalStorage *local_storage;
+ int ret;
+
+ local_storage = E_LOCAL_STORAGE (data);
+ ret = real_do_folder_create (local_storage, path, type,
+ description, NULL, data);
+
+ return ret;
+}
+
+static void
+impl_async_create_folder (EStorage *storage,
+ const char *path,
+ const char *type,
+ const char *description,
+ EStorageResultCallback callback,
+ void *data)
+{
+ ELocalStorage *local_storage;
+
+ local_storage = E_LOCAL_STORAGE (storage);
+ real_do_folder_create (local_storage, path, type,
+ description, callback, data);
}
static void
@@ -613,6 +653,8 @@ construct (ELocalStorage *local_storage,
g_assert (priv->bonobo_interface == NULL);
priv->bonobo_interface = evolution_local_storage_new (E_LOCAL_STORAGE_NAME);
+ gtk_signal_connect (GTK_OBJECT (priv->bonobo_interface), "create_folder",
+ GTK_SIGNAL_FUNC (create_folder_cb), local_storage);
gtk_signal_connect (GTK_OBJECT (priv->bonobo_interface), "update_folder",
GTK_SIGNAL_FUNC (bonobo_interface_update_folder_cb),
local_storage);
diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c
index bf02c19110..9c790dcbe0 100644
--- a/shell/evolution-storage.c
+++ b/shell/evolution-storage.c
@@ -295,6 +295,7 @@ impl_Storage_async_create_folder (PortableServer_Servant servant,
storage = EVOLUTION_STORAGE (bonobo_object);
int_result = GNOME_Evolution_Storage_UNSUPPORTED_OPERATION;
+ g_warning ("Creating %s:%s", path, parent_physical_uri);
gtk_signal_emit (GTK_OBJECT (storage), signals[CREATE_FOLDER],
path, type, description, parent_physical_uri,
&int_result);