* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "mutt.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include <errno.h>
static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
+static char LastSaveFolder[_POSIX_PATH_MAX] = "";
#define CHECK_READONLY if (Context->readonly) \
{\
{ NULL }
};
+int mutt_extract_path(char *filename, char *path)
+{
+ char *tmp=safe_malloc(sizeof(char) * _POSIX_PATH_MAX);
+ char *help_ptr;
+
+ help_ptr = tmp;
+
+ while(*filename != '\0')
+ {
+ if (*filename == '/')
+ {
+ *help_ptr++=*filename++;
+ *help_ptr++='\0';
+ strcat(path, tmp);
+ help_ptr = tmp;
+ }
+ *help_ptr++=*filename++;
+ }
+ safe_free((void **) &tmp);
+
+ return 0;
+}
+
void mutt_update_tree (ATTACHPTR **idx, short idxlen)
{
char buf[STRING];
{
char *prompt;
char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
+ char path[_POSIX_PATH_MAX]="";
int is_message;
int append = 0;
int rc;
+ int ret = -1;
if (body->filename)
{
else
buf[0] = 0;
- prompt = _("Save to file: ");
+ prompt = _("Save to file ('#' for last used folder): ");
while (prompt)
{
- if (mutt_get_field (prompt, buf, sizeof (buf), M_FILE | M_CLEAR) != 0
- || !buf[0])
+ ret = mutt_get_field (prompt, buf, sizeof (buf), M_FILE | M_CLEAR | M_LASTFOLDER);
+ if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
return -1;
+
+ if (ret == 2)
+ {
+ char tmpbuf[_POSIX_PATH_MAX];
+ snprintf(tmpbuf,sizeof(tmpbuf),"%s%s",LastSaveFolder,buf);
+ strfcpy (buf, tmpbuf, sizeof (buf));
+ ret = mutt_get_field (_("Save to file: ")
+ , buf, sizeof (buf), M_FILE);
+ if ((ret != 0) || (!buf[0]))
+ return -1;
+ }
+ else
+ {
+ mutt_extract_path(buf,path);
+ strfcpy (LastSaveFolder, path, sizeof (LastSaveFolder));
+ }
prompt = NULL;
mutt_expand_path (buf, sizeof (buf));
/* check to make sure that this file is really the one the user wants */
if ((rc = mutt_save_confirm (buf, &st)) == 1)
{
- prompt = _("Save to file: ");
- continue;
+ prompt = _("Save to file: ");
+ continue;
}
else if (rc == -1)
- return -1;
+ return -1;
strfcpy(tfile, buf, sizeof(tfile));
}
else
{
if ((rc = mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile), &append, directory)) == -1)
- return -1;
+ return -1;
else if (rc == 1)
{
- prompt = _("Save to file: ");
- continue;
+ prompt = _("Save to file: ");
+ continue;
}
}
break;
/* functions which are passed through from the pager */
case OP_CHECK_TRADITIONAL:
- if (!(WithCrypto & APPLICATION_PGP))
+ if (!(WithCrypto & APPLICATION_PGP) || (hdr && hdr->security & PGP_TRADITIONAL_CHECKED))
{
op = OP_NULL;
break;
mx_close_message (&msg);
return;
}
- if ((WithCrypto & APPLICATION_SMIME) && hdr->security & APPLICATION_SMIME)
+ if ((WithCrypto & APPLICATION_SMIME) && (hdr->security & APPLICATION_SMIME))
{
if (hdr->env)
- crypt_smime_getkeys (hdr->env);
+ crypt_smime_getkeys (hdr->env);
if (mutt_is_application_smime(hdr->content))
- secured = ! crypt_smime_decrypt_mime (msg->fp, &fp,
+ {
+ secured = ! crypt_smime_decrypt_mime (msg->fp, &fp,
hdr->content, &cur);
+
+ /* S/MIME nesting */
+ if ((mutt_is_application_smime (cur) & SMIMEOPAQUE))
+ {
+ BODY *_cur = cur;
+ FILE *_fp = fp;
+
+ fp = NULL; cur = NULL;
+ secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
+
+ mutt_free_body (&_cur);
+ safe_fclose (&_fp);
+ }
+ }
else
- need_secured = 0;
+ need_secured = 0;
}
- if ((WithCrypto & APPLICATION_PGP) && hdr->security & APPLICATION_PGP)
+ if ((WithCrypto & APPLICATION_PGP) && (hdr->security & APPLICATION_PGP))
{
if (mutt_is_multipart_encrypted(hdr->content))
- secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
+ secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
else
- need_secured = 0;
+ need_secured = 0;
}
if (need_secured && !secured)