2006-08-17 [colin] 2.4.0cvs57
authorColin Leroy <colin@colino.net>
Thu, 17 Aug 2006 16:46:14 +0000 (16:46 +0000)
committerColin Leroy <colin@colino.net>
Thu, 17 Aug 2006 16:46:14 +0000 (16:46 +0000)
* src/imap.c
Add View Log button on auth error
* src/procmsg.c
Fix encrypted mail marked as new when
saved in normal folders
* src/plugins/pgpinline/pgpinline.c
Fix encrypt bug on IMAP
* src/mimeview.c
* src/common/utils.c
* src/common/utils.h
* src/gtk/inputdialog.c
* src/gtk/inputdialog.h
Get rid of metamail stuff, simplify
opening, and allow remembering of user's
choices (by updating ~/.mailcap). There's
still to drop "Audio player" and "Image
viewer" preferences.

ChangeLog
PATCHSETS
configure.ac
src/common/utils.c
src/common/utils.h
src/gtk/inputdialog.c
src/gtk/inputdialog.h
src/imap.c
src/mimeview.c
src/plugins/pgpinline/pgpinline.c
src/procmsg.c

index 2433bc87149cf6fc7cd0340dad6746881555ee04..6fc38eb19af7c587ed9190fa436a7b2c0c342604 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2006-08-17 [colin]     2.4.0cvs57
+
+       * src/imap.c
+               Add View Log button on auth error
+       * src/procmsg.c
+               Fix encrypted mail marked as new when
+               saved in normal folders
+       * src/plugins/pgpinline/pgpinline.c
+               Fix encrypt bug on IMAP
+       * src/mimeview.c
+       * src/common/utils.c
+       * src/common/utils.h
+       * src/gtk/inputdialog.c
+       * src/gtk/inputdialog.h
+               Get rid of metamail stuff, simplify
+               opening, and allow remembering of user's
+               choices (by updating ~/.mailcap). There's
+               still to drop "Audio player" and "Image
+               viewer" preferences.
+
 2006-08-17 [mones]     2.4.0cvs56
 
        * manual/es/sylpheed-claws-manual.xml
index a0273daa428600bbd1eb90c861d875701acf8992..3eb1e161270cc4e59c92a29c09276d5817ab0ffa 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.382.2.300 -r 1.382.2.301 src/compose.c;  cvs diff -u -r 1.115.2.102 -r 1.115.2.103 src/main.c;  cvs diff -u -r 1.274.2.137 -r 1.274.2.138 src/mainwindow.c;  cvs diff -u -r 1.49.2.79 -r 1.49.2.80 src/procmime.c;  cvs diff -u -r 1.3.2.19 -r 1.3.2.20 src/ssl_manager.c;  cvs diff -u -r 1.395.2.229 -r 1.395.2.230 src/summaryview.c;  cvs diff -u -r 1.96.2.136 -r 1.96.2.137 src/textview.c;  cvs diff -u -r 1.43.2.50 -r 1.43.2.51 src/toolbar.c;  cvs diff -u -r 1.1.2.10 -r 1.1.2.11 src/gtk/foldersort.c;  cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/plugins/pgpcore/prefs_gpg.c;  cvs diff -u -r 1.1.2.25 -r 1.1.2.26 src/plugins/pgpcore/sgpgme.c;  cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/pgpcore/sgpgme.h;  ) > 2.4.0cvs54.patchset
 ( cvs diff -u -r 1.654.2.1793 -r 1.654.2.1794 configure.ac;  cvs diff -u -r 1.1.2.4 -r 1.1.2.5 manual/Makefile.am;  diff -u /dev/null manual/es/Makefile.am;  diff -u /dev/null manual/es/account.xml;  diff -u /dev/null manual/es/ack.xml;  diff -u /dev/null manual/es/addrbook.xml;  diff -u /dev/null manual/es/advanced.xml;  diff -u /dev/null manual/es/faq.xml;  diff -u /dev/null manual/es/glossary.xml;  diff -u /dev/null manual/es/gpl.xml;  diff -u /dev/null manual/es/handling.xml;  diff -u /dev/null manual/es/intro.xml;  diff -u /dev/null manual/es/keyboard.xml;  diff -u /dev/null manual/es/plugins.xml;  diff -u /dev/null manual/es/starting.xml;  diff -u /dev/null manual/es/sylpheed-claws-manual.xml;  diff -u /dev/null manual/es/dist/Makefile.am;  diff -u /dev/null manual/es/dist/html/Makefile.am;  diff -u /dev/null manual/es/dist/pdf/Makefile.am;  diff -u /dev/null manual/es/dist/ps/Makefile.am;  diff -u /dev/null manual/es/dist/txt/Makefile.am;  ) > 2.4.0cvs55.patchset
 ( cvs diff -u -r 1.1.2.1 -r 1.1.2.2 manual/es/sylpheed-claws-manual.xml;  ) > 2.4.0cvs56.patchset
