diff options
author | Chris Toshok <toshok@helixcode.com> | 2000-10-11 10:05:29 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2000-10-11 10:05:29 +0800 |
commit | 73f3bc0bd4680f3e4d4fd77d5b9f5d598ffca209 (patch) | |
tree | 827b5cdf36e3a4f8e1daaaa13305d2783a07602f /mail | |
parent | 6d26494925d2875fed9739a55ec5d214f18fb972 (diff) | |
download | gsoc2013-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')
-rw-r--r-- | mail/ChangeLog | 29 | ||||
-rw-r--r-- | mail/component-factory.c | 35 | ||||
-rw-r--r-- | mail/mail-ops.c | 2 | ||||
-rw-r--r-- | mail/mail.h | 3 | ||||
-rw-r--r-- | mail/subscribe-dialog.c | 92 | ||||
-rw-r--r-- | mail/subscribe-dialog.h | 4 |
6 files changed, 123 insertions, 42 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index a803676dc2..e955c86300 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,32 @@ +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. + 2000-10-10 Larry Ewing <lewing@helixcode.com> * mail-format.c (mail_generate_reply): make sure we dup the return 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; } diff --git a/mail/mail-ops.c b/mail/mail-ops.c index ff4ff8ed1b..4a784d3688 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -1254,6 +1254,8 @@ setup_scan_subfolders (gpointer in_data, gpointer op_data, gtk_object_ref (GTK_OBJECT (input->storage)); data->new_folders = g_ptr_array_new (); + + gtk_object_ref (GTK_OBJECT(input->storage)); } static void diff --git a/mail/mail.h b/mail/mail.h index 8f548945f3..3b4b7b81df 100644 --- a/mail/mail.h +++ b/mail/mail.h @@ -26,6 +26,7 @@ #include "mail-config.h" #include "mail-config-gui.h" #include "folder-browser.h" +#include "shell/evolution-storage.h" extern char *evolution_dir; @@ -116,6 +117,8 @@ GtkWidget *mail_view_create (CamelFolder *source, const char *uid, CamelMimeMess /*takes a GSList of MailConfigServices */ void mail_load_storages (Evolution_Shell corba_shell, GSList *sources); void mail_add_new_storage (const char *uri, Evolution_Shell corba_shell, CamelException *ex); +/* used in the subscribe dialog code */ +EvolutionStorage* mail_lookup_storage (CamelService *service); /* session */ void session_init (void); diff --git a/mail/subscribe-dialog.c b/mail/subscribe-dialog.c index 3a4ae24951..22a12b0b92 100644 --- a/mail/subscribe-dialog.c +++ b/mail/subscribe-dialog.c @@ -136,6 +136,38 @@ make_folder_search_widget (GtkSignalFunc start_search_func, static void +subscribe_folder_info (SubscribeDialog *sc, CamelFolderInfo *info) +{ + char *path; + + path = g_strdup_printf ("/%s", info->full_name); /* XXX */ + + camel_store_subscribe_folder (sc->store, info->name, NULL); + + evolution_storage_new_folder (sc->storage, + path, + info->name, "mail", + info->url, + _("(No description)") /* XXX */); + + g_free (path); +} + +static void +unsubscribe_folder_info (SubscribeDialog *sc, CamelFolderInfo *info) +{ + char *path; + + path = g_strdup_printf ("/%s", info->full_name); /* XXX */ + + camel_store_unsubscribe_folder (sc->store, info->name, NULL); + + evolution_storage_removed_folder (sc->storage, path); + + g_free (path); +} + +static void subscribe_close (BonoboUIComponent *uic, void *user_data, const char *path) { @@ -166,19 +198,12 @@ subscribe_folder_foreach (int model_row, gpointer closure) printf ("subscribe: row %d, node_data %p\n", model_row, e_tree_model_node_get_data (sc->folder_model, node)); - if (!camel_store_folder_subscribed (sc->store, info->name)) { - camel_store_subscribe_folder (sc->store, info->name, NULL); -#if 0 - /* we need to remove it from the shell */ - evolution_storage_removed_folder (sc->storage, info->name); -#endif - - e_tree_model_node_changed (sc->folder_model, node); - } + if (!camel_store_folder_subscribed (sc->store, info->name)) + subscribe_folder_info (sc, info); } static void -subscribe_folder (GtkWidget *widget, gpointer user_data) +subscribe_folders (GtkWidget *widget, gpointer user_data) { SubscribeDialog *sc = SUBSCRIBE_DIALOG (user_data); @@ -196,21 +221,13 @@ unsubscribe_folder_foreach (int model_row, gpointer closure) printf ("unsubscribe: row %d, node_data %p\n", model_row, e_tree_model_node_get_data (sc->folder_model, node)); - if (camel_store_folder_subscribed (sc->store, info->name)) { - camel_store_unsubscribe_folder (sc->store, info->name, NULL); - -#if 0 - /* we need to remove it from the shell */ - evolution_storage_removed_folder (sc->storage, info->name); -#endif - - e_tree_model_node_changed (sc->folder_model, node); - } + if (camel_store_folder_subscribed (sc->store, info->name)) + unsubscribe_folder_info (sc, info); } static void -unsubscribe_folder (GtkWidget *widget, gpointer user_data) +unsubscribe_folders (GtkWidget *widget, gpointer user_data) { SubscribeDialog *sc = SUBSCRIBE_DIALOG (user_data); @@ -392,7 +409,7 @@ store_etable_value_at (ETableModel *etm, int col, int row, void *data) SubscribeDialog *sc = SUBSCRIBE_DIALOG (data); CamelStore *store = (CamelStore*)g_list_nth_data (sc->store_list, row); - return camel_service_get_name (CAMEL_SERVICE (store), FALSE); + return camel_service_get_name (CAMEL_SERVICE (store), TRUE); } static void @@ -466,8 +483,11 @@ storage_selected_cb (ETable *table, /* free up the existing CamelFolderInfo* if there is any */ if (sc->folder_info) camel_store_free_folder_info (sc->store, sc->folder_info); + if (sc->storage) + gtk_object_unref (GTK_OBJECT (sc->storage)); sc->store = store; + sc->storage = mail_lookup_storage (CAMEL_SERVICE (sc->store)); sc->folder_info = camel_store_get_folder_info (sc->store, NULL, TRUE, TRUE, FALSE, ex); if (camel_exception_is_set (ex)) { @@ -497,21 +517,10 @@ folder_toggle_cb (ETable *table, ETreePath *node = e_tree_model_node_at_row (sc->folder_model, row); CamelFolderInfo *info = e_tree_model_node_get_data (sc->folder_model, node); - if (camel_store_folder_subscribed (sc->store, info->name)) { - camel_store_unsubscribe_folder (sc->store, info->name, NULL); - -#if 0 - /* we need to remove it from the shell */ - evolution_storage_removed_folder (sc->storage, info->name); -#endif - } - else { - camel_store_subscribe_folder (sc->store, info->name, NULL); -#if 0 - /* we need to remove it from the shell */ - evolution_storage_removed_folder (sc->storage, info->name); -#endif - } + if (camel_store_folder_subscribed (sc->store, info->name)) + subscribe_folder_info (sc, info); + else + unsubscribe_folder_info (sc, info); e_tree_model_node_changed (sc->folder_model, node); } @@ -532,8 +541,8 @@ static BonoboUIVerb verbs [] = { BONOBO_UI_UNSAFE_VERB ("EditUnSelectAll", subscribe_unselect_all), /* Folder Menu / Toolbar */ - BONOBO_UI_UNSAFE_VERB ("SubscribeFolder", subscribe_folder), - BONOBO_UI_UNSAFE_VERB ("UnsubscribeFolder", unsubscribe_folder), + BONOBO_UI_UNSAFE_VERB ("SubscribeFolder", subscribe_folders), + BONOBO_UI_UNSAFE_VERB ("UnsubscribeFolder", unsubscribe_folders), /* Toolbar Specific */ BONOBO_UI_UNSAFE_VERB ("RefreshList", subscribe_refresh_list), @@ -778,6 +787,10 @@ subscribe_dialog_destroy (GtkObject *object) gtk_object_unref (GTK_OBJECT (sc->store_model)); g_list_foreach (sc->store_list, (GFunc)gtk_object_unref, NULL); + /* free our storage */ + if (sc->storage) + gtk_object_unref (GTK_OBJECT (sc->storage)); + subscribe_dialog_parent_class->destroy (object); } @@ -804,6 +817,7 @@ subscribe_dialog_construct (GtkObject *object, Evolution_Shell shell) */ sc->shell = shell; sc->store = NULL; + sc->storage = NULL; sc->folder_info = NULL; sc->store_list = NULL; diff --git a/mail/subscribe-dialog.h b/mail/subscribe-dialog.h index 7f8dff8405..84538f16f2 100644 --- a/mail/subscribe-dialog.h +++ b/mail/subscribe-dialog.h @@ -11,8 +11,7 @@ #include <bonobo/bonobo-control.h> #include <bonobo/bonobo-ui-compat.h> #include <bonobo/bonobo-property-bag.h> -#include "shell/Evolution.h" -#include "shell/evolution-storage-set-view-listener.h" +#include "shell/evolution-storage.h" #define SUBSCRIBE_DIALOG_TYPE (subscribe_dialog_get_type ()) #define SUBSCRIBE_DIALOG(o) (GTK_CHECK_CAST ((o), SUBSCRIBE_DIALOG_TYPE, SubscribeDialog)) @@ -39,6 +38,7 @@ struct _SubscribeDialog { ETreePath *folder_root; CamelStore *store; + EvolutionStorage *storage; CamelFolderInfo *folder_info; GList *store_list; |