aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2000-09-09 03:15:32 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2000-09-09 03:15:32 +0800
commitae4764c108d1efe86f0d7b41227959d6b0af2b96 (patch)
tree6b58110068cca13ecc99f7a328b164bc094eba32
parent22c9e50e6996f98cb98f3e342708081786eefd2a (diff)
downloadgsoc2013-evolution-ae4764c108d1efe86f0d7b41227959d6b0af2b96.tar
gsoc2013-evolution-ae4764c108d1efe86f0d7b41227959d6b0af2b96.tar.gz
gsoc2013-evolution-ae4764c108d1efe86f0d7b41227959d6b0af2b96.tar.bz2
gsoc2013-evolution-ae4764c108d1efe86f0d7b41227959d6b0af2b96.tar.lz
gsoc2013-evolution-ae4764c108d1efe86f0d7b41227959d6b0af2b96.tar.xz
gsoc2013-evolution-ae4764c108d1efe86f0d7b41227959d6b0af2b96.tar.zst
gsoc2013-evolution-ae4764c108d1efe86f0d7b41227959d6b0af2b96.zip
Implemented a new `EFolderTree' object. Make `EStorage' use it
instead of doing the folder tree bookkeeping by itself. Fix my broken fix to Clahey's broken warning fix. svn path=/trunk/; revision=5272
-rw-r--r--shell/ChangeLog32
-rw-r--r--shell/Makefile.am6
-rw-r--r--shell/e-folder-tree.c377
-rw-r--r--shell/e-folder-tree.h52
-rw-r--r--shell/e-storage.c240
-rw-r--r--shell/evolution-storage-listener.c2
6 files changed, 522 insertions, 187 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 7441bf61cc..2a3c9d06ed 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,5 +1,37 @@
2000-09-08 Ettore Perazzoli <ettore@helixcode.com>
+ * e-storage.c: Replaced the `path_to_folder' GHashTable with an
+ EFolderTree named `folder_tree'.
+ (init): Updated accordingly.
+ (destroy): Updated accordingly.
+ (free_private): Removed.
+ (remove_folder): Removed.
+ (folder_new): Removed.
+ (folder_remove_subfolder): Removed.
+ (folder_add_subfolder): Removed.
+ (folder_destroy): Removed.
+ (get_parent_path): Removed.
+ (impl_list_folders): Reimplemented by using the `EFolderTree'
+ methods.
+ (e_storage_construct): Don't create the root folder here.
+ (get_path_for_physical_uri_foreach): Updated to be an
+ `EFolderTreeForeachFunc'.
+ (e_storage_get_path_for_physical_uri): Likewise, updated to use
+ `e_folder_tree_foreach()'.
+ (e_storage_new_folder): Updated to use the EFolderTree.
+ (e_storage_removed_folder): Likewise.
+ (folder_destroy_notify): New function, for the destroy
+ notification of `EFolder'.
+
+ * evolution-storage-listener.c: Change the `servant' member in
+ `EvolutionStorageListenerPrivate' into an
+ `EvolutionStorageListenerServant'.
+
+ * e-folder-tree.c: New.
+ * e-folder-tree.h: New.
+
+2000-09-08 Ettore Perazzoli <ettore@helixcode.com>
+
* evolution-storage-listener.c (create_servant): Return an
`EvolutionStorageListenerServant' instead of a
`POA_Evolution_StorageListener'.
diff --git a/shell/Makefile.am b/shell/Makefile.am
index b167fe3354..848310ce33 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -46,16 +46,18 @@ noinst_LIBRARIES = \
libeshell_a_SOURCES = \
$(IDL_GENERATED) \
+ e-folder-tree.c \
+ e-folder-tree.h \
evolution-local-storage.c \
evolution-local-storage.h \
evolution-session.c \
evolution-session.h \
evolution-shell-client.c \
evolution-shell-client.h \
- evolution-shell-component.c \
- evolution-shell-component.h \
evolution-shell-component-client.c \
evolution-shell-component-client.h \
+ evolution-shell-component.c \
+ evolution-shell-component.h \
evolution-shell-view.c \
evolution-shell-view.h \
evolution-storage-listener.c \
diff --git a/shell/e-folder-tree.c b/shell/e-folder-tree.c
new file mode 100644
index 0000000000..38a7206051
--- /dev/null
+++ b/shell/e-folder-tree.c
@@ -0,0 +1,377 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-folder-set.c
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <string.h>
+
+#include "e-folder-tree.h"
+
+
+struct _Folder {
+ struct _Folder *parent;
+ char *path;
+ void *data;
+ GList *subfolders;
+};
+typedef struct _Folder Folder;
+
+struct _EFolderTree {
+ GHashTable *path_to_folder;
+
+ EFolderDestroyNotify folder_destroy_notify;
+ void *folder_destroy_notify_closure;
+};
+
+
+/* Utility functions. */
+
+static char *
+get_parent_path (const char *path)
+{
+ const char *last_separator;
+
+ g_assert (g_path_is_absolute (path));
+
+ last_separator = strrchr (path, G_DIR_SEPARATOR);
+
+ if (last_separator == path)
+ return g_strdup (G_DIR_SEPARATOR_S);
+
+ return g_strndup (path, last_separator - path);
+}
+
+static void
+traverse_subtree (EFolderTree *tree,
+ Folder *root_folder,
+ EFolderTreeForeachFunc foreach_func,
+ void *data)
+{
+ GList *p;
+
+ g_assert (foreach_func != NULL);
+
+ (* foreach_func) (tree, root_folder->path, root_folder->data, data);
+
+ for (p = root_folder->subfolders; p != NULL; p = p->next) {
+ Folder *folder;
+
+ folder = (Folder *) p->data;
+ traverse_subtree (tree, folder, foreach_func, data);
+ }
+}
+
+
+/* Folder handling. */
+
+static Folder *
+folder_new (const char *path,
+ void *data)
+{
+ Folder *folder;
+
+ folder = g_new (Folder, 1);
+ folder->parent = NULL;
+ folder->path = g_strdup (path);
+ folder->data = data;
+ folder->subfolders = NULL;
+
+ return folder;
+}
+
+static void
+folder_remove_subfolder (Folder *folder,
+ Folder *subfolder)
+{
+ g_list_remove (folder->subfolders, folder);
+}
+
+static void
+folder_add_subfolder (Folder *folder,
+ Folder *subfolder)
+{
+ folder->subfolders = g_list_prepend (folder->subfolders, subfolder);
+ subfolder->parent = folder;
+}
+
+static void
+folder_destroy (Folder *folder)
+{
+ g_assert (folder->subfolders == NULL);
+
+ if (folder->parent != NULL)
+ folder_remove_subfolder (folder->parent, folder);
+
+ g_free (folder->path);
+
+ g_free (folder);
+}
+
+static void
+remove_folder (EFolderTree *folder_tree,
+ Folder *folder)
+{
+ if (folder->subfolders != NULL) {
+ GList *p;
+
+ for (p = folder->subfolders; p != NULL; p = p->next) {
+ Folder *subfolder;
+
+ subfolder = (Folder *) p->data;
+ remove_folder (folder_tree, subfolder);
+ }
+
+ g_list_free (folder->subfolders);
+ folder->subfolders = NULL;
+ }
+
+ g_hash_table_remove (folder_tree->path_to_folder, folder->path);
+
+ if (folder_tree->folder_destroy_notify != NULL)
+ (* folder_tree->folder_destroy_notify) (folder_tree,
+ folder->path,
+ folder->data,
+ folder_tree->folder_destroy_notify_closure);
+
+ folder_destroy (folder);
+}
+
+
+/**
+ * e_folder_tree_new:
+ * @folder_destroy_notify: Function to be called when a folder gets removed from the tree
+ * @closure: Additional data to pass to @folder_destroy_notify
+ *
+ * Create a new EFolderTree.
+ *
+ * Return value: A pointer to the newly created EFolderTree.
+ **/
+EFolderTree *
+e_folder_tree_new (EFolderDestroyNotify folder_destroy_notify,
+ void *closure)
+{
+ EFolderTree *new;
+ Folder *root_folder;
+
+ new = g_new (EFolderTree, 1);
+
+ new->folder_destroy_notify = folder_destroy_notify;
+ new->folder_destroy_notify_closure = closure;
+
+ new->path_to_folder = g_hash_table_new (g_str_hash, g_str_equal);
+
+ root_folder = folder_new (G_DIR_SEPARATOR_S, NULL);
+ g_hash_table_insert (new->path_to_folder, root_folder->path, root_folder);
+
+ return new;
+}
+
+/**
+ * e_folder_tree_destroy:
+ * @folder_tree: A pointer to an EFolderTree
+ *
+ * Destroy @folder_tree.
+ **/
+void
+e_folder_tree_destroy (EFolderTree *folder_tree)
+{
+ Folder *root_folder;
+
+ g_return_if_fail (folder_tree != NULL);
+
+ root_folder = g_hash_table_lookup (folder_tree->path_to_folder, G_DIR_SEPARATOR_S);
+ remove_folder (folder_tree, root_folder);
+
+ g_hash_table_destroy (folder_tree->path_to_folder);
+
+ g_free (folder_tree);
+}
+
+/**
+ * e_folder_tree_add:
+ * @folder_tree: A pointer to an EFolderTree
+ * @path: Path at which the new folder must be added
+ * @data: Data associated with the new folder
+ *
+ * Insert a new folder at @path, with the specified @data.
+ *
+ * Return value: %TRUE if successful, %FALSE if failed.
+ **/
+gboolean
+e_folder_tree_add (EFolderTree *folder_tree,
+ const char *path,
+ void *data)
+{
+ Folder *parent_folder;
+ Folder *folder;
+ char *parent_path;
+
+ g_return_val_if_fail (folder_tree != NULL, FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (g_path_is_absolute (path), FALSE);
+
+ parent_path = get_parent_path (path);
+
+ parent_folder = g_hash_table_lookup (folder_tree->path_to_folder, parent_path);
+ if (parent_folder == NULL) {
+ g_warning ("%s: Trying to add a subfolder to a path that does not exist yet -- %s",
+ __FUNCTION__, parent_path);
+ return FALSE;
+ }
+
+ folder = g_hash_table_lookup (folder_tree->path_to_folder, path);
+ if (folder != NULL) {
+ g_warning ("%s: Trying to add a subfolder for a path that already exists -- %s",
+ __FUNCTION__, path);
+ return FALSE;
+ }
+
+ folder = folder_new (path, data);
+ folder_add_subfolder (parent_folder, folder);
+
+ g_hash_table_insert (folder_tree->path_to_folder, folder->path, folder);
+
+ g_free (parent_path);
+
+ return TRUE;
+}
+
+/**
+ * e_folder_tree_remove:
+ * @folder_tree: A pointer to an EFolderTree
+ * @path: Path of the folder to remove
+ *
+ * Remove the folder at @path from @folder_tree.
+ *
+ * Return value: %TRUE if successful, %FALSE if failed.
+ **/
+gboolean
+e_folder_tree_remove (EFolderTree *folder_tree,
+ const char *path)
+{
+ Folder *folder;
+
+ g_return_val_if_fail (folder_tree != NULL, FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (g_path_is_absolute (path), FALSE);
+
+ folder = g_hash_table_lookup (folder_tree->path_to_folder, path);
+ if (folder == NULL)
+ return FALSE;
+
+ remove_folder (folder_tree, folder);
+ return TRUE;
+}
+
+/**
+ * e_folder_tree_get_folder:
+ * @folder_tree: A pointer to an EFolderTree
+ * @path: Path of the folder for which we want to get the data
+ *
+ * Get the data for the folder at @path.
+ *
+ * Return value: The pointer to the data for the folder at @path.
+ **/
+void *
+e_folder_tree_get_folder (EFolderTree *folder_tree,
+ const char *path)
+{
+ Folder *folder;
+
+ g_return_val_if_fail (folder_tree != NULL, NULL);
+ g_return_val_if_fail (path != NULL, NULL);
+ g_return_val_if_fail (g_path_is_absolute (path), NULL);
+
+ folder = g_hash_table_lookup (folder_tree->path_to_folder, path);
+ return folder->data;
+}
+
+/**
+ * e_folder_tree_get_subfolders:
+ * @folder_tree: A pointer to an EFolderTree
+ * @path: A path in @folder_tree
+ *
+ * Get a list of the paths of the subfolders of @path.
+ *
+ * Return value: A list of pointers to the paths of the subfolders. The list
+ * and the strings must be freed by the caller.
+ **/
+GList *
+e_folder_tree_get_subfolders (EFolderTree *folder_tree,
+ const char *path)
+{
+ Folder *folder;
+ GList *list;
+ GList *p;
+
+ g_return_val_if_fail (folder_tree != NULL, NULL);
+ g_return_val_if_fail (path != NULL, NULL);
+ g_return_val_if_fail (g_path_is_absolute (path), NULL);
+
+ folder = g_hash_table_lookup (folder_tree->path_to_folder, path);
+ if (folder == NULL)
+ return NULL;
+
+ list = NULL;
+ for (p = folder->subfolders; p != NULL; p = p->next) {
+ const Folder *folder;
+
+ folder = (const Folder *) p->data;
+ list = g_list_prepend (list, g_strdup (folder->path));
+ }
+
+ return list;
+}
+
+
+/**
+ * e_folder_tree_foreach:
+ * @folder_tree:
+ * @foreach_func:
+ * @data:
+ *
+ * Call @foreach_func with the specified @data for all the folders
+ * in @folder_tree, starting at the root node.
+ **/
+void
+e_folder_tree_foreach (EFolderTree *folder_tree,
+ EFolderTreeForeachFunc foreach_func,
+ void *data)
+{
+ Folder *root_node;
+
+ g_return_if_fail (folder_tree != NULL);
+ g_return_if_fail (foreach_func != NULL);
+
+ root_node = g_hash_table_lookup (folder_tree->path_to_folder,
+ G_DIR_SEPARATOR_S);
+ if (root_node == NULL) {
+ g_warning ("%s -- What?! No root node!?", __FUNCTION__);
+ return;
+ }
+
+ traverse_subtree (folder_tree, root_node, foreach_func, data);
+}
diff --git a/shell/e-folder-tree.h b/shell/e-folder-tree.h
new file mode 100644
index 0000000000..59613cbaba
--- /dev/null
+++ b/shell/e-folder-tree.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-folder-tree.h
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+#ifndef _E_FOLDER_TREE_H_
+#define _E_FOLDER_TREE_H_
+
+
+typedef struct _EFolderTree EFolderTree;
+
+typedef void (* EFolderDestroyNotify) (EFolderTree *tree, const char *path, void *data, void *closure);
+typedef void (* EFolderTreeForeachFunc) (EFolderTree *tree, const char *path, void *data, void *closure);
+
+
+EFolderTree *e_folder_tree_new (EFolderDestroyNotify folder_destroy_notify,
+ void *closure);
+void e_folder_tree_destroy (EFolderTree *folder_tree);
+gboolean e_folder_tree_add (EFolderTree *folder_tree,
+ const char *path,
+ void *data);
+gboolean e_folder_tree_remove (EFolderTree *folder_tree,
+ const char *path);
+
+void *e_folder_tree_get_folder (EFolderTree *folder_tree,
+ const char *path);
+GList *e_folder_tree_get_subfolders (EFolderTree *folder_tree,
+ const char *path);
+
+void e_folder_tree_foreach (EFolderTree *folder_tree,
+ EFolderTreeForeachFunc foreach_func,
+ void *data);
+
+#endif /* _E_FOLDER_TREE_H_ */
diff --git a/shell/e-storage.c b/shell/e-storage.c
index ae984f7a09..ee09b5576c 100644
--- a/shell/e-storage.c
+++ b/shell/e-storage.c
@@ -32,6 +32,8 @@
#include "e-util/e-util.h"
+#include "e-folder-tree.h"
+
#include "e-storage.h"
@@ -41,18 +43,8 @@ static GtkObjectClass *parent_class = NULL;
#define ES_CLASS(obj) \
E_STORAGE_CLASS (GTK_OBJECT (obj)->klass)
-/* This describes a folder and its children. */
-struct _Folder {
- struct _Folder *parent;
-
- char *path;
- EFolder *e_folder;
- GList *subfolders;
-};
-typedef struct _Folder Folder;
-
struct _EStoragePrivate {
- GHashTable *path_to_folder; /* Folder */
+ EFolderTree *folder_tree;
};
enum {
@@ -64,111 +56,23 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-/* Folder handling. */
-
-static Folder *
-folder_new (EFolder *e_folder,
- const char *path)
-{
- Folder *folder;
-
- folder = g_new (Folder, 1);
- folder->path = g_strdup (path);
- folder->parent = NULL;
- folder->e_folder = e_folder;
- folder->subfolders = NULL;
-
- return folder;
-}
-
-static void
-folder_remove_subfolder (Folder *folder, Folder *subfolder)
-{
- g_list_remove (folder->subfolders, folder);
-}
-
-static void
-folder_add_subfolder (Folder *folder, Folder *subfolder)
-{
- folder->subfolders = g_list_prepend (folder->subfolders, subfolder);
- subfolder->parent = folder;
-}
-
-static void
-folder_destroy (Folder *folder)
-{
- g_assert (folder->subfolders == NULL);
-
- if (folder->parent != NULL)
- folder_remove_subfolder (folder->parent, folder);
-
- g_free (folder->path);
-
- if (folder->e_folder != NULL)
- gtk_object_unref (GTK_OBJECT (folder->e_folder));
-
- g_free (folder);
-}
+/* Destroy notification function for the folders in the tree. */
static void
-remove_folder (EStorage *storage,
- Folder *folder)
+folder_destroy_notify (EFolderTree *tree,
+ const char *path,
+ void *data,
+ void *closure)
{
- EStoragePrivate *priv;
-
- priv = storage->priv;
-
- if (folder->subfolders != NULL) {
- GList *p;
-
- for (p = folder->subfolders; p != NULL; p = p->next) {
- Folder *subfolder;
-
- subfolder = (Folder *) p->data;
- remove_folder (storage, subfolder);
- }
+ EFolder *e_folder;
- g_list_free (folder->subfolders);
- folder->subfolders = NULL;
+ if (data == NULL) {
+ /* The root folder has no EFolder associated to it. */
+ return;
}
- g_hash_table_remove (priv->path_to_folder, folder->path);
-
- folder_destroy (folder);
-}
-
-static void
-free_private (EStorage *storage)
-{
- EStoragePrivate *priv;
- Folder *root_folder;
-
- priv = storage->priv;
-
- root_folder = g_hash_table_lookup (priv->path_to_folder, G_DIR_SEPARATOR_S);
- remove_folder (storage, root_folder);
-
- g_hash_table_destroy (priv->path_to_folder);
-
- g_free (priv);
-}
-
-
-/* Private utility functions. */
-
-static char *
-get_parent_path (const char *path)
-{
- const char *last_separator;
-
- g_assert (g_path_is_absolute (path));
-
- last_separator = strrchr (path, G_DIR_SEPARATOR);
-
- if (last_separator == path)
- return g_strdup (G_DIR_SEPARATOR_S);
-
- return g_strndup (path, last_separator - path);
+ e_folder = E_FOLDER (data);
+ gtk_object_unref (GTK_OBJECT (e_folder));
}
@@ -178,10 +82,13 @@ static void
destroy (GtkObject *object)
{
EStorage *storage;
+ EStoragePrivate *priv;
storage = E_STORAGE (object);
+ priv = storage->priv;
- free_private (storage);
+ if (priv->folder_tree != NULL)
+ e_folder_tree_destroy (priv->folder_tree);
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@@ -193,23 +100,29 @@ static GList *
impl_list_folders (EStorage *storage,
const char *path)
{
- Folder *folder;
- Folder *subfolder;
+ EStoragePrivate *priv;
+ GList *path_list;
GList *list;
GList *p;
- folder = g_hash_table_lookup (storage->priv->path_to_folder, path);
- if (folder == NULL)
- return NULL;
+ priv = storage->priv;
+
+ path_list = e_folder_tree_get_subfolders (priv->folder_tree, path);
list = NULL;
- for (p = folder->subfolders; p != NULL; p = p->next) {
- subfolder = (Folder *) p->data;
+ for (p = path_list; p != NULL; p = p->next) {
+ EFolder *e_folder;
+ const char *sub_path;
+
+ sub_path = (const char *) p->data;
+ e_folder = e_folder_tree_get_folder (priv->folder_tree, sub_path);
- gtk_object_ref (GTK_OBJECT (subfolder->e_folder));
- list = g_list_prepend (list, subfolder->e_folder);
+ gtk_object_ref (GTK_OBJECT (e_folder));
+ list = g_list_prepend (list, e_folder);
}
+ e_free_string_list (path_list);
+
return list;
}
@@ -218,15 +131,13 @@ impl_get_folder (EStorage *storage,
const char *path)
{
EStoragePrivate *priv;
- Folder *folder;
+ EFolder *e_folder;
priv = storage->priv;
- folder = g_hash_table_lookup (priv->path_to_folder, path);
- if (folder == NULL)
- return NULL;
+ e_folder = (EFolder *) e_folder_tree_get_folder (priv->folder_tree, path);
- return folder->e_folder;
+ return e_folder;
}
static const char *
@@ -300,7 +211,8 @@ init (EStorage *storage)
EStoragePrivate *priv;
priv = g_new (EStoragePrivate, 1);
- priv->path_to_folder = g_hash_table_new (g_str_hash, g_str_equal);
+
+ priv->folder_tree = e_folder_tree_new (folder_destroy_notify, NULL);
storage->priv = priv;
}
@@ -311,15 +223,10 @@ init (EStorage *storage)
void
e_storage_construct (EStorage *storage)
{
- Folder *root_folder;
-
g_return_if_fail (storage != NULL);
g_return_if_fail (E_IS_STORAGE (storage));
GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (storage), GTK_FLOATING);
-
- root_folder = folder_new (NULL, G_DIR_SEPARATOR_S);
- g_hash_table_insert (storage->priv->path_to_folder, root_folder->path, root_folder);
}
EStorage *
@@ -463,30 +370,27 @@ struct _GetPathForPhysicalUriForeachData {
typedef struct _GetPathForPhysicalUriForeachData GetPathForPhysicalUriForeachData;
static void
-get_path_for_physical_uri_foreach (void *key,
- void *value,
- void *data)
+get_path_for_physical_uri_foreach (EFolderTree *folder_tree,
+ const char *path,
+ void *data,
+ void *closure)
{
GetPathForPhysicalUriForeachData *foreach_data;
const char *physical_uri;
- Folder *folder;
+ EFolder *e_folder;
foreach_data = (GetPathForPhysicalUriForeachData *) data;
if (foreach_data->retval != NULL)
return;
- folder = (Folder *) value;
- if (folder->e_folder == NULL)
+ e_folder = (EFolder *) data;
+ if (e_folder == NULL)
return;
- physical_uri = e_folder_get_physical_uri (folder->e_folder);
-
- if (strcmp (foreach_data->physical_uri, physical_uri) == 0) {
- const char *path;
+ physical_uri = e_folder_get_physical_uri (e_folder);
- path = (const char *) key;
+ if (strcmp (foreach_data->physical_uri, physical_uri) == 0)
foreach_data->retval = g_strdup (path);
- }
}
/**
@@ -514,9 +418,9 @@ e_storage_get_path_for_physical_uri (EStorage *storage,
priv = storage->priv;
foreach_data.physical_uri = physical_uri;
- foreach_data.retval = NULL;
+ foreach_data.retval = NULL;
- g_hash_table_foreach (priv->path_to_folder, get_path_for_physical_uri_foreach, &foreach_data);
+ e_folder_tree_foreach (priv->folder_tree, get_path_for_physical_uri_foreach, &foreach_data);
return foreach_data.retval;
}
@@ -529,52 +433,24 @@ e_storage_get_path_for_physical_uri (EStorage *storage,
gboolean
e_storage_new_folder (EStorage *storage,
- const char *full_path,
+ const char *path,
EFolder *e_folder)
{
EStoragePrivate *priv;
- Folder *folder;
- Folder *parent_folder;
- const char *name;
- char *parent_path;
g_return_val_if_fail (storage != NULL, FALSE);
g_return_val_if_fail (E_IS_STORAGE (storage), FALSE);
- g_return_val_if_fail (full_path != NULL, FALSE);
- g_return_val_if_fail (g_path_is_absolute (full_path), FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (g_path_is_absolute (path), FALSE);
g_return_val_if_fail (e_folder != NULL, FALSE);
g_return_val_if_fail (E_IS_FOLDER (e_folder), FALSE);
priv = storage->priv;
- parent_path = get_parent_path (full_path);
-
- parent_folder = g_hash_table_lookup (priv->path_to_folder, parent_path);
- if (parent_folder == NULL) {
- g_warning ("%s: Trying to add a subfolder to a path that does not exist yet -- %s",
- __FUNCTION__, parent_path);
- return FALSE;
- }
-
- name = e_folder_get_name (e_folder);
- g_assert (name != NULL);
- g_return_val_if_fail (*name != G_DIR_SEPARATOR, FALSE);
-
- folder = g_hash_table_lookup (priv->path_to_folder, full_path);
- if (folder != NULL) {
- g_warning ("%s: Trying to add a subfolder for a path that already exists -- %s",
- __FUNCTION__, full_path);
+ if (! e_folder_tree_add (priv->folder_tree, path, e_folder))
return FALSE;
- }
-
- folder = folder_new (e_folder, full_path);
- folder_add_subfolder (parent_folder, folder);
-
- g_hash_table_insert (priv->path_to_folder, folder->path, folder);
- gtk_signal_emit (GTK_OBJECT (storage), signals[NEW_FOLDER], folder->path);
-
- g_free (parent_path);
+ gtk_signal_emit (GTK_OBJECT (storage), signals[NEW_FOLDER], path);
return TRUE;
}
@@ -584,7 +460,6 @@ e_storage_removed_folder (EStorage *storage,
const char *path)
{
EStoragePrivate *priv;
- Folder *folder;
g_return_val_if_fail (storage != NULL, FALSE);
g_return_val_if_fail (E_IS_STORAGE (storage), FALSE);
@@ -593,15 +468,12 @@ e_storage_removed_folder (EStorage *storage,
priv = storage->priv;
- folder = g_hash_table_lookup (priv->path_to_folder, path);
- if (folder == NULL) {
- g_warning ("%s: Folder not found -- %s", __FUNCTION__, path);
+ if (e_folder_tree_get_folder (priv->folder_tree, path) == NULL)
return FALSE;
- }
gtk_signal_emit (GTK_OBJECT (storage), signals[REMOVED_FOLDER], path);
- remove_folder (storage, folder);
+ e_folder_tree_remove (priv->folder_tree, path);
return TRUE;
}
diff --git a/shell/evolution-storage-listener.c b/shell/evolution-storage-listener.c
index 79afb04032..250c884734 100644
--- a/shell/evolution-storage-listener.c
+++ b/shell/evolution-storage-listener.c
@@ -38,7 +38,7 @@ static GtkObjectClass *parent_class = NULL;
struct _EvolutionStorageListenerPrivate {
Evolution_StorageListener corba_objref;
- POA_Evolution_StorageListener *servant;
+ EvolutionStorageListenerServant *servant;
};