aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-local.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/mail-local.c')
-rw-r--r--mail/mail-local.c119
1 files changed, 62 insertions, 57 deletions
diff --git a/mail/mail-local.c b/mail/mail-local.c
index 7d9c034708..eba907e178 100644
--- a/mail/mail-local.c
+++ b/mail/mail-local.c
@@ -53,7 +53,6 @@
#include "mail.h"
#include "mail-local.h"
#include "mail-tools.h"
-#include "folder-browser.h"
#include "mail-mt.h"
#include "mail-folder-cache.h"
#include "mail-vfolder.h"
@@ -1304,7 +1303,9 @@ mail_local_storage_startup (EvolutionShellClient *shellclient, const char *evolu
struct _reconfigure_msg {
struct _mail_msg msg;
- FolderBrowser *fb;
+ char *uri;
+ CamelFolder *folder;
+
char *newtype;
unsigned int index_body:1;
GtkWidget *frame;
@@ -1312,7 +1313,9 @@ struct _reconfigure_msg {
GtkWidget *cancel;
GtkWidget *check_index_body;
GtkOptionMenu *optionlist;
- CamelFolder *folder_out;
+
+ void (*done)(const char *uri, CamelFolder *folder, void*data);
+ void *done_data;
};
/* hash table of folders that the user has a reconfig-folder dialog for */
@@ -1324,7 +1327,7 @@ reconfigure_folder_describe (struct _mail_msg *mm, int done)
struct _reconfigure_msg *m = (struct _reconfigure_msg *)mm;
return g_strdup_printf (_("Changing folder \"%s\" to \"%s\" format"),
- m->fb->uri,
+ camel_folder_get_full_name (m->folder),
m->newtype);
}
@@ -1332,25 +1335,10 @@ static void
reconfigure_folder_reconfigure (struct _mail_msg *mm)
{
struct _reconfigure_msg *m = (struct _reconfigure_msg *)mm;
- CamelFolder *local_folder = NULL;
- d(printf("reconfiguring folder: %s to type %s\n", m->fb->uri, m->newtype));
+ d(printf("reconfiguring folder: %s to type %s\n", m->uri, m->newtype));
- if (strncmp (m->fb->uri, "file:", 5)) {
- camel_exception_setv (&mm->ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("%s may not be reconfigured because it is not a local folder"),
- m->fb->uri);
- return;
- }
-
- local_folder = mail_tool_uri_to_folder (m->fb->uri, 0, &mm->ex);
- if (camel_exception_is_set (&mm->ex)) {
- g_warning ("Can't resolve URI \"%s\" for reconfiguration!", m->fb->uri);
- return;
- }
-
- mail_local_folder_reconfigure (MAIL_LOCAL_FOLDER (local_folder), m->newtype, m->index_body, &mm->ex);
- m->folder_out = local_folder;
+ mail_local_folder_reconfigure (MAIL_LOCAL_FOLDER (m->folder), m->newtype, m->index_body, &mm->ex);
}
static void
@@ -1364,7 +1352,8 @@ reconfigure_folder_reconfigured (struct _mail_msg *mm)
"you may need to repair it manually."));
}
- message_list_set_folder (m->fb->message_list, m->folder_out, FALSE);
+ if (m->done)
+ m->done(m->uri, m->folder, m->done_data);
}
static void
@@ -1373,16 +1362,16 @@ reconfigure_folder_free (struct _mail_msg *mm)
struct _reconfigure_msg *m = (struct _reconfigure_msg *)mm;
/* remove this folder from our hash since we are done with it */
- g_hash_table_remove (reconfigure_folder_hash, m->fb->folder);
+ g_hash_table_remove (reconfigure_folder_hash, m->folder);
if (g_hash_table_size (reconfigure_folder_hash) == 0) {
/* additional cleanup */
g_hash_table_destroy (reconfigure_folder_hash);
reconfigure_folder_hash = NULL;
}
- if (m->folder_out)
- camel_object_unref (CAMEL_OBJECT (m->folder_out));
- gtk_object_unref (GTK_OBJECT (m->fb));
+ if (m->folder)
+ camel_object_unref (CAMEL_OBJECT (m->folder));
+ g_free(m->uri);
g_free (m->newtype);
}
@@ -1398,12 +1387,6 @@ reconfigure_clicked (GnomeDialog *dialog, int button, struct _reconfigure_msg *m
{
if (button == 0) {
GtkWidget *menu, *item;
-
- /* hack to clear the message list during update */
- /* we need to do this because the message list caches
- * CamelMessageInfos from the old folder. */
- message_list_set_folder(m->fb->message_list, NULL, FALSE);
-
menu = gtk_option_menu_get_menu(m->optionlist);
item = gtk_menu_get_active(GTK_MENU(menu));
m->newtype = g_strdup(gtk_object_get_data((GtkObject *)item, "type"));
@@ -1414,68 +1397,70 @@ reconfigure_clicked (GnomeDialog *dialog, int button, struct _reconfigure_msg *m
gtk_widget_set_sensitive (m->cancel, FALSE);
e_thread_put (mail_thread_queued, (EMsg *)m);
- } else
+ } else {
+ if (m->done)
+ m->done(m->uri, NULL, m->done_data);
mail_msg_free ((struct _mail_msg *)m);
+ }
if (button != -1)
gnome_dialog_close (dialog);
}
-void
-mail_local_reconfigure_folder (FolderBrowser *fb)
+static void
+reconfigure_got_folder(char *uri, CamelFolder *folder, void *data)
{
GladeXML *gui;
GnomeDialog *gd;
- struct _reconfigure_msg *m;
+ struct _reconfigure_msg *m = data;
char *title;
GList *p;
GtkWidget *menu;
char *currentformat;
int index=0, history=0;
- if (fb->folder == NULL) {
+ if (folder == NULL
+ || !MAIL_IS_LOCAL_FOLDER (folder)) {
g_warning ("Trying to reconfigure nonexistant folder");
+ /* error display ? */
+ if (m->done)
+ m->done(uri, NULL, m->done_data);
+ mail_msg_free((struct _mail_msg *)m);
return;
}
if (!reconfigure_folder_hash)
reconfigure_folder_hash = g_hash_table_new (NULL, NULL);
- if ((gd = g_hash_table_lookup (reconfigure_folder_hash, fb->folder))) {
+ if ((gd = g_hash_table_lookup (reconfigure_folder_hash, folder))) {
gdk_window_raise (GTK_WIDGET (gd)->window);
+ if (m->done)
+ m->done(uri, NULL, m->done_data);
+ mail_msg_free((struct _mail_msg *)m);
return;
}
- /* check if we can work on this folder */
- if (!MAIL_IS_LOCAL_FOLDER (fb->folder)) {
- e_notice (NULL, GNOME_MESSAGE_BOX_WARNING,
- _("You cannot change the format of a non-local folder."));
- return;
- }
-
- m = mail_msg_new (&reconfigure_folder_op, NULL, sizeof (*m));
-
gui = glade_xml_new (EVOLUTION_GLADEDIR "/local-config.glade", "dialog_format");
gd = (GnomeDialog *)glade_xml_get_widget (gui, "dialog_format");
title = g_strdup_printf (_("Reconfigure /%s"),
- camel_folder_get_full_name (fb->folder));
+ camel_folder_get_full_name (folder));
gtk_window_set_title (GTK_WINDOW (gd), title);
g_free (title);
-
+
+ m->uri = g_strdup(uri);
m->frame = glade_xml_get_widget (gui, "frame_format");
m->apply = glade_xml_get_widget (gui, "apply_format");
m->cancel = glade_xml_get_widget (gui, "cancel_format");
m->optionlist = (GtkOptionMenu *)glade_xml_get_widget (gui, "option_format");
m->check_index_body = glade_xml_get_widget (gui, "check_index_body");
m->newtype = NULL;
- m->fb = fb;
- m->folder_out = NULL;
- gtk_object_ref (GTK_OBJECT (fb));
+ m->folder = folder;
+ camel_object_ref(folder);
/* dynamically create the folder type list from camel */
/* we assume the list is static and never freed */
- currentformat = MAIL_LOCAL_FOLDER (fb->folder)->meta->format;
+ currentformat = MAIL_LOCAL_FOLDER (folder)->meta->format;
p = camel_session_list_providers(session, TRUE);
menu = gtk_menu_new();
while (p) {
@@ -1502,15 +1487,35 @@ mail_local_reconfigure_folder (FolderBrowser *fb)
gtk_option_menu_remove_menu (GTK_OPTION_MENU(m->optionlist));
gtk_option_menu_set_menu (GTK_OPTION_MENU(m->optionlist), menu);
gtk_option_menu_set_history(GTK_OPTION_MENU(m->optionlist), history);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m->check_index_body), MAIL_LOCAL_FOLDER (fb->folder)->meta->indexed);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m->check_index_body), MAIL_LOCAL_FOLDER (folder)->meta->indexed);
gtk_label_set_text ((GtkLabel *)glade_xml_get_widget (gui, "label_format"),
- MAIL_LOCAL_FOLDER (fb->folder)->meta->format);
+ MAIL_LOCAL_FOLDER (folder)->meta->format);
gtk_signal_connect (GTK_OBJECT (gd), "clicked", reconfigure_clicked, m);
gtk_object_unref (GTK_OBJECT (gui));
- g_hash_table_insert (reconfigure_folder_hash, (gpointer) fb->folder, (gpointer) gd);
+ g_hash_table_insert (reconfigure_folder_hash, (gpointer) folder, (gpointer) gd);
- gnome_dialog_run (GNOME_DIALOG (gd));
+ gtk_widget_show((GtkWidget *)gd);
+}
+
+void
+mail_local_reconfigure_folder(const char *uri, void (*done)(const char *uri, CamelFolder *folder, void *data), void *done_data)
+{
+ struct _reconfigure_msg *m;
+
+ if (strncmp(uri, "file:", 5) != 0) {
+ e_notice (NULL, GNOME_MESSAGE_BOX_WARNING,
+ _("You cannot change the format of a non-local folder."));
+ if (done)
+ done(uri, NULL, done_data);
+ return;
+ }
+
+ m = mail_msg_new (&reconfigure_folder_op, NULL, sizeof (*m));
+ m->done = done;
+ m->done_data = done_data;
+
+ mail_get_folder(uri, 0, reconfigure_got_folder, m, mail_thread_new);
}