[PATCH 1/3] NEWS: Insert markdown formatting commands in 0.13 section text

2012-05-16 Thread David Bremner
Tomi Ollila  writes:
>
> id:"1337152910-22371-4-git-send-email-tomi.ollila at iki.fi"
> id:"1337152910-22371-5-git-send-email-tomi.ollila at iki.fi"
> id:"1337152910-22371-6-git-send-email-tomi.ollila at iki.fi"
> id:"1337152910-22371-7-git-send-email-tomi.ollila at iki.fi"

I pushed those to release. I'll merge them to master after a bit;
hopefully we'll figure out that reply encoding thing and do a bug fix
release.

d


[PATCH 6/6] cli: lazily create the crypto gpg context only when needed

2012-05-16 Thread Jameson Graef Rollins
Move the creation of the crypto ctx into mime-node.c and create it
only when needed.  This removes code duplication from notmuch-show and
notmuch-reply, and should speed up these functions considerably if the
crypto flags are provided but the messages don't have any
cryptographic parts.
---
 mime-node.c |   25 +
 notmuch-reply.c |   19 ---
 notmuch-show.c  |   23 ---
 3 files changed, 25 insertions(+), 42 deletions(-)

diff --git a/mime-node.c b/mime-node.c
index 8cdabc8..7278c74 100644
--- a/mime-node.c
+++ b/mime-node.c
@@ -182,6 +182,31 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
return NULL;
 }

+/* Lazily create the gpgctx if it's needed and hasn't been initialized yet 
*/
+if ((GMIME_IS_MULTIPART_ENCRYPTED (part) || GMIME_IS_MULTIPART_SIGNED 
(part))
+   && (node->ctx->crypto.verify || node->ctx->crypto.decrypt)) {
+   if (!node->ctx->crypto.gpgctx) {
+#ifdef GMIME_ATLEAST_26
+   /* TODO: GMimePasswordRequestFunc */
+   node->ctx->crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");
+#else
+   GMimeSession* session = g_object_new (g_mime_session_get_type(), 
NULL);
+   node->ctx->crypto.gpgctx = g_mime_gpg_context_new (session, "gpg");
+   g_object_unref (session);
+#endif
+   if (node->ctx->crypto.gpgctx) {
+   g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) 
node->ctx->crypto.gpgctx, FALSE);
+   } else {
+   /* If we fail to create the gpgctx set the verify and
+* decrypt flags to FALSE so we don't try to do any
+* further verification or decryption */
+   node->ctx->crypto.verify = FALSE;
+   node->ctx->crypto.decrypt = FALSE;
+   fprintf (stderr, "Failed to construct gpg context.\n");
+   }
+   }
+}
+
 /* Handle PGP/MIME parts */
 if (GMIME_IS_MULTIPART_ENCRYPTED (part) && node->ctx->crypto.decrypt) {
if (node->nchildren != 2) {
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 997fdd1..a56cf9f 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -708,25 +708,6 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 else
reply_format_func = notmuch_reply_format_default;

-if (crypto.decrypt) {
-#ifdef GMIME_ATLEAST_26
-   /* TODO: GMimePasswordRequestFunc */
-   crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");
-#else
-   GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);
-   crypto.gpgctx = g_mime_gpg_context_new (session, "gpg");
-#endif
-   if (crypto.gpgctx) {
-   g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) 
crypto.gpgctx, FALSE);
-   } else {
-   crypto.decrypt = FALSE;
-   fprintf (stderr, "Failed to construct gpg context.\n");
-   }
-#ifndef GMIME_ATLEAST_26
-   g_object_unref (session);
-#endif
-}
-
 config = notmuch_config_open (ctx, NULL, NULL);
 if (config == NULL)
return 1;
diff --git a/notmuch-show.c b/notmuch-show.c
index 99a10bd..0616f68 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1058,29 +1058,6 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
break;
 }

-if (params.crypto.decrypt || params.crypto.verify) {
-#ifdef GMIME_ATLEAST_26
-   /* TODO: GMimePasswordRequestFunc */
-   params.crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");
-#else
-   GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);
-   params.crypto.gpgctx = g_mime_gpg_context_new (session, "gpg");
-#endif
-   if (params.crypto.gpgctx) {
-   g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) 
params.crypto.gpgctx, FALSE);
-   } else {
-   /* If we fail to create the gpgctx set the verify and
-* decrypt flags to FALSE so we don't try to do any
-* further verification or decryption */
-   params.crypto.verify = FALSE;
-   params.crypto.decrypt = FALSE;
-   fprintf (stderr, "Failed to construct gpg context.\n");
-   }
-#ifndef GMIME_ATLEAST_26
-   g_object_unref (session);
-#endif
-}
-
 config = notmuch_config_open (ctx, NULL, NULL);
 if (config == NULL)
return 1;
-- 
1.7.10



[PATCH 5/6] cli: new crypto verify flag to handle verification

2012-05-16 Thread Jameson Graef Rollins
Use this flag rather than depend on the existence of an initialized
gpgctx, to determine whether we should verify a multipart/signed.  We
will be moving to create the ctx lazily, so we don't want to depend on
it being previously initialized if it's not needed.
---
 mime-node.c  |5 ++---
 notmuch-client.h |1 +
 notmuch-reply.c  |1 +
 notmuch-show.c   |   14 +++---
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/mime-node.c b/mime-node.c
index 4faeffc..8cdabc8 100644
--- a/mime-node.c
+++ b/mime-node.c
@@ -183,8 +183,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
 }

 /* Handle PGP/MIME parts */
-if (GMIME_IS_MULTIPART_ENCRYPTED (part)
-   && node->ctx->crypto.gpgctx && node->ctx->crypto.decrypt) {
+if (GMIME_IS_MULTIPART_ENCRYPTED (part) && node->ctx->crypto.decrypt) {
if (node->nchildren != 2) {
/* this violates RFC 3156 section 4, so we won't bother with it. */
fprintf (stderr, "Error: %d part(s) for a multipart/encrypted "
@@ -218,7 +217,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
 (err ? err->message : "no error explanation given"));
}
}
-} else if (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->crypto.gpgctx) {
+} else if (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->crypto.verify) {
if (node->nchildren != 2) {
/* this violates RFC 3156 section 5, so we won't bother with it. */
fprintf (stderr, "Error: %d part(s) for a multipart/signed message "
diff --git a/notmuch-client.h b/notmuch-client.h
index d86fab3..1ca111f 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -80,6 +80,7 @@ typedef struct notmuch_crypto {
 #else
 GMimeCipherContext* gpgctx;
 #endif
+notmuch_bool_t verify;
 notmuch_bool_t decrypt;
 } notmuch_crypto_t;

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 3c967a0..997fdd1 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -675,6 +675,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_crypto_t *crypto, notmuch_bool_t reply_all);
 notmuch_crypto_t crypto = {
.decrypt = FALSE,
+   .verify = FALSE,
.gpgctx = NULL,
 };
 int format = FORMAT_DEFAULT;
diff --git a/notmuch-show.c b/notmuch-show.c
index c606333..99a10bd 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -985,6 +985,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
 const notmuch_show_format_t *format = _text;
 notmuch_crypto_t crypto = {
.decrypt = FALSE,
+   .verify = FALSE,
.gpgctx = NULL,
 };
 notmuch_show_params_t params = {
@@ -993,7 +994,6 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
.crypto = crypto,
 };
 int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
-notmuch_bool_t verify = FALSE;
 int exclude = EXCLUDE_TRUE;

 notmuch_opt_desc_t options[] = {
@@ -1010,7 +1010,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
{ NOTMUCH_OPT_INT, , "part", 'p', 0 },
{ NOTMUCH_OPT_BOOLEAN, _thread, "entire-thread", 't', 0 },
{ NOTMUCH_OPT_BOOLEAN, , "decrypt", 'd', 0 },
-   { NOTMUCH_OPT_BOOLEAN, , "verify", 'v', 0 },
+   { NOTMUCH_OPT_BOOLEAN, , "verify", 'v', 0 },
{ 0, 0, 0, 0, 0 }
 };

@@ -1020,6 +1020,10 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
return 1;
 }

+/* decryption implies verification */
+if (params.crypto.decrypt)
+   params.crypto.verify = TRUE;
+
 if (format_sel == NOTMUCH_FORMAT_NOT_SPECIFIED) {
/* if part was requested and format was not specified, use format=raw */
if (params.part >= 0)
@@ -1054,7 +1058,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
break;
 }

-if (params.crypto.decrypt || verify) {
+if (params.crypto.decrypt || params.crypto.verify) {
 #ifdef GMIME_ATLEAST_26
/* TODO: GMimePasswordRequestFunc */
params.crypto.gpgctx = g_mime_gpg_context_new (NULL, "gpg");
@@ -1065,6 +1069,10 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
if (params.crypto.gpgctx) {
g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) 
params.crypto.gpgctx, FALSE);
} else {
+   /* If we fail to create the gpgctx set the verify and
+* decrypt flags to FALSE so we don't try to do any
+* further verification or decryption */
+   params.crypto.verify = FALSE;
params.crypto.decrypt = FALSE;
fprintf (stderr, "Failed to construct gpg context.\n");
}
-- 
1.7.10



[PATCH 4/6] cli: intialize crypto structure in show and reply

2012-05-16 Thread Jameson Graef Rollins
This makes sure it has proper initialization values when it's created.
---
 notmuch-reply.c |5 -
 notmuch-show.c  |   10 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 6662adb..3c967a0 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -673,7 +673,10 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 char *query_string;
 int opt_index, ret = 0;
 int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_crypto_t *crypto, notmuch_bool_t reply_all);
-notmuch_crypto_t crypto = { .decrypt = FALSE };
+notmuch_crypto_t crypto = {
+   .decrypt = FALSE,
+   .gpgctx = NULL,
+};
 int format = FORMAT_DEFAULT;
 int reply_all = TRUE;

diff --git a/notmuch-show.c b/notmuch-show.c
index 8b4d308..c606333 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -983,7 +983,15 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
 char *query_string;
 int opt_index, ret;
 const notmuch_show_format_t *format = _text;
-notmuch_show_params_t params = { .part = -1, .omit_excluded = TRUE };
+notmuch_crypto_t crypto = {
+   .decrypt = FALSE,
+   .gpgctx = NULL,
+};
+notmuch_show_params_t params = {
+   .part = -1,
+   .omit_excluded = TRUE,
+   .crypto = crypto,
+};
 int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
 notmuch_bool_t verify = FALSE;
 int exclude = EXCLUDE_TRUE;
