aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-07-19 10:11:31 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-07-19 10:11:31 +0800
commit25e8440cb73edfccb4ac1d76c285919da87f661e (patch)
treee6f4faa89b7cf16f3dead9f8541ff5990204d4a5 /camel
parente2ed8ac67cd766acc5d3706cef8a7705c06b74e1 (diff)
downloadgsoc2013-evolution-25e8440cb73edfccb4ac1d76c285919da87f661e.tar
gsoc2013-evolution-25e8440cb73edfccb4ac1d76c285919da87f661e.tar.gz
gsoc2013-evolution-25e8440cb73edfccb4ac1d76c285919da87f661e.tar.bz2
gsoc2013-evolution-25e8440cb73edfccb4ac1d76c285919da87f661e.tar.lz
gsoc2013-evolution-25e8440cb73edfccb4ac1d76c285919da87f661e.tar.xz
gsoc2013-evolution-25e8440cb73edfccb4ac1d76c285919da87f661e.tar.zst
gsoc2013-evolution-25e8440cb73edfccb4ac1d76c285919da87f661e.zip
Added some debug stuff.
2004-07-16 Not Zed <NotZed@Ximian.com> * camel-gpg-context.c: Added some debug stuff. svn path=/trunk/; revision=26672
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog4
-rw-r--r--camel/camel-gpg-context.c63
2 files changed, 64 insertions, 3 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 80a664716a..28d899fbf0 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,7 @@
+2004-07-16 Not Zed <NotZed@Ximian.com>
+
+ * camel-gpg-context.c: Added some debug stuff.
+
2004-07-15 Jeffrey Stedfast <fejj@novell.com>
* providers/imap/camel-imap-folder.c (imap_transfer_online): Don't
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index fabf3495da..c03b095e6e 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -20,6 +20,11 @@
*
*/
+/* Debug states:
+ gpg:sign dump canonicalised to-be-signed data to a file
+ gpg:verify dump canonicalised verification and signature data to file
+ gpg:status print gpg status-fd output to stdout
+*/
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -57,6 +62,13 @@
#define d(x)
+#define GPG_LOG
+
+#ifdef GPG_LOG
+#include "camel-debug.h"
+static int logid;
+#endif
+
static CamelCipherContextClass *parent_class = NULL;
/**
@@ -714,8 +726,9 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex)
*inptr++ = '\0';
status = gpg->statusbuf;
-
- printf ("status: %s\n", status);
+
+ if (camel_debug("gpg:status"))
+ printf ("status: %s\n", status);
if (strncmp (status, "[GNUPG:] ", 9) != 0) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -1263,6 +1276,24 @@ gpg_sign (CamelCipherContext *context, const char *userid, CamelCipherHash hash,
goto fail;
}
+#ifdef GPG_LOG
+ if (camel_debug_start("gpg:sign")) {
+ char *name;
+ CamelStream *out;
+
+ name = g_strdup_printf("camel-gpg.%d.sign-data", logid++);
+ out = camel_stream_fs_new_with_name(name, O_CREAT|O_TRUNC|O_WRONLY, 0666);
+ if (out) {
+ printf("Writing gpg signing data to '%s'\n", name);
+ camel_stream_write_to_stream(istream, out);
+ camel_stream_reset(istream);
+ camel_object_unref(out);
+ }
+ g_free(name);
+ camel_debug_end();
+ }
+#endif
+
gpg = gpg_ctx_new (context->session);
gpg_ctx_set_mode (gpg, GPG_CTX_MODE_SIGN);
gpg_ctx_set_hash (gpg, hash);
@@ -1413,6 +1444,32 @@ gpg_verify (CamelCipherContext *context, CamelMimePart *ipart, CamelException *e
camel_object_unref (istream);
return NULL;
}
+
+#ifdef GPG_LOG
+ if (camel_debug_start("gpg:sign")) {
+ char *name;
+ CamelStream *out;
+
+ name = g_strdup_printf("camel-gpg.%d.verify.data", logid);
+ out = camel_stream_fs_new_with_name(name, O_CREAT|O_TRUNC|O_WRONLY, 0666);
+ if (out) {
+ printf("Writing gpg verify data to '%s'\n", name);
+ camel_stream_write_to_stream(istream, out);
+ camel_stream_reset(istream);
+ camel_object_unref(out);
+ }
+ g_free(name);
+ name = g_strdup_printf("camel-gpg.%d.verify.signature", logid++);
+ out = camel_stream_fs_new_with_name(name, O_CREAT|O_TRUNC|O_WRONLY, 0666);
+ if (out) {
+ printf("Writing gpg verify signature to '%s'\n", name);
+ camel_data_wrapper_write_to_stream((CamelDataWrapper *)sigpart, out);
+ camel_object_unref(out);
+ }
+ g_free(name);
+ camel_debug_end();
+ }
+#endif
sigfile = swrite (sigpart);
if (sigfile == NULL) {
@@ -1508,7 +1565,7 @@ gpg_encrypt (CamelCipherContext *context, const char *userid, GPtrArray *recipie
_("Could not generate encrypting data: %s"), g_strerror(errno));
goto fail1;
}
-
+
gpg = gpg_ctx_new (context->session);
gpg_ctx_set_mode (gpg, GPG_CTX_MODE_ENCRYPT);
gpg_ctx_set_armor (gpg, TRUE);