+( cvs diff -u -r 1.179.2.128 -r 1.179.2.129 src/imap.c;  cvs diff -u -r 1.83.2.78 -r 1.83.2.79 src/mimeview.c;  cvs diff -u -r 1.150.2.71 -r 1.150.2.72 src/procmsg.c;  cvs diff -u -r 1.36.2.74 -r 1.36.2.75 src/common/utils.c;  cvs diff -u -r 1.20.2.34 -r 1.20.2.35 src/common/utils.h;  cvs diff -u -r 1.2.2.16 -r 1.2.2.17 src/gtk/inputdialog.c;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/gtk/inputdialog.h;  cvs diff -u -r 1.1.2.15 -r 1.1.2.16 src/plugins/pgpinline/pgpinline.c;  ) > 2.4.0cvs57.patchset
index 182d9cf5050389fe0a78a6511a8f76f0bdc2ae21..522a9a7302f118d0cc55e72e68ad34006aad0084 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=4
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=56
+EXTRA_VERSION=57
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 22bfea1cc3129ee056a7bb73017ba0f74e4d3318..a069522f479afe6214735c6ae444262067bd4a82 100644 (file)
@@ -4699,7 +4699,7 @@ gchar *make_http_string(const gchar *bp, const gchar *ep)
        return result;
 }
 