-- 
1.7.10



[PATCH 3/6] cli: modify mime_node_open to take crypto struct as argument

2012-05-16 Thread Jameson Graef Rollins
Again, for interface simplification and getting rid of more #ifdefs.
---
 mime-node.c  |   10 ++
 notmuch-client.h |   14 +-
 notmuch-reply.c  |6 ++
 notmuch-show.c   |3 +--
 4 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/mime-node.c b/mime-node.c
index 79a3654..4faeffc 100644
--- a/mime-node.c
+++ b/mime-node.c
@@ -56,12 +56,7 @@ _mime_node_context_free (mime_node_context_t *res)

 notmuch_status_t
 mime_node_open (const void *ctx, notmuch_message_t *message,
-#ifdef GMIME_ATLEAST_26
-   GMimeCryptoContext *cryptoctx,
-#else
-   GMimeCipherContext *cryptoctx,
-#endif
-   notmuch_bool_t decrypt, mime_node_t **root_out)
+   notmuch_crypto_t *crypto, mime_node_t **root_out)
 {
 const char *filename = notmuch_message_get_filename (message);
 mime_node_context_t *mctx;
@@ -113,8 +108,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
goto DONE;
 }

-mctx->crypto.gpgctx = cryptoctx;
-mctx->crypto.decrypt = decrypt;
+mctx->crypto = *crypto;

 /* Create the root node */
 root->part = GMIME_OBJECT (mctx->mime_message);
diff --git a/notmuch-client.h b/notmuch-client.h
index 2ad24cf..d86fab3 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -345,9 +345,10 @@ struct mime_node {
 };

 /* Construct a new MIME node pointing to the root message part of
- * message.  If cryptoctx is non-NULL, it will be used to verify
- * signatures on any child parts.  If decrypt is true, then cryptoctx
- * will additionally be used to decrypt any encrypted child parts.
+ * message.  If crypto.gpgctx is non-NULL, it will be used to verify
+ * signatures on any child parts.  If crypto.decrypt is true, then
+ * crypto.gpgctx will additionally be used to decrypt any encrypted
+ * child parts.
  *
  * Return value:
  *
@@ -359,12 +360,7 @@ struct mime_node {
  */
 notmuch_status_t
 mime_node_open (const void *ctx, notmuch_message_t *message,
-#ifdef GMIME_ATLEAST_26
-   GMimeCryptoContext *cryptoctx,
-#else
-   GMimeCipherContext *cryptoctx,
-#endif
-   notmuch_bool_t decrypt, mime_node_t **node_out);
+   notmuch_crypto_t *crypto, mime_node_t **node_out);

 /* Return a new MIME node for the requested child part of parent.
  * parent will be used as the talloc context for the returned child
diff --git a/notmuch-reply.c b/notmuch-reply.c
index ed87899..6662adb 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -544,8 +544,7 @@ notmuch_reply_format_default(void *ctx,
g_object_unref (G_OBJECT (reply));
reply = NULL;

-   if (mime_node_open (ctx, message, crypto->gpgctx, crypto->decrypt,
-   ) == NOTMUCH_STATUS_SUCCESS) {
+   if (mime_node_open (ctx, message, crypto, ) == 
NOTMUCH_STATUS_SUCCESS) {
format_part_reply (root);
talloc_free (root);
}
@@ -574,8 +573,7 @@ notmuch_reply_format_json(void *ctx,

 messages = notmuch_query_search_messages (query);
 message = notmuch_messages_get (messages);
-if (mime_node_open (ctx, message, crypto->gpgctx, crypto->decrypt,
-   ) != NOTMUCH_STATUS_SUCCESS)
+if (mime_node_open (ctx, message, crypto, ) != NOTMUCH_STATUS_SUCCESS)
return 1;

 reply = create_reply_message (ctx, config, message, reply_all);
diff --git a/notmuch-show.c b/notmuch-show.c
index d254179..8b4d308 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -810,8 +810,7 @@ show_message (void *ctx,
 mime_node_t *root, *part;
 notmuch_status_t status;

-status = mime_node_open (local, message, params->crypto.gpgctx,
-params->crypto.decrypt, );
+status = mime_node_open (local, message, &(params->crypto), );
 if (status)
goto DONE;
 part = mime_node_seek_dfs (root, (params->part < 0 ? 0 : params->part));
-- 
1.7.10



[PATCH 2/6] cli: modify mime_node_context to use the new notmuch_crypto_t

2012-05-16 Thread Jameson Graef Rollins
This simplifies some more interfaces and gets rid of another #ifdef.
---
 mime-node.c |   23 +--
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/mime-node.c b/mime-node.c
index a95bdab..79a3654 100644
--- a/mime-node.c
+++ b/mime-node.c
@@ -33,12 +33,7 @@ typedef struct mime_node_context {
 GMimeMessage *mime_message;

 /* Context provided by the caller. */
-#ifdef GMIME_ATLEAST_26
-GMimeCryptoContext *cryptoctx;
-#else
-GMimeCipherContext *cryptoctx;
-#endif
-notmuch_bool_t decrypt;
+notmuch_crypto_t crypto;
 } mime_node_context_t;

 static int
@@ -118,8 +113,8 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
goto DONE;
 }

-mctx->cryptoctx = cryptoctx;
-mctx->decrypt = decrypt;
+mctx->crypto.gpgctx = cryptoctx;
+mctx->crypto.decrypt = decrypt;

 /* Create the root node */
 root->part = GMIME_OBJECT (mctx->mime_message);
