aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-crypto.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-08-12 04:27:12 +0800
committerDan Winship <danw@src.gnome.org>2000-08-12 04:27:12 +0800
commited88f237863dc3dd5aec568196b61008df2e9b8c (patch)
tree10a840b719f981de144c72ff22d19cf0cf64617b /mail/mail-crypto.c
parent4824927269ed26278e9cddc9d523ad813d0fd626 (diff)
downloadgsoc2013-evolution-ed88f237863dc3dd5aec568196b61008df2e9b8c.tar
gsoc2013-evolution-ed88f237863dc3dd5aec568196b61008df2e9b8c.tar.gz
gsoc2013-evolution-ed88f237863dc3dd5aec568196b61008df2e9b8c.tar.bz2
gsoc2013-evolution-ed88f237863dc3dd5aec568196b61008df2e9b8c.tar.lz
gsoc2013-evolution-ed88f237863dc3dd5aec568196b61008df2e9b8c.tar.xz
gsoc2013-evolution-ed88f237863dc3dd5aec568196b61008df2e9b8c.tar.zst
gsoc2013-evolution-ed88f237863dc3dd5aec568196b61008df2e9b8c.zip
Update this for CamelObject (try_inline_pgp): Deal with decrypting here
* mail-format.c (destroy_part): Update this for CamelObject (try_inline_pgp): Deal with decrypting here rather than trying to pawn the data off to handle_multipart_encrypted, since it most likely won't be correct (won't have the proper MIME headers inside the encrypted part). (handle_multipart_encrypted): Add code from Nathan Thompson-Amato to re-MIME-parse the decrypted data after decrypting. * mail-crypto.c (mail_crypto_openpgp_{de,en}crypt): Get the password here rather than having it passed in. Remove some dead code. * session.c (mail_request_dialog): Allow this to work in either a sync or an async context. svn path=/trunk/; revision=4751
Diffstat (limited to 'mail/mail-crypto.c')
-rw-r--r--mail/mail-crypto.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/mail/mail-crypto.c b/mail/mail-crypto.c
index 7314aaeffc..1055bb4569 100644
--- a/mail/mail-crypto.c
+++ b/mail/mail-crypto.c
@@ -326,22 +326,22 @@ crypto_exec_with_passwd (char *path, char *argv[], const char *input,
char *
-mail_crypto_openpgp_decrypt (const char *ciphertext, const char *passphrase,
- CamelException *ex)
+mail_crypto_openpgp_decrypt (const char *ciphertext, CamelException *ex)
{
- int retval;
+ int retval, i;
char *path, *argv[12];
- int i;
- char *plaintext = NULL;
- char *diagnostics = NULL;
+ char *passphrase, *plaintext = NULL, *diagnostics = NULL;
int passwd_fds[2];
char passwd_fd[32];
-#ifndef PGP_PROGRAM
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("No GPG/PGP program available."));
- return NULL;
-#endif
+ passphrase = mail_request_dialog (
+ _("Please enter your PGP/GPG passphrase."),
+ TRUE, "pgp", FALSE);
+ if (!passphrase) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("No password provided."));
+ return NULL;
+ }
if (pipe (passwd_fds) < 0) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -403,24 +403,26 @@ mail_crypto_openpgp_decrypt (const char *ciphertext, const char *passphrase,
}
char *
-mail_crypto_openpgp_encrypt (const char *plaintext, const GPtrArray *recipients, const char *passphrase,
+mail_crypto_openpgp_encrypt (const char *plaintext,
+ const GPtrArray *recipients,
gboolean sign, CamelException *ex)
{
GPtrArray *recipient_list = NULL;
- int retval;
+ int retval, i, r;
char *path, *argv[12];
- int i, r;
- char *cyphertext = NULL;
- char *diagnostics = NULL;
+ char *passphrase, *ciphertext = NULL, *diagnostics = NULL;
int passwd_fds[2];
char passwd_fd[32];
-#ifndef PGP_PROGRAM
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("No GPG/PGP program available."));
- return NULL;
-#endif
-
+ passphrase = mail_request_dialog (
+ _("Please enter your PGP/GPG passphrase."),
+ TRUE, "pgp", FALSE);
+ if (!passphrase) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("No password provided."));
+ return NULL;
+ }
+
if (pipe (passwd_fds) < 0) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Couldn't create pipe to GPG/PGP: %s"),
@@ -488,14 +490,14 @@ mail_crypto_openpgp_encrypt (const char *plaintext, const GPtrArray *recipients,
argv[i++] = NULL;
retval = crypto_exec_with_passwd (path, argv, plaintext, passwd_fds,
- passphrase, &cyphertext,
+ passphrase, &ciphertext,
&diagnostics);
- if (retval != 0 || !*cyphertext) {
+ if (retval != 0 || !*ciphertext) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
"%s", diagnostics);
- g_free (cyphertext);
- cyphertext = NULL;
+ g_free (ciphertext);
+ ciphertext = NULL;
}
if (recipient_list) {
@@ -505,7 +507,7 @@ mail_crypto_openpgp_encrypt (const char *plaintext, const GPtrArray *recipients,
}
g_free (diagnostics);
- return cyphertext;
+ return ciphertext;
}
#endif /* PGP_PROGRAM */