aboutsummaryrefslogtreecommitdiffstats
path: root/mail/component-factory.c
diff options
context:
space:
mode:
authorChris Toshok <toshok@helixcode.com>2000-10-11 10:05:29 +0800
committerChris Toshok <toshok@src.gnome.org>2000-10-11 10:05:29 +0800
commit73f3bc0bd4680f3e4d4fd77d5b9f5d598ffca209 (patch)
tree827b5cdf36e3a4f8e1daaaa13305d2783a07602f /mail/component-factory.c
parent6d26494925d2875fed9739a55ec5d214f18fb972 (diff)
downloadgsoc2013-evolution-73f3bc0bd4680f3e4d4fd77d5b9f5d598ffca209.tar
gsoc2013-evolution-73f3bc0bd4680f3e4d4fd77d5b9f5d598ffca209.tar.gz
gsoc2013-evolution-73f3bc0bd4680f3e4d4fd77d5b9f5d598ffca209.tar.bz2
gsoc2013-evolution-73f3bc0bd4680f3e4d4fd77d5b9f5d598ffca209.tar.lz
gsoc2013-evolution-73f3bc0bd4680f3e4d4fd77d5b9f5d598ffca209.tar.xz
gsoc2013-evolution-73f3bc0bd4680f3e4d4fd77d5b9f5d598ffca209.tar.zst
gsoc2013-evolution-73f3bc0bd4680f3e4d4fd77d5b9f5d598ffca209.zip
add a ref to input->storage here so that the ref/unref pattern more
2000-10-10 Chris Toshok <toshok@helixcode.com> * mail-ops.c (setup_scan_subfolders): add a ref to input->storage here so that the ref/unref pattern more closely matches other mail-ops. also, this keeps the storage from being freed when we hit the unref in cleanup_scan_subfolders, which is important because we maintain a reference to it in the storage_hash in component-factory.c * subscribe-dialog.h: add storage field. * subscribe-dialog.c (subscribe_folder_info): new function, subscribe to a folder given it's CamelFolderInfo, and add it to the shell - we're generating a path from the name of the folder which is bad. (unsubscribe_folder_info): same (except we unsubscribe and remove from the shell). (storage_selected_cb): unref the currently selected storage. (subscribe_dialog_destroy): unref the currently selected storage. (subscribe_dialog_construct): sc->storage = NULL. * component-factory.c (mail_lookup_storage): new function, to look up a EvolutionStorage corresponding to a CamelService. we ref the EvolutionStorage before passing it back. (mail_add_new_storage): insert the storage into storages_hash if result is EVOLUTION_STORAGE_OK. * mail.h: add prototype for mail_lookup_storage. svn path=/trunk/; revision=5830
Diffstat (limited to 'mail/component-factory.c')
-rw-r--r--mail/component-factory.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 44702245ee..22a740854e 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -58,6 +58,7 @@ static void create_vfolder_storage (EvolutionShellComponent *shell_component);
static BonoboGenericFactory *factory = NULL;
static BonoboGenericFactory *summary_factory = NULL;
static gint running_objects = 0;
+static GHashTable *storages_hash;
static const EvolutionShellComponentFolderType folder_types[] = {
{ "mail", "evolution-inbox.png" },
@@ -149,6 +150,15 @@ owner_unset_cb (EvolutionShellComponent *shell_component, gpointer user_data)
}
static void
+hash_foreach (gpointer key,
+ gpointer value,
+ gpointer data)
+{
+ g_free (key);
+ gtk_object_unref (GTK_OBJECT (value));
+}
+
+static void
factory_destroy (BonoboEmbeddable *embeddable,
gpointer dummy)
{
@@ -162,6 +172,10 @@ factory_destroy (BonoboEmbeddable *embeddable,
g_warning ("Serious ref counting error");
factory = NULL;
+ g_hash_table_foreach (storages_hash, hash_foreach, NULL);
+ g_hash_table_destroy (storages_hash);
+ storages_hash = NULL;
+
gtk_main_quit ();
}
@@ -207,6 +221,7 @@ component_factory_init (void)
factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL);
summary_factory = bonobo_generic_factory_new (SUMMARY_FACTORY_ID, summary_fn, NULL);
+ storages_hash = g_hash_table_new (g_str_hash, g_str_equal);
if (factory == NULL) {
e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
@@ -218,6 +233,11 @@ component_factory_init (void)
e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
_("Cannot initialize Evolution's mail summary component."));
}
+
+ if (storages_hash == NULL) {
+ e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
+ _("Cannot initialize Evolution's mail storage hash."));
+ }
}
/* FIXME: remove */
@@ -304,12 +324,12 @@ mail_add_new_storage (const char *uri, Evolution_Shell corba_shell, CamelExcepti
}
storage = evolution_storage_new (url->host);
- camel_url_free (url);
res = evolution_storage_register_on_shell (storage, corba_shell);
switch (res) {
case EVOLUTION_STORAGE_OK:
+ g_hash_table_insert (storages_hash, g_strdup(url->host), storage);
mail_do_scan_subfolders (uri, storage);
/* falllll */
case EVOLUTION_STORAGE_ERROR_ALREADYREGISTERED:
@@ -320,4 +340,17 @@ mail_add_new_storage (const char *uri, Evolution_Shell corba_shell, CamelExcepti
"mail_tool_add_new_storage: Cannot register storage on shell");
break;
}
+
+ camel_url_free (url);
+}
+
+EvolutionStorage*
+mail_lookup_storage (CamelService *service)
+{
+ EvolutionStorage *storage = g_hash_table_lookup (storages_hash, service->url->host);
+
+ if (storage)
+ gtk_object_ref (GTK_OBJECT (storage));
+
+ return storage;
}