-static gchar *mailcap_get_command_in_file(const gchar *path, const gchar *type)
+static gchar *mailcap_get_command_in_file(const gchar *path, const gchar *type, const gchar *file_to_open)
 {
        FILE *fp = fopen(path, "rb");
        gchar buf[BUFFSIZE];
@@ -4707,7 +4707,7 @@ static gchar *mailcap_get_command_in_file(const gchar *path, const gchar *type)
        if (!fp)
                return NULL;
        while (fgets(buf, sizeof (buf), fp) != NULL) {
-               gchar **parts = g_strsplit(buf, ";", -1);
+               gchar **parts = g_strsplit(buf, ";", 3);
                gchar *trimmed = parts[0];
                while (trimmed[0] == ' ')
                        trimmed++;
@@ -4715,19 +4715,63 @@ static gchar *mailcap_get_command_in_file(const gchar *path, const gchar *type)
                        trimmed[strlen(trimmed)-1] = '\0';
 
                if (!strcmp(trimmed, type)) {
+                       gboolean needsterminal = FALSE;
+                       if (parts[2] && strstr(parts[2], "needsterminal")) {
+                               needsterminal = TRUE;
+                       }
+                       if (parts[2] && strstr(parts[2], "test=")) {
+                               gchar *orig_testcmd = g_strdup(strstr(parts[2], "test=")+5);
+                               gchar *testcmd = orig_testcmd;
+                               if (strstr(testcmd,";"))
+                                       *(strstr(testcmd,";")) = '\0';
+                               while (testcmd[0] == ' ')
+                                       testcmd++;
+                               while (testcmd[strlen(testcmd)-1] == '\n')
+                                       testcmd[strlen(testcmd)-1] = '\0';
+                               while (testcmd[strlen(testcmd)-1] == '\r')
+                                       testcmd[strlen(testcmd)-1] = '\0';
+                               while (testcmd[strlen(testcmd)-1] == ' ')
+                                       testcmd[strlen(testcmd)-1] = '\0';
+                                       
+                               if (strstr(testcmd, "%s")) {
+                                       gchar *tmp = g_strdup_printf(testcmd, file_to_open);
+                                       gint res = system(tmp);
+                                       g_free(tmp);
+                                       g_free(orig_testcmd);
+                                       
+                                       if (res != 0) {
+                                               g_strfreev(parts);
+                                               continue;
+                                       }
+                               } else {
+                                       gint res = system(testcmd);
+                                       g_free(orig_testcmd);
+                                       
+                                       if (res != 0) {
+                                               g_strfreev(parts);
+                                               continue;
+                                       }
+                               }
+                       }
+                       
                        trimmed = parts[1];
                        while (trimmed[0] == ' ')
                                trimmed++;
-                       while (trimmed[strlen(trimmed)-1] == ' ')
-                               trimmed[strlen(trimmed)-1] = '\0';
                        while (trimmed[strlen(trimmed)-1] == '\n')
                                trimmed[strlen(trimmed)-1] = '\0';
                        while (trimmed[strlen(trimmed)-1] == '\r')
                                trimmed[strlen(trimmed)-1] = '\0';
+                       while (trimmed[strlen(trimmed)-1] == ' ')
+                               trimmed[strlen(trimmed)-1] = '\0';
                        result = g_strdup(trimmed);
                        g_strfreev(parts);
                        fclose(fp);
-                       if (strstr(result, "%s") && !strstr(result, "'%s'")) {
+                       /* if there are no single quotes around %s, add them.
+                        * '.*%s.*' is ok, as in display 'png:%s'
+                        */
+                       if (strstr(result, "%s") 
+                       && !(strstr(result, "'") < strstr(result,"%s") &&
+                            strstr(strstr(result,"%s"), "'"))) {
                                gchar *start = g_strdup(result);
                                gchar *end = g_strdup(strstr(result, "%s")+2);
                                gchar *tmp;
@@ -4738,6 +4782,11 @@ static gchar *mailcap_get_command_in_file(const gchar *path, const gchar *type)
                                g_free(result);
                                result = tmp;
                        }
+                       if (needsterminal) {
+                               gchar *tmp = g_strdup_printf("xterm -e %s", result);
+                               g_free(result);
+                               result = tmp;
+                       }
                        return result;
                }
                g_strfreev(parts);
@@ -4745,21 +4794,64 @@ static gchar *mailcap_get_command_in_file(const gchar *path, const gchar *type)
        fclose(fp);
        return NULL;
 }
-gchar *mailcap_get_command_for_type(const gchar *type)
+gchar *mailcap_get_command_for_type(const gchar *type, const gchar *file_to_open)
 {
        gchar *result = NULL;
        gchar *path = NULL;
        if (type == NULL)
                return NULL;
        path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".mailcap", NULL);
-       result = mailcap_get_command_in_file(path, type);
+       result = mailcap_get_command_in_file(path, type, file_to_open);
        g_free(path);
        if (result)
                return result;
-       result = mailcap_get_command_in_file("/etc/mailcap", type);
+       result = mailcap_get_command_in_file("/etc/mailcap", type, file_to_open);
        return result;
 }
 
+void mailcap_update_default(const gchar *type, const gchar *command)
+{
+       gchar *path = NULL, *outpath = NULL;
+       path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".mailcap", NULL);
+       outpath = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".mailcap.new", NULL);
+       FILE *fp = fopen(path, "rb");
+       FILE *outfp = fopen(outpath, "wb");
+       gchar buf[BUFFSIZE];
+
+       if (!fp) {
+               g_free(path);
+               g_free(outpath);
+               return;
+       }
+       if (!outfp) {
+               g_free(path);
+               g_free(outpath);
+               fclose(fp);
+               return;
+       }
+       while (fgets(buf, sizeof (buf), fp) != NULL) {
+               gchar **parts = g_strsplit(buf, ";", 3);
+               gchar *trimmed = parts[0];
+               while (trimmed[0] == ' ')
+                       trimmed++;
+               while (trimmed[strlen(trimmed)-1] == ' ')
+                       trimmed[strlen(trimmed)-1] = '\0';
+
+               if (!strcmp(trimmed, type)) {
+                       g_strfreev(parts);
+                       continue;
+               }
+               else {
+                       fputs(buf, outfp);
+               }
+               g_strfreev(parts);
+       }
+       fprintf(outfp, "%s; %s\n", type, command);
+       fclose(fp);
+       fclose(outfp);
+       g_rename(outpath, path);
+}
+
 gint copy_dir(const gchar *src, const gchar *dst)
 {
        GDir *dir;
index 917f09e047c7c1ed43cacbca8580d49b2f01cb88..f63cde8af91d543e140843834ca303b7715ed2bc 100644 (file)
@@ -562,7 +562,7 @@ gboolean get_email_part(const gchar *start, const gchar *scanpos,
                               const gchar **bp, const gchar **ep, gboolean hdr);
 gchar *make_email_string(const gchar *bp, const gchar *ep);
 gchar *make_http_string(const gchar *bp, const gchar *ep);
-gchar *mailcap_get_command_for_type(const gchar *type);
+gchar *mailcap_get_command_for_type(const gchar *type, const gchar *file_to_open);
 gboolean file_is_email (const gchar *filename);
 
 #ifdef __cplusplus
index 00d9b623da52be20cb5a2003e17377db69bba6ba..1b40c1fb67a5b3b0c4e78de28a135b0166366585 100644 (file)
@@ -38,6 +38,8 @@
 #include <gtk/gtkhbbox.h>
 #include <gtk/gtkstock.h>
 #include <gtk/gtkimage.h>
+#include <gtk/gtktogglebutton.h>
+#include <gtk/gtkcheckbutton.h>
 
 #include "inputdialog.h"
 #include "manage_window.h"
@@ -63,13 +65,15 @@ static GtkWidget *msg_title;
 static GtkWidget *msg_label;
 static GtkWidget *entry;
 static GtkWidget *combo;
+static GtkWidget *remember_chkbtn;
 static GtkWidget *ok_button;
 static GtkWidget *icon_q, *icon_p;
 static gboolean is_pass = FALSE;
 static void input_dialog_create        (gboolean is_password);
 static gchar *input_dialog_open        (const gchar    *title,
                                 const gchar    *message,
-                                const gchar    *default_string);
+                                const gchar    *default_string,
+                                gboolean       *remember);
 static void input_dialog_set   (const gchar    *title,
                                 const gchar    *message,
                                 const gchar    *default_string);
