[balsa/gmime3: 5/49] More GMime 3 changes



commit 459aba6656def5971c548197513e13df3a43a3a6
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Nov 20 19:10:44 2019 -0800

    More GMime 3 changes
    
    g_mime_utils_header_decode_text() now has a parser-options argument;
    g_mime_message_get_date() now returns a GDateTime * pointer, and the
    object needs to be unreffed.

 libbalsa/body.c         | 11 +++++++----
 libbalsa/mailbox_imap.c | 10 +++++-----
 libbalsa/message.c      | 15 ++++++++++-----
 src/sendmsg-window.c    |  2 +-
 4 files changed, 23 insertions(+), 15 deletions(-)
---
diff --git a/libbalsa/body.c b/libbalsa/body.c
index 0aea5118c..e8d5c9b2a 100644
--- a/libbalsa/body.c
+++ b/libbalsa/body.c
@@ -102,7 +102,7 @@ libbalsa_message_body_extract_embedded_headers(GMimeMessage* msg)
 {
     LibBalsaMessageHeaders *ehdr;
     const char *subj;
-    int offset;
+    GDateTime *datetime;
 
     ehdr = g_new0(LibBalsaMessageHeaders, 1);
 
@@ -112,11 +112,14 @@ libbalsa_message_body_extract_embedded_headers(GMimeMessage* msg)
     subj = g_mime_message_get_subject(msg);
     if (subj) {
        ehdr->subject =
-           g_mime_utils_header_decode_text(subj);
+           g_mime_utils_header_decode_text(libbalsa_parser_options(), subj);
        libbalsa_utf8_sanitize(&ehdr->subject, TRUE, NULL);
-    } else 
+    } else
        ehdr->subject = g_strdup(_("(No subject)"));
-    g_mime_message_get_date(msg, &ehdr->date, &offset);
+
+    datetime = g_mime_message_get_date(msg);
+    ehdr->date = g_date_time_to_unix(datetime);
+    g_date_time_unref(datetime);
 
     return ehdr;
 }
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index 1fa80f977..20fbc49d2 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -1899,11 +1899,11 @@ libbalsa_mailbox_imap_sync(LibBalsaMailbox * mailbox, gboolean expunge)
 static InternetAddress*
 imap_address_to_gmime_mailbox(ImapAddress *addr)
 {
-    gchar *tmp = g_mime_utils_header_decode_text(addr->addr_spec);
+    gchar *tmp = g_mime_utils_header_decode_text(libbalsa_parser_options(), addr->addr_spec);
     InternetAddress *address = internet_address_mailbox_new(NULL, tmp);
     g_free(tmp);
     if (addr->name) {
-        tmp = g_mime_utils_header_decode_text(addr->name);
+        tmp = g_mime_utils_header_decode_text(libbalsa_parser_options(), addr->name);
         internet_address_set_name(address, tmp);
         g_free(tmp);
     }
@@ -1930,7 +1930,7 @@ internet_address_new_list_from_imap_address(ImapAddress *list,
                 /* Group head */
                 ImapAddress *imap_addr = NULL;
                 InternetAddressList *l;
-                gchar *tmp = g_mime_utils_header_decode_text(list->name);
+                gchar *tmp = g_mime_utils_header_decode_text(libbalsa_parser_options(), list->name);
                 addr = internet_address_group_new(tmp);
                 g_free(tmp);
                 l = internet_address_new_list_from_imap_address(list->next,
@@ -1980,7 +1980,7 @@ lb_set_headers(LibBalsaMessageHeaders *headers, ImapEnvelope *  envelope,
 
     if(is_embedded) {
         headers->subject =
-            g_mime_utils_header_decode_text(envelope->subject);
+            g_mime_utils_header_decode_text(libbalsa_parser_options(), envelope->subject);
         libbalsa_utf8_sanitize(&headers->subject, TRUE, NULL);
     }
 }
@@ -2114,7 +2114,7 @@ lbm_imap_construct_body(LibBalsaMessageBody *lbbody, ImapBody *imap_body)
     if(!str) str = imap_body_get_param(imap_body, "name");
     if(str) {
         lbbody->filename  =
-           g_mime_utils_header_decode_text(str);
+           g_mime_utils_header_decode_text(libbalsa_parser_options(), str);
         libbalsa_utf8_sanitize(&lbbody->filename, TRUE, NULL);
     }
     lbbody->charset   = g_strdup(imap_body_get_param(imap_body, "charset"));
diff --git a/libbalsa/message.c b/libbalsa/message.c
index 5aa0e442f..cf4171316 100644
--- a/libbalsa/message.c
+++ b/libbalsa/message.c
@@ -501,7 +501,7 @@ prepend_header_misc(GList      *res,
     return
         g_list_prepend(res,
                        libbalsa_create_hdr_pair(name,
-                                                g_mime_utils_header_decode_text(value)));
+                                                g_mime_utils_header_decode_text(libbalsa_parser_options(), 
value)));
 }
 
 /* 
@@ -565,7 +565,7 @@ libbalsa_message_user_hdrs_from_gmime(GMimeMessage * message)
             g_list_prepend(res,
                            libbalsa_create_hdr_pair
                                ("In-Reply-To",
-                               g_mime_utils_header_decode_text(value)));
+                               g_mime_utils_header_decode_text(libbalsa_parser_options(), value)));
     }
 
     hdrlist = g_mime_object_get_header_list (GMIME_OBJECT(message));
@@ -993,8 +993,13 @@ lb_message_headers_basic_from_gmime(LibBalsaMessageHeaders *headers,
     if (headers->from == NULL)
         headers->from = internet_address_list_parse(libbalsa_parser_options(), mime_msg->from);
 
-    if (headers->date == 0)
-        g_mime_message_get_date(mime_msg, &headers->date, NULL);
+    if (headers->date == 0) {
+        GDateTime *datetime;
+
+        datetime = g_mime_message_get_date(mime_msg);
+        headers->date = g_date_time_to_unix(datetime);
+        g_date_time_unref(datetime);
+    }
 
     if (headers->to_list == NULL) {
         headers->to_list =
@@ -1471,7 +1476,7 @@ libbalsa_message_set_subject_from_header(LibBalsaMessage *message,
 
     if (header) {
         gchar *subject =
-            g_mime_utils_header_decode_text(header);
+            g_mime_utils_header_decode_text(libbalsa_parser_options(), header);
         libbalsa_message_set_subject(message, subject);
         g_free(subject);
     }
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 6f4c8b241..0b6994610 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -1646,7 +1646,7 @@ get_fwd_mail_headers(const gchar *mailfile)
        if (!subject)
            headers->subject = g_strdup(_("(no subject)"));
        else
-           headers->subject = g_mime_utils_header_decode_text(subject);
+           headers->subject = g_mime_utils_header_decode_text(libbalsa_parser_options(), subject);
     }
     libbalsa_utf8_sanitize(&headers->subject,
                           balsa_app.convert_unknown_8bit,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]