aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-pgp-context.c
diff options
context:
space:
mode:
Diffstat (limited to 'camel/camel-pgp-context.c')
-rw-r--r--camel/camel-pgp-context.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/camel/camel-pgp-context.c b/camel/camel-pgp-context.c
index aae330bc8e..cde9f76d25 100644
--- a/camel/camel-pgp-context.c
+++ b/camel/camel-pgp-context.c
@@ -58,6 +58,7 @@
struct _CamelPgpContextPrivate {
CamelPgpType type;
char *path;
+ gboolean remember;
};
static int pgp_sign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash,
@@ -132,6 +133,7 @@ camel_pgp_context_get_type (void)
* @session: CamelSession
* @type: One of CAMEL_PGP_TYPE_PGP2, PGP5, GPG, or PGP6
* @path: path to PGP binary
+ * @remember: Remember the pgp passphrase
*
* This creates a new CamelPgpContext object which is used to sign,
* verify, encrypt and decrypt streams.
@@ -139,7 +141,7 @@ camel_pgp_context_get_type (void)
* Return value: the new CamelPgpContext
**/
CamelPgpContext *
-camel_pgp_context_new (CamelSession *session, CamelPgpType type, const char *path)
+camel_pgp_context_new (CamelSession *session, CamelPgpType type, const char *path, gboolean remember)
{
CamelPgpContext *context;
@@ -154,6 +156,7 @@ camel_pgp_context_new (CamelSession *session, CamelPgpType type, const char *pat
context->priv->type = type;
context->priv->path = g_strdup (path);
+ context->priv->remember = remember;
return context;
}
@@ -639,6 +642,9 @@ pgp_sign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash,
return -1;
}
+ if (!context->priv->remember)
+ pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid);
+
g_free (diagnostics);
camel_stream_write (ostream, ciphertext, strlen (ciphertext));
@@ -808,6 +814,9 @@ pgp_clearsign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash
pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid);
}
+ if (!context->priv->remember)
+ pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid);
+
g_free (diagnostics);
camel_stream_write (ostream, ciphertext, strlen (ciphertext));
@@ -1220,6 +1229,9 @@ pgp_encrypt (CamelCipherContext *ctx, gboolean sign, const char *userid, GPtrArr
return -1;
}
+ if (!context->priv->remember)
+ pgp_forget_passphrase (ctx->session, context->priv->type, (char *) userid);
+
g_free (diagnostics);
camel_stream_write (ostream, ciphertext, strlen (ciphertext));
@@ -1346,6 +1358,9 @@ pgp_decrypt (CamelCipherContext *ctx, CamelStream *istream,
return -1;
}
+ if (!context->priv->remember)
+ pgp_forget_passphrase (ctx->session, context->priv->type, NULL);
+
g_free (diagnostics);
camel_stream_write (ostream, plaintext, plainlen);