@@ -195,7 +190,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)

 /* Handle PGP/MIME parts */
 if (GMIME_IS_MULTIPART_ENCRYPTED (part)
-   && node->ctx->cryptoctx && node->ctx->decrypt) {
+   && node->ctx->crypto.gpgctx && node->ctx->crypto.decrypt) {
if (node->nchildren != 2) {
/* this violates RFC 3156 section 4, so we won't bother with it. */
fprintf (stderr, "Error: %d part(s) for a multipart/encrypted "
@@ -208,10 +203,10 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
 #ifdef GMIME_ATLEAST_26
GMimeDecryptResult *decrypt_result = NULL;
node->decrypted_child = g_mime_multipart_encrypted_decrypt
-   (encrypteddata, node->ctx->cryptoctx, _result, );
+   (encrypteddata, node->ctx->crypto.gpgctx, _result, 
);
 #else
node->decrypted_child = g_mime_multipart_encrypted_decrypt
-   (encrypteddata, node->ctx->cryptoctx, );
+   (encrypteddata, node->ctx->crypto.gpgctx, );
 #endif
if (node->decrypted_child) {
node->decrypt_success = node->verify_attempted = TRUE;
@@ -229,7 +224,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
 (err ? err->message : "no error explanation given"));
}
}
-} else if (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->cryptoctx) {
+} else if (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->crypto.gpgctx) {
if (node->nchildren != 2) {
/* this violates RFC 3156 section 5, so we won't bother with it. */
fprintf (stderr, "Error: %d part(s) for a multipart/signed message "
@@ -238,7 +233,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
} else {
 #ifdef GMIME_ATLEAST_26
node->sig_list = g_mime_multipart_signed_verify
-   (GMIME_MULTIPART_SIGNED (part), node->ctx->cryptoctx, );
+   (GMIME_MULTIPART_SIGNED (part), node->ctx->crypto.gpgctx, );
node->verify_attempted = TRUE;

if (!node->sig_list)
@@ -254,7 +249,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
 * In GMime 2.6, they're both non-const, so we'll be able
 * to clean up this asymmetry. */
GMimeSignatureValidity *sig_validity = 
g_mime_multipart_signed_verify
-   (GMIME_MULTIPART_SIGNED (part), node->ctx->cryptoctx, );
+   (GMIME_MULTIPART_SIGNED (part), node->ctx->crypto.gpgctx, );
node->verify_attempted = TRUE;
node->sig_validity = sig_validity;
if (sig_validity) {
-- 
1.7.10



[PATCH 1/6] cli: new crypto structure to store crypto contexts and parameters

2012-05-16 Thread Jameson Graef Rollins
The main point here is to keep track of the crypto stuff together in
one place.  In notmuch-show the crypto struct is a sub structure of
the parameters struct.  In notmuch-reply, which had been using a
notmuch_show_params_t to store the crypto parameters, we can now just
use the general crypto struct.

I slip in a name change of the crypto context itself to better reflect
what the context is specifically for: it's actually a GPG context,
which is a sub type of Crypto context.  There are other types of
Crypto contexts (Pkcs7 in particular) so we want to be clear.

The following patches will use this to simplify some function
interfaces.
---
 notmuch-client.h |   16 ++--
 notmuch-reply.c  |   34 +-
 notmuch-show.c   |   22 +++---
 3 files changed, 38 insertions(+), 34 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index 19b7f01..2ad24cf 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -74,17 +74,21 @@ typedef struct notmuch_show_format {
 const char *message_set_end;
 } notmuch_show_format_t;

+typedef struct notmuch_crypto {
+#ifdef GMIME_ATLEAST_26
+GMimeCryptoContext* gpgctx;
+#else
+GMimeCipherContext* gpgctx;
+#endif
+notmuch_bool_t decrypt;
+} notmuch_crypto_t;
+
 typedef struct notmuch_show_params {
 notmuch_bool_t entire_thread;
 notmuch_bool_t omit_excluded;
 notmuch_bool_t raw;
 int part;
-#ifdef GMIME_ATLEAST_26
-GMimeCryptoContext* cryptoctx;
-#else
-GMimeCipherContext* cryptoctx;
-#endif
-notmuch_bool_t decrypt;
+notmuch_crypto_t crypto;
 } notmuch_show_params_t;

 /* There's no point in continuing when we've detected that we've done
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 7184a5d..ed87899 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -515,7 +515,7 @@ static int
 notmuch_reply_format_default(void *ctx,
 notmuch_config_t *config,
 notmuch_query_t *query,
-notmuch_show_params_t *params,
+notmuch_crypto_t *crypto,
 notmuch_bool_t reply_all)
 {
 GMimeMessage *reply;
@@ -544,7 +544,7 @@ notmuch_reply_format_default(void *ctx,
g_object_unref (G_OBJECT (reply));
reply = NULL;

-   if (mime_node_open (ctx, message, params->cryptoctx, params->decrypt,
+   if (mime_node_open (ctx, message, crypto->gpgctx, crypto->decrypt,
) == NOTMUCH_STATUS_SUCCESS) {
format_part_reply (root);
talloc_free (root);
@@ -559,7 +559,7 @@ static int
 notmuch_reply_format_json(void *ctx,
  notmuch_config_t *config,
  notmuch_query_t *query,
- notmuch_show_params_t *params,
+ notmuch_crypto_t *crypto,
  notmuch_bool_t reply_all)
 {
 GMimeMessage *reply;
@@ -574,7 +574,7 @@ notmuch_reply_format_json(void *ctx,

 messages = notmuch_query_search_messages (query);
 message = notmuch_messages_get (messages);
-if (mime_node_open (ctx, message, params->cryptoctx, params->decrypt,
+if (mime_node_open (ctx, message, crypto->gpgctx, crypto->decrypt,
) != NOTMUCH_STATUS_SUCCESS)
return 1;

@@ -605,7 +605,7 @@ static int
 notmuch_reply_format_headers_only(void *ctx,
  notmuch_config_t *config,
  notmuch_query_t *query,
- unused (notmuch_show_params_t *params),
+ unused (notmuch_crypto_t *crypto),
  notmuch_bool_t reply_all)
 {
 GMimeMessage *reply;
@@ -674,8 +674,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 notmuch_query_t *query;
 char *query_string;
 int opt_index, ret = 0;
-int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
reply_all);
-notmuch_show_params_t params = { .part = -1 };
+int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_crypto_t *crypto, notmuch_bool_t reply_all);
+notmuch_crypto_t crypto = { .decrypt = FALSE };
 int format = FORMAT_DEFAULT;
 int reply_all = TRUE;

@@ -689,7 +689,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
  (notmuch_keyword_t []){ { "all", TRUE },
  { "sender", FALSE },
  { 0, 0 } } },
-   { NOTMUCH_OPT_BOOLEAN, , "decrypt", 'd', 0 },
+   { NOTMUCH_OPT_BOOLEAN, , "decrypt", 'd', 0 },
{ 0, 0, 0, 0, 0 }
 };

@@ -706,18 +706,18 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 else
reply_format_func = notmuch_reply_format_default;

-if (params.decrypt) {
+if (crypto.decrypt) {
 #ifdef 

[PATCH 0/6] cli: improve handling of crypto parameters contexts

2012-05-16 Thread Jameson Graef Rollins
I wanted to see if I could hack in S/MIME support, but ultimately
failed (the interface is too stupid for me to deal with at the
moment).  However, on the way there I did manage to make some tangible
improvements to how crypto is handled in show and reply.

Most importantly I've moved the initialization of the gpg context to
mime_node.c where it is created lazily, only when needed.  This should
provide some speed up in notmuch show and reply when crypto flags are
provided but the messages have no crypto parts.

I was also able to get rid of a bunch of those pesky
"#ifdef GMIME_ATLEAST_26" conditionals.

This should provide a better framework for someone to try to hack in
S/MIME support at a later date if they're so inclined.

jamie.



emacs complains about encoding?

2012-05-16 Thread Tomi Ollila
On Wed, May 16 2012, Jani Nikula wrote:

> Tomi Ollila  writes:
>> IT h\344ppens.
>>
>> Attempting to reply to this email should expose the problem.
>>
>> \304\344li\366 \344l\344 ly\366, \366\366li\344 l\344ikkyy.

(\nnn text above hand-(query)-replaced)

>
> The problem bisected to f6c170fabca8f39e74705e3813504137811bf162
> ("emacs: Correctly quote non-text/plain parts in reply"). The commit
> reverts cleanly, replying without it now.
>
> Tomi, it would be great if you could post your message as a patch to the
> test suite.

Haa, It doesn't matter which is the original encoding of the message;

notmuch reply id:20120515194455.B7AD5100646 at guru.guru-group.fi

where  notmuch show --format=raw ^^^  outputs (among other lines):

  Content-Type: text/plain; charset="iso-8859-1"
  Content-Transfer-Encoding: quoted-printable

and

notmuch reply id:"878vgsbprq.fsf at nikula.org"

where  notmuch show --format=raw ^^^  outputs (among other lines):

  Content-Type: text/plain; charset="utf-8"
  Content-Transfer-Encoding: base64

produce correct reply content, both in utf-8.

So it is the emacs side which breaks replies.

I'll see what kind of test cases I can create...

>
> BR,
> Jani.

Tomi


[PATCH 1/3] NEWS: Insert markdown formatting commands in 0.13 section text

2012-05-16 Thread Tomi Ollila

Sorry about the spam -- sent too many patches... PEBKAC.

The only relevant are:

id:"1337152910-22371-4-git-send-email-tomi.ollila at iki.fi"
id:"1337152910-22371-5-git-send-email-tomi.ollila at iki.fi"
id:"1337152910-22371-6-git-send-email-tomi.ollila at iki.fi"
id:"1337152910-22371-7-git-send-email-tomi.ollila at iki.fi"

rest are marked obsolete.

Tomi




[PATCH 4/4] NEWS: Capitalized go bindings changes title

2012-05-16 Thread Tomi Ollila
Align 'Go bindings changes' title capitalization to rest of the file
---
 NEWS |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index ad4859d..668281c 100644
--- a/NEWS
+++ b/NEWS
@@ -103,7 +103,7 @@ The function `notmuch_database_close` has been split into
   functions now return a `notmuch_status_t` and take an out-argument for
   returning the new database object or directory object.

-go bindings changes
+Go bindings changes
 ---

 Go 1 compatibility
-- 
1.7.1



[PATCH 3/4] NEWS: Insert markdown formatting commands in 0.13 section text

2012-05-16 Thread Tomi Ollila
NEWS entries in section 0.13 is brought consistent with rest of the
NEWS file.
---
 NEWS |   34 +-
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/NEWS b/NEWS
index 970aa40..ad4859d 100644
--- a/NEWS
+++ b/NEWS
@@ -6,12 +6,12 @@ Command-Line Interface

 JSON reply format

-  "notmuch reply" can now produce JSON output that contains the headers
+  `notmuch reply` can now produce JSON output that contains the headers
   for a reply message and full information about the original message
   begin replied to. This allows MUAs to create replies intelligently.
   For example, an MUA that can parse HTML might quote HTML parts.

-  Calling notmuch reply with --format=json imposes the restriction that
+  Calling notmuch reply with `--format=json` imposes the restriction that
   only a single message is returned by the search, as replying to
   multiple messages does not have a well-defined behavior. The default
   retains its current behavior for multiple message replies.
@@ -19,24 +19,24 @@ JSON reply format
 Tag exclusion

   Tags can be automatically excluded from search results by adding them
-  to the new 'search.exclude_tags' option in the Notmuch config file.
+  to the new `search.exclude_tags` option in the Notmuch config file.

   This behaviour can be overridden by explicitly including an excluded
   tag in your query, for example:

-notmuch search $your_query and tag:$excluded_tag
+notmuch search $your_query and tag:$excluded_tag

-  Existing users will probably want to run "notmuch setup" again to add
+  Existing users will probably want to run `notmuch setup` again to add
   the new well-commented [search] section to the configuration file.

   For new configurations, accepting the default setting will cause the
   tags "deleted" and "spam" to be excluded, equivalent to running:

-notmuch config set search.exclude_tags deleted spam
+notmuch config set search.exclude_tags deleted spam

 Raw show format changes

-  The output of show --format=raw has changed for multipart and
+  The output of show `--format=raw` has changed for multipart and
   message parts.  Previously, the output was a mash of somewhat-parsed
   headers and transfer-decoded bodies.  Now, such parts are reproduced
   faithfully from the original source.  Message parts (which includes
@@ -47,7 +47,7 @@ Raw show format changes

 Listing configuration items

-  The new "config list" command prints out all configuration items and
+  The new `config list` command prints out all configuration items and
   their values.

 Emacs Interface
@@ -57,7 +57,7 @@ Changes to tagging interface

   The user-facing tagging functions in the Emacs interface have been
   normalized across all notmuch modes.  The tagging functions are now
-  'notmuch-search-tag' in search-mode, and 'notmuch-show-tag' in
+  notmuch-search-tag in search-mode, and notmuch-show-tag in
   show-mode.  They accept a string representing a single tag change,
   or a list of tag changes.  See 'M-x describe-function notmuch-tag'
   for more information.
@@ -76,11 +76,11 @@ Reply improvement using the JSON format
 New add-on tool: notmuch-mutt
 -

-The new contrib/ tool "notmuch-mutt" provides Notmuch integration for
+The new contrib/ tool `notmuch-mutt` provides Notmuch integration for
 the Mutt mail user agent. Using it, Mutt users can perform mail
 search, thread reconstruction, and mail tagging/untagging without
 leaving Mutt.  notmuch-mutt, formerly distributed under the name
-"mutt-notmuch" by Stefano Zacchiroli, will be maintained as a notmuch
+`mutt-notmuch` by Stefano Zacchiroli, will be maintained as a notmuch
 contrib/ from now on.

 Library changes
@@ -89,18 +89,18 @@ Library changes
 The API changes detailed below break binary and source compatibility,
 so libnotmuch has been bumped to version 3.0.0.

-The function notmuch_database_close has been split into
-notmuch_database_close and notmuch_database_destroy
+The function `notmuch_database_close` has been split into
+`notmuch_database_close` and `notmuch_database_destroy`

   This makes it possible for long running programs to close the xapian
   database and thus release the lock associated with it without
   destroying the data structures obtained from it.

-notmuch_database_open, notmuch_database_create, and
-notmuch_database_get_directory now return errors
+`notmuch_database_open`, `notmuch_database_create`, and
+`notmuch_database_get_directory` now return errors

   The type signatures of these functions have changed so that the
-  functions now return a notmuch_status_t and take an out-argument for
+  functions now return a `notmuch_status_t` and take an out-argument for
   returning the new database object or directory object.

 go bindings changes
@@ -108,7 +108,7 @@ go bindings changes

 Go 1 compatibility

-  The go bindings and the notmuch-addrlookup utility are now
+  The go bindings and the 

[PATCH 2/4] NEWS: Changed 0.13 release date in NEWS file to 2012-05-15

2012-05-16 Thread Tomi Ollila
---
 NEWS |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 9a690cb..970aa40 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Notmuch 0.13 (2012-xx-xx)
+Notmuch 0.13 (2012-05-15)
 =

 Command-Line Interface
-- 
1.7.1



[PATCH 1/4] NEWS: Dropped old 'Reply to sender' section

2012-05-16 Thread Tomi Ollila
'Reply to sender' section was 0.12 news which was accidentally
duplicated in 0.13 news
---
 NEWS |7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index 69a7203..9a690cb 100644
--- a/NEWS
+++ b/NEWS
@@ -4,13 +4,6 @@ Notmuch 0.13 (2012-xx-xx)
 Command-Line Interface
 --

-Reply to sender
-
-  "notmuch reply" has gained the ability to create a reply template
-  for replying just to the sender of the message, in addition to reply
-  to all. The feature is available through the new command line option
-  --reply-to=(all|sender).
-
 JSON reply format

   "notmuch reply" can now produce JSON output that contains the headers
-- 
1.7.1



[PATCH 3/3] Capitalized go bindings changes title

2012-05-16 Thread Tomi Ollila
Align 'Go bindings changes' title capitalization to rest of the file
---
 NEWS |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 8a73e08..4978261 100644
--- a/NEWS
+++ b/NEWS
@@ -110,7 +110,7 @@ The function `notmuch_database_close` has been split into
   functions now return a `notmuch_status_t` and take an out-argument for
   returning the new database object or directory object.

-go bindings changes
+Go bindings changes
 ---

 Go 1 compatibility
-- 
1.7.1



[PATCH 2/3] Changed 0.13 release date in NEWS file to 2012-05-15

2012-05-16 Thread Tomi Ollila
---
 NEWS |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index d841a4c..8a73e08 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Notmuch 0.13 (2012-xx-xx)
+Notmuch 0.13 (2012-05-15)
 =

 Command-Line Interface
-- 
1.7.1



[PATCH 1/3] NEWS: Insert markdown formatting commands in 0.13 section text

2012-05-16 Thread Tomi Ollila
NEWS entries in section 0.13 is brought consistent with rest of the
NEWS file.
---
 NEWS |   38 +++---
 1 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/NEWS b/NEWS
index 69a7203..d841a4c 100644
--- a/NEWS
+++ b/NEWS
@@ -6,19 +6,19 @@ Command-Line Interface

 Reply to sender

-  "notmuch reply" has gained the ability to create a reply template
+  `notmuch reply` has gained the ability to create a reply template
   for replying just to the sender of the message, in addition to reply
   to all. The feature is available through the new command line option
-  --reply-to=(all|sender).
+  `--reply-to=(all|sender)`.

 JSON reply format

-  "notmuch reply" can now produce JSON output that contains the headers
+  `notmuch reply` can now produce JSON output that contains the headers
   for a reply message and full information about the original message
   begin replied to. This allows MUAs to create replies intelligently.
   For example, an MUA that can parse HTML might quote HTML parts.

-  Calling notmuch reply with --format=json imposes the restriction that
+  Calling notmuch reply with `--format=json` imposes the restriction that
   only a single message is returned by the search, as replying to
   multiple messages does not have a well-defined behavior. The default
   retains its current behavior for multiple message replies.
@@ -26,24 +26,24 @@ JSON reply format
 Tag exclusion

   Tags can be automatically excluded from search results by adding them
-  to the new 'search.exclude_tags' option in the Notmuch config file.
+  to the new `search.exclude_tags` option in the Notmuch config file.

   This behaviour can be overridden by explicitly including an excluded
   tag in your query, for example:

-notmuch search $your_query and tag:$excluded_tag
+notmuch search $your_query and tag:$excluded_tag

-  Existing users will probably want to run "notmuch setup" again to add
+  Existing users will probably want to run `notmuch setup` again to add
   the new well-commented [search] section to the configuration file.

   For new configurations, accepting the default setting will cause the
   tags "deleted" and "spam" to be excluded, equivalent to running:

-notmuch config set search.exclude_tags deleted spam
+notmuch config set search.exclude_tags deleted spam

 Raw show format changes

-  The output of show --format=raw has changed for multipart and
+  The output of show `--format=raw` has changed for multipart and
   message parts.  Previously, the output was a mash of somewhat-parsed
   headers and transfer-decoded bodies.  Now, such parts are reproduced
   faithfully from the original source.  Message parts (which includes
@@ -54,7 +54,7 @@ Raw show format changes

 Listing configuration items

-  The new "config list" command prints out all configuration items and
+  The new `config list` command prints out all configuration items and
   their values.

 Emacs Interface
@@ -64,7 +64,7 @@ Changes to tagging interface

   The user-facing tagging functions in the Emacs interface have been
   normalized across all notmuch modes.  The tagging functions are now
-  'notmuch-search-tag' in search-mode, and 'notmuch-show-tag' in
+  notmuch-search-tag in search-mode, and notmuch-show-tag in
   show-mode.  They accept a string representing a single tag change,
   or a list of tag changes.  See 'M-x describe-function notmuch-tag'
   for more information.
@@ -83,11 +83,11 @@ Reply improvement using the JSON format
 New add-on tool: notmuch-mutt
 -

-The new contrib/ tool "notmuch-mutt" provides Notmuch integration for
+The new contrib/ tool `notmuch-mutt` provides Notmuch integration for
 the Mutt mail user agent. Using it, Mutt users can perform mail
 search, thread reconstruction, and mail tagging/untagging without
 leaving Mutt.  notmuch-mutt, formerly distributed under the name
-"mutt-notmuch" by Stefano Zacchiroli, will be maintained as a notmuch
+`mutt-notmuch` by Stefano Zacchiroli, will be maintained as a notmuch
 contrib/ from now on.

 Library changes
@@ -96,18 +96,18 @@ Library changes
 The API changes detailed below break binary and source compatibility,
 so libnotmuch has been bumped to version 3.0.0.

-The function notmuch_database_close has been split into
-notmuch_database_close and notmuch_database_destroy
+The function `notmuch_database_close` has been split into
+`notmuch_database_close` and `notmuch_database_destroy`

   This makes it possible for long running programs to close the xapian
   database and thus release the lock associated with it without
   destroying the data structures obtained from it.

-notmuch_database_open, notmuch_database_create, and
-notmuch_database_get_directory now return errors
+`notmuch_database_open`, `notmuch_database_create`, and
+`notmuch_database_get_directory` now return errors

   The type signatures of these functions have changed so that the
-  functions now return a 

[PATCH 3/3] Capitalized go bindings changes title

2012-05-16 Thread Tomi Ollila
Align 'Go bindings changes' title capitalization to rest of the file
---
 NEWS |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 8a73e08..4978261 100644
--- a/NEWS
+++ b/NEWS
@@ -110,7 +110,7 @@ The function `notmuch_database_close` has been split into
   functions now return a `notmuch_status_t` and take an out-argument for
   returning the new database object or directory object.

-go bindings changes
+Go bindings changes
 ---

 Go 1 compatibility
-- 
1.7.1



[PATCH 2/3] Changed 0.13 release date in NEWS file to 2012-05-15

2012-05-16 Thread Tomi Ollila
---
 NEWS |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index d841a4c..8a73e08 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Notmuch 0.13 (2012-xx-xx)
+Notmuch 0.13 (2012-05-15)
 =

 Command-Line Interface
-- 
1.7.1



[PATCH 1/3] NEWS: Insert markdown formatting commands in 0.13 section text

2012-05-16 Thread Tomi Ollila
NEWS entries in section 0.13 is brought consistent with rest of the
NEWS file.
---
 NEWS |   38 +++---
 1 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/NEWS b/NEWS
index 69a7203..d841a4c 100644
--- a/NEWS
+++ b/NEWS
@@ -6,19 +6,19 @@ Command-Line Interface

 Reply to sender

-  "notmuch reply" has gained the ability to create a reply template
+  `notmuch reply` has gained the ability to create a reply template
   for replying just to the sender of the message, in addition to reply
   to all. The feature is available through the new command line option
-  --reply-to=(all|sender).
+  `--reply-to=(all|sender)`.

 JSON reply format

-  "notmuch reply" can now produce JSON output that contains the headers
+  `notmuch reply` can now produce JSON output that contains the headers
   for a reply message and full information about the original message
   begin replied to. This allows MUAs to create replies intelligently.
   For example, an MUA that can parse HTML might quote HTML parts.

-  Calling notmuch reply with --format=json imposes the restriction that
+  Calling notmuch reply with `--format=json` imposes the restriction that
   only a single message is returned by the search, as replying to
   multiple messages does not have a well-defined behavior. The default
   retains its current behavior for multiple message replies.
@@ -26,24 +26,24 @@ JSON reply format
 Tag exclusion

   Tags can be automatically excluded from search results by adding them
-  to the new 'search.exclude_tags' option in the Notmuch config file.
+  to the new `search.exclude_tags` option in the Notmuch config file.

   This behaviour can be overridden by explicitly including an excluded
   tag in your query, for example:

-notmuch search $your_query and tag:$excluded_tag
+notmuch search $your_query and tag:$excluded_tag

-  Existing users will probably want to run "notmuch setup" again to add
+  Existing users will probably want to run `notmuch setup` again to add
   the new well-commented [search] section to the configuration file.

   For new configurations, accepting the default setting will cause the
   tags "deleted" and "spam" to be excluded, equivalent to running:

-notmuch config set search.exclude_tags deleted spam
+notmuch config set search.exclude_tags deleted spam

 Raw show format changes

-  The output of show --format=raw has changed for multipart and
+  The output of show `--format=raw` has changed for multipart and
   message parts.  Previously, the output was a mash of somewhat-parsed
   headers and transfer-decoded bodies.  Now, such parts are reproduced
   faithfully from the original source.  Message parts (which includes
@@ -54,7 +54,7 @@ Raw show format changes

 Listing configuration items

-  The new "config list" command prints out all configuration items and
+  The new `config list` command prints out all configuration items and
   their values.

 Emacs Interface
@@ -64,7 +64,7 @@ Changes to tagging interface

   The user-facing tagging functions in the Emacs interface have been
   normalized across all notmuch modes.  The tagging functions are now
-  'notmuch-search-tag' in search-mode, and 'notmuch-show-tag' in
+  notmuch-search-tag in search-mode, and notmuch-show-tag in
   show-mode.  They accept a string representing a single tag change,
   or a list of tag changes.  See 'M-x describe-function notmuch-tag'
   for more information.
@@ -83,11 +83,11 @@ Reply improvement using the JSON format
 New add-on tool: notmuch-mutt
 -

-The new contrib/ tool "notmuch-mutt" provides Notmuch integration for
+The new contrib/ tool `notmuch-mutt` provides Notmuch integration for
 the Mutt mail user agent. Using it, Mutt users can perform mail
 search, thread reconstruction, and mail tagging/untagging without
 leaving Mutt.  notmuch-mutt, formerly distributed under the name
-"mutt-notmuch" by Stefano Zacchiroli, will be maintained as a notmuch
+`mutt-notmuch` by Stefano Zacchiroli, will be maintained as a notmuch
 contrib/ from now on.

 Library changes
@@ -96,18 +96,18 @@ Library changes
 The API changes detailed below break binary and source compatibility,
 so libnotmuch has been bumped to version 3.0.0.

-The function notmuch_database_close has been split into
-notmuch_database_close and notmuch_database_destroy
+The function `notmuch_database_close` has been split into
+`notmuch_database_close` and `notmuch_database_destroy`

   This makes it possible for long running programs to close the xapian
   database and thus release the lock associated with it without
   destroying the data structures obtained from it.

-notmuch_database_open, notmuch_database_create, and
-notmuch_database_get_directory now return errors
+`notmuch_database_open`, `notmuch_database_create`, and
+`notmuch_database_get_directory` now return errors

   The type signatures of these functions have changed so that the
-  functions now return a 

emacs complains about encoding?

2012-05-16 Thread Jani Nikula
Tomi Ollila  writes:
> IT h?ppens.
>
> Attempting to reply to this email should expose the problem.
>
> ??li? ?l? ly?, ??li? l?ikkyy.

The problem bisected to f6c170fabca8f39e74705e3813504137811bf162
("emacs: Correctly quote non-text/plain parts in reply"). The commit
reverts cleanly, replying without it now.

Tomi, it would be great if you could post your message as a patch to the
test suite.

BR,
Jani.


emacs complains about encoding?

2012-05-16 Thread Tomi Ollila
On Tue, May 15 2012, Tomi Ollila  wrote:

> IT h?ppens.
>
> Attempting to reply to this email should expose the problem.
>
> ??li? ?l? ly?, ??li? l?ikkyy.

This email: id:"20120515194455.B7AD5100646 at guru.guru-group.fi"

was supposed to be reply to email id:"878vgzrvik.fsf at beesknees.cern.ch"

I (once again) failed to copy Message id correctly to the
email headers ;/ :

In-Reply-To: 
References: 

Tomi


Re: emacs complains about encoding?

2012-05-16 Thread Jani Nikula
Tomi Ollila tomi.oll...@iki.fi writes:
 IT häppens.

 Attempting to reply to this email should expose the problem.

 Ääliö älä lyö, ööliä läikkyy.

The problem bisected to f6c170fabca8f39e74705e3813504137811bf162
(emacs: Correctly quote non-text/plain parts in reply). The commit
reverts cleanly, replying without it now.

Tomi, it would be great if you could post your message as a patch to the
test suite.

BR,
Jani.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/3] NEWS: Insert markdown formatting commands in 0.13 section text

2012-05-16 Thread Jani Nikula
Tomi Ollila tomi.oll...@iki.fi writes:

 NEWS entries in section 0.13 is brought consistent with rest of the
 NEWS file.
 ---
  NEWS |   38 +++---
  1 files changed, 19 insertions(+), 19 deletions(-)

 diff --git a/NEWS b/NEWS
 index 69a7203..d841a4c 100644
 --- a/NEWS
 +++ b/NEWS
 @@ -6,19 +6,19 @@ Command-Line Interface
  
  Reply to sender
  
 -  notmuch reply has gained the ability to create a reply template
 +  `notmuch reply` has gained the ability to create a reply template
for replying just to the sender of the message, in addition to reply
to all. The feature is available through the new command line option
 -  --reply-to=(all|sender).
 +  `--reply-to=(all|sender)`.

The whole reply to sender section should go. It's old news, for 0.12.

Jani.


  
  JSON reply format
  
 -  notmuch reply can now produce JSON output that contains the headers
 +  `notmuch reply` can now produce JSON output that contains the headers
for a reply message and full information about the original message
begin replied to. This allows MUAs to create replies intelligently.
For example, an MUA that can parse HTML might quote HTML parts.
  
 -  Calling notmuch reply with --format=json imposes the restriction that
 +  Calling notmuch reply with `--format=json` imposes the restriction that
only a single message is returned by the search, as replying to
multiple messages does not have a well-defined behavior. The default
retains its current behavior for multiple message replies.
 @@ -26,24 +26,24 @@ JSON reply format
  Tag exclusion
  
Tags can be automatically excluded from search results by adding them
 -  to the new 'search.exclude_tags' option in the Notmuch config file.
 +  to the new `search.exclude_tags` option in the Notmuch config file.
  
This behaviour can be overridden by explicitly including an excluded
tag in your query, for example:
  
 -notmuch search $your_query and tag:$excluded_tag
 +notmuch search $your_query and tag:$excluded_tag
  
 -  Existing users will probably want to run notmuch setup again to add
 +  Existing users will probably want to run `notmuch setup` again to add
the new well-commented [search] section to the configuration file.
  
For new configurations, accepting the default setting will cause the
tags deleted and spam to be excluded, equivalent to running:
  
 -notmuch config set search.exclude_tags deleted spam
 +notmuch config set search.exclude_tags deleted spam
  
  Raw show format changes
  
 -  The output of show --format=raw has changed for multipart and
 +  The output of show `--format=raw` has changed for multipart and
message parts.  Previously, the output was a mash of somewhat-parsed
headers and transfer-decoded bodies.  Now, such parts are reproduced
faithfully from the original source.  Message parts (which includes
 @@ -54,7 +54,7 @@ Raw show format changes
  
  Listing configuration items
  
 -  The new config list command prints out all configuration items and
 +  The new `config list` command prints out all configuration items and
their values.
  
  Emacs Interface
 @@ -64,7 +64,7 @@ Changes to tagging interface
  
The user-facing tagging functions in the Emacs interface have been
normalized across all notmuch modes.  The tagging functions are now
 -  'notmuch-search-tag' in search-mode, and 'notmuch-show-tag' in
 +  notmuch-search-tag in search-mode, and notmuch-show-tag in
show-mode.  They accept a string representing a single tag change,
or a list of tag changes.  See 'M-x describe-function notmuch-tag'
for more information.
 @@ -83,11 +83,11 @@ Reply improvement using the JSON format
  New add-on tool: notmuch-mutt
  -
  
 -The new contrib/ tool notmuch-mutt provides Notmuch integration for
 +The new contrib/ tool `notmuch-mutt` provides Notmuch integration for
  the Mutt mail user agent. Using it, Mutt users can perform mail
  search, thread reconstruction, and mail tagging/untagging without
  leaving Mutt.  notmuch-mutt, formerly distributed under the name
 -mutt-notmuch by Stefano Zacchiroli, will be maintained as a notmuch
 +`mutt-notmuch` by Stefano Zacchiroli, will be maintained as a notmuch
  contrib/ from now on.
  
  Library changes
 @@ -96,18 +96,18 @@ Library changes
  The API changes detailed below break binary and source compatibility,
  so libnotmuch has been bumped to version 3.0.0.
  
 -The function notmuch_database_close has been split into
 -notmuch_database_close and notmuch_database_destroy
 +The function `notmuch_database_close` has been split into
 +`notmuch_database_close` and `notmuch_database_destroy`
  
This makes it possible for long running programs to close the xapian
database and thus release the lock associated with it without
destroying the data structures obtained from it.
  
 -notmuch_database_open, notmuch_database_create, and
 

[PATCH 1/3] NEWS: Insert markdown formatting commands in 0.13 section text

2012-05-16 Thread Tomi Ollila
NEWS entries in section 0.13 is brought consistent with rest of the
NEWS file.
---
 NEWS |   38 +++---
 1 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/NEWS b/NEWS
index 69a7203..d841a4c 100644
--- a/NEWS
+++ b/NEWS
@@ -6,19 +6,19 @@ Command-Line Interface
 
 Reply to sender
 
-  notmuch reply has gained the ability to create a reply template
+  `notmuch reply` has gained the ability to create a reply template
   for replying just to the sender of the message, in addition to reply
   to all. The feature is available through the new command line option
-  --reply-to=(all|sender).
+  `--reply-to=(all|sender)`.
 
 JSON reply format
 
-  notmuch reply can now produce JSON output that contains the headers
+  `notmuch reply` can now produce JSON output that contains the headers
   for a reply message and full information about the original message
   begin replied to. This allows MUAs to create replies intelligently.
   For example, an MUA that can parse HTML might quote HTML parts.
 
-  Calling notmuch reply with --format=json imposes the restriction that
+  Calling notmuch reply with `--format=json` imposes the restriction that
   only a single message is returned by the search, as replying to
   multiple messages does not have a well-defined behavior. The default
   retains its current behavior for multiple message replies.
@@ -26,24 +26,24 @@ JSON reply format
 Tag exclusion
 
   Tags can be automatically excluded from search results by adding them
-  to the new 'search.exclude_tags' option in the Notmuch config file.
+  to the new `search.exclude_tags` option in the Notmuch config file.
 
   This behaviour can be overridden by explicitly including an excluded
   tag in your query, for example:
 
-notmuch search $your_query and tag:$excluded_tag
+notmuch search $your_query and tag:$excluded_tag
 
-  Existing users will probably want to run notmuch setup again to add
+  Existing users will probably want to run `notmuch setup` again to add
   the new well-commented [search] section to the configuration file.
 
   For new configurations, accepting the default setting will cause the
   tags deleted and spam to be excluded, equivalent to running:
 
-notmuch config set search.exclude_tags deleted spam
+notmuch config set search.exclude_tags deleted spam
 
 Raw show format changes
 
-  The output of show --format=raw has changed for multipart and
+  The output of show `--format=raw` has changed for multipart and
   message parts.  Previously, the output was a mash of somewhat-parsed
   headers and transfer-decoded bodies.  Now, such parts are reproduced
   faithfully from the original source.  Message parts (which includes
@@ -54,7 +54,7 @@ Raw show format changes
 
 Listing configuration items
 
-  The new config list command prints out all configuration items and
+  The new `config list` command prints out all configuration items and
   their values.
 
 Emacs Interface
@@ -64,7 +64,7 @@ Changes to tagging interface
 
   The user-facing tagging functions in the Emacs interface have been
   normalized across all notmuch modes.  The tagging functions are now
-  'notmuch-search-tag' in search-mode, and 'notmuch-show-tag' in
+  notmuch-search-tag in search-mode, and notmuch-show-tag in
   show-mode.  They accept a string representing a single tag change,
   or a list of tag changes.  See 'M-x describe-function notmuch-tag'
   for more information.
@@ -83,11 +83,11 @@ Reply improvement using the JSON format
 New add-on tool: notmuch-mutt
 -
 
-The new contrib/ tool notmuch-mutt provides Notmuch integration for
+The new contrib/ tool `notmuch-mutt` provides Notmuch integration for
 the Mutt mail user agent. Using it, Mutt users can perform mail
 search, thread reconstruction, and mail tagging/untagging without
 leaving Mutt.  notmuch-mutt, formerly distributed under the name
-mutt-notmuch by Stefano Zacchiroli, will be maintained as a notmuch
+`mutt-notmuch` by Stefano Zacchiroli, will be maintained as a notmuch
 contrib/ from now on.
 
 Library changes
@@ -96,18 +96,18 @@ Library changes
 The API changes detailed below break binary and source compatibility,
 so libnotmuch has been bumped to version 3.0.0.
 
-The function notmuch_database_close has been split into
-notmuch_database_close and notmuch_database_destroy
+The function `notmuch_database_close` has been split into
+`notmuch_database_close` and `notmuch_database_destroy`
 
   This makes it possible for long running programs to close the xapian
   database and thus release the lock associated with it without
   destroying the data structures obtained from it.
 
-notmuch_database_open, notmuch_database_create, and
-notmuch_database_get_directory now return errors
+`notmuch_database_open`, `notmuch_database_create`, and
+`notmuch_database_get_directory` now return errors
 
   The type signatures of these functions have changed so that the
-  functions now return a 

[PATCH 2/3] Changed 0.13 release date in NEWS file to 2012-05-15

2012-05-16 Thread Tomi Ollila
---
 NEWS |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index d841a4c..8a73e08 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Notmuch 0.13 (2012-xx-xx)
+Notmuch 0.13 (2012-05-15)
 =
 
 Command-Line Interface
-- 
1.7.1

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 3/3] Capitalized go bindings changes title

2012-05-16 Thread Tomi Ollila
Align 'Go bindings changes' title capitalization to rest of the file
---
 NEWS |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 8a73e08..4978261 100644
--- a/NEWS
+++ b/NEWS
@@ -110,7 +110,7 @@ The function `notmuch_database_close` has been split into
   functions now return a `notmuch_status_t` and take an out-argument for
   returning the new database object or directory object.
 
-go bindings changes
+Go bindings changes
 ---
 
 Go 1 compatibility
-- 
1.7.1

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/4] NEWS: Dropped old 'Reply to sender' section

2012-05-16 Thread Tomi Ollila
'Reply to sender' section was 0.12 news which was accidentally
duplicated in 0.13 news
---
 NEWS |7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index 69a7203..9a690cb 100644
--- a/NEWS
+++ b/NEWS
@@ -4,13 +4,6 @@ Notmuch 0.13 (2012-xx-xx)
 Command-Line Interface
 --
 
-Reply to sender
-
-  notmuch reply has gained the ability to create a reply template
-  for replying just to the sender of the message, in addition to reply
-  to all. The feature is available through the new command line option
-  --reply-to=(all|sender).
-
 JSON reply format
 
   notmuch reply can now produce JSON output that contains the headers
-- 
1.7.1

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/4] NEWS: Changed 0.13 release date in NEWS file to 2012-05-15

2012-05-16 Thread Tomi Ollila
---
 NEWS |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 9a690cb..970aa40 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Notmuch 0.13 (2012-xx-xx)
+Notmuch 0.13 (2012-05-15)
 =
 
 Command-Line Interface
-- 
1.7.1

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 4/4] NEWS: Capitalized go bindings changes title

2012-05-16 Thread Tomi Ollila
Align 'Go bindings changes' title capitalization to rest of the file
---
 NEWS |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index ad4859d..668281c 100644
--- a/NEWS
+++ b/NEWS
@@ -103,7 +103,7 @@ The function `notmuch_database_close` has been split into
   functions now return a `notmuch_status_t` and take an out-argument for
   returning the new database object or directory object.
 
-go bindings changes
+Go bindings changes
 ---
 
 Go 1 compatibility
-- 
1.7.1

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 3/4] NEWS: Insert markdown formatting commands in 0.13 section text

2012-05-16 Thread Tomi Ollila
NEWS entries in section 0.13 is brought consistent with rest of the
NEWS file.
---
 NEWS |   34 +-
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/NEWS b/NEWS
index 970aa40..ad4859d 100644
--- a/NEWS
+++ b/NEWS
@@ -6,12 +6,12 @@ Command-Line Interface
 
 JSON reply format
 
-  notmuch reply can now produce JSON output that contains the headers
+  `notmuch reply` can now produce JSON output that contains the headers
   for a reply message and full information about the original message
   begin replied to. This allows MUAs to create replies intelligently.
   For example, an MUA that can parse HTML might quote HTML parts.
 
-  Calling notmuch reply with --format=json imposes the restriction that
+  Calling notmuch reply with `--format=json` imposes the restriction that
   only a single message is returned by the search, as replying to
   multiple messages does not have a well-defined behavior. The default
   retains its current behavior for multiple message replies.
@@ -19,24 +19,24 @@ JSON reply format
 Tag exclusion
 
   Tags can be automatically excluded from search results by adding them
-  to the new 'search.exclude_tags' option in the Notmuch config file.
+  to the new `search.exclude_tags` option in the Notmuch config file.
 
   This behaviour can be overridden by explicitly including an excluded
   tag in your query, for example:
 
-notmuch search $your_query and tag:$excluded_tag
+notmuch search $your_query and tag:$excluded_tag
 
-  Existing users will probably want to run notmuch setup again to add
+  Existing users will probably want to run `notmuch setup` again to add
   the new well-commented [search] section to the configuration file.
 
   For new configurations, accepting the default setting will cause the
   tags deleted and spam to be excluded, equivalent to running:
 
-notmuch config set search.exclude_tags deleted spam
+notmuch config set search.exclude_tags deleted spam
 
 Raw show format changes
 
-  The output of show --format=raw has changed for multipart and
+  The output of show `--format=raw` has changed for multipart and
   message parts.  Previously, the output was a mash of somewhat-parsed
   headers and transfer-decoded bodies.  Now, such parts are reproduced
   faithfully from the original source.  Message parts (which includes
@@ -47,7 +47,7 @@ Raw show format changes
 
 Listing configuration items
 
-  The new config list command prints out all configuration items and
+  The new `config list` command prints out all configuration items and
   their values.
 
 Emacs Interface
@@ -57,7 +57,7 @@ Changes to tagging interface
 
   The user-facing tagging functions in the Emacs interface have been
   normalized across all notmuch modes.  The tagging functions are now
-  'notmuch-search-tag' in search-mode, and 'notmuch-show-tag' in
+  notmuch-search-tag in search-mode, and notmuch-show-tag in
   show-mode.  They accept a string representing a single tag change,
   or a list of tag changes.  See 'M-x describe-function notmuch-tag'
   for more information.
@@ -76,11 +76,11 @@ Reply improvement using the JSON format
 New add-on tool: notmuch-mutt
 -
 
-The new contrib/ tool notmuch-mutt provides Notmuch integration for
+The new contrib/ tool `notmuch-mutt` provides Notmuch integration for
 the Mutt mail user agent. Using it, Mutt users can perform mail
 search, thread reconstruction, and mail tagging/untagging without
 leaving Mutt.  notmuch-mutt, formerly distributed under the name
-mutt-notmuch by Stefano Zacchiroli, will be maintained as a notmuch
+`mutt-notmuch` by Stefano Zacchiroli, will be maintained as a notmuch
 contrib/ from now on.
 
 Library changes
@@ -89,18 +89,18 @@ Library changes
 The API changes detailed below break binary and source compatibility,
 so libnotmuch has been bumped to version 3.0.0.
 
-The function notmuch_database_close has been split into
-notmuch_database_close and notmuch_database_destroy
+The function `notmuch_database_close` has been split into
+`notmuch_database_close` and `notmuch_database_destroy`
 
   This makes it possible for long running programs to close the xapian
   database and thus release the lock associated with it without
   destroying the data structures obtained from it.
 
-notmuch_database_open, notmuch_database_create, and
-notmuch_database_get_directory now return errors
+`notmuch_database_open`, `notmuch_database_create`, and
+`notmuch_database_get_directory` now return errors
 
   The type signatures of these functions have changed so that the
-  functions now return a notmuch_status_t and take an out-argument for
+  functions now return a `notmuch_status_t` and take an out-argument for
   returning the new database object or directory object.
 
 go bindings changes
@@ -108,7 +108,7 @@ go bindings changes
 
 Go 1 compatibility
 
-  The go bindings and the notmuch-addrlookup utility are now
+  The go bindings and the 

Re: [PATCH 1/3] NEWS: Insert markdown formatting commands in 0.13 section text

2012-05-16 Thread Tomi Ollila

Sorry about the spam -- sent too many patches... PEBKAC.

The only relevant are:

id:1337152910-22371-4-git-send-email-tomi.oll...@iki.fi
id:1337152910-22371-5-git-send-email-tomi.oll...@iki.fi
id:1337152910-22371-6-git-send-email-tomi.oll...@iki.fi
id:1337152910-22371-7-git-send-email-tomi.oll...@iki.fi

rest are marked obsolete.

Tomi


___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: emacs complains about encoding?

2012-05-16 Thread Tomi Ollila
On Wed, May 16 2012, Jani Nikula wrote:

 Tomi Ollila tomi.oll...@iki.fi writes:
 IT h\344ppens.

 Attempting to reply to this email should expose the problem.

 \304\344li\366 \344l\344 ly\366, \366\366li\344 l\344ikkyy.

(\nnn text above hand-(query)-replaced)


 The problem bisected to f6c170fabca8f39e74705e3813504137811bf162
 (emacs: Correctly quote non-text/plain parts in reply). The commit
 reverts cleanly, replying without it now.

 Tomi, it would be great if you could post your message as a patch to the
 test suite.

Haa, It doesn't matter which is the original encoding of the message;

notmuch reply id:20120515194455.b7ad5100...@guru.guru-group.fi

where  notmuch show --format=raw ^^^  outputs (among other lines):

  Content-Type: text/plain; charset=iso-8859-1
  Content-Transfer-Encoding: quoted-printable

and

notmuch reply id:878vgsbprq@nikula.org

where  notmuch show --format=raw ^^^  outputs (among other lines):

  Content-Type: text/plain; charset=utf-8
  Content-Transfer-Encoding: base64

produce correct reply content, both in utf-8.

So it is the emacs side which breaks replies.

I'll see what kind of test cases I can create...


 BR,
 Jani.

Tomi
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 3/6] cli: modify mime_node_open to take crypto struct as argument

2012-05-16 Thread Jameson Graef Rollins
Again, for interface simplification and getting rid of more #ifdefs.
---
 mime-node.c  |   10 ++
 notmuch-client.h |   14 +-
 notmuch-reply.c  |6 ++
 notmuch-show.c   |3 +--
 4 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/mime-node.c b/mime-node.c
index 79a3654..4faeffc 100644
--- a/mime-node.c
+++ b/mime-node.c
@@ -56,12 +56,7 @@ _mime_node_context_free (mime_node_context_t *res)
 
 notmuch_status_t
 mime_node_open (const void *ctx, notmuch_message_t *message,
-#ifdef GMIME_ATLEAST_26
-   GMimeCryptoContext *cryptoctx,
-#else
-   GMimeCipherContext *cryptoctx,
-#endif
-   notmuch_bool_t decrypt, mime_node_t **root_out)
+   notmuch_crypto_t *crypto, mime_node_t **root_out)
 {
 const char *filename = notmuch_message_get_filename (message);
 mime_node_context_t *mctx;
@@ -113,8 +108,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
goto DONE;
 }
 
-mctx-crypto.gpgctx = cryptoctx;
-mctx-crypto.decrypt = decrypt;
+mctx-crypto = *crypto;
 
 /* Create the root node */
 root-part = GMIME_OBJECT (mctx-mime_message);
diff --git a/notmuch-client.h b/notmuch-client.h
index 2ad24cf..d86fab3 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -345,9 +345,10 @@ struct mime_node {
 };
 
 /* Construct a new MIME node pointing to the root message part of
- * message.  If cryptoctx is non-NULL, it will be used to verify
- * signatures on any child parts.  If decrypt is true, then cryptoctx
- * will additionally be used to decrypt any encrypted child parts.
+ * message.  If crypto.gpgctx is non-NULL, it will be used to verify
+ * signatures on any child parts.  If crypto.decrypt is true, then
+ * crypto.gpgctx will additionally be used to decrypt any encrypted
+ * child parts.
  *
  * Return value:
  *
@@ -359,12 +360,7 @@ struct mime_node {
  */
 notmuch_status_t
 mime_node_open (const void *ctx, notmuch_message_t *message,
-#ifdef GMIME_ATLEAST_26
-   GMimeCryptoContext *cryptoctx,
-#else
-   GMimeCipherContext *cryptoctx,
-#endif
-   notmuch_bool_t decrypt, mime_node_t **node_out);
+   notmuch_crypto_t *crypto, mime_node_t **node_out);
 
 /* Return a new MIME node for the requested child part of parent.
  * parent will be used as the talloc context for the returned child
diff --git a/notmuch-reply.c b/notmuch-reply.c
index ed87899..6662adb 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -544,8 +544,7 @@ notmuch_reply_format_default(void *ctx,
g_object_unref (G_OBJECT (reply));
reply = NULL;
 
-   if (mime_node_open (ctx, message, crypto-gpgctx, crypto-decrypt,
-   root) == NOTMUCH_STATUS_SUCCESS) {
+   if (mime_node_open (ctx, message, crypto, root) == 
NOTMUCH_STATUS_SUCCESS) {
format_part_reply (root);
talloc_free (root);
}
@@ -574,8 +573,7 @@ notmuch_reply_format_json(void *ctx,
 
 messages = notmuch_query_search_messages (query);
 message = notmuch_messages_get (messages);
-if (mime_node_open (ctx, message, crypto-gpgctx, crypto-decrypt,
-   node) != NOTMUCH_STATUS_SUCCESS)
+if (mime_node_open (ctx, message, crypto, node) != NOTMUCH_STATUS_SUCCESS)
return 1;
 
 reply = create_reply_message (ctx, config, message, reply_all);
diff --git a/notmuch-show.c b/notmuch-show.c
index d254179..8b4d308 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -810,8 +810,7 @@ show_message (void *ctx,
 mime_node_t *root, *part;
 notmuch_status_t status;
 
-status = mime_node_open (local, message, params-crypto.gpgctx,
-params-crypto.decrypt, root);
+status = mime_node_open (local, message, (params-crypto), root);
 if (status)
goto DONE;
 part = mime_node_seek_dfs (root, (params-part  0 ? 0 : params-part));
-- 
1.7.10

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 0/6] cli: improve handling of crypto parameters contexts

2012-05-16 Thread Jameson Graef Rollins
I wanted to see if I could hack in S/MIME support, but ultimately
failed (the interface is too stupid for me to deal with at the
moment).  However, on the way there I did manage to make some tangible
improvements to how crypto is handled in show and reply.

Most importantly I've moved the initialization of the gpg context to
mime_node.c where it is created lazily, only when needed.  This should
provide some speed up in notmuch show and reply when crypto flags are
provided but the messages have no crypto parts.

I was also able to get rid of a bunch of those pesky
#ifdef GMIME_ATLEAST_26 conditionals.

This should provide a better framework for someone to try to hack in
S/MIME support at a later date if they're so inclined.

jamie.

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/6] cli: modify mime_node_context to use the new notmuch_crypto_t

2012-05-16 Thread Jameson Graef Rollins
This simplifies some more interfaces and gets rid of another #ifdef.
---
 mime-node.c |   23 +--
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/mime-node.c b/mime-node.c
index a95bdab..79a3654 100644
--- a/mime-node.c
+++ b/mime-node.c
@@ -33,12 +33,7 @@ typedef struct mime_node_context {
 GMimeMessage *mime_message;
 
 /* Context provided by the caller. */
-#ifdef GMIME_ATLEAST_26
-GMimeCryptoContext *cryptoctx;
-#else
-GMimeCipherContext *cryptoctx;
-#endif
-notmuch_bool_t decrypt;
+notmuch_crypto_t crypto;
 } mime_node_context_t;
 
 static int
@@ -118,8 +113,8 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
goto DONE;
 }
 
-mctx-cryptoctx = cryptoctx;
-mctx-decrypt = decrypt;
+mctx-crypto.gpgctx = cryptoctx;
+mctx-crypto.decrypt = decrypt;
 
 /* Create the root node */
 root-part = GMIME_OBJECT (mctx-mime_message);
@@ -195,7 +190,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
 
 /* Handle PGP/MIME parts */
 if (GMIME_IS_MULTIPART_ENCRYPTED (part)
-node-ctx-cryptoctx  node-ctx-decrypt) {
+node-ctx-crypto.gpgctx  node-ctx-crypto.decrypt) {
if (node-nchildren != 2) {
/* this violates RFC 3156 section 4, so we won't bother with it. */
fprintf (stderr, Error: %d part(s) for a multipart/encrypted 
@@ -208,10 +203,10 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
 #ifdef GMIME_ATLEAST_26
GMimeDecryptResult *decrypt_result = NULL;
node-decrypted_child = g_mime_multipart_encrypted_decrypt
-   (encrypteddata, node-ctx-cryptoctx, decrypt_result, err);
+   (encrypteddata, node-ctx-crypto.gpgctx, decrypt_result, 
err);
 #else
node-decrypted_child = g_mime_multipart_encrypted_decrypt
-   (encrypteddata, node-ctx-cryptoctx, err);
+   (encrypteddata, node-ctx-crypto.gpgctx, err);
 #endif
if (node-decrypted_child) {
node-decrypt_success = node-verify_attempted = TRUE;
@@ -229,7 +224,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
 (err ? err-message : no error explanation given));
}
}
-} else if (GMIME_IS_MULTIPART_SIGNED (part)  node-ctx-cryptoctx) {
+} else if (GMIME_IS_MULTIPART_SIGNED (part)  node-ctx-crypto.gpgctx) {
if (node-nchildren != 2) {
/* this violates RFC 3156 section 5, so we won't bother with it. */
fprintf (stderr, Error: %d part(s) for a multipart/signed message 
@@ -238,7 +233,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
} else {
 #ifdef GMIME_ATLEAST_26
node-sig_list = g_mime_multipart_signed_verify
-   (GMIME_MULTIPART_SIGNED (part), node-ctx-cryptoctx, err);
+   (GMIME_MULTIPART_SIGNED (part), node-ctx-crypto.gpgctx, err);
node-verify_attempted = TRUE;
 
if (!node-sig_list)
@@ -254,7 +249,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
 * In GMime 2.6, they're both non-const, so we'll be able
 * to clean up this asymmetry. */
GMimeSignatureValidity *sig_validity = 
g_mime_multipart_signed_verify
-   (GMIME_MULTIPART_SIGNED (part), node-ctx-cryptoctx, err);
+   (GMIME_MULTIPART_SIGNED (part), node-ctx-crypto.gpgctx, err);
node-verify_attempted = TRUE;
node-sig_validity = sig_validity;
if (sig_validity) {
-- 
1.7.10

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 6/6] cli: lazily create the crypto gpg context only when needed

2012-05-16 Thread Jameson Graef Rollins
Move the creation of the crypto ctx into mime-node.c and create it
only when needed.  This removes code duplication from notmuch-show and
notmuch-reply, and should speed up these functions considerably if the
crypto flags are provided but the messages don't have any
cryptographic parts.
---
 mime-node.c |   25 +
 notmuch-reply.c |   19 ---
 notmuch-show.c  |   23 ---
 3 files changed, 25 insertions(+), 42 deletions(-)

diff --git a/mime-node.c b/mime-node.c
index 8cdabc8..7278c74 100644
--- a/mime-node.c
+++ b/mime-node.c
@@ -182,6 +182,31 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
return NULL;
 }
 
+/* Lazily create the gpgctx if it's needed and hasn't been initialized yet 
*/
+if ((GMIME_IS_MULTIPART_ENCRYPTED (part) || GMIME_IS_MULTIPART_SIGNED 
(part))
+(node-ctx-crypto.verify || node-ctx-crypto.decrypt)) {
+   if (!node-ctx-crypto.gpgctx) {
+#ifdef GMIME_ATLEAST_26
+   /* TODO: GMimePasswordRequestFunc */
+   node-ctx-crypto.gpgctx = g_mime_gpg_context_new (NULL, gpg);
+#else
+   GMimeSession* session = g_object_new (g_mime_session_get_type(), 
NULL);
+   node-ctx-crypto.gpgctx = g_mime_gpg_context_new (session, gpg);
+   g_object_unref (session);
+#endif
+   if (node-ctx-crypto.gpgctx) {
+   g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) 
node-ctx-crypto.gpgctx, FALSE);
+   } else {
+   /* If we fail to create the gpgctx set the verify and
+* decrypt flags to FALSE so we don't try to do any
+* further verification or decryption */
+   node-ctx-crypto.verify = FALSE;
+   node-ctx-crypto.decrypt = FALSE;
+   fprintf (stderr, Failed to construct gpg context.\n);
+   }
+   }
+}
+
 /* Handle PGP/MIME parts */
 if (GMIME_IS_MULTIPART_ENCRYPTED (part)  node-ctx-crypto.decrypt) {
if (node-nchildren != 2) {
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 997fdd1..a56cf9f 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -708,25 +708,6 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 else
reply_format_func = notmuch_reply_format_default;
 
-if (crypto.decrypt) {
-#ifdef GMIME_ATLEAST_26
-   /* TODO: GMimePasswordRequestFunc */
-   crypto.gpgctx = g_mime_gpg_context_new (NULL, gpg);
-#else
-   GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);
-   crypto.gpgctx = g_mime_gpg_context_new (session, gpg);
-#endif
-   if (crypto.gpgctx) {
-   g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) 
crypto.gpgctx, FALSE);
-   } else {
-   crypto.decrypt = FALSE;
-   fprintf (stderr, Failed to construct gpg context.\n);
-   }
-#ifndef GMIME_ATLEAST_26
-   g_object_unref (session);
-#endif
-}
-
 config = notmuch_config_open (ctx, NULL, NULL);
 if (config == NULL)
