2005-10-01 [paul] 1.9.14cvs64
authorPaul Mangan <paul@claws-mail.org>
Sat, 1 Oct 2005 07:56:18 +0000 (07:56 +0000)
committerPaul Mangan <paul@claws-mail.org>
Sat, 1 Oct 2005 07:56:18 +0000 (07:56 +0000)
        * src/export.c
* src/import.c
synchronise import_mbox() and export_mbox()
* src/mbox.c
proc_mbox(): add alert if file cannot be opened
export_list_to_mbox(): test if dest file exists,
prompt user to overwrite if it does. add alert
if file cannot be created

Patch by wwp

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/export.c
src/import.c
src/mbox.c

index c3be5cb7d01e5d5af3f649cc0aec6529d879b855..e97c9e12f8ef4c8652cd5b77cedf8b0be868ebe4 100644 (file)
@@ -1,3 +1,16 @@
+2005-10-01 [paul]      1.9.14cvs64
+        * src/export.c
+       * src/import.c
+               synchronise import_mbox() and export_mbox()
+       * src/mbox.c
+               proc_mbox(): add alert if file cannot be opened
+               export_list_to_mbox(): test if dest file exists,
+               prompt user to overwrite if it does. add alert
+               if file cannot be created
+                                                               
+       Patch by wwp
+                                                                                                               
+
 2005-09-30 [paul]      1.9.14cvs63
 
        * src/addressbook.c
index 8f804b188a4dd0798d060c8d3eda934917165fc9..5c368a5239b517700feccb5d23ac5309c5732933 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/pgpinline/pgpinline.c;  ) > 1.9.14cvs61.patchset
 ( cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/partial_download.c;  cvs diff -u -r 1.56.2.40 -r 1.56.2.41 src/pop.c;  ) > 1.9.14cvs62.patchset
 ( cvs diff -u -r 1.60.2.32 -r 1.60.2.33 src/addressbook.c;  cvs diff -u -r 1.65.2.40 -r 1.65.2.41 src/codeconv.c;  cvs diff -u -r 1.1.4.13 -r 1.1.4.14 src/common/xml.c;  cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/plugins/pgpcore/sgpgme.c;  ) > 1.9.14cvs63.patchset
+( cvs diff -u -r 1.8.2.9 -r 1.8.2.10 src/export.c;  cvs diff -u -r 1.13.2.9 -r 1.13.2.10 src/import.c;  cvs diff -u -r 1.28.2.9 -r 1.28.2.10 src/mbox.c;  ) > 1.9.14cvs64.patchset
index 64ed931325d4b75dc327715b6c881473332fb61f..f25ce0d15166b064de41d15797c91bd34c0f9705 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=14
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=63
+EXTRA_VERSION=64
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 7104490a706d4fc87e3032f4ac117d5bd6273c4d..411c85ff2efb94532e20c986822b0345ef9a9295 100644 (file)
@@ -72,21 +72,25 @@ gint export_mbox(FolderItem *default_src)
        gint ok = 0;
        gchar *src_id = NULL;
 
-       if (!window)
+       if (!window) {
                export_create();
-       else
+       }
+       else {
                gtk_widget_show(window);
+       }
 
        change_dir(sylpheed_get_startup_dir());
 
-       if (default_src && default_src->path)
+       if (default_src && default_src->path) {
                src_id = folder_item_get_identifier(default_src);
+       }
 
        if (src_id) {
                gtk_entry_set_text(GTK_ENTRY(src_entry), src_id);
                g_free(src_id);
-       } else
+       } else {
                gtk_entry_set_text(GTK_ENTRY(src_entry), "");
+       }
        gtk_entry_set_text(GTK_ENTRY(file_entry), "");
        gtk_widget_grab_focus(file_entry);
 
@@ -101,21 +105,20 @@ gint export_mbox(FolderItem *default_src)
                srcdir = gtk_entry_get_text(GTK_ENTRY(src_entry));
                utf8mbox = gtk_entry_get_text(GTK_ENTRY(file_entry));
                if (utf8mbox && *utf8mbox) {
-                       const gchar *src_codeset = CS_UTF_8;
-                       const gchar *dest_codeset = conv_get_locale_charset_str();
                        gchar *mbox;
 
-                       mbox = conv_codeset_strdup(utf8mbox, src_codeset, dest_codeset);
+                       mbox = g_filename_from_utf8(utf8mbox, -1, NULL, NULL, NULL);
                        if (!mbox) {
-                               g_warning("faild to convert character set\n");
+                               g_warning("Failed to convert character set.\n");
                                mbox = g_strdup(utf8mbox);
                        }
 
                        src = folder_find_item_from_identifier(srcdir);
-                       if (!src)
+                       if (!src) {
                                g_warning("Can't find the folder.\n");
-                       else
+                       } else {
                                ok = export_to_mbox(src, mbox);
+                       }
 
                        g_free(mbox);
                }