@@ -105,7 +109,7 @@ gchar *input_dialog(const gchar *title, const gchar *message,
        is_pass = FALSE;
        gtk_entry_set_visibility(GTK_ENTRY(entry), TRUE);
 
-       return input_dialog_open(title, message, default_string);
+       return input_dialog_open(title, message, default_string, NULL);
 }
 
 gchar *input_dialog_with_invisible(const gchar *title, const gchar *message,
@@ -125,12 +129,20 @@ gchar *input_dialog_with_invisible(const gchar *title, const gchar *message,
        is_pass = TRUE;
        gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
 
-       return input_dialog_open(title, message, default_string);
+       return input_dialog_open(title, message, default_string, NULL);
 }
 
 gchar *input_dialog_combo(const gchar *title, const gchar *message,
                          const gchar *default_string, GList *list,
                          gboolean case_sensitive)
+{
+       return input_dialog_combo_remember(title, message, 
+               default_string, list, case_sensitive, NULL);
+}
+
+gchar *input_dialog_combo_remember(const gchar *title, const gchar *message,
+                         const gchar *default_string, GList *list,
+                         gboolean case_sensitive, gboolean *remember)
 {
        if (dialog && GTK_WIDGET_VISIBLE(dialog)) return NULL;
 
@@ -141,6 +153,12 @@ gchar *input_dialog_combo(const gchar *title, const gchar *message,
        gtk_widget_hide(entry);
        gtk_widget_show(combo);
 
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remember_chkbtn), FALSE);
+       if (remember)
+               gtk_widget_show(remember_chkbtn);
+       else
+               gtk_widget_hide(remember_chkbtn);
+
        gtk_widget_show(icon_q);
        gtk_widget_hide(icon_p);
        is_pass = FALSE;
@@ -157,7 +175,7 @@ gchar *input_dialog_combo(const gchar *title, const gchar *message,
 
        gtk_combo_set_case_sensitive(GTK_COMBO(combo), case_sensitive);
 
-       return input_dialog_open(title, message, default_string);
+       return input_dialog_open(title, message, default_string, remember);
 }
 
 gchar *input_dialog_query_password(const gchar *server, const gchar *user)
@@ -253,6 +271,9 @@ static void input_dialog_create(gboolean is_password)
        g_signal_connect(G_OBJECT(GTK_COMBO(combo)->entry), "activate",
                         G_CALLBACK(combo_activated), NULL);
 
+       remember_chkbtn = gtk_check_button_new_with_label(_("Remember this"));
+       gtk_box_pack_start(GTK_BOX(vbox), remember_chkbtn, FALSE, FALSE, 0);
+
        hbox = gtk_hbox_new(TRUE, 0);
 
        gtkut_stock_button_set_create(&confirm_area,
@@ -266,6 +287,8 @@ static void input_dialog_create(gboolean is_password)
 
        gtk_widget_show_all(GTK_DIALOG(dialog)->vbox);
        
+       gtk_widget_hide(remember_chkbtn);
+
        if (is_password)
                gtk_widget_hide(icon_q);
        else
@@ -282,7 +305,7 @@ static void input_dialog_create(gboolean is_password)
 }
 
 static gchar *input_dialog_open(const gchar *title, const gchar *message,
-                               const gchar *default_string)
+                               const gchar *default_string, gboolean *remember)
 {
        gchar *str;
 
@@ -323,6 +346,9 @@ static gchar *input_dialog_open(const gchar *title, const gchar *message,
 
        GTK_EVENTS_FLUSH();
 
+       if (remember) {
+               *remember = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(remember_chkbtn));
+       }
        debug_print("return string = %s\n", str ? str : "(none)");
        return str;
 }