return 1;
diff --git a/notmuch-show.c b/notmuch-show.c
index 99a10bd..0616f68 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1058,29 +1058,6 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
break;
 }
 
-if (params.crypto.decrypt || params.crypto.verify) {
-#ifdef GMIME_ATLEAST_26
-   /* TODO: GMimePasswordRequestFunc */
-   params.crypto.gpgctx = g_mime_gpg_context_new (NULL, gpg);
-#else
-   GMimeSession* session = g_object_new (g_mime_session_get_type(), NULL);
-   params.crypto.gpgctx = g_mime_gpg_context_new (session, gpg);
-#endif
-   if (params.crypto.gpgctx) {
-   g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) 
params.crypto.gpgctx, FALSE);
-   } else {
-   /* If we fail to create the gpgctx set the verify and
-* decrypt flags to FALSE so we don't try to do any
-* further verification or decryption */
-   params.crypto.verify = FALSE;
-   params.crypto.decrypt = FALSE;
-   fprintf (stderr, Failed to construct gpg context.\n);
-   }
-#ifndef GMIME_ATLEAST_26
-   g_object_unref (session);
-#endif
-}
-
 config = notmuch_config_open (ctx, NULL, NULL);
 if (config == NULL)
return 1;
-- 
1.7.10

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 4/6] cli: intialize crypto structure in show and reply

