prefs_actions.c:
authorMelvin Hadasht <melvin.hadasht@free.fr>
Mon, 28 Oct 2002 15:32:51 +0000 (15:32 +0000)
committerMelvin Hadasht <melvin.hadasht@free.fr>
Mon, 28 Oct 2002 15:32:51 +0000 (15:32 +0000)
Fixed bug #627322 where MIME parts were not always correctly
passed to a %p action
Display an error dialog when message filename is not found

ChangeLog.claws
configure.in
src/prefs_actions.c

index 3c355fd6ed8a16a7d3ab50a357aa5f42f639a615..9e8b6672ef2acc23fb521a94472357faf83e405b 100644 (file)
@@ -1,3 +1,10 @@
+2002-10-28 [melvin]    0.8.5claws59
+
+       * src/prefs_actions.c
+               Fixed bug #627322 where MIME parts were not always
+               correctly passed to a %p action
+               Display an error dialog when message filename is not found.
+
 2002-10-28 [melvin]    0.8.5claws58
 
        * src/prefs_common.c
                actions callback from compose toolbar
        * src/folderview.c
                remove include toolbar.h
-               
+
 2002-09-22 [oliver]    0.8.3claws7
        
        * src/prefs_toolbar.[ch]
                custom toolbar for compose
                - generic prefs_toolbar handles both
                  Mainwin's toolbar as well as Compose toolbar          
-               
+
 2002-09-22 [oliver]    0.8.3claws6
        
        * src/toolbar.[ch]
                custom toolbar for compose
                restructure toolbar.[ch]
-               
+
 2002-09-22 [oliver]    0.8.3claws5
 
        * src/compose.[ch]
                custom toolbar for compose
-               
+
 2002-09-22 [oliver]    0.8.3claws4
        
        * src/mainwindow.[ch]
index 00f81db77a8aa43ff949002fdada8b149c219f71..4f2a7263cbd23aa90624ce8862b470a288f670bb 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws58
+EXTRA_VERSION=claws59
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 6fdc8986f2bc0771a62409c1ba36edd5f35d1cb5..9e65f44fd0ee25e553e772499bbd077ebc9a6f74 100644 (file)
@@ -173,10 +173,10 @@ static gchar *parse_action_cmd            (gchar          *action,
                                         MsgInfo        *msginfo,
                                         GtkCTree       *ctree,
                                         MimeView       *mimeview);
