aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-storage.c
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2000-06-08 01:01:52 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2000-06-08 01:01:52 +0800
commite7971bb4f5f1d262a3f3af99f81c221a724131da (patch)
tree9a27ea0d6eeda598771c40bea1b896a58d0bbe0f /shell/e-storage.c
parent6aac85ab5b50dc9e3cc454c37858755a564120c3 (diff)
downloadgsoc2013-evolution-e7971bb4f5f1d262a3f3af99f81c221a724131da.tar.gz
gsoc2013-evolution-e7971bb4f5f1d262a3f3af99f81c221a724131da.tar.zst
gsoc2013-evolution-e7971bb4f5f1d262a3f3af99f81c221a724131da.zip
Fixed a refcount leak and added interfaces to add/remove folders
from an EStorage (although they are not implemented yet). svn path=/trunk/; revision=3460
Diffstat (limited to 'shell/e-storage.c')
-rw-r--r--shell/e-storage.c148
1 files changed, 116 insertions, 32 deletions
diff --git a/shell/e-storage.c b/shell/e-storage.c
index 98ce48da70..b50a080fc4 100644
--- a/shell/e-storage.c
+++ b/shell/e-storage.c
@@ -64,6 +64,8 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
+/* Folder handling. */
+
static Folder *
folder_new (EFolder *e_folder,
const char *path)
@@ -71,9 +73,9 @@ folder_new (EFolder *e_folder,
Folder *folder;
folder = g_new (Folder, 1);
- folder->path = g_strdup (path);
- folder->parent = NULL;
- folder->e_folder = e_folder;
+ folder->path = g_strdup (path);
+ folder->parent = NULL;
+ folder->e_folder = e_folder;
folder->subfolders = NULL;
return folder;
@@ -95,29 +97,56 @@ folder_add_subfolder (Folder *folder, Folder *subfolder)
static void
folder_destroy (Folder *folder)
{
- GList *p;
+ g_assert (folder->subfolders == NULL);
if (folder->parent != NULL)
folder_remove_subfolder (folder->parent, folder);
g_free (folder->path);
- gtk_object_unref (GTK_OBJECT (folder->e_folder));
-
- for (p = folder->subfolders; p != NULL; p = p->next)
- folder_destroy (p->data);
+ if (folder->e_folder != NULL)
+ gtk_object_unref (GTK_OBJECT (folder->e_folder));
g_free (folder);
}
static void
+remove_folder (EStorage *storage,
+ Folder *folder)
+{
+ 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);
+ }
+
+ g_list_free (folder->subfolders);
+ folder->subfolders = NULL;
+ }
+
+ 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;
- g_hash_table_foreach (priv->path_to_folder, (GHFunc) folder_destroy, NULL);
+ 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);
@@ -125,11 +154,26 @@ free_private (EStorage *storage)
}
+/* GtkObject methods. */
+
+static void
+destroy (GtkObject *object)
+{
+ EStorage *storage;
+
+ storage = E_STORAGE (object);
+
+ free_private (storage);
+
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+
/* EStorage methods. */
static GList *
-list_folders (EStorage *storage,
- const char *path)
+impl_list_folders (EStorage *storage,
+ const char *path)
{
Folder *folder;
Folder *subfolder;
@@ -152,8 +196,8 @@ list_folders (EStorage *storage,
}
static EFolder *
-get_folder (EStorage *storage,
- const char *path)
+impl_get_folder (EStorage *storage,
+ const char *path)
{
EStoragePrivate *priv;
Folder *folder;
@@ -168,24 +212,29 @@ get_folder (EStorage *storage,
}
static const char *
-get_name (EStorage *storage)
+impl_get_name (EStorage *storage)
{
- return "(No name)";
+ return _("(No name)");
}
-
-/* GtkObject methods. */
-
static void
-destroy (GtkObject *object)
+impl_create_folder (EStorage *storage,
+ const char *path,
+ const char *type,
+ const char *description,
+ EStorageResultCallback callback,
+ void *data)
{
- EStorage *storage;
-
- storage = E_STORAGE (object);
-
- free_private (storage);
+ (* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data);
+}
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+static void
+impl_remove_folder (EStorage *storage,
+ const char *path,
+ EStorageResultCallback callback,
+ void *data)
+{
+ (* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data);
}
@@ -201,9 +250,11 @@ class_init (EStorageClass *class)
object_class->destroy = destroy;
- class->list_folders = list_folders;
- class->get_folder = get_folder;
- class->get_name = get_name;
+ class->list_folders = impl_list_folders;
+ class->get_folder = impl_get_folder;
+ class->get_name = impl_get_name;
+ class->create_folder = impl_create_folder;
+ class->remove_folder = impl_remove_folder;
signals[NEW_FOLDER] =
gtk_signal_new ("new_folder",
@@ -317,6 +368,40 @@ e_storage_get_name (EStorage *storage)
}
+/* Folder operations. */
+
+void
+e_storage_create_folder (EStorage *storage,
+ const char *path,
+ const char *type,
+ const char *description,
+ EStorageResultCallback callback,
+ void *data)
+{
+ g_return_if_fail (storage != NULL);
+ g_return_if_fail (E_IS_STORAGE (storage));
+ g_return_if_fail (path != NULL);
+ g_return_if_fail (type != NULL);
+ g_return_if_fail (callback != NULL);
+
+ (* ES_CLASS (storage)->create_folder) (storage, path, type, description, callback, data);
+}
+
+void
+e_storage_remove_folder (EStorage *storage,
+ const char *path,
+ EStorageResultCallback callback,
+ void *data)
+{
+ g_return_if_fail (storage != NULL);
+ g_return_if_fail (E_IS_STORAGE (storage));
+ g_return_if_fail (path != NULL);
+ g_return_if_fail (callback != NULL);
+
+ (* ES_CLASS (storage)->remove_folder) (storage, path, callback, data);
+}
+
+
/* These functions are used by subclasses to add and remove folders from the
state stored in the storage object. */
@@ -374,8 +459,8 @@ e_storage_new_folder (EStorage *storage,
}
gboolean
-e_storage_remove_folder (EStorage *storage,
- const char *path)
+e_storage_removed_folder (EStorage *storage,
+ const char *path)
{
EStoragePrivate *priv;
Folder *folder;
@@ -395,8 +480,7 @@ e_storage_remove_folder (EStorage *storage,
gtk_signal_emit (GTK_OBJECT (storage), signals[REMOVED_FOLDER], path);
- g_hash_table_remove (priv->path_to_folder, path);
- folder_destroy (folder);
+ remove_folder (storage, folder);
return TRUE;
}
4561b6abdf0ec4299d3c47f24e02ba3'>- Fix build, install / [list with custom LOCALBASE and PREFIXitetcu2009-06-091-16/+47 * - Update to 1.16pgollucci2009-06-063-4/+10 * - Update to 0.07001dhn2009-05-292-4/+4 * - Update to 1.50amdmi32009-05-222-4/+4 * - Chase math/libgmp4 shlib bumppav2009-05-141-1/+2 * Chase libgmp and bump PORTREVISION.ale2009-05-131-0/+1 * - Update to 1.49amdmi32009-05-122-4/+4 * - Adapt for aqbanking 3.xpav2009-05-122-7/+5 * - Update to 3.8.1pav2009-05-128-302/+325 * - Update to 2.2.9 (and fix build with new goffice)pav2009-05-124-5/+145 * - Update to 0.36dhn2009-05-119-129/+40 * - Update to 4.0.3miwi2009-05-094-29/+144 * Drop maintainership.lioux2009-05-071-1/+1 * - Pass maintainership to submitteramdmi32009-05-071-1/+1 * - Update to 2.6.1dhn2009-04-244-28/+20 * - Update to 6.03amdmi32009-04-223-7/+4 * - Update to 1.3chinsan2009-03-272-4/+4 * Mark MAKE_JOBS_SAFE for SMP compilationlioux2009-03-261-0/+1 * bump PORTREVISION after cmake updatemakc2009-03-251-0/+1 * - Update to 1.1.0chinsan2009-03-242-4/+4 * - Update to 6.02pav2009-03-233-4/+8 * - Update to version 0.9.1miwi2009-03-216-194/+120 * Release these ports into wild. I don't have time for these ports anymore. I ammezz2009-03-191-1/+1 * - externd support for tcl/tk 8.2dinoex2009-03-151-2/+0 * Update to 1.21arved2009-03-133-5/+5 * - Update to 6.01lwhsu2009-03-093-34/+32 * - Fix USE_GETTEXTtabthorpe2009-03-031-1/+1 * - Fix maintainer emailtabthorpe2009-03-031-1/+1 * - Remove finance/eqonomize, use finance/eqonomize-kde3tabthorpe2009-03-02