CVS: sylpheed-claws/src export.c,1.8.2.17,1.8.2.18 import.c,1.13.2.16,1.13.2.17 mainwindow.c,1.274.2.109,1.274.2.110 mbox.c,1.28.2.13,1.28.2.14 summaryview.c,1.395.2.197,1.395.2.198 summaryview.h,1.68.2.23,1.68.2.24
wwp <[email protected]>
| Newsgroups | gmane.mail.sylpheed.claws.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/sylpheed-claws/sylpheed-claws/src
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv7121/src
Modified Files:
Tag: gtk2
export.c import.c mainwindow.c mbox.c summaryview.c
summaryview.h
Log Message:
2006-05-13 [wwp] 2.2.0cvs11
* src/export.c
* src/import.c
* src/mainwindow.c
* src/mbox.c
* src/summaryview.c
* src/summaryview.h
no more silent failures (or at least less ones) when importing
or exporting from/to mbox. Also start importing/exporting if
the necessary info is set.
Index: export.c
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/export.c,v
retrieving revision 1.8.2.17
retrieving revision 1.8.2.18
diff -u -r1.8.2.17 -r1.8.2.18
--- export.c 20 Jan 2006 07:44:18 -0000 1.8.2.17
+++ export.c 13 May 2006 10:02:32 -0000 1.8.2.18
@@ -57,7 +57,7 @@
static GtkWidget *file_button;
static GtkWidget *ok_button;
static GtkWidget *cancel_button;
-static gboolean export_ack;
+static gboolean export_ok; /* see export_mbox() return values */
static void export_create(void);
static void export_ok_cb(GtkWidget *widget, gpointer data);
@@ -68,10 +68,12 @@
static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data);
gint export_mbox(FolderItem *default_src)
+/* return values: -2 skipped/cancelled, -1 error, 0 OK */
{
- gint ok = 0;
gchar *src_id = NULL;
+ export_ok = -2; // skipped or cancelled
+
if (!window) {
export_create();
}
@@ -98,35 +100,9 @@
gtk_main();
- if (export_ack) {
- const gchar *srcdir, *utf8mbox;
- FolderItem *src;
-
- srcdir = gtk_entry_get_text(GTK_ENTRY(src_entry));
- utf8mbox = gtk_entry_get_text(GTK_ENTRY(file_entry));
- if (utf8mbox && *utf8mbox) {
- gchar *mbox;
-
- mbox = g_filename_from_utf8(utf8mbox, -1, NULL, NULL, NULL);
- if (!mbox) {
- g_warning("Failed to convert character set.\n");
- mbox = g_strdup(utf8mbox);
- }
-
- src = folder_find_item_from_identifier(srcdir);
- if (!src) {
- g_warning("Can't find the folder.\n");
- } else {
- ok = export_to_mbox(src, mbox);
- }
-
- g_free(mbox);
- }
- }
-
gtk_widget_hide(window);
- return ok;
+ return export_ok;
}
static void export_create(void)
@@ -223,14 +199,47 @@
static void export_ok_cb(GtkWidget *widget, gpointer data)
{
- export_ack = TRUE;
+ const gchar *srcdir, *utf8mbox;
+ FolderItem *src;
+ gchar *mbox;
+
+ srcdir = gtk_entry_get_text(GTK_ENTRY(src_entry));
+ utf8mbox = gtk_entry_get_text(GTK_ENTRY(file_entry));
+
+ if (utf8mbox && !*utf8mbox) {
+ alertpanel_error(_("Target mbox filename can't be left empty."));
+ gtk_widget_grab_focus(file_entry);
+ return;
+ }
+ if (srcdir && !*srcdir) {
+ alertpanel_error(_("Source folder can't be left empty."));
+ gtk_widget_grab_focus(src_entry);
+ return;
+ }
+
+ mbox = g_filename_from_utf8(utf8mbox, -1, NULL, NULL, NULL);
+ if (!mbox) {
+ g_warning("export_ok_cb(): failed to convert character set.\n");
+ mbox = g_strdup(utf8mbox);
+ }
+
+ src = folder_find_item_from_identifier(srcdir);
+ if (!src) {
+ alertpanel_error(_("Can't find the source folder."));
+ gtk_widget_grab_focus(src_entry);
+ return;
+ } else {
+ export_ok = export_to_mbox(src, mbox);
+ }
+
+ g_free(mbox);
+
if (gtk_main_level() > 1)
gtk_main_quit();
}
static void export_cancel_cb(GtkWidget *widget, gpointer data)
{
- export_ack = FALSE;
if (gtk_main_level() > 1)
gtk_main_quit();
}
Index: import.c
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/import.c,v
retrieving revision 1.13.2.16
retrieving revision 1.13.2.17
diff -u -r1.13.2.16 -r1.13.2.17
--- import.c 20 Jan 2006 07:44:18 -0000 1.13.2.16
+++ import.c 13 May 2006 10:02:32 -0000 1.13.2.17
@@ -49,6 +49,7 @@
#include "manage_window.h"
#include "folder.h"
#include "codeconv.h"
+#include "alertpanel.h"
static GtkWidget *window;
static GtkWidget *file_entry;
@@ -57,7 +58,7 @@
static GtkWidget *dest_button;
static GtkWidget *ok_button;
static GtkWidget *cancel_button;
-static gboolean import_ack;
+static gboolean import_ok; /* see import_mbox() return values */
static void import_create(void);
static void import_ok_cb(GtkWidget *widget, gpointer data);
@@ -68,10 +69,12 @@
static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data);
gint import_mbox(FolderItem *default_dest)
+/* return values: -2 skipped/cancelled, -1 error, 0 OK */
{
- gint ok = 0;
gchar *dest_id = NULL;
+ import_ok = -2; // skipped or cancelled
+
if (!window) {
import_create();
}
@@ -98,41 +101,9 @@
gtk_main();
- if (import_ack) {
- const gchar *utf8mbox, *destdir;
- FolderItem *dest;
-
- utf8mbox = gtk_entry_get_text(GTK_ENTRY(file_entry));
- destdir = gtk_entry_get_text(GTK_ENTRY(dest_entry));
- if (utf8mbox && *utf8mbox) {
- gchar *mbox;
-
- mbox = g_filename_from_utf8(utf8mbox, -1, NULL, NULL, NULL);
- if (!mbox) {
- g_warning("Failed to convert character set.\n");
- mbox = g_strdup(utf8mbox);
- }
-
- if (!destdir || !*destdir) {
- dest = folder_find_item_from_path(INBOX_DIR);
- } else {
- dest = folder_find_item_from_identifier
- (destdir);
- }
-
- if (!dest) {
- g_warning("Can't find the folder.\n");
- } else {
- ok = proc_mbox(dest, mbox, FALSE);
- }
-
- g_free(mbox);
- }
- }
-
gtk_widget_hide(window);
- return ok;
+ return import_ok;
}
static void import_create(void)
@@ -228,14 +199,56 @@
static void import_ok_cb(GtkWidget *widget, gpointer data)
{
- import_ack = TRUE;
+ const gchar *utf8mbox, *destdir;
+ FolderItem *dest;
+ gchar *mbox;
+
+ utf8mbox = gtk_entry_get_text(GTK_ENTRY(file_entry));
+ destdir = gtk_entry_get_text(GTK_ENTRY(dest_entry));
+
+ if (utf8mbox && !*utf8mbox) {
+ alertpanel_error(_("Source mbox filename can't be left empty."));
+ gtk_widget_grab_focus(file_entry);
+ return;
+ }
+ if (destdir && !*destdir) {
+ if (alertpanel(_("Import mbox file"), _("Destination folder is not set.\nImport mbox file to the inbox folder?"),
+ GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
+ == G_ALERTALTERNATE) {
+ gtk_widget_grab_focus(dest_entry);
+ return;
+ }
+ }
+
+ mbox = g_filename_from_utf8(utf8mbox, -1, NULL, NULL, NULL);
+ if (!mbox) {
+ g_warning("import_ok_cb(): failed to convert character set.\n");
+ mbox = g_strdup(utf8mbox);
+ }
+
+ if (!destdir || !*destdir) {
+ dest = folder_find_item_from_path(INBOX_DIR);
+ } else {
+ dest = folder_find_item_from_identifier
+ (destdir);
+ }
+
+ if (!dest) {
+ alertpanel_error(_("Can't find the destination folder."));
+ gtk_widget_grab_focus(dest_entry);
+ return;
+ } else {
+ import_ok = proc_mbox(dest, mbox, FALSE);
+ }
+
+ g_free(mbox);
+
if (gtk_main_level() > 1)
gtk_main_quit();
}
static void import_cancel_cb(GtkWidget *widget, gpointer data)
{
- import_ack = FALSE;
if (gtk_main_level() > 1)
gtk_main_quit();
}
Index: mainwindow.c
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/mainwindow.c,v
retrieving revision 1.274.2.109
retrieving revision 1.274.2.110
diff -u -r1.274.2.109 -r1.274.2.110
--- mainwindow.c 12 May 2006 17:42:48 -0000 1.274.2.109
+++ mainwindow.c 13 May 2006 10:02:32 -0000 1.274.2.110
@@ -2904,19 +2904,28 @@
static void import_mbox_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
{
- import_mbox(mainwin->summaryview->folder_item);
+ /* only notify if import has failed */
+ if (import_mbox(mainwin->summaryview->folder_item) == -1) {
+ alertpanel_error(_("Mbox import has failed."));
+ }
}
static void export_mbox_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
{
- export_mbox(mainwin->summaryview->folder_item);
+ /* only notify if export has failed */
+ if (export_mbox(mainwin->summaryview->folder_item) == -1) {
+ alertpanel_error(_("Export to mbox has failed."));
+ }
}
static void export_list_mbox_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
{
- summaryview_export_mbox_list(mainwin->summaryview);
+ /* only notify if export has failed */
+ if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
+ alertpanel_error(_("Export to mbox has failed."));
+ }
}
static void empty_trash_cb(MainWindow *mainwin, guint action,
Index: mbox.c
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/mbox.c,v
retrieving revision 1.28.2.13
retrieving revision 1.28.2.14
diff -u -r1.28.2.13 -r1.28.2.14
--- mbox.c 6 Feb 2006 18:02:16 -0000 1.28.2.13
+++ mbox.c 13 May 2006 10:02:32 -0000 1.28.2.14
@@ -59,6 +59,7 @@
}
gint proc_mbox(FolderItem *dest, const gchar *mbox, gboolean apply_filter)
+/* return values: -1 error, >=0 number of msgs added */
{
FILE *mbox_fp;
gchar buf[MSGBUFSIZE];
@@ -375,6 +376,7 @@
}
gint export_list_to_mbox(GSList *mlist, const gchar *mbox)
+/* return values: -2 skipped, -1 error, 0 OK */
{
GSList *cur;
MsgInfo *msginfo;
@@ -388,7 +390,7 @@
_("Overwrite"), GTK_STOCK_CANCEL, NULL, FALSE,
NULL, ALERT_WARNING, G_ALERTALTERNATE)
== G_ALERTALTERNATE) {
- return -1;
+ return -2;
}
}
@@ -456,9 +458,11 @@
}
/* read all messages in SRC, and store them into one MBOX file. */
+/* return values: -2 skipped, -1 error, 0 OK */
gint export_to_mbox(FolderItem *src, const gchar *mbox)
{
GSList *mlist;
+ gint ret;
g_return_val_if_fail(src != NULL, -1);
g_return_val_if_fail(src->folder != NULL, -1);
@@ -469,9 +473,9 @@
mlist = folder_item_get_msg_list(src);
- export_list_to_mbox(mlist, mbox);
+ ret = export_list_to_mbox(mlist, mbox);
procmsg_msg_list_free(mlist);
- return 0;
+ return ret;
}
Index: summaryview.c
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/summaryview.c,v
retrieving revision 1.395.2.197
retrieving revision 1.395.2.198
diff -u -r1.395.2.197 -r1.395.2.198
--- summaryview.c 12 May 2006 18:12:31 -0000 1.395.2.197
+++ summaryview.c 13 May 2006 10:02:32 -0000 1.395.2.198
@@ -5914,19 +5914,22 @@
summary_select_node(summaryview, node, TRUE, TRUE);
}
-void summaryview_export_mbox_list(SummaryView *summaryview)
+gint summaryview_export_mbox_list(SummaryView *summaryview)
+/* return values: -2 skipped, -1 error, 0 OK */
{
GSList *list = summary_get_selected_msg_list(summaryview);
gchar *mbox = filesel_select_file_save(_("Export to mbox file"), NULL);
+ gint ret;
if (mbox == NULL || list == NULL)
return;
- export_list_to_mbox(list, mbox);
+ ret = export_list_to_mbox(list, mbox);
g_slist_free(list);
g_free(mbox);
+ return ret;
}
void summaryview_lock(SummaryView *summaryview, FolderItem *item)
Index: summaryview.h
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/summaryview.h,v
retrieving revision 1.68.2.23
retrieving revision 1.68.2.24
diff -u -r1.68.2.23 -r1.68.2.24
--- summaryview.h 25 Apr 2006 06:33:15 -0000 1.68.2.23
+++ summaryview.h 13 May 2006 10:02:32 -0000 1.68.2.24
@@ -282,7 +282,7 @@
(SummaryView *summaryview, FolderItem *item);
void summary_save_prefs_to_folderitem
(SummaryView *summaryview, FolderItem *item);
-void summaryview_export_mbox_list (SummaryView *summaryview);
+gint summaryview_export_mbox_list (SummaryView *summaryview);
void summaryview_lock(SummaryView *summaryview, FolderItem *item);
void summaryview_unlock(SummaryView *summaryview, FolderItem *item);
void summary_reflect_prefs(void);
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642