save-all fixes
[claws.git] / src / mimeview.c
index fd12892641e3d52b5a7ca62de29a8dcc0daa4323..fd37a520232813bd7e11983236a767166d4d31f7 100644 (file)
@@ -108,9 +108,6 @@ static void mimeview_open_with              (MimeView       *mimeview);
 static void mimeview_view_file         (const gchar    *filename,
                                         MimeInfo       *partinfo,
                                         const gchar    *cmdline);
-#if USE_GPGME
-static void mimeview_check_signature   (MimeView       *mimeview);
-#endif
 
 static GtkItemFactoryEntry mimeview_popup_entries[] =
 {
@@ -308,7 +305,8 @@ void mimeview_show_message(MimeView *mimeview, MimeInfo *mimeinfo,
 
        procmime_scan_multipart_message(mimeinfo, fp);
 #if USE_GPGME
-       if (prefs_common.auto_check_signatures)
+       if ((prefs_common.auto_check_signatures)
+           && (gpg_started))
                rfc2015_check_signature(mimeinfo, fp);
        else
                set_unchecked_signature(mimeinfo);
@@ -468,7 +466,8 @@ static void mimeview_show_image_part(MimeView *mimeview, MimeInfo *partinfo)
                /* Workaround for the GTK+ bug with handling scroll adjustments
                 * in GtkViewport */
                imageview_clear(mimeview->imageview);
-               imageview_show_image(mimeview->imageview, partinfo, filename);
+               imageview_show_image(mimeview->imageview, partinfo, filename,
+                                    prefs_common.resize_image);
                unlink(filename);
        }
 
@@ -811,37 +810,39 @@ static void mimeview_save_all(MimeView *mimeview)
        if (!dirname) return;
 
        /* return to first children */
+       if (!partinfo->parent->children) return;  /* multipart container? */
        attachment = partinfo->parent->children->next;
        /* for each attachment, extract it in the selected dir. */
-       while(attachment != NULL)
-       {
+       while (attachment != NULL) {
                static guint subst_cnt = 1;
                gchar *attachdir;
-               gchar *attachname = (attachment->filename)
-                       ? g_strdup(attachment->filename)
-                       : g_strdup_printf("noname.%d",subst_cnt++);
+               gchar *attachname = g_strdup(get_part_name(attachment));
+               AlertValue aval = G_ALERTDEFAULT;
+               gchar *res;
 
-               subst_chars(attachname, "/\\", G_DIR_SEPARATOR);
+               if (!attachname || !strlen(attachname))
+                       attachname = g_strdup_printf("noname.%d",subst_cnt++);
                subst_chars(attachname, ":?*&|<>\t\r\n", '_');
                g_snprintf(buf, sizeof(buf), "%s%s",
                           dirname,
                           (attachname[0] == G_DIR_SEPARATOR)
                           ? &attachname[1]
                           : attachname);
+               subst_chars(buf, "/\\", G_DIR_SEPARATOR);
                attachdir = g_dirname(buf);
                make_dir_hier(attachdir);
                g_free(attachdir);
-               g_free(attachname);
 
                if (is_file_exist(buf)) {
-                       AlertValue aval;
-
-                       aval = alertpanel(_("Overwrite"),
-                                         _("Overwrite existing file?"),
-                                         _("OK"), _("Cancel"), NULL);
-                       if (G_ALERTDEFAULT != aval) return;
+                       res = g_strdup_printf(_("Overwrite existing file '%s'?"),
+                                             attachname);
+                       aval = alertpanel(_("Overwrite"), res, _("OK"), 
+                                         _("Cancel"), NULL);
+                       g_free(res);                                      
                }
-               if (procmime_get_part(buf, mimeview->file, attachment) < 0)
+               g_free(attachname);
+
+               if ((G_ALERTDEFAULT != aval) || (procmime_get_part(buf, mimeview->file, attachment) < 0))
                        alertpanel_error(_("Can't save the part of multipart message."));
                attachment = attachment->next;
        }
@@ -874,6 +875,7 @@ static void mimeview_save_as(MimeView *mimeview)
        gchar *filename;
        gchar *defname = NULL;
        MimeInfo *partinfo;
+       gchar *res;
 
        if (!mimeview->opened) return;
        if (!mimeview->file) return;
@@ -893,10 +895,11 @@ static void mimeview_save_as(MimeView *mimeview)
        if (!filename) return;
        if (is_file_exist(filename)) {
                AlertValue aval;
-
-               aval = alertpanel(_("Overwrite"),
-                                 _("Overwrite existing file?"),
-                                 _("OK"), _("Cancel"), NULL);
+               res = g_strdup_printf(_("Overwrite existing file '%s'?"),
+                                     filename);
+               aval = alertpanel(_("Overwrite"), res, _("OK"), 
+                                 _("Cancel"), NULL);
+               g_free(res);                                      
                if (G_ALERTDEFAULT != aval) return;
        }
 
@@ -977,8 +980,7 @@ static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
 {
        static gchar *default_image_cmdline = "display '%s'";
        static gchar *default_audio_cmdline = "play '%s'";
-       static gchar *default_html_cmdline =
-               "netscape -remote 'openURL(%s,raise)'";
+       static gchar *default_html_cmdline = DEFAULT_BROWSER_CMD;
        static gchar *mime_cmdline = "metamail -d -b -x -c %s '%s'";
        gchar buf[1024];
        gchar m_buf[1024];
@@ -1012,7 +1014,7 @@ static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
                g_snprintf(buf, sizeof(buf), cmd, filename);
        else {
                if (cmd)
-                       g_warning(_("MIME viewer command line is invalid: `%s'"), cmd);
+                       g_warning("MIME viewer command line is invalid: `%s'", cmd);
                if (def_cmd)
                        g_snprintf(buf, sizeof(buf), def_cmd, filename);
                else
@@ -1061,12 +1063,13 @@ static void mimeview_update_signature_info(MimeView *mimeview)
        }
 }
 
-static void mimeview_check_signature(MimeView *mimeview)
+void mimeview_check_signature(MimeView *mimeview)
 {
        MimeInfo *mimeinfo;
        FILE *fp;
 
        g_return_if_fail (mimeview_is_signed(mimeview));
+       g_return_if_fail (gpg_started);
 
        mimeinfo = gtk_ctree_node_get_row_data
                (GTK_CTREE(mimeview->ctree), mimeview->opened);