Rocco Rutte:
[apps/madmutt.git] / crypt-mod-pgp-gpgme.c
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 2004 g10 Code GmbH
4  *
5  * This file is part of mutt-ng, see http://www.muttng.org/.
6  * It's licensed under the GNU General Public License,
7  * please see the file GPL in the top level source directory.
8  */
9
10 /* 
11     This is a crytpo module wrapping the gpgme based pgp code.
12  */
13
14 #if HAVE_CONFIG_H
15 # include "config.h"
16 #endif
17
18 #ifdef CRYPT_BACKEND_GPGME
19
20 #include "crypt-mod.h"
21 #include "crypt-gpgme.h"
22
23 static void crypt_mod_pgp_init (void)
24 {
25   pgp_gpgme_init ();
26 }
27
28 static void crypt_mod_pgp_void_passphrase (void)
29 {
30   /* Handled by gpg-agent.  */
31 }
32
33 static int crypt_mod_pgp_valid_passphrase (void)
34 {
35   /* Handled by gpg-agent.  */
36   return 1;
37 }
38
39 static int crypt_mod_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c,
40                                        BODY ** d)
41 {
42   return pgp_gpgme_decrypt_mime (a, b, c, d);
43 }
44
45 static void crypt_mod_pgp_application_handler (BODY * m, STATE * s)
46 {
47   pgp_gpgme_application_handler (m, s);
48 }
49
50 static void crypt_mod_pgp_encrypted_handler (BODY * m, STATE * s)
51 {
52   pgp_gpgme_encrypted_handler (m, s);
53 }
54
55 static int crypt_mod_pgp_check_traditional (FILE * fp, BODY * b,
56                                             int tagged_only)
57 {
58   return pgp_gpgme_check_traditional (fp, b, tagged_only);
59 }
60
61 static char *crypt_mod_pgp_findkeys (ADDRESS * to, ADDRESS * cc,
62                                      ADDRESS * bcc)
63 {
64   return pgp_gpgme_findkeys (to, cc, bcc);
65 }
66
67 static BODY *crypt_mod_pgp_sign_message (BODY * a)
68 {
69   return pgp_gpgme_sign_message (a);
70 }
71
72 static int crypt_mod_pgp_verify_one (BODY * sigbdy, STATE * s,
73                                      const char *tempf)
74 {
75   return pgp_gpgme_verify_one (sigbdy, s, tempf);
76 }
77
78 static int crypt_mod_pgp_send_menu (HEADER * msg, int *redraw)
79 {
80   return pgp_gpgme_send_menu (msg, redraw);
81 }
82
83 static BODY *crypt_mod_pgp_encrypt_message (BODY * a, char *keylist, int sign)
84 {
85   return pgp_gpgme_encrypt_message (a, keylist, sign);
86 }
87
88 struct crypt_module_specs crypt_mod_pgp_gpgme = { APPLICATION_PGP,
89   {
90    /* Common.  */
91    crypt_mod_pgp_init,
92    crypt_mod_pgp_void_passphrase,
93    crypt_mod_pgp_valid_passphrase,
94    crypt_mod_pgp_decrypt_mime,
95    crypt_mod_pgp_application_handler,
96    crypt_mod_pgp_encrypted_handler,
97    crypt_mod_pgp_findkeys,
98    crypt_mod_pgp_sign_message,
99    crypt_mod_pgp_verify_one,
100    crypt_mod_pgp_send_menu,
101
102    /* PGP specific.  */
103    crypt_mod_pgp_encrypt_message,
104    NULL,                        /* pgp_make_key_attachment, */
105    crypt_mod_pgp_check_traditional,
106    NULL,                        /* pgp_traditional_encryptsign  */
107    NULL,                        /* pgp_invoke_getkeys  */
108    NULL,                        /* pgp_invoke_import  */
109    NULL,                        /* pgp_extract_keys_from_attachment_list  */
110
111    NULL,                        /* smime_getkeys */
112    NULL,                        /* smime_verify_sender */
113    NULL,                        /* smime_build_smime_entity */
114    NULL,                        /* smime_invoke_import */
115    }
116 };
117
118 #endif