Redone to show a dialogue first, and show progress of whats happening as
2000-08-07 Not Zed <NotZed@HelixCode.com> * mail-local.c (local_reconfigure_folder): Redone to show a dialogue first, and show progress of whats happening as its done. * Makefile.am (glade_DATA): Added local-config.glade, for mailbox reconfig dialogue. 2000-08-04 Not Zed <NotZed@HelixCode.com> * folder-browser.c (mail_uri_to_folder): Use local_uri_to_folder() for local uri's (file://). * mail-local.c (local_uri_to_folder): Handle looking up folder storage type before opening the store/folder. (local_reconfigure_folder): Function to reconfigure the format of a local mailbox into another storage format. * Makefile.am (evolution_mail_SOURCES): Added mail-local.c and missing mail-vfolder.h. svn path=/trunk/; revision=4591
This commit is contained in:
@ -1,3 +1,24 @@
|
||||
2000-08-07 Not Zed <NotZed@HelixCode.com>
|
||||
|
||||
* mail-local.c (local_reconfigure_folder): Redone to show a
|
||||
dialogue first, and show progress of whats happening as its done.
|
||||
|
||||
* Makefile.am (glade_DATA): Added local-config.glade, for mailbox
|
||||
reconfig dialogue.
|
||||
|
||||
2000-08-04 Not Zed <NotZed@HelixCode.com>
|
||||
|
||||
* folder-browser.c (mail_uri_to_folder): Use local_uri_to_folder()
|
||||
for local uri's (file://).
|
||||
|
||||
* mail-local.c (local_uri_to_folder): Handle looking up folder
|
||||
storage type before opening the store/folder.
|
||||
(local_reconfigure_folder): Function to reconfigure the format of
|
||||
a local mailbox into another storage format.
|
||||
|
||||
* Makefile.am (evolution_mail_SOURCES): Added mail-local.c and
|
||||
missing mail-vfolder.h.
|
||||
|
||||
2000-08-07 Jeffrey Stedfast <fejj@helixcode.com>
|
||||
|
||||
* Makefile.am: Added mail-view.c
|
||||
|
||||
@ -53,6 +53,8 @@ evolution_mail_SOURCES = \
|
||||
mail-threads.h \
|
||||
mail-types.h \
|
||||
mail-vfolder.c \
|
||||
mail-vfolder.h \
|
||||
mail-local.c \
|
||||
mail-view.c \
|
||||
main.c \
|
||||
message-list.c \
|
||||
@ -108,7 +110,7 @@ gnorba_DATA = $(GOAD_FILES)
|
||||
endif
|
||||
|
||||
gladedir = $(datadir)/evolution/glade
|
||||
glade_DATA = mail-config.glade mail-config-druid.glade
|
||||
glade_DATA = mail-config.glade mail-config-druid.glade local-config.glade
|
||||
|
||||
iconsdir = $(datadir)/images/evolution
|
||||
|
||||
|
||||
@ -115,6 +115,13 @@ control_activate (BonoboControl *control, BonoboUIHandler *uih,
|
||||
0,
|
||||
0, 0, forget_passwords, NULL);
|
||||
|
||||
|
||||
bonobo_ui_handler_menu_new_item (uih, "/Tools/Configure Folder", _("_Configure Folder"),
|
||||
NULL, -1,
|
||||
BONOBO_UI_HANDLER_PIXMAP_NONE,
|
||||
0,
|
||||
0, 0, configure_folder, folder_browser);
|
||||
|
||||
toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL,
|
||||
GTK_TOOLBAR_BOTH);
|
||||
|
||||
@ -155,6 +162,7 @@ control_deactivate (BonoboControl *control, BonoboUIHandler *uih,
|
||||
bonobo_ui_handler_menu_remove (uih, "/Tools/vFolder Editor ...");
|
||||
bonobo_ui_handler_menu_remove (uih, "/Tools/Mail Configuration ...");
|
||||
bonobo_ui_handler_menu_remove (uih, "/Tools/Forget Passwords");
|
||||
bonobo_ui_handler_menu_remove (uih, "/Tools/Configure Folder");
|
||||
bonobo_ui_handler_dock_remove (uih, toolbar_name);
|
||||
g_free (toolbar_name);
|
||||
}
|
||||
|
||||
@ -23,6 +23,8 @@
|
||||
#include "filter/filter-option.h"
|
||||
#include "filter/filter-input.h"
|
||||
|
||||
#include "mail-local.h"
|
||||
|
||||
#define PARENT_TYPE (gtk_table_get_type ())
|
||||
|
||||
static GtkObjectClass *folder_browser_parent_class;
|
||||
@ -66,7 +68,7 @@ folder_browser_class_init (GtkObjectClass *object_class)
|
||||
CamelFolder *
|
||||
mail_uri_to_folder (const char *name)
|
||||
{
|
||||
char *store_name, *msg;
|
||||
char *msg;
|
||||
CamelStore *store = NULL;
|
||||
CamelFolder *folder = NULL;
|
||||
CamelException *ex;
|
||||
@ -122,13 +124,7 @@ mail_uri_to_folder (const char *name)
|
||||
folder = camel_store_get_folder (store, folder_name, FALSE, ex);
|
||||
}
|
||||
} else if (!strncmp (name, "file:", 5)) {
|
||||
/* Change "file:" to "mbox:". */
|
||||
store_name = g_strdup_printf ("mbox:%s", name + 5);
|
||||
store = camel_session_get_store (session, store_name, ex);
|
||||
g_free (store_name);
|
||||
if (store) {
|
||||
folder = camel_store_get_folder (store, "mbox", FALSE, ex);
|
||||
}
|
||||
folder = local_uri_to_folder(name, ex);
|
||||
} else {
|
||||
msg = g_strdup_printf ("Can't open URI %s", name);
|
||||
gnome_error_dialog (msg);
|
||||
|
||||
240
mail/local-config.glade
Normal file
240
mail/local-config.glade
Normal file
@ -0,0 +1,240 @@
|
||||
<?xml version="1.0"?>
|
||||
<GTK-Interface>
|
||||
|
||||
<project>
|
||||
<name>Mail</name>
|
||||
<program_name>mail</program_name>
|
||||
<directory></directory>
|
||||
<source_directory>src</source_directory>
|
||||
<pixmaps_directory>pixmaps</pixmaps_directory>
|
||||
<language>C</language>
|
||||
<gnome_support>True</gnome_support>
|
||||
<gettext_support>True</gettext_support>
|
||||
</project>
|
||||
|
||||
<widget>
|
||||
<class>GnomeDialog</class>
|
||||
<name>dialog_format</name>
|
||||
<type>GTK_WINDOW_TOPLEVEL</type>
|
||||
<position>GTK_WIN_POS_NONE</position>
|
||||
<modal>False</modal>
|
||||
<allow_shrink>False</allow_shrink>
|
||||
<allow_grow>False</allow_grow>
|
||||
<auto_shrink>False</auto_shrink>
|
||||
<auto_close>False</auto_close>
|
||||
<hide_on_close>False</hide_on_close>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<child_name>GnomeDialog:vbox</child_name>
|
||||
<name>dialog-vbox1</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>8</spacing>
|
||||
<child>
|
||||
<padding>4</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHButtonBox</class>
|
||||
<child_name>GnomeDialog:action_area</child_name>
|
||||
<name>dialog-action_area1</name>
|
||||
<layout_style>GTK_BUTTONBOX_END</layout_style>
|
||||
<spacing>8</spacing>
|
||||
<child_min_width>85</child_min_width>
|
||||
<child_min_height>27</child_min_height>
|
||||
<child_ipad_x>7</child_ipad_x>
|
||||
<child_ipad_y>0</child_ipad_y>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
<pack>GTK_PACK_END</pack>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>apply_format</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>cancel_format</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkFrame</class>
|
||||
<name>frame_format</name>
|
||||
<label>Mailbox Format</label>
|
||||
<label_xalign>0</label_xalign>
|
||||
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkTable</class>
|
||||
<name>table1</name>
|
||||
<border_width>2</border_width>
|
||||
<rows>2</rows>
|
||||
<columns>2</columns>
|
||||
<homogeneous>False</homogeneous>
|
||||
<row_spacing>0</row_spacing>
|
||||
<column_spacing>2</column_spacing>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label2</name>
|
||||
<label>New store format:</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>1</top_attach>
|
||||
<bottom_attach>2</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label1</name>
|
||||
<label>Current store format:</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>0</top_attach>
|
||||
<bottom_attach>1</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label_format</name>
|
||||
<label>mbox</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>7.45058e-09</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>0</top_attach>
|
||||
<bottom_attach>1</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>True</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkOptionMenu</class>
|
||||
<name>option_format</name>
|
||||
<can_focus>True</can_focus>
|
||||
<items>mh
|
||||
mbox
|
||||
</items>
|
||||
<initial_choice>0</initial_choice>
|
||||
<child>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>1</top_attach>
|
||||
<bottom_attach>2</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>True</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label4</name>
|
||||
<label>Note: When converting between mailbox formats, a failure
|
||||
(such as lack of disk space) may not be automatically
|
||||
recoverable. Please use this feature with care.</label>
|
||||
<justify>GTK_JUSTIFY_LEFT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkProgressBar</class>
|
||||
<name>progress_format</name>
|
||||
<value>0</value>
|
||||
<lower>0</lower>
|
||||
<upper>100</upper>
|
||||
<bar_style>GTK_PROGRESS_CONTINUOUS</bar_style>
|
||||
<orientation>GTK_PROGRESS_LEFT_TO_RIGHT</orientation>
|
||||
<activity_mode>False</activity_mode>
|
||||
<show_text>False</show_text>
|
||||
<format>%P %%</format>
|
||||
<text_xalign>0.5</text_xalign>
|
||||
<text_yalign>0.5</text_yalign>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
</GTK-Interface>
|
||||
413
mail/mail-local.c
Normal file
413
mail/mail-local.c
Normal file
@ -0,0 +1,413 @@
|
||||
|
||||
/*
|
||||
code for handling local mail boxes
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <bonobo.h>
|
||||
#include <gnome.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#include "Evolution.h"
|
||||
#include "evolution-storage.h"
|
||||
|
||||
#include "evolution-shell-component.h"
|
||||
#include "folder-browser.h"
|
||||
|
||||
#include "camel/camel.h"
|
||||
|
||||
#include "filter/vfolder-context.h"
|
||||
#include "filter/vfolder-rule.h"
|
||||
#include "filter/vfolder-editor.h"
|
||||
|
||||
#include "mail.h"
|
||||
#include "mail-local.h"
|
||||
|
||||
#define d(x)
|
||||
|
||||
struct _local_meta {
|
||||
char *path; /* path of metainfo file */
|
||||
|
||||
char *format; /* format of mailbox */
|
||||
char *name; /* name of mbox itself */
|
||||
};
|
||||
|
||||
static struct _local_meta *
|
||||
load_metainfo(const char *path)
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr node;
|
||||
struct _local_meta *meta;
|
||||
|
||||
meta = g_malloc0(sizeof(*meta));
|
||||
meta->path = g_strdup(path);
|
||||
|
||||
printf("Loading folder metainfo from : %s\n", meta->path);
|
||||
|
||||
doc = xmlParseFile(meta->path);
|
||||
if (doc == NULL) {
|
||||
goto dodefault;
|
||||
}
|
||||
node = doc->root;
|
||||
if (strcmp(node->name, "folderinfo")) {
|
||||
goto dodefault;
|
||||
}
|
||||
node = node->childs;
|
||||
while (node) {
|
||||
if (!strcmp(node->name, "folder")) {
|
||||
meta->format = xmlGetProp(node, "type");
|
||||
meta->name = xmlGetProp(node, "name");
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
xmlFreeDoc(doc);
|
||||
return meta;
|
||||
|
||||
dodefault:
|
||||
meta->format = g_strdup("mbox"); /* defaults */
|
||||
meta->name = g_strdup("mbox");
|
||||
if (doc)
|
||||
xmlFreeDoc(doc);
|
||||
return meta;
|
||||
}
|
||||
|
||||
static void
|
||||
free_metainfo(struct _local_meta *meta)
|
||||
{
|
||||
g_free(meta->path);
|
||||
g_free(meta->format);
|
||||
g_free(meta->name);
|
||||
g_free(meta);
|
||||
}
|
||||
|
||||
static int
|
||||
save_metainfo(struct _local_meta *meta)
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr root, node;
|
||||
int ret;
|
||||
|
||||
printf("Saving folder metainfo to : %s\n", meta->path);
|
||||
|
||||
doc = xmlNewDoc("1.0");
|
||||
root = xmlNewDocNode(doc, NULL, "folderinfo", NULL);
|
||||
xmlDocSetRootElement(doc, root);
|
||||
|
||||
node = xmlNewChild(root, NULL, "folder", NULL);
|
||||
xmlSetProp(node, "type", meta->format);
|
||||
xmlSetProp(node, "name", meta->name);
|
||||
|
||||
ret = xmlSaveFile(meta->path, doc);
|
||||
xmlFreeDoc(doc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
CamelFolder *
|
||||
local_uri_to_folder(const char *uri, CamelException *ex)
|
||||
{
|
||||
CamelURL *url;
|
||||
char *metapath;
|
||||
char *storename;
|
||||
CamelStore *store;
|
||||
CamelFolder *folder = NULL;
|
||||
struct _local_meta *meta;
|
||||
|
||||
if (strncmp(uri, "file:", 5)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
printf("opening local folder %s\n", uri);
|
||||
|
||||
/* get the actual location of the mailbox */
|
||||
url = camel_url_new(uri, ex);
|
||||
if (camel_exception_is_set(ex)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
metapath = g_strdup_printf("%s/local-metadata.xml", url->path);
|
||||
meta = load_metainfo(metapath);
|
||||
g_free(metapath);
|
||||
|
||||
/* change file: to format: */
|
||||
camel_url_set_protocol(url, meta->format);
|
||||
storename = camel_url_to_string(url, TRUE);
|
||||
|
||||
printf("store name is %s\n", storename);
|
||||
|
||||
store = camel_session_get_store(session, storename, ex);
|
||||
g_free(storename);
|
||||
if (store) {
|
||||
folder = camel_store_get_folder(store, meta->name, FALSE, ex);
|
||||
gtk_object_unref((GtkObject *)store);
|
||||
}
|
||||
camel_url_free(url);
|
||||
free_metainfo(meta);
|
||||
|
||||
return folder;
|
||||
}
|
||||
|
||||
/*
|
||||
open new
|
||||
copy old->new
|
||||
close old
|
||||
rename old oldsave
|
||||
rename new old
|
||||
open oldsave
|
||||
delete oldsave
|
||||
|
||||
close old
|
||||
rename oldtmp
|
||||
open new
|
||||
open oldtmp
|
||||
copy oldtmp new
|
||||
close oldtmp
|
||||
close oldnew
|
||||
|
||||
*/
|
||||
|
||||
static void update_progress(GtkProgress *progress, char *fmt, float percent)
|
||||
{
|
||||
if (fmt)
|
||||
gtk_progress_set_format_string(progress, fmt);
|
||||
gtk_progress_set_percentage(progress, percent);
|
||||
while( gtk_events_pending() )
|
||||
gtk_main_iteration();
|
||||
}
|
||||
|
||||
static void
|
||||
do_local_reconfigure_folder(FolderBrowser *fb, char *newtype, GtkProgress *progress, CamelException *ex)
|
||||
{
|
||||
CamelStore *fromstore, *tostore;
|
||||
char *fromurl, *tourl, *uri;
|
||||
CamelFolder *fromfolder, *tofolder;
|
||||
GPtrArray *uids;
|
||||
int i;
|
||||
char *metapath;
|
||||
char *tmpname;
|
||||
CamelURL *url;
|
||||
struct _local_meta *meta;
|
||||
|
||||
printf("reconfiguring folder: %s to type %s\n", fb->uri, newtype);
|
||||
|
||||
/* get the actual location of the mailbox */
|
||||
url = camel_url_new(fb->uri, ex);
|
||||
if (url == NULL || camel_exception_is_set(ex)) {
|
||||
camel_exception_free(ex);
|
||||
g_warning("%s is not a workable url!", fb->uri);
|
||||
return;
|
||||
}
|
||||
|
||||
metapath = g_strdup_printf("%s/local-metadata.xml", url->path);
|
||||
meta = load_metainfo(metapath);
|
||||
g_free(metapath);
|
||||
|
||||
/* first, 'close' the old folder */
|
||||
if (fb->folder != NULL) {
|
||||
update_progress(progress, "Closing current folder", 0.0);
|
||||
printf("Closing old folder ...\n");
|
||||
camel_folder_sync(fb->folder, FALSE, ex);
|
||||
gtk_object_unref (GTK_OBJECT (fb->folder));
|
||||
fb->folder = NULL;
|
||||
}
|
||||
|
||||
camel_url_set_protocol(url, meta->format);
|
||||
fromurl = camel_url_to_string(url, TRUE);
|
||||
camel_url_set_protocol(url, newtype);
|
||||
tourl = camel_url_to_string(url, TRUE);
|
||||
|
||||
printf("opening stores %s and %s\n", fromurl, tourl);
|
||||
fromstore = camel_session_get_store(session, fromurl, ex);
|
||||
if (camel_exception_is_set(ex)) {
|
||||
return;
|
||||
}
|
||||
tostore = camel_session_get_store(session, tourl, ex);
|
||||
if (camel_exception_is_set(ex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* rename the old mbox and open it again */
|
||||
tmpname = g_strdup_printf("%s_reconfig", meta->name);
|
||||
printf("renaming mbox to mboxtmp, and opening it\n");
|
||||
update_progress(progress, "Renaming old folder and opening", 0.0);
|
||||
camel_store_rename_folder(fromstore, meta->name, tmpname, ex);
|
||||
if (camel_exception_is_set(ex)) {
|
||||
return;
|
||||
}
|
||||
fromfolder = camel_store_get_folder(fromstore, tmpname, TRUE, ex);
|
||||
if (fromfolder == NULL || camel_exception_is_set(ex)) {
|
||||
/* try and recover ... */
|
||||
camel_store_rename_folder(fromstore, tmpname, meta->name, ex);
|
||||
return;
|
||||
}
|
||||
|
||||
/* create a new mbox */
|
||||
printf("Creating the destination mbox\n");
|
||||
update_progress(progress, "Creating new folder", 0.0);
|
||||
tofolder = camel_store_get_folder(tostore, meta->name, TRUE, ex);
|
||||
if (tofolder == NULL || camel_exception_is_set(ex)) {
|
||||
printf("cannot open destination folder\n");
|
||||
/* try and recover ... */
|
||||
camel_store_rename_folder(fromstore, tmpname, meta->name, ex);
|
||||
return;
|
||||
}
|
||||
|
||||
/* copy the messages across */
|
||||
uids = camel_folder_get_uids (fromfolder);
|
||||
printf("got %d messages in source\n", uids->len);
|
||||
update_progress(progress, "Copying messages", 0.0);
|
||||
for (i = 0; i < uids->len; i++) {
|
||||
CamelMimeMessage *msg;
|
||||
char *uid = uids->pdata[i];
|
||||
|
||||
update_progress(progress, NULL, i/uids->len);
|
||||
|
||||
printf("copying message %s\n", uid);
|
||||
msg = camel_folder_get_message(fromfolder, uid, ex);
|
||||
if (camel_exception_is_set(ex)) {
|
||||
/* we're fucked a bit ... */
|
||||
/* need to: delete new folder
|
||||
rename old back again */
|
||||
g_warning("cannot get message");
|
||||
return;
|
||||
}
|
||||
camel_folder_append_message(tofolder, msg,
|
||||
camel_folder_get_message_flags(fromfolder, uid),
|
||||
ex);
|
||||
if (camel_exception_is_set(ex)) {
|
||||
/* we're fucked a bit ... */
|
||||
/* need to: delete new folder
|
||||
rename old back again */
|
||||
g_warning("cannot append message");
|
||||
return;
|
||||
}
|
||||
gtk_object_unref((GtkObject *)msg);
|
||||
#warning "because flags were removed from the message"
|
||||
#warning "we can't keep them when converting mail storage format"
|
||||
}
|
||||
update_progress(progress, "Synchronising", 0.0);
|
||||
|
||||
/* sync while we're doing i/o, just to make sure */
|
||||
camel_folder_sync(tofolder, FALSE, ex);
|
||||
if (camel_exception_is_set(ex)) {
|
||||
/* same again */
|
||||
}
|
||||
|
||||
/* delete everything in the old mailbox */
|
||||
printf("deleting old mbox contents\n");
|
||||
for (i = 0; i < uids->len; i++) {
|
||||
char *uid = uids->pdata[i];
|
||||
camel_folder_delete_message(fromfolder, uid);
|
||||
}
|
||||
camel_folder_sync(fromfolder, TRUE, ex);
|
||||
gtk_object_unref((GtkObject *)fromfolder);
|
||||
printf("and old mbox ...\n");
|
||||
camel_store_delete_folder(fromstore, tmpname, ex);
|
||||
|
||||
/* switch format */
|
||||
g_free(meta->format);
|
||||
meta->format = g_strdup(newtype);
|
||||
if (save_metainfo(meta) == -1) {
|
||||
g_warning("Cannot save folder metainfo, you'll probably find you can't\n"
|
||||
"open this folder anymore: %s", tourl);
|
||||
}
|
||||
free_metainfo(meta);
|
||||
|
||||
/* force a reload of the newly formatted folder */
|
||||
printf("opening new source\n");
|
||||
uri = g_strdup(fb->uri);
|
||||
folder_browser_set_uri(fb, uri);
|
||||
g_free(uri);
|
||||
|
||||
/* and unref our copy of the new folder ... */
|
||||
gtk_object_unref((GtkObject *)tofolder);
|
||||
g_free(fromurl);
|
||||
g_free(tourl);
|
||||
}
|
||||
|
||||
struct _reconfig_data {
|
||||
FolderBrowser *fb;
|
||||
GtkProgress *progress;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *apply;
|
||||
GtkWidget *cancel;
|
||||
GtkOptionMenu *optionlist;
|
||||
};
|
||||
|
||||
static void
|
||||
reconfigure_clicked(GnomeDialog *d, int button, struct _reconfig_data *data)
|
||||
{
|
||||
if (button == 0) {
|
||||
GtkMenu *menu;
|
||||
int type;
|
||||
char *types[] = { "mh", "mbox" };
|
||||
CamelException *ex;
|
||||
|
||||
ex = camel_exception_new();
|
||||
|
||||
menu = (GtkMenu *)gtk_option_menu_get_menu(data->optionlist);
|
||||
type = g_list_index(GTK_MENU_SHELL(menu)->children, gtk_menu_get_active(menu));
|
||||
if (type < 0 || type > 1)
|
||||
type = 1;
|
||||
|
||||
gtk_progress_set_percentage(data->progress, 0.0);
|
||||
gtk_widget_set_sensitive(data->frame, FALSE);
|
||||
gtk_widget_set_sensitive(data->apply, FALSE);
|
||||
gtk_widget_set_sensitive(data->cancel, FALSE);
|
||||
|
||||
do_local_reconfigure_folder(data->fb, types[type], data->progress, ex);
|
||||
if (camel_exception_is_set(ex)) {
|
||||
GtkWidget *win = gtk_widget_get_ancestor((GtkWidget *)d, GTK_TYPE_WINDOW);
|
||||
char *error;
|
||||
|
||||
error = g_strdup_printf("A failure occured:\n %s\n\n"
|
||||
"If you can no longer open this mailbox, then\n"
|
||||
"you may need to repair it manually.",
|
||||
camel_exception_get_description(ex));
|
||||
gnome_error_dialog_parented(error, GTK_WINDOW (win));
|
||||
g_free(error);
|
||||
}
|
||||
camel_exception_free(ex);
|
||||
}
|
||||
if (button != -1) {
|
||||
gnome_dialog_close(d);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
local_reconfigure_folder(FolderBrowser *fb)
|
||||
{
|
||||
CamelStore *store;
|
||||
GladeXML *gui;
|
||||
GnomeDialog *gd;
|
||||
struct _reconfig_data *data;
|
||||
|
||||
if (fb->folder == NULL) {
|
||||
g_warning("Trying to reconfigure nonexistant folder");
|
||||
return;
|
||||
}
|
||||
|
||||
data = g_malloc0(sizeof(*data));
|
||||
|
||||
store = camel_folder_get_parent_store(fb->folder);
|
||||
|
||||
gui = glade_xml_new(EVOLUTION_GLADEDIR "/local-config.glade", "dialog_format");
|
||||
gd = (GnomeDialog *)glade_xml_get_widget (gui, "dialog_format");
|
||||
|
||||
data->progress = (GtkProgress *)glade_xml_get_widget (gui, "progress_format");
|
||||
gtk_progress_set_show_text(data->progress, TRUE);
|
||||
data->frame = glade_xml_get_widget (gui, "frame_format");
|
||||
data->apply = glade_xml_get_widget (gui, "apply_format");
|
||||
data->cancel = glade_xml_get_widget (gui, "cancel_format");
|
||||
data->optionlist = (GtkOptionMenu *)glade_xml_get_widget (gui, "option_format");
|
||||
data->fb = fb;
|
||||
|
||||
gtk_label_set_text((GtkLabel *)glade_xml_get_widget (gui, "label_format"),
|
||||
((CamelService *)store)->url->protocol);
|
||||
|
||||
gtk_signal_connect((GtkObject *)gd, "clicked", reconfigure_clicked, data);
|
||||
gtk_object_set_data_full((GtkObject *)gd, "data", data, g_free);
|
||||
gtk_widget_show((GtkWidget *)gd);
|
||||
gtk_object_unref((GtkObject *)gui);
|
||||
}
|
||||
11
mail/mail-local.h
Normal file
11
mail/mail-local.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef _MAIL_LOCAL_H
|
||||
#define _MAIL_LOCAL_H
|
||||
|
||||
#include "camel/camel-folder.h"
|
||||
#include "folder-browser.h"
|
||||
|
||||
/* mail-local.c */
|
||||
CamelFolder *local_uri_to_folder(const char *uri, CamelException *ex);
|
||||
void local_reconfigure_folder(FolderBrowser *fb);
|
||||
|
||||
#endif
|
||||
@ -1029,6 +1029,15 @@ print_msg (GtkWidget *button, gpointer user_data)
|
||||
gtk_object_unref (GTK_OBJECT (print_master));
|
||||
}
|
||||
|
||||
void
|
||||
configure_folder(BonoboUIHandler *uih, void *user_data, const char *path)
|
||||
{
|
||||
FolderBrowser *fb = FOLDER_BROWSER(user_data);
|
||||
|
||||
local_reconfigure_folder(fb);
|
||||
}
|
||||
|
||||
|
||||
struct view_msg_data {
|
||||
FolderBrowser *fb;
|
||||
CamelException *ex;
|
||||
@ -1072,3 +1081,4 @@ view_message (BonoboUIHandler *uih, void *user_data, const char *path)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -78,6 +78,8 @@ void filter_edit (BonoboUIHandler *uih, void *user_data, const char *path);
|
||||
void vfolder_edit_vfolders (BonoboUIHandler *uih, void *user_data, const char *path);
|
||||
void providers_config (BonoboUIHandler *uih, void *user_data, const char *path);
|
||||
|
||||
void configure_folder(BonoboUIHandler *uih, void *user_data, const char *path);
|
||||
|
||||
/* mail view */
|
||||
GtkWidget *mail_view_create (CamelMimeMessage *msg, FolderBrowser *folder_browser);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user