2012-05-16 Thread Jameson Graef Rollins
This makes sure it has proper initialization values when it's created.
---
 notmuch-reply.c |5 -
 notmuch-show.c  |   10 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 6662adb..3c967a0 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -673,7 +673,10 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 char *query_string;
 int opt_index, ret = 0;
 int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_crypto_t *crypto, notmuch_bool_t reply_all);
-notmuch_crypto_t crypto = { .decrypt = FALSE };
+notmuch_crypto_t crypto = {
+   .decrypt = FALSE,
+   .gpgctx = NULL,
+};
 int format = FORMAT_DEFAULT;
 int reply_all = TRUE;
 
diff --git a/notmuch-show.c b/notmuch-show.c
index 8b4d308..c606333 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -983,7 +983,15 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
 char *query_string;
 int opt_index, ret;
 const notmuch_show_format_t *format = format_text;
-notmuch_show_params_t params = { .part = -1, .omit_excluded = TRUE };
+notmuch_crypto_t crypto = {
+   .decrypt = FALSE,
+   .gpgctx = NULL,
+};
+notmuch_show_params_t params = {
+   .part = -1,
+   .omit_excluded = TRUE,
+   .crypto = crypto,
+};
 int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
 notmuch_bool_t verify = FALSE;
 int exclude = EXCLUDE_TRUE;