-static GString *parse_append_filename  (GString        *cmd,
+static gboolean parse_append_filename  (GString        **cmd,
                                         MsgInfo        *msginfo);
 
-static GString *parse_append_msgpart   (GString        *cmd,
+static gboolean parse_append_msgpart   (GString        **cmd,
                                         MsgInfo        *msginfo,
                                         MimeView       *mimeview);
 
@@ -577,7 +577,7 @@ static guint get_action_type(gchar *action)
 static gchar *parse_action_cmd(gchar *action, MsgInfo *msginfo,
                               GtkCTree *ctree, MimeView *mimeview)
 {
-       GString *cmd, *tmpcmd;
+       GString *cmd;
        gchar *p;
        GList *cur;
        MsgInfo *msg;
@@ -593,7 +593,10 @@ static gchar *parse_action_cmd(gchar *action, MsgInfo *msginfo,
                if (p[0] == '%' && p[1]) {
                        switch (p[1]) {
                        case 'f':
-                               cmd = parse_append_filename(cmd, msginfo);
+                               if (!parse_append_filename(&cmd, msginfo)) {
+                                       g_string_free(cmd, TRUE);
+                                       return NULL;
+                               }
                                p++;
                                break;
                        case 'F':
@@ -601,18 +604,18 @@ static gchar *parse_action_cmd(gchar *action, MsgInfo *msginfo,
                                     cur != NULL; cur = cur->next) {
                                        msg = gtk_ctree_node_get_row_data(ctree,
                                              GTK_CTREE_NODE(cur->data));
-                                       cmd = parse_append_filename(cmd, msg);
+                                       if (!parse_append_filename(&cmd, msg)) {
+                                               g_string_free(cmd, TRUE);
+                                               return NULL;
+                                       }
                                        if (cur->next)
                                                cmd = g_string_append_c(cmd, ' ');
                                }
                                p++;
                                break;
                        case 'p':
-                               tmpcmd = parse_append_msgpart
-                                       (cmd, msginfo, mimeview);
-                               if (tmpcmd)
-                                       cmd = tmpcmd;
-                               else {
+                               if (!parse_append_msgpart(&cmd, msginfo,
+                                                         mimeview)) {
                                        g_string_free(cmd, TRUE);
                                        return NULL;
                                }
@@ -638,23 +641,27 @@ static gchar *parse_action_cmd(gchar *action, MsgInfo *msginfo,
        return p;
 }
 
-static GString *parse_append_filename(GString *cmd, MsgInfo *msginfo)
+static gboolean parse_append_filename(GString **cmd, MsgInfo *msginfo)
 {
        gchar *filename;
 
-       g_return_val_if_fail(msginfo, cmd);
+       g_return_val_if_fail(msginfo, FALSE);
 
        filename = procmsg_get_message_file(msginfo);
 
        if (filename) {
-               cmd = g_string_append(cmd, filename);
+               *cmd = g_string_append(*cmd, filename);
                g_free(filename);
-       } 
+       } else {
+               alertpanel_error(_("Could not get message file %d"),
+                               msginfo->msgnum);
+               return FALSE;
+       }
 
-       return cmd;
+       return TRUE;
 }
 
-static GString *parse_append_msgpart(GString *cmd, MsgInfo *msginfo,
+static gboolean parse_append_msgpart(GString **cmd, MsgInfo *msginfo,
                                     MimeView *mimeview)
 {
        gchar    *filename;
@@ -668,12 +675,12 @@ static GString *parse_append_msgpart(GString *cmd, MsgInfo *msginfo,
                if ((fp = procmsg_open_message_decrypted(msginfo, &partinfo))
                    == NULL) {
                        alertpanel_error(_("Could not get message file."));
-                       return NULL;
+                       return FALSE;
                }
 #else
                if ((fp = procmsg_open_message(msginfo)) == NULL) {
                        alertpanel_error(_("Could not get message file."));
-                       return NULL;
+                       return FALSE;
                }
                partinfo = procmime_scan_mime_header(fp);
 #endif
@@ -681,22 +688,22 @@ static GString *parse_append_msgpart(GString *cmd, MsgInfo *msginfo,
                if (!partinfo) {
                        procmime_mimeinfo_free(partinfo);
                        alertpanel_error(_("Could not get message part."));
-                       return NULL;
+                       return FALSE;
                }
                filename = procmsg_get_message_file(msginfo);
        } else {
                if (!mimeview->opened) {
                        alertpanel_error(_("No message part selected."));
-                       return NULL;
+                       return FALSE;
                }
                if (!mimeview->file) {
                        alertpanel_error(_("No message file selected."));
-                       return NULL;
+                       return FALSE;
                }
                partinfo = gtk_ctree_node_get_row_data
                                (GTK_CTREE(mimeview->ctree),
                                 mimeview->opened);
-               g_return_val_if_fail(partinfo != NULL, cmd);
+               g_return_val_if_fail(partinfo != NULL, FALSE);
                filename = mimeview->file;
        }
        partname = procmime_get_tmp_file_name(partinfo);
@@ -711,14 +718,14 @@ static GString *parse_append_msgpart(GString *cmd, MsgInfo *msginfo,
        if (ret < 0) {
                alertpanel_error(_("Can't get part of multipart message"));
                g_free(partname);
-               return NULL;
+               return FALSE;
        }
 
-       cmd = g_string_append(cmd,partname);
+       *cmd = g_string_append(*cmd, partname);
 
        g_free(partname);
 
-       return cmd;
+       return TRUE;
 }
 
 static void prefs_actions_set_dialog(void)
@@ -1109,13 +1116,13 @@ static void mainwin_actions_execute_cb(MainWindow *mainwin, guint action_nb,
                        text = messageview->textview->text;
                break;
        case MVIEW_MIME:
-               if (messageview->mimeview &&
-                   messageview->mimeview->type == MIMEVIEW_TEXT &&
-                   messageview->mimeview->textview &&
-                   messageview->mimeview->textview->text) {
-                       text = messageview->mimeview->textview->text;
+               if (messageview->mimeview) {
                        mimeview = messageview->mimeview;
-               }
+                       if (messageview->mimeview->type == MIMEVIEW_TEXT &&
+                                       messageview->mimeview->textview &&
+                                       messageview->mimeview->textview->text)
+                               text = messageview->mimeview->textview->text;
+               } 
                break;
        }