[PATCH v2 03/15] gmime-cleanup: remove GMime 2.6 variant codeblocks

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu May 2 06:19:35 PDT 2019


signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
---
 lib/message-file.c | 42 ---------------------
 notmuch-show.c     | 21 -----------
 util/gmime-extra.c | 93 ----------------------------------------------
 util/gmime-extra.h | 12 ------
 4 files changed, 168 deletions(-)

diff --git a/lib/message-file.c b/lib/message-file.c
index 8f0dbbda..ac5545b3 100644
--- a/lib/message-file.c
+++ b/lib/message-file.c
@@ -238,47 +238,6 @@ _extend_header (char *combined, const char *value) {
     return combined;
 }
 
-#if (GMIME_MAJOR_VERSION < 3)
-static char *
-_notmuch_message_file_get_combined_header (notmuch_message_file_t *message,
-					   const char *header)
-{
-    GMimeHeaderList *headers;
-    GMimeHeaderIter *iter;
-    char *combined = NULL;
-
-    headers = g_mime_object_get_header_list (GMIME_OBJECT (message->message));
-    if (! headers)
-	return NULL;
-
-    iter = g_mime_header_iter_new ();
-    if (! iter)
-	return NULL;
-
-    if (! g_mime_header_list_get_iter (headers, iter))
-	goto DONE;
-
-    do {
-	const char *value;
-	if (strcasecmp (g_mime_header_iter_get_name (iter), header) != 0)
-	    continue;
-
-	/* Note that GMime retains ownership of value... */
-	value = g_mime_header_iter_get_value (iter);
-
-	combined = _extend_header (combined, value);
-    } while (g_mime_header_iter_next (iter));
-
-    /* Return empty string for non-existing headers. */
-    if (! combined)
-	combined = g_strdup ("");
-
-  DONE:
-    g_mime_header_iter_free (iter);
-
-    return combined;
-}
-#else
 static char *
 _notmuch_message_file_get_combined_header (notmuch_message_file_t *message,
 					   const char *header)
@@ -310,7 +269,6 @@ _notmuch_message_file_get_combined_header (notmuch_message_file_t *message,
 
     return combined;
 }
-#endif
 
 const char *
 _notmuch_message_file_get_header (notmuch_message_file_t *message,
diff --git a/notmuch-show.c b/notmuch-show.c
index 4ed5ff2b..ad7cf122 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -383,26 +383,6 @@ do_format_signature_errors (sprinter_t *sp, struct key_map_struct *key_map,
     sp->end (sp);
 }
 
-#if (GMIME_MAJOR_VERSION < 3)
-static void
-format_signature_errors (sprinter_t *sp, GMimeSignature *signature)
-{
-    GMimeSignatureError errors = g_mime_signature_get_errors (signature);
-
-    if (errors == GMIME_SIGNATURE_ERROR_NONE)
-	return;
-
-    struct key_map_struct key_map[] = {
-	{ GMIME_SIGNATURE_ERROR_EXPSIG, "sig-expired" },
-	{ GMIME_SIGNATURE_ERROR_NO_PUBKEY, "key-missing"},
-	{ GMIME_SIGNATURE_ERROR_EXPKEYSIG, "key-expired"},
-	{ GMIME_SIGNATURE_ERROR_REVKEYSIG, "key-revoked"},
-	{ GMIME_SIGNATURE_ERROR_UNSUPP_ALGO, "alg-unsupported"},
-    };
-
-    do_format_signature_errors (sp, key_map, ARRAY_SIZE(key_map), errors);
-}
-#else
 static void
 format_signature_errors (sprinter_t *sp, GMimeSignature *signature)
 {
@@ -425,7 +405,6 @@ format_signature_errors (sprinter_t *sp, GMimeSignature *signature)
 
     do_format_signature_errors (sp, key_map, ARRAY_SIZE(key_map), errors);
 }
-#endif
 
 /* Signature status sprinter */
 static void
diff --git a/util/gmime-extra.c b/util/gmime-extra.c
index bc1e3c4d..4b577a5b 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -31,97 +31,6 @@ g_string_talloc_strdup (void *ctx, char *g_string)
     return new_str;
 }
 
