Commit 822535ed authored by Thomas Roessler's avatar Thomas Roessler

A first take at adding a mixmaster front-end to mutt. Don't worry,

it's optional. ;-)
parent a983c119
......@@ -24,10 +24,12 @@ INCLUDES=-I. -I$(includedir)
non_us_sources = pgp.c pgpinvoke.c pgpkey.c pgppubring.c sha1dgst.c \
gnupgparse.c sha.h sha_locl.h \
doc/language.txt doc/language50.txt OPS.PGP doc/PGP-Notes
doc/language.txt doc/language50.txt OPS.PGP doc/PGP-Notes \
OPS.MIX remailer.c remailer.h
EXTRA_mutt_SOURCES = pgp.c pgpinvoke.c pgpkey.c pgppubring.c sha1dgst.c \
gnupgparse.c resize.c dotlock.c pop.c imap.c socket.c
remailer.c remailer.h
EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP TODO configure acconfig.h attach.h \
buffy.h charset.h config.h copy.h dotlock.h functions.h gen_defs \
......@@ -35,7 +37,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP TODO configure acconfig.h attach.h \
mailbox.h mapping.h mime.h mutt.h mutt_curses.h mutt_menu.h \
mutt_regex.h mutt_socket.h mx.h pager.h parse.h pgp.h protos.h \
reldate.h rfc1524.h rfc2047.h rfc822.h sha.h sha_locl.h \
sort.h mime.types VERSION prepare _regex.h
sort.h mime.types VERSION prepare _regex.h OPS.MIX
BUILT_SOURCES = mutt_dotlock.c keymap_defs.h
......@@ -54,7 +56,7 @@ LDADD = @LIBOBJS@ @INTLLIBS@
SUBDIRS = doc intl m4 po contrib
OPS=$(srcdir)/OPS $(srcdir)/OPS.PGP
OPS=@OPS@
keymap_defs.h: $(OPS) $(srcdir)/gen_defs
$(srcdir)/gen_defs $(OPS) > keymap_defs.h
......@@ -108,7 +110,7 @@ us-distdir: distdir dist-hook
us-dist: us-distdir
for file in $(distdir)-us/*.c $(distdir)-us/*.h ; do \
$(srcdir)/reap.pl _PGPPATH < $$file > $$file.n && rm $$file && mv $$file.n $$file ; \
$(srcdir)/reap.pl _PGPPATH < $$file | $(srcdir)/reap.pl MIXMASTER > $$file.n && rm $$file && mv $$file.n $$file ; \
done
for file in $(non_us_sources) ; do \
echo "/* This file is only available in the international mutt version */" \
......
OP_MIX_USE "Accept the chain constructed"
OP_MIX_APPEND "Append a remailer to the chain"
OP_MIX_INSERT "Insert a remailer into the chain"
OP_MIX_DELETE "Delete a remailer from the chain"
OP_MIX_CHAIN_PREV "Select the previous element of the chain"
OP_MIX_CHAIN_NEXT "Select the next element of the chain"
OP_COMPOSE_MIX "send the message through a mixmaster remailer chain"
......@@ -137,3 +137,6 @@
/* Use the included regex.c? */
#undef USE_GNU_REGEX
/* Where's mixmaster located? */
#undef MIXMASTER
......@@ -26,6 +26,10 @@
#include "mailbox.h"
#include "sort.h"
#ifdef MIXMASTER
#include "remailer.h"
#endif
#include <string.h>
#include <sys/stat.h>
#include <sys/wait.h>
......@@ -46,13 +50,15 @@ enum
HDR_REPLYTO,
HDR_FCC,
#ifdef MIXMASTER
HDR_MIX,
#endif
#ifdef _PGPPATH
HDR_PGP,
HDR_PGPSIGINFO,
#endif
HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
};
......@@ -214,7 +220,35 @@ static int pgp_send_menu (int bits, int *redraw)
}
#endif /* _PGPPATH */
#ifdef MIXMASTER
static void redraw_mix_line (LIST *chain)
{
int c;
mvaddstr (HDR_MIX, 0, " Mix: ");
if (!chain)
{
addstr ("no");
clrtoeol ();
return;
}
for (c = 12; chain; chain = chain->next)
{
if (c + mutt_strlen ((char *) chain->data) + 2 >= COLS)
break;
addstr (NONULL((char *) chain->data));
if (chain->next)
addstr (", ");
c += mutt_strlen ((char *) chain->data) + 2;
}
}
#endif
static int
check_attachments(ATTACHPTR **idx, short idxlen)
......@@ -276,9 +310,17 @@ static void draw_envelope (HEADER *msg, char *fcc)
redraw_pgp_lines (msg->pgp);
#endif /* _PGPPATH */
#ifdef MIXMASTER
redraw_mix_line (msg->chain);
#endif
SETCOLOR (MT_COLOR_STATUS);
mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
BKGDSET (MT_COLOR_STATUS);
clrtoeol ();
mvaddstr (HDR_ATTACH - 1, 0, _("===== Attachments ====="));
BKGDSET (MT_COLOR_NORMAL);
SETCOLOR (MT_COLOR_NORMAL);
}
static int edit_address_list (int line, ADDRESS **addr)
......@@ -779,6 +821,12 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
menu->redraw = REDRAW_FULL;
break;
}
#ifdef MIXMASTER
if (mix_check_message (msg) != 0)
break;
#endif
if (!fccSet && *fcc)
{
......@@ -987,7 +1035,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
/* fall through to postpone! */
case OP_COMPOSE_POSTPONE_MESSAGE:
if(check_attachments(idx, idxlen) != 0)
{
menu->redraw = REDRAW_FULL;
......@@ -1050,7 +1098,12 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
#endif /* _PGPPATH */
#ifdef MIXMASTER
case OP_COMPOSE_MIX:
mix_make_chain (&msg->chain, &menu->redraw);
break;
#endif
}
}
......
......@@ -80,6 +80,18 @@ else
MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS pgp.o pgpinvoke.o pgpkey.o pgppubring.o sha1dgst.o gnupgparse.o"
OPS="$OPS \$(srcdir)/OPS.PGP"
fi
AC_ARG_WITH(mixmaster, [ --with-mixmaster[=PATH] include Mixmaster support],
[if test -x "$withval" ; then
MIXMASTER="$withval"
else
MIXMASTER="mixmaster"
fi
OPS="$OPS \$(srcdir)/OPS.MIX"
MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS remailer.o"
AC_DEFINE_UNQUOTED(MIXMASTER, "$MIXMASTER")
])
fi
AC_SUBST(OPS)
......
......@@ -296,6 +296,10 @@ struct binding_t OpCompose[] = {
{ "pgp-menu", OP_COMPOSE_PGP_MENU, "p" },
#endif
#ifdef MIXMASTER
{ "mix", OP_COMPOSE_MIX, "M" },
#endif
{ NULL, 0, NULL }
};
......@@ -356,3 +360,16 @@ struct binding_t OpPgp[] = {
{ NULL, 0, NULL }
};
#endif /* _PGPPATH */
#ifdef MIXMASTER
struct binding_t OpMix[] = {
{ "accept", OP_MIX_USE, M_ENTER_S },
{ "append", OP_MIX_APPEND, "a" },
{ "insert", OP_MIX_INSERT, "i" },
{ "delete", OP_MIX_DELETE, "d" },
{ "chain-prev", OP_MIX_CHAIN_PREV, "<left>" },
{ "chain-next", OP_MIX_CHAIN_NEXT, "<right>" },
{ NULL, 0, NULL }
};
#endif /* MIXMASTER */
......@@ -52,6 +52,11 @@ WHERE char *Locale;
WHERE char *MailcapPath;
WHERE char *Maildir;
WHERE char *MsgFmt;
#ifdef MIXMASTER
WHERE char *Mixmaster;
#endif
WHERE char *Muttrc INITVAL (NULL);
WHERE char *Outbox;
WHERE char *Pager;
......
......@@ -18,50 +18,10 @@
#include "mutt.h"
#ifdef _PGPPATH
#include "pgp.h"
#endif
#include <sys/stat.h>
#include <string.h>
#include <ctype.h>
......@@ -90,7 +50,7 @@ void mutt_edit_headers (const char *editor,
return;
}
mutt_write_rfc822_header (ofp, msg->env, NULL, 1);
mutt_write_rfc822_header (ofp, msg->env, NULL, 1, 0);
fputc ('\n', ofp); /* tie off the header. */
/* now copy the body of the message. */
......
......@@ -150,6 +150,13 @@ struct option_t MuttVars[] = {
{ "mime_forward", DT_QUAD, R_NONE, OPT_MIMEFWD, M_NO },
{ "mime_forward_decode", DT_BOOL, R_NONE, OPTMIMEFORWDECODE, 0 },
{ "mime_fwd", DT_SYN, R_NONE, UL "mime_forward", 0 },
#ifdef MIXMASTER
{ "mixmaster", DT_PATH, R_NONE, UL &Mixmaster, UL MIXMASTER },
#endif
{ "move", DT_QUAD, R_NONE, OPT_MOVE, M_ASKNO },
{ "message_format", DT_STR, R_NONE, UL &MsgFmt, UL "%s" },
{ "msg_format", DT_SYN, R_NONE, UL "message_format", 0 },
......
......@@ -39,12 +39,14 @@ struct mapping_t Menus[] = {
{ "pager", MENU_PAGER },
{ "postpone", MENU_POST },
#ifdef _PGPPATH
{ "pgp", MENU_PGP },
#endif
#ifdef MIXMASTER
{ "mix", MENU_MIX },
#endif
{ "query", MENU_QUERY },
......@@ -533,7 +535,13 @@ void km_init (void)
create_bindings (OpPgp, MENU_PGP);
#endif
#ifdef MIXMASTER
create_bindings (OpMix, MENU_MIX);
km_bindkey ("<space>", MENU_MIX, OP_GENERIC_SELECT_ENTRY);
km_bindkey ("h", MENU_MIX, OP_MIX_CHAIN_PREV);
km_bindkey ("l", MENU_MIX, OP_MIX_CHAIN_NEXT);
#endif
/* bindings for the line editor */
create_bindings (OpEditor, MENU_EDITOR);
......@@ -728,6 +736,10 @@ struct binding_t *km_get_table (int menu)
#endif
#ifdef MIXMASTER
case MENU_MIX:
return OpMix;
#endif
}
return NULL;
......
......@@ -58,16 +58,19 @@ enum
MENU_MAIN,
MENU_PAGER,
MENU_POST,
MENU_QUERY,
#ifdef _PGPPATH
MENU_PGP,
#endif
#ifdef MIXMASTER
MENU_MIX,
#endif
MENU_QUERY,
MENU_MAX
};
......@@ -102,6 +105,10 @@ extern struct binding_t OpQuery[];
extern struct binding_t OpPgp[];
#endif /* _PGPPATH */
#ifdef MIXMASTER
extern struct binding_t OpMix[];
#endif
#include "keymap_defs.h"
#endif /* KEYMAP_H */
......@@ -155,6 +155,9 @@ void mutt_free_header (HEADER **h)
mutt_free_body (&(*h)->content);
safe_free ((void **) &(*h)->tree);
safe_free ((void **) &(*h)->path);
#ifdef MIXMASTER
mutt_free_list (&(*h)->chain);
#endif
safe_free ((void **) h);
}
......
......@@ -48,6 +48,10 @@
# define N_(a) a
#endif
#ifdef MIXMASTER
# include "remailer.h"
#endif
#ifdef SUBVERSION
# define MUTT_VERSION (VERSION SUBVERSION)
#else
......@@ -575,6 +579,10 @@ typedef struct header
struct header *last_sort; /* last message in subthread, for secondary SORT_LAST */
char *tree; /* character string to print thread tree */
#ifdef MIXMASTER
LIST *chain;
#endif
} HEADER;
#include "mutt_regex.h"
......
......@@ -273,7 +273,10 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size
#ifdef _PGPPATH
else if (mutt_strncmp ("Pgp:", tmp->data, 4) == 0)
else if (mutt_strncmp ("Pgp:", tmp->data, 4) == 0 /* this is generated
* by old mutt versions
*/
|| mutt_strncmp ("X-Mutt-PGP:", tmp->data, 11) == 0)
{
hdr->pgp = mutt_parse_pgp_hdr (tmp->data+4, 1);
......@@ -289,7 +292,29 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size
}
#endif /* _PGPPATH */
#ifdef MIXMASTER
else if (mutt_strncmp ("X-Mutt-Mix:", tmp->data, 11) == 0)
{
char *t;
mutt_free_list (&hdr->chain);
t = strtok (tmp->data + 11, " \t\n");
while (t)
{
hdr->chain = mutt_add_list (hdr->chain, t);
t = strtok (NULL, " \t\n");
}
next = tmp->next;
if (last)
last->next = tmp->next;
else
hdr->env->userhdrs = tmp->next;
tmp->next = NULL;
mutt_free_list (&tmp);
tmp = next;
}
#endif
else
{
......
......@@ -277,7 +277,7 @@ int mutt_which_case (const char *);
int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int, char *);
int mutt_write_mime_body (BODY *, FILE *);
int mutt_write_mime_header (BODY *, FILE *);
int mutt_write_rfc822_header (FILE *, ENVELOPE *, BODY *, int);
int mutt_write_rfc822_header (FILE *, ENVELOPE *, BODY *, int, int);
int mutt_yesorno (const char *, int);
void mutt_set_header_color(CONTEXT *, HEADER *);
int mutt_save_confirm (const char *, struct stat *);
......@@ -432,3 +432,16 @@ int ioctl (int, int, ...);
/* unsorted */
void ci_bounce_message (HEADER *, int *);
void ci_send_message (int, HEADER *, char *, CONTEXT *, HEADER *);
#ifdef MIXMASTER
/* mixmaster support - must go here so we get the
* type definitions in the right order.
*/
int mix_send_message (LIST *, const char *);
int mix_check_message (HEADER *msg);
void mix_make_chain (LIST **, int *);
#endif
This diff is collapsed.
#ifndef _REMAILER_H
#define _REMAILER_H
/*
* Copyright (C) 1999 Thomas Roessler <roessler@guug.de>
*
* 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.
*/
/*
* Mixmaster support for Mutt
*/
#include "config.h"
#ifdef MIXMASTER
#define MIX_CAP_COMPRESS (1 << 0)
#define MIX_CAP_MIDDLEMAN (1 << 1)
#define MIX_CAP_NEWSPOST (1 << 2)
#define MIX_CAP_NEWSMAIL (1 << 3)
/* Mixmaster's maximum chain length. Don't change this. */
#define MAXMIXES 20
struct type2
{
char *shortname;
char *addr;
char *ver;
int caps;
};
typedef struct type2 REMAILER;
struct mixchain
{
size_t cl;
int ch[MAXMIXES];
};
typedef struct mixchain MIXCHAIN;
/* function prototypes are in protos.h */
#endif /* MIXMASTER */
#endif /* _REMAILER_H */
......@@ -799,7 +799,13 @@ static int send_message (HEADER *msg)
if ((tempfp = safe_fopen (tempfile, "w")) == NULL)
return (-1);
mutt_write_rfc822_header (tempfp, msg->env, msg->content, 0);
#ifdef MIXMASTER
mutt_write_rfc822_header (tempfp, msg->env, msg->content, 0, msg->chain ? 1 : 0);
#endif
#ifndef MIXMASTER
mutt_write_rfc822_header (tempfp, msg->env, msg->content, 0, 0);
#endif
fputc ('\n', tempfp); /* tie off the header. */
if ((mutt_write_mime_body (msg->content, tempfp) == -1))
......@@ -816,6 +822,11 @@ static int send_message (HEADER *msg)
return (-1);
}
#ifdef MIXMASTER
if (msg->chain)
return mix_send_message (msg->chain, tempfile);
#endif
i = mutt_invoke_sendmail (msg->env->to, msg->env->cc, msg->env->bcc,
tempfile, (msg->content->encoding == ENC8BIT));
return (i ? -1 : 0);
......
......@@ -1224,14 +1224,18 @@ static void write_references (LIST *r, FILE *f)
* mode == 1 => "lite" mode (used for edit_hdrs)
* mode == 0 => normal mode. write full header + MIME headers
* mode == -1 => write just the envelope info (used for postponing messages)
*
* privacy != 0 => will omit any headers which may identify the user.
*
*/
int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach, int mode)
int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach,
int mode, int privacy)
{
char buffer[LONG_STRING];
LIST *tmp = env->userhdrs;
if (option(OPTUSEHEADERDATE))
if (option(OPTUSEHEADERDATE) && !privacy)
{
if(env->date)
fprintf(fp, "Date: %s\n", env->date);
......@@ -1246,7 +1250,7 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach, int mode)
/* OPTUSEFROM is not consulted here so that we can still write a From:
* field if the user sets it with the `my_hdr' command
*/
if (env->from)
if (env->from && !privacy)
{
buffer[0] = 0;
rfc822_write_address (buffer, sizeof (buffer), env->from);
......@@ -1286,7 +1290,7 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach, int mode)
fputs ("Subject: \n", fp);
/* save message id if the user has set it */
if (env->message_id)
if (env->message_id && !privacy)
fprintf (fp, "Message-ID: %s\n", env->message_id);
if (env->reply_to)
......@@ -1318,7 +1322,7 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach, int mode)
}
#ifndef NO_XMAILER
if (mode == 0)
if (mode == 0 && !privacy)
{
/* Add a vanity header */
fprintf (fp, "X-Mailer: Mutt %s\n", MUTT_VERSION);
......@@ -1899,7 +1903,7 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
/* post == 1 => postpone message. Set mode = -1 in mutt_write_rfc822_header()
* post == 0 => Normal mode. Set mode = 0 in mutt_write_rfc822_header()
* */
mutt_write_rfc822_header (msg->fp, hdr->env, hdr->content, post ? -post : 0);
mutt_write_rfc822_header (msg->fp, hdr->env, hdr->content, post ? -post : 0, 0);
/* (postponment) if this was a reply of some sort, <msgid> contians the
* Message-ID: of message replied to. Save it using a special X-Mutt-
......@@ -1923,7 +1927,7 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
/* (postponment) if the mail is to be signed or encrypted, save this info */
if (post && (hdr->pgp & (PGPENCRYPT | PGPSIGN)))
{
fputs ("Pgp: ", msg->fp);
fputs ("X-Mutt-PGP: ", msg->fp);
if (hdr->pgp & PGPENCRYPT)
fputc ('E', msg->fp);
if (hdr->pgp & PGPSIGN)
......@@ -1938,7 +1942,22 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
}
#endif /* _PGPPATH */
#ifdef MIXMASTER
/* (postponement) if the mail is to be sent through a mixmaster
* chain, save that information
*/
if (post && hdr->chain && hdr->chain)
{
LIST *p;
fputs ("X-Mutt-Mix:", msg->fp);
for (p = hdr->chain; p; p = p->next)
fprintf (msg->fp, " %s", (char *) p->data);
fputc ('\n', msg->fp);
}
#endif
if (tempfp)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment