aboutsummaryrefslogtreecommitdiffstats
path: root/mail/subscribe-dialog.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/subscribe-dialog.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/subscribe-dialog.c')
-rw-r--r--mail/subscribe-dialog.c92
1 files changed, 53 insertions, 39 deletions
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;