/*
* Copyright (C) 1996-8 Michael R. Elkins <me@cs.hmc.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "mutt.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "rfc1524.h"
#include "mime.h"
#include "attach.h"
#include "mapping.h"
#include "mailbox.h"
#include "sort.h"
#include <string.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#define CHECK_COUNT if (idxlen == 0) { mutt_error ("There are no attachments."); break; }
enum
{
HDR_FROM = 1,
HDR_TO,
HDR_CC,
HDR_BCC,
HDR_SUBJECT,
HDR_REPLYTO,
HDR_FCC,
#ifdef _PGPPATH
HDR_PGP,
HDR_PGPSIGINFO,
#endif
HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
};
#define HDR_XOFFSET 10
static struct mapping_t ComposeHelp[] = {
{ "Send", OP_COMPOSE_SEND_MESSAGE },
{ "Abort", OP_EXIT },
{ "To", OP_COMPOSE_EDIT_TO },
{ "CC", OP_COMPOSE_EDIT_CC },
{ "Subj", OP_COMPOSE_EDIT_SUBJECT },
{ "Attach", OP_COMPOSE_ATTACH_FILE },
{ "Descrip", OP_COMPOSE_EDIT_DESCRIPTION },
{ "Help", OP_HELP },
{ NULL }
};
void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
{
mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
(unsigned long)(((ATTACHPTR **) menu->data)[num]),
M_FORMAT_STAT_FILE | M_FORMAT_ARROWCURSOR);
}
#ifdef _PGPPATH
#include "pgp.h"
static int pgp_send_menu (int bits)
{
int c;
char *p;
char *micalg = NULL;
char input_signas[SHORT_STRING];
char input_micalg[SHORT_STRING];
KEYINFO *secring;
struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_SIGN);
mvaddstr (LINES-1, 0, "(e)ncrypt, (s)ign, sign (a)s, (b)oth, select (m)ic algorithm, or (f)orget it? ");
clrtoeol ();
do
{
mutt_refresh ();
if ((c = mutt_getch ()) == ERR)
break;
if (c == 'a')
{
unset_option(OPTPGPCHECKTRUST);
if(pgp)
{
if(!(secring = pgp->read_secring(pgp)))
{
mutt_error("Can't open your secret key ring!");
bits &= ~PGPSIGN;
}
else
{
if ((p = pgp_ask_for_key (pgp, secring, "Sign as: ",
NULL, KEYFLAG_CANSIGN, &micalg)))
{
snprintf (input_signas, sizeof (input_signas), "0x%s", p);
safe_free((void **) &PgpSignAs);
PgpSignAs = safe_strdup(input_signas);
safe_free((void **) &PgpSignMicalg);
PgpSignMicalg = micalg; /* micalg is malloc()ed by pgp_ask_for_key */
pgp_void_passphrase (); /* probably need a different passphrase */
safe_free ((void **) &p);
bits |= PGPSIGN;
}
pgp_close_keydb(&secring);
}
}
else
{
bits &= ~PGPSIGN;
mutt_error("An unkown PGP version was defined for signing.");
}
}
else if (c == 'm')
{
if(!(bits & PGPSIGN))