index 632421186f68fa45eadf99a6ea736bc308890f0f..ced5838275dcffcbdfa79ec1db0ba22d15922f00 100644 (file)
@@ -38,6 +38,7 @@
 #include <gtk/gtkfilesel.h>
 #include <gtk/gtksignal.h>
 
+#include "sylpheed.h"
 #include "main.h"
 #include "inc.h"
 #include "mbox.h"
@@ -71,20 +72,26 @@ gint import_mbox(FolderItem *default_dest)
        gint ok = 0;
        gchar *dest_id = NULL;
 
-       if (!window)
+       if (!window) {
                import_create();
-       else
+       }
+       else {
                gtk_widget_show(window);
+       }
 
-       gtk_entry_set_text(GTK_ENTRY(file_entry), "");
-       if (default_dest && default_dest->path)
+       change_dir(sylpheed_get_startup_dir());
+
+       if (default_dest && default_dest->path) {
                dest_id = folder_item_get_identifier(default_dest);
+       }
 
        if (dest_id) {
                gtk_entry_set_text(GTK_ENTRY(dest_entry), dest_id);
                g_free(dest_id);
-       } else
+       } else {
                gtk_entry_set_text(GTK_ENTRY(dest_entry), "");
+       }
+       gtk_entry_set_text(GTK_ENTRY(file_entry), "");
        gtk_widget_grab_focus(file_entry);
 
        manage_window_set_transient(GTK_WINDOW(window));
@@ -92,34 +99,34 @@ gint import_mbox(FolderItem *default_dest)
        gtk_main();
 
        if (import_ack) {
-               const gchar *utf8filename, *destdir;
+               const gchar *utf8mbox, *destdir;
                FolderItem *dest;
 
-               utf8filename = gtk_entry_get_text(GTK_ENTRY(file_entry));
+               utf8mbox = gtk_entry_get_text(GTK_ENTRY(file_entry));
                destdir = gtk_entry_get_text(GTK_ENTRY(dest_entry));
-               if (utf8filename && *utf8filename) {
-                       gchar *filename;
-
-                       filename = g_filename_from_utf8
-                               (utf8filename, -1, NULL, NULL, NULL);
-                       if (!filename) {
-                               g_warning("faild to convert character set\n");
-                               filename = g_strdup(utf8filename);
+               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
+                       } else {
                                dest = folder_find_item_from_identifier
                                        (destdir);
+                       }
 
                        if (!dest) {
                                g_warning("Can't find the folder.\n");
                        } else {
-                               ok = proc_mbox(dest, filename, FALSE);
+                               ok = proc_mbox(dest, mbox, FALSE);
                        }
 
-                       g_free(filename);
+                       g_free(mbox);
                }
        }
 
index ca612480d778348701f7956d7e22c5353a4fc3b1..79906d087fa59c0ac072afd171f72770ee6be1c7 100644 (file)
@@ -41,6 +41,7 @@
 #include "account.h"
 #include "utils.h"
 #include "filtering.h"
+#include "alertpanel.h"
 
 #define MSGBUFSIZE     8192
 
@@ -71,6 +72,7 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox, gboolean apply_filter)
 
        if ((mbox_fp = g_fopen(mbox, "rb")) == NULL) {
                FILE_OP_ERROR(mbox, "fopen");
+               alertpanel_error(_("Could not open mbox file:\n%s\n"), mbox);
                return -1;
        }
 
@@ -378,8 +380,18 @@ gint export_list_to_mbox(GSList *mlist, const gchar *mbox)
        FILE *mbox_fp;
        gchar buf[BUFFSIZE];
 
+       if (g_file_test(mbox, G_FILE_TEST_EXISTS) == TRUE) {
+               if (alertpanel_full(_("Overwrite mbox file"),
+                                                       _("This file already exists. Do you want to overwrite it?"),
+                                                       _("Overwrite"), GTK_STOCK_CANCEL, NULL, FALSE,
+                                                       NULL, ALERT_WARNING, G_ALERTALTERNATE)
+                       == G_ALERTALTERNATE)
+               return -1;
+       }
+
        if ((mbox_fp = g_fopen(mbox, "wb")) == NULL) {
                FILE_OP_ERROR(mbox, "fopen");
+               alertpanel_error(_("Could not create mbox file:\n%s\n"), mbox);
                return -1;
        }