g_object_unref(stream_filter);
}
-/* Get signature status string (GMime 2.6) */
static const char*
-signature_status_to_string (GMimeSignatureStatus x)
+signature_status_to_string (GMimeSignatureStatus status)
{
- switch (x) {
- case GMIME_SIGNATURE_STATUS_GOOD:
- return "good";
- case GMIME_SIGNATURE_STATUS_BAD:
+ if (g_mime_signature_status_bad (status))
return "bad";
- case GMIME_SIGNATURE_STATUS_ERROR:
+
+ if (g_mime_signature_status_error (status))
return "error";
- }
+
+ if (g_mime_signature_status_good (status))
+ return "good";
+
return "unknown";
}
-
/* Print signature flags */
struct key_map_struct {
GMimeSignatureError bit;
sp->end (sp);
}
+#if (GMIME_MAJOR_VERSION < 3)
static void
format_signature_errors (sprinter_t *sp, GMimeSignature *signature)
{
do_format_signature_errors (sp, key_map, ARRAY_SIZE(key_map), errors);
}
+#else
+static void
+format_signature_errors (sprinter_t *sp, GMimeSignature *signature)
+{
+ GMimeSignatureError errors = g_mime_signature_get_errors (signature);
+
+ if (!(errors & GMIME_SIGNATURE_STATUS_ERROR_MASK))
+ return;
+
+ struct key_map_struct key_map[] = {
+ { GMIME_SIGNATURE_STATUS_KEY_REVOKED, "key-revoked"},
+ { GMIME_SIGNATURE_STATUS_KEY_EXPIRED, "key-expired"},
+ { GMIME_SIGNATURE_STATUS_SIG_EXPIRED, "sig-expired" },
+ { GMIME_SIGNATURE_STATUS_KEY_MISSING, "key-missing"},
+ { GMIME_SIGNATURE_STATUS_CRL_MISSING, "crl-missing"},
+ { GMIME_SIGNATURE_STATUS_CRL_TOO_OLD, "crl-too-old"},
+ { GMIME_SIGNATURE_STATUS_BAD_POLICY, "bad-policy"},
+ { GMIME_SIGNATURE_STATUS_SYS_ERROR, "sys-error"},
+ { GMIME_SIGNATURE_STATUS_TOFU_CONFLICT, "tofu-conflict"},
+ };
+
+ do_format_signature_errors (sp, key_map, ARRAY_SIZE(key_map), errors);
+}
+#endif
/* Signature status sprinter (GMime 2.6) */
static void
sp->string (sp, signature_status_to_string (status));
GMimeCertificate *certificate = g_mime_signature_get_certificate (signature);
- if (status == GMIME_SIGNATURE_STATUS_GOOD) {
+ if (g_mime_signature_status_good (status)) {
if (certificate) {
sp->map_key (sp, "fingerprint");
sp->string (sp, g_mime_certificate_get_fingerprint (certificate));
if (notmuch_format_version <= 3) {
GMimeSignatureError errors = g_mime_signature_get_errors (signature);
- if (errors != GMIME_SIGNATURE_ERROR_NONE) {
+ if (g_mime_signature_status_error (errors)) {
sp->map_key (sp, "errors");
sp->integer (sp, errors);
}
return talloc_strdup(ctx, g_mime_message_get_reply_to (message));
}
+gboolean
+g_mime_signature_status_good (GMimeSignatureStatus status) {
+ return (status == GMIME_SIGNATURE_STATUS_GOOD);
+}
+
+gboolean
+g_mime_signature_status_bad (GMimeSignatureStatus status) {
+ return (status == GMIME_SIGNATURE_STATUS_BAD);
+}
+
+gboolean
+g_mime_signature_status_error (GMimeSignatureError error) {
+ return (error != GMIME_SIGNATURE_ERROR_NONE);
+}
#else /* GMime >= 3.0 */
return g_string_talloc_strdup (ctx, internet_address_list_to_string (list, NULL, 0));
}
+void
+g_mime_parser_set_scan_from (GMimeParser *parser, gboolean flag)
+{
+ g_mime_parser_set_format (parser, flag ? GMIME_FORMAT_MBOX : GMIME_FORMAT_MESSAGE);
+}
+
+/* In GMime 3.0, status GOOD and VALID both imply something about the
+ * validity of the UIDs attached to the signing key. This forces us to
+ * use following somewhat relaxed definition of a "good" signature to
+ * preserve current notmuch semantics.
+ */
+
+gboolean
+g_mime_signature_status_good (GMimeSignatureStatus status) {
+ return ((status & (GMIME_SIGNATURE_STATUS_RED | GMIME_SIGNATURE_STATUS_ERROR_MASK)) == 0);
+}
+
+gboolean
+g_mime_signature_status_bad (GMimeSignatureStatus status) {
+ return (status & GMIME_SIGNATURE_STATUS_RED);
+}
+
+gboolean
+g_mime_signature_status_error (GMimeSignatureStatus status) {
+ return (status & GMIME_SIGNATURE_STATUS_ERROR_MASK);
+}
+
#endif
#define GMIME_ADDRESS_TYPE_CC GMIME_RECIPIENT_TYPE_CC
#define GMIME_ADDRESS_TYPE_BCC GMIME_RECIPIENT_TYPE_BCC
-
#else /* GMime >= 3.0 */
typedef GMimeAddressType GMimeRecipientType;
#define internet_address_to_string(ia,encode) internet_address_to_string (ia,NULL,encode)
#define internet_address_list_parse_string(str) internet_address_list_parse (NULL,str)
typedef GMimeAddressType GMimeRecipientType;
+
+typedef GMimeSignatureStatus GMimeSignatureError;
+
#endif
/**
InternetAddressList * g_mime_message_get_from (GMimeMessage *message);
+
/**
* return string for From: address
* (owned by gmime)
* return talloc allocated reply-to string
*/
char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
+
+void g_mime_parser_set_scan_from (GMimeParser *parser, gboolean flag);
+
+gboolean g_mime_signature_status_good (GMimeSignatureStatus status);
+
+gboolean g_mime_signature_status_bad (GMimeSignatureStatus status);
+
+gboolean g_mime_signature_status_error (GMimeSignatureError status);
#endif