-#if (GMIME_MAJOR_VERSION < 3)
-
-const char *
-g_mime_certificate_get_valid_userid (GMimeCertificate *cert)
-{
-    /* output user id only if validity is FULL or ULTIMATE. */
-    /* note that gmime 2.6 is using the term "trust" here, which
-     * is WRONG.  It's actually user id "validity". */
-    const char *name = g_mime_certificate_get_name (cert);
-    if (name == NULL)
-	return name;
-    GMimeCertificateTrust trust = g_mime_certificate_get_trust (cert);
-    if (trust == GMIME_CERTIFICATE_TRUST_FULLY || trust == GMIME_CERTIFICATE_TRUST_ULTIMATE)
-	return name;
-    return NULL;
-}
-
-char *
-g_mime_message_get_address_string (GMimeMessage *message, GMimeRecipientType type)
-{
-    InternetAddressList *list = g_mime_message_get_recipients (message, type);
-    return internet_address_list_to_string (list, 0);
-}
-
-inline InternetAddressList *
-g_mime_message_get_addresses (GMimeMessage *message, GMimeRecipientType type)
-{
-    return g_mime_message_get_recipients (message, type);
-}
-
-char *
-g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
-{
-    char *date = g_mime_message_get_date_as_string (message);
-    return g_string_talloc_strdup (ctx, date);
-}
-
-InternetAddressList *
-g_mime_message_get_from (GMimeMessage *message)
-{
-    return internet_address_list_parse_string (g_mime_message_get_sender (message));
-}
-
-const char *
-g_mime_message_get_from_string (GMimeMessage *message) {
-    return  g_mime_message_get_sender (message);
-}
-
-InternetAddressList *
-g_mime_message_get_reply_to_list (GMimeMessage *message)
-{
-    const char *reply_to;
-
-    reply_to = g_mime_message_get_reply_to (message);
-    if (reply_to && *reply_to)
-	return internet_address_list_parse_string (reply_to);
-    else
-	return NULL;
-}
-
-/**
- * return talloc allocated reply-to string
- */
-char *
-g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message)
-{
-    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);
-}
-
-gint64
-g_mime_utils_header_decode_date_unix (const char *date) {
-    return (gint64) g_mime_utils_header_decode_date (date, NULL);
-}
-
-#else /* GMime >= 3.0 */
-
 const char *
 g_mime_certificate_get_valid_userid (GMimeCertificate *cert)
 {
@@ -223,5 +132,3 @@ g_mime_utils_header_decode_date_unix (const char *date) {
 
     return ret;
 }
-
-#endif
diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index 5d8c52f7..d539ec3a 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -9,17 +9,6 @@ extern "C" {
 
 GMimeStream *g_mime_stream_stdout_new(void);
 
-#if (GMIME_MAJOR_VERSION < 3)
-
-#define GMIME_ADDRESS_TYPE_TO GMIME_RECIPIENT_TYPE_TO
-#define GMIME_ADDRESS_TYPE_CC GMIME_RECIPIENT_TYPE_CC
-#define GMIME_ADDRESS_TYPE_BCC GMIME_RECIPIENT_TYPE_BCC
-
-#define g_mime_2_6_unref(obj) g_object_unref (obj)
-#define g_mime_3_unused(arg) arg
-#define g_mime_certificate_get_fpr16(cert) g_mime_certificate_get_key_id (cert)
-#else /* GMime >= 3.0 */
-
 #define GMIME_ENABLE_RFC_2047_WORKAROUNDS 0xdeadbeef
 #define g_mime_content_type_to_string(c) g_mime_content_type_get_mime_type (c)
 #define g_mime_filter_crlf_new(encode,dots) g_mime_filter_dos2unix_new (FALSE)
@@ -47,7 +36,6 @@ typedef GMimeSignatureStatus GMimeSignatureError;
 
 #define g_mime_2_6_unref(obj) /*ignore*/
 #define g_mime_3_unused(arg) unused(arg)
-#endif
 
 /**
  * Get last 16 hex digits of fingerprint ("keyid")
-- 
2.20.1



More information about the notmuch mailing list