-- 
1.7.10

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 5/6] cli: new crypto verify flag to handle verification

2012-05-16 Thread Jameson Graef Rollins
Use this flag rather than depend on the existence of an initialized
gpgctx, to determine whether we should verify a multipart/signed.  We
will be moving to create the ctx lazily, so we don't want to depend on
it being previously initialized if it's not needed.
---
 mime-node.c  |5 ++---
 notmuch-client.h |1 +
 notmuch-reply.c  |1 +
 notmuch-show.c   |   14 +++---
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/mime-node.c b/mime-node.c
index 4faeffc..8cdabc8 100644
--- a/mime-node.c
+++ b/mime-node.c
@@ -183,8 +183,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
 }
 
 /* Handle PGP/MIME parts */
-if (GMIME_IS_MULTIPART_ENCRYPTED (part)
-node-ctx-crypto.gpgctx  node-ctx-crypto.decrypt) {
+if (GMIME_IS_MULTIPART_ENCRYPTED (part)  node-ctx-crypto.decrypt) {
if (node-nchildren != 2) {
/* this violates RFC 3156 section 4, so we won't bother with it. */
fprintf (stderr, Error: %d part(s) for a multipart/encrypted 
@@ -218,7 +217,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
 (err ? err-message : no error explanation given));
}
}
-} else if (GMIME_IS_MULTIPART_SIGNED (part)  node-ctx-crypto.gpgctx) {
+} else if (GMIME_IS_MULTIPART_SIGNED (part)  node-ctx-crypto.verify) {
if (node-nchildren != 2) {
/* this violates RFC 3156 section 5, so we won't bother with it. */
fprintf (stderr, Error: %d part(s) for a multipart/signed message 
diff --git a/notmuch-client.h b/notmuch-client.h
index d86fab3..1ca111f 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -80,6 +80,7 @@ typedef struct notmuch_crypto {
 #else
 GMimeCipherContext* gpgctx;
 #endif
+notmuch_bool_t verify;
 notmuch_bool_t decrypt;
 } notmuch_crypto_t;
 
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 3c967a0..997fdd1 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -675,6 +675,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_crypto_t *crypto, notmuch_bool_t reply_all);
 notmuch_crypto_t crypto = {
.decrypt = FALSE,
+   .verify = FALSE,
.gpgctx = NULL,
 };
 int format = FORMAT_DEFAULT;
diff --git a/notmuch-show.c b/notmuch-show.c
index c606333..99a10bd 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -985,6 +985,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
 const notmuch_show_format_t *format = format_text;
 notmuch_crypto_t crypto = {
.decrypt = FALSE,
+   .verify = FALSE,
.gpgctx = NULL,
 };
 notmuch_show_params_t params = {
@@ -993,7 +994,6 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
.crypto = crypto,
 };
 int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
-notmuch_bool_t verify = FALSE;
 int exclude = EXCLUDE_TRUE;
 
 notmuch_opt_desc_t options[] = {
@@ -1010,7 +1010,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
{ NOTMUCH_OPT_INT, params.part, part, 'p', 0 },
{ NOTMUCH_OPT_BOOLEAN, params.entire_thread, entire-thread, 't', 0 },
{ NOTMUCH_OPT_BOOLEAN, params.crypto.decrypt, decrypt, 'd', 0 },
-   { NOTMUCH_OPT_BOOLEAN, verify, verify, 'v', 0 },
+   { NOTMUCH_OPT_BOOLEAN, params.crypto.verify, verify, 'v', 0 },
{ 0, 0, 0, 0, 0 }
 };
 
@@ -1020,6 +1020,10 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
return 1;
 }
 
+/* decryption implies verification */
+if (params.crypto.decrypt)
+   params.crypto.verify = TRUE;
+
 if (format_sel == NOTMUCH_FORMAT_NOT_SPECIFIED) {
/* if part was requested and format was not specified, use format=raw */
if (params.part = 0)
@@ -1054,7 +1058,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
break;
 }
 
-if (params.crypto.decrypt || verify) {
+if (params.crypto.decrypt || params.crypto.verify) {
 #ifdef GMIME_ATLEAST_26
/* TODO: GMimePasswordRequestFunc */
params.crypto.gpgctx = g_mime_gpg_context_new (NULL, gpg);
@@ -1065,6 +1069,10 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
if (params.crypto.gpgctx) {
g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) 
params.crypto.gpgctx, FALSE);
} else {
+   /* If we fail to create the gpgctx set the verify and
+* decrypt flags to FALSE so we don't try to do any
+* further verification or decryption */
+   params.crypto.verify = FALSE;
params.crypto.decrypt = FALSE;
fprintf (stderr, Failed to construct gpg context.\n);
}
-- 
1.7.10

___
notmuch mailing list

Re: [PATCH 1/3] NEWS: Insert markdown formatting commands in 0.13 section text

2012-05-16 Thread David Bremner
Tomi Ollila tomi.oll...@iki.fi writes:

 id:1337152910-22371-4-git-send-email-tomi.oll...@iki.fi
 id:1337152910-22371-5-git-send-email-tomi.oll...@iki.fi
 id:1337152910-22371-6-git-send-email-tomi.oll...@iki.fi
 id:1337152910-22371-7-git-send-email-tomi.oll...@iki.fi

I pushed those to release. I'll merge them to master after a bit;
hopefully we'll figure out that reply encoding thing and do a bug fix
release.

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch