diff options
author | Moritz Schulte <moritz@g10code.com> | 2004-06-17 20:36:13 +0000 |
---|---|---|
committer | Moritz Schulte <moritz@g10code.com> | 2004-06-17 20:36:13 +0000 |
commit | e48dd50afa44e0c6ee30f7ae6ebbe2a3d9179f7b (patch) | |
tree | 499908cd1df56ebbb660122665d1aeed291a98e1 /compose.c | |
parent | 6c365235e8df76ca3fdaaeb6606738938672b58d (diff) |
This is the sequel to the crypto modularization changes I did on
2003-01-21. Moritz added another abstraction layer which cleans up
the code and allows the crypto modules to use their own option menu.
Everything should work as it used to but is now in a really good
shape for part III, the Return of the GnuPG Easy Makers. -wk
* crypt-mod-pgp-classic.c, crypt-mod-smime-classic.c, crypt-mod.c,
crypt-mod.h: New files.
* smime.c (smime_valid_passphrase, smime_send_menu): New functions.
* smime.h: Removed macro: smime_valid_passphrase.
Declared: smime_valid_passphrase, smime_send_menu.
* pgp.c: Include "mutt_menu.h".
(pgp_valid_passphrase, pgp_send_menu): New functions.
* pgp.h: Removed macro: pgp_valid_passphrase.
Declared: pgp_valid_passphrase, pgp_send_menu.
* mutt_curses.h: Declare: mutt_need_hard_redraw.
* mutt_crypt.h: Declare: crypt_pgp_valid_passphrase,
crypt_pgp_send_menu, crypt_smime_valid_passphrase,
crypt_smime_send_menu, crypt_init.
Adjust WithCrypto definition since the GPGME backend does not
exclude anymore the other `classic' backends.
(KEYFLAG_ISX509): New symbol.
* mutt.h (enum): New symbol: OPTCRYPTUSEGPGME.
(struct body): New member: is_signed_data, warnsig.
* main.c (main): Call crypt_init.
* keymap.c (km_get_table): Support for MENU_KEY_SELECT_PGP and
MENU_KEY_SELECT_SMIME.
(Menus): Added entries fuer MENU_KEY_SELECT_PGP and
MENU_KEY_SELECT_SMIME.
(km_init): Create bindings for MENU_KEY_SELECT_PGP and
MENU_KEY_SELECT_SMIME.
* keymap.h (enum): New enum symbols: MENU_KEY_SELECT_PGP,
MENU_KEY_SELECT_SMIME.
* init.h: New configuration variable: crypt_use_gpgme.
* compose.c (pgp_send_menu, smime_send_menu): Removed functions,
they are now contained in the crypto backend modules.
(mutt_compose_menu): Use crypt_pgp_send_menu and
crypt_smime_send_menu instead pgp_send_menu and smime_send_menu.
* cryptglue.c: Slightly rewritten in order to make use of the
module mechanism used to access crypto backends.
* curs_lib.c (mutt_need_hard_redraw): New function.
* crypt.c (crypt_forget_passphrase): Adjust for new crypto backend
interface.
(crypt_valid_passphrase): Stripped, use calls to
crypt_pgp_valid_passphrase and crypt_smime_valid_passphrase.
Diffstat (limited to 'compose.c')
-rw-r--r-- | compose.c | 166 |
1 files changed, 3 insertions, 163 deletions
@@ -1,5 +1,6 @@ /* * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org> + * Copyright (C) 2004 g10 Code GmbH * * 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 @@ -162,167 +163,6 @@ static void redraw_crypt_lines (HEADER *msg) } - -static int pgp_send_menu (HEADER *msg, int *redraw) -{ - pgp_key_t p; - char input_signas[SHORT_STRING]; - - if (!(WithCrypto & APPLICATION_PGP)) - return msg->security; - - switch (mutt_multi_choice (_("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "), - _("esabif"))) - { - case 1: /* (e)ncrypt */ - msg->security ^= ENCRYPT; - break; - - case 2: /* (s)ign */ - msg->security ^= SIGN; - break; - - case 3: /* sign (a)s */ - unset_option(OPTPGPCHECKTRUST); - - if ((p = crypt_pgp_ask_for_key (_("Sign as: "), NULL, - KEYFLAG_CANSIGN, PGP_PUBRING))) - { - snprintf (input_signas, sizeof (input_signas), "0x%s", - crypt_pgp_keyid (p)); - mutt_str_replace (&PgpSignAs, input_signas); - crypt_pgp_free_key (&p); - - msg->security |= SIGN; - - crypt_pgp_void_passphrase (); /* probably need a different passphrase */ - } - else - { - msg->security &= ~SIGN; - } - - *redraw = REDRAW_FULL; - break; - - case 4: /* (b)oth */ - if ((msg->security & (ENCRYPT | SIGN)) == (ENCRYPT | SIGN)) - msg->security = 0; - else - msg->security |= (ENCRYPT | SIGN); - break; - - case 5: /* (i)nline */ - if ((msg->security & (ENCRYPT | SIGN))) - msg->security ^= INLINE; - else - msg->security &= ~INLINE; - break; - - case 6: /* (f)orget it */ - msg->security = 0; - break; - } - - if (msg->security) - { - if (! (msg->security & (ENCRYPT | SIGN))) - msg->security = 0; - else - msg->security |= APPLICATION_PGP; - } - - if(*redraw) - redraw_crypt_lines (msg); - return (msg->security); -} - - - -static int smime_send_menu (HEADER *msg, int *redraw) -{ - char *p; - - if (!(WithCrypto & APPLICATION_SMIME)) - return msg->security; - - switch (mutt_multi_choice (_("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (f)orget it? "), - _("eswabf"))) - { - case 1: /* (e)ncrypt */ - msg->security |= ENCRYPT; - break; - - case 3: /* encrypt (w)ith */ - msg->security |= ENCRYPT; - switch (mutt_multi_choice (_("1: DES, 2: Triple-DES, 3: RC2-40," - " 4: RC2-64, 5: RC2-128, or (f)orget it? "), - _("12345f"))) { - case 1: - mutt_str_replace (&SmimeCryptAlg, "des"); - break; - case 2: - mutt_str_replace (&SmimeCryptAlg, "des3"); - break; - case 3: - mutt_str_replace (&SmimeCryptAlg, "rc2-40"); - break; - case 4: - mutt_str_replace (&SmimeCryptAlg, "rc2-64"); - break; - case 5: - mutt_str_replace (&SmimeCryptAlg, "rc2-128"); - break; - case 6: /* forget it */ - break; - } - break; - - case 2: /* (s)ign */ - - if(!SmimeDefaultKey) - mutt_message("Can\'t sign: No key specified. use sign(as)."); - else - msg->security |= SIGN; - break; - - case 4: /* sign (a)s */ - - if ((p = crypt_smime_ask_for_key (_("Sign as: "), NULL, 0))) { - p[mutt_strlen (p)-1] = '\0'; - mutt_str_replace (&SmimeDefaultKey, p); - - msg->security |= SIGN; - - /* probably need a different passphrase */ - crypt_smime_void_passphrase (); - } - else - msg->security &= ~SIGN; - - *redraw = REDRAW_FULL; - break; - - case 5: /* (b)oth */ - msg->security = ENCRYPT | SIGN; - break; - - case 6: /* (f)orget it */ - msg->security = 0; - break; - } - - if (msg->security && msg->security != APPLICATION_SMIME) - msg->security |= APPLICATION_SMIME; - else - msg->security = 0; - - if(*redraw) - redraw_crypt_lines (msg); - return (msg->security); -} - - #ifdef MIXMASTER static void redraw_mix_line (LIST *chain) @@ -1344,7 +1184,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ } msg->security = 0; } - msg->security = pgp_send_menu (msg, &menu->redraw); + msg->security = crypt_pgp_send_menu (msg, &menu->redraw); redraw_crypt_lines (msg); break; @@ -1369,7 +1209,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ } msg->security = 0; } - msg->security = smime_send_menu(msg, &menu->redraw); + msg->security = crypt_smime_send_menu(msg, &menu->redraw); redraw_crypt_lines (msg); break; |