aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-01-05 01:02:57 +0800
committerDan Winship <danw@src.gnome.org>2001-01-05 01:02:57 +0800
commitf9f6c398725a2e0969e23753106edfb896ea5930 (patch)
tree669c0a196ef914fac5261bc8d7380bfcacc4f601 /shell
parent349554fff69003e2cb426d68092f6ed33b6eb1ff (diff)
downloadgsoc2013-evolution-f9f6c398725a2e0969e23753106edfb896ea5930.tar
gsoc2013-evolution-f9f6c398725a2e0969e23753106edfb896ea5930.tar.gz
gsoc2013-evolution-f9f6c398725a2e0969e23753106edfb896ea5930.tar.bz2
gsoc2013-evolution-f9f6c398725a2e0969e23753106edfb896ea5930.tar.lz
gsoc2013-evolution-f9f6c398725a2e0969e23753106edfb896ea5930.tar.xz
gsoc2013-evolution-f9f6c398725a2e0969e23753106edfb896ea5930.tar.zst
gsoc2013-evolution-f9f6c398725a2e0969e23753106edfb896ea5930.zip
New function to update a folder given its URI. Plus associated changes to
* evolution-storage.c (evolution_storage_update_folder_by_uri): New function to update a folder given its URI. Plus associated changes to other functions to keep track of the path<->URI mappings. svn path=/trunk/; revision=7248
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog7
-rw-r--r--shell/evolution-storage.c64
-rw-r--r--shell/evolution-storage.h38
3 files changed, 82 insertions, 27 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index df579059bd..c6befcb49b 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,10 @@
+2001-01-04 Dan Winship <danw@helixcode.com>
+
+ * evolution-storage.c (evolution_storage_update_folder_by_uri):
+ New function to update a folder given its URI. Plus associated
+ changes to other functions to keep track of the path<->URI
+ mappings.
+
2000-12-28 Ettore Perazzoli <ettore@helixcode.com>
* evolution-shell-client.c (user_select_folder): Make sure the
diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c
index 5ad51472a3..c87c031cd0 100644
--- a/shell/evolution-storage.c
+++ b/shell/evolution-storage.c
@@ -54,6 +54,9 @@ struct _EvolutionStoragePrivate {
/* The set of folders we have in this storage. */
EFolderTree *folder_tree;
+ /* Mappings from URIs to folder tree paths. */
+ GHashTable *uri_to_path;
+
/* The listener registered on this storage. */
GList *corba_storage_listeners;
};
@@ -271,6 +274,13 @@ impl_Storage_remove_listener (PortableServer_Servant servant,
/* GtkObject methods. */
static void
+free_mapping (gpointer key, gpointer value, gpointer user_data)
+{
+ g_free (key);
+ g_free (value);
+}
+
+static void
destroy (GtkObject *object)
{
EvolutionStorage *storage;
@@ -286,6 +296,10 @@ destroy (GtkObject *object)
g_free (priv->toplevel_node_type);
if (priv->folder_tree != NULL)
e_folder_tree_destroy (priv->folder_tree);
+ if (priv->uri_to_path != NULL) {
+ g_hash_table_foreach (priv->uri_to_path, free_mapping, NULL);
+ g_hash_table_destroy (priv->uri_to_path);
+ }
CORBA_exception_init (&ev);
@@ -351,6 +365,7 @@ init (EvolutionStorage *storage)
priv->toplevel_node_uri = NULL;
priv->toplevel_node_type = NULL;
priv->folder_tree = e_folder_tree_new (folder_destroy_notify, storage);
+ priv->uri_to_path = g_hash_table_new (g_str_hash, g_str_equal);
priv->corba_storage_listeners = NULL;
storage->priv = priv;
@@ -544,6 +559,12 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage,
corba_folder->physical_uri = CORBA_string_dup (physical_uri);
corba_folder->highlighted = highlighted;
+ if (! e_folder_tree_add (priv->folder_tree, path, corba_folder)) {
+ CORBA_free (corba_folder);
+ return EVOLUTION_STORAGE_ERROR_EXISTS;
+ }
+ g_hash_table_insert (priv->uri_to_path, g_strdup (physical_uri), g_strdup (path));
+
result = EVOLUTION_STORAGE_OK;
for (p = priv->corba_storage_listeners; p != NULL; p = p->next) {
@@ -567,11 +588,6 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage,
CORBA_exception_free (&ev);
- if (result == EVOLUTION_STORAGE_OK) {
- if (! e_folder_tree_add (priv->folder_tree, path, corba_folder))
- result = EVOLUTION_STORAGE_ERROR_EXISTS;
- }
-
return result;
}
@@ -637,12 +653,35 @@ evolution_storage_update_folder (EvolutionStorage *evolution_storage,
}
EvolutionStorageResult
+evolution_storage_update_folder_by_uri (EvolutionStorage *evolution_storage,
+ const char *physical_uri,
+ const char *display_name,
+ gboolean highlighted)
+{
+ EvolutionStoragePrivate *priv;
+ char *path;
+
+ g_return_val_if_fail (evolution_storage != NULL,
+ EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
+ g_return_val_if_fail (EVOLUTION_IS_STORAGE (evolution_storage),
+ EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
+ g_return_val_if_fail (physical_uri != NULL, EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
+
+ priv = evolution_storage->priv;
+
+ path = g_hash_table_lookup (priv->uri_to_path, physical_uri);
+ return evolution_storage_update_folder (evolution_storage, path, display_name, highlighted);
+}
+
+EvolutionStorageResult
evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
const char *path)
{
EvolutionStorageResult result;
EvolutionStoragePrivate *priv;
CORBA_Environment ev;
+ GNOME_Evolution_Folder *corba_folder;
+ gpointer key, value;
GList *p;
g_return_val_if_fail (evolution_storage != NULL,
@@ -657,6 +696,16 @@ evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
if (priv->corba_storage_listeners == NULL)
return EVOLUTION_STORAGE_ERROR_NOTREGISTERED;
+ corba_folder = e_folder_tree_get_folder (priv->folder_tree, path);
+ if (corba_folder == NULL)
+ return EVOLUTION_STORAGE_ERROR_NOTFOUND;
+ if (g_hash_table_lookup_extended (priv->uri_to_path, corba_folder->physical_uri, &key, &value)) {
+ g_hash_table_remove (priv->uri_to_path, key);
+ g_free (key);
+ g_free (value);
+ }
+ e_folder_tree_remove (priv->folder_tree, path);
+
CORBA_exception_init (&ev);
result = EVOLUTION_STORAGE_OK;
@@ -682,11 +731,6 @@ evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
CORBA_exception_free (&ev);
- if (result == EVOLUTION_STORAGE_OK) {
- if (! e_folder_tree_remove (priv->folder_tree, path))
- result = EVOLUTION_STORAGE_ERROR_NOTFOUND;
- }
-
return result;
}
diff --git a/shell/evolution-storage.h b/shell/evolution-storage.h
index 4457d9f9b8..824c7ea12a 100644
--- a/shell/evolution-storage.h
+++ b/shell/evolution-storage.h
@@ -84,23 +84,27 @@ EvolutionStorage *evolution_storage_new (const char *name,
const char *toplevel_node_uri,
const char *toplevel_node_type);
-EvolutionStorageResult evolution_storage_register (EvolutionStorage *storage,
- GNOME_Evolution_StorageRegistry corba_registry);
-EvolutionStorageResult evolution_storage_register_on_shell (EvolutionStorage *evolution_storage,
- GNOME_Evolution_Shell corba_shell);
-EvolutionStorageResult evolution_storage_new_folder (EvolutionStorage *evolution_storage,
- const char *path,
- const char *display_name,
- const char *type,
- const char *physical_uri,
- const char *description,
- gboolean highlighted);
-EvolutionStorageResult evolution_storage_update_folder (EvolutionStorage *evolution_storage,
- const char *path,
- const char *display_name,
- gboolean highlighted);
-EvolutionStorageResult evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
- const char *path);
+EvolutionStorageResult evolution_storage_register (EvolutionStorage *storage,
+ GNOME_Evolution_StorageRegistry corba_registry);
+EvolutionStorageResult evolution_storage_register_on_shell (EvolutionStorage *evolution_storage,
+ GNOME_Evolution_Shell corba_shell);
+EvolutionStorageResult evolution_storage_new_folder (EvolutionStorage *evolution_storage,
+ const char *path,
+ const char *display_name,
+ const char *type,
+ const char *physical_uri,
+ const char *description,
+ gboolean highlighted);
+EvolutionStorageResult evolution_storage_update_folder (EvolutionStorage *evolution_storage,
+ const char *path,
+ const char *display_name,
+ gboolean highlighted);
+EvolutionStorageResult evolution_storage_update_folder_by_uri (EvolutionStorage *evolution_storage,
+ const char *physical_uri,
+ const char *display_name,
+ gboolean highlighted);
+EvolutionStorageResult evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
+ const char *path);
#ifdef __cplusplus
}