index 377caf64179eff64ed667e50412c725f33cde99c..34fe682f0c5075ec734555eb17845eb7cdf1ba98 100644 (file)
@@ -33,6 +33,12 @@ gchar *input_dialog_combo            (const gchar    *title,
                                         const gchar    *default_string,
                                         GList          *list,
                                         gboolean        case_sensitive);
+gchar *input_dialog_combo_remember     (const gchar    *title,
+                                        const gchar    *message,
+                                        const gchar    *default_string,
+                                        GList          *list,
+                                        gboolean        case_sensitive,
+                                        gboolean       *remember);
 gchar *input_dialog_query_password     (const gchar    *server,
                                         const gchar    *user);
 
index 1116b7a588f855f74d9ab5c2f9c718e08e2dcc0a..af4a05a6f03543c64c2c04afb41d1fcce79ff3d1 100644 (file)
@@ -896,7 +896,7 @@ try_again:
                        failed = TRUE;
                        goto try_again;
                } else {
-                       alertpanel_error(_("Couldn't login to IMAP server %s."), account->recv_server);
+                       alertpanel_error_log(_("Couldn't login to IMAP server %s."), account->recv_server);
                }               
 
                return;
index 788008531b7f0673c3ff30f1261fcc010e42c030..86717050f4d8aee4fcf4f9b0db997a5e3b18507a 100644 (file)
@@ -122,10 +122,11 @@ static void mimeview_save_all             (MimeView       *mimeview);
 static void mimeview_launch            (MimeView       *mimeview);
 static void mimeview_open_with         (MimeView       *mimeview);
 static void mimeview_open_part_with    (MimeView       *mimeview,
-                                        MimeInfo       *partinfo);
+                                        MimeInfo       *partinfo,
+                                        gboolean        automatic);
 static void mimeview_view_file         (const gchar    *filename,
                                         MimeInfo       *partinfo,
-                                        const gchar    *cmdline,
+                                        const gchar    *cmd,
                                         MimeView       *mimeview);
 static gboolean icon_clicked_cb                (GtkWidget      *button, 
                                         GdkEventButton *event, 
@@ -1607,10 +1608,10 @@ static void mimeview_open_with(MimeView *mimeview)
 
        partinfo = mimeview_get_part_to_use(mimeview);
 
-       mimeview_open_part_with(mimeview, partinfo);
+       mimeview_open_part_with(mimeview, partinfo, FALSE);
 }
 
-static void mimeview_open_part_with(MimeView *mimeview, MimeInfo *partinfo)
+static void mimeview_open_part_with(MimeView *mimeview, MimeInfo *partinfo, gboolean automatic)
 {
        gchar *filename;
        gchar *cmd;
@@ -1641,24 +1642,47 @@ static void mimeview_open_part_with(MimeView *mimeview, MimeInfo *partinfo)
                content_type = procmime_get_content_type_str(partinfo->type,
                        partinfo->subtype);
        }
-       mime_command = mailcap_get_command_for_type(content_type);
-
+       
+       if (partinfo->type != MIMETYPE_TEXT || !prefs_common.ext_editor_cmd
+       ||  !prefs_common.ext_editor_cmd[0])
+               mime_command = mailcap_get_command_for_type(content_type, filename);
+       else
+               mime_command = g_strdup(prefs_common.ext_editor_cmd);
        if (mime_command == NULL) {
                /* try with extension this time */
                g_free(content_type);
                content_type = procmime_get_mime_type(filename);
-               mime_command = mailcap_get_command_for_type(content_type);
+               mime_command = mailcap_get_command_for_type(content_type, filename);
        }
 
-       g_free(content_type);
-       cmd = input_dialog_combo
-               (_("Open with"),
-                _("Enter the command line to open file:\n"
-                  "('%s' will be replaced with file name)"),
-                mime_command ? mime_command : prefs_common.mime_open_cmd,
-                prefs_common.mime_open_cmd_history,
-                TRUE);
-       g_free(mime_command);
+       if (mime_command == NULL)
+               automatic = FALSE;
+       
+       if (!automatic) {
+               gboolean remember = FALSE;
+               if (content_type != NULL)
+                       cmd = input_dialog_combo_remember
+                               (_("Open with"),
+                                _("Enter the command line to open file:\n"
+                                  "('%s' will be replaced with file name)"),
+                                mime_command ? mime_command : prefs_common.mime_open_cmd,
+                                prefs_common.mime_open_cmd_history,
+                                TRUE, &remember);
+               else
+                       cmd = input_dialog_combo
+                               (_("Open with"),
+                                _("Enter the command line to open file:\n"
+                                  "('%s' will be replaced with file name)"),
+                                mime_command ? mime_command : prefs_common.mime_open_cmd,
+                                prefs_common.mime_open_cmd_history,
+                                TRUE);
+               if (cmd && remember) {
+                       mailcap_update_default(content_type, cmd);
+               }
+               g_free(mime_command);
+       } else {
+               cmd = mime_command;
+       }
        if (cmd) {
                mimeview_view_file(filename, partinfo, cmd, mimeview);
                g_free(prefs_common.mime_open_cmd);
@@ -1666,66 +1690,28 @@ static void mimeview_open_part_with(MimeView *mimeview, MimeInfo *partinfo)
                prefs_common.mime_open_cmd_history =
                        add_history(prefs_common.mime_open_cmd_history, cmd);
        }
-
+       g_free(content_type);
        g_free(filename);
 }
 
 static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
-                              const gchar *cmdline, MimeView *mimeview)
-{
-       static gchar *default_image_cmdline = DEFAULT_IMAGE_VIEWER_CMD;
-       static gchar *default_audio_cmdline = DEFAULT_AUDIO_PLAYER_CMD;
-       static gchar *default_html_cmdline = DEFAULT_BROWSER_CMD;
-       static gchar *mime_cmdline = DEFAULT_MIME_CMD;
-       gchar buf[1024];
-       gchar m_buf[1024];
-       const gchar *cmd;
-       const gchar *def_cmd;
-       const gchar *p;
-
-       if (cmdline) {
-               cmd = cmdline;
-               def_cmd = NULL;
-       } else if (MIMETYPE_APPLICATION == partinfo->type &&
-                  !g_ascii_strcasecmp(partinfo->subtype, "octet-stream")) {
-               mimeview_open_part_with(mimeview, partinfo);
-               return;
-       } else if (MIMETYPE_IMAGE == partinfo->type) {
-               cmd = prefs_common.mime_image_viewer;
-               def_cmd = default_image_cmdline;
-       } else if (MIMETYPE_AUDIO == partinfo->type) {
-               cmd = prefs_common.mime_audio_player;
-               def_cmd = default_audio_cmdline;
-       } else if (MIMETYPE_TEXT == partinfo->type && !strcasecmp(partinfo->subtype, "html")) {
-               cmd = prefs_common.uri_cmd;
-               def_cmd = default_html_cmdline;
-       } else {
-               gchar *content_type;
-               
-               content_type = procmime_get_content_type_str(partinfo->type, partinfo->subtype);
-               g_snprintf(m_buf, sizeof(m_buf), mime_cmdline,
-                          content_type, "%s");
-               g_free(content_type);
-               cmd = m_buf;
-               def_cmd = NULL;
-       }
-
-       if (cmd && (p = strchr(cmd, '%')) && *(p + 1) == 's' &&
-           !strchr(p + 2, '%'))
-               g_snprintf(buf, sizeof(buf), cmd, filename);
+                              const gchar *cmd, MimeView *mimeview)
+{
+       gchar *p;
+       gchar buf[BUFFSIZE];
+       if (cmd == NULL)
+               mimeview_open_part_with(mimeview, partinfo, TRUE);
        else {
-               if (cmd)
+               if ((p = strchr(cmd, '%')) && *(p + 1) == 's' &&
+                   !strchr(p + 2, '%'))
+                       g_snprintf(buf, sizeof(buf), cmd, filename);
+               else {
                        g_warning("MIME viewer command line is invalid: '%s'", cmd);
-               if (def_cmd)
-                       g_snprintf(buf, sizeof(buf), def_cmd, filename);
-               else {
-                       mimeview_open_part_with(mimeview, partinfo);
-                       return;
-               }
+                       mimeview_open_part_with(mimeview, partinfo, FALSE);
+               }
+               if (execute_command_line(buf, TRUE) != 0)
+                       mimeview_open_part_with(mimeview, partinfo, FALSE);
        }
-
-       if (execute_command_line(buf, TRUE) != 0)
-               mimeview_open_part_with(mimeview, partinfo);
 }
 
 void mimeview_register_viewer_factory(MimeViewerFactory *factory)
index 2c6ae913e6114ea10b1a0b18bba143d15855e603..c5279809ddf3f05f743bb71cf0c6c42115b2d7f7 100644 (file)
@@ -585,7 +585,8 @@ static gboolean pgpinline_sign(MimeInfo *mimeinfo, PrefsAccount *account)
 
        if (msgcontent->content == MIMECONTENT_FILE &&
            msgcontent->data.filename != NULL) {
-               g_unlink(msgcontent->data.filename);
+               if (msgcontent->tmp == TRUE)
+                       g_unlink(msgcontent->data.filename);
                g_free(msgcontent->data.filename);
        }
        msgcontent->data.mem = g_strdup(tmp);
@@ -694,7 +695,8 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
 
        if (msgcontent->content == MIMECONTENT_FILE &&
            msgcontent->data.filename != NULL) {
-               g_unlink(msgcontent->data.filename);
+               if (msgcontent->tmp == TRUE)
+                       g_unlink(msgcontent->data.filename);
                g_free(msgcontent->data.filename);
        }
        msgcontent->data.mem = g_strdup(tmp);
index 208c3bc4664229e4ddeeea7247662f373785fddb..b09615fc75cefa55c8586de2b7e659f8deb24374 100644 (file)
@@ -1084,7 +1084,6 @@ gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
                        g_warning("can't save message\n");
                        return -1;
                }
-               return 0;
        }
        msginfo = folder_item_get_msginfo(outbox, num);         /* refcnt++ */
        tmp_msginfo = procmsg_msginfo_get_full_info(msginfo);   /* refcnt++ */ 
@@ -1095,8 +1094,8 @@ gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
                if (tmp_msginfo && (msginfo->dispositionnotificationto || 
                    msginfo->returnreceiptto)) {
                        procmsg_msginfo_set_flags(msginfo, MSG_RETRCPT_SENT, 0); 
-                       procmsg_msginfo_free(msginfo);          /* refcnt-- */
                }       
+               procmsg_msginfo_free(tmp_msginfo);              /* refcnt-- */
        }
 
        return 0;