[balsa] balsa-message: Pass message headers to handler



commit 8ab10b41a35afda8648fcc119f3438c0978c1a94
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sat Jul 13 22:26:44 2019 -0400

    balsa-message: Pass message headers to handler
    
    Pass message headers to disposition-notify handler
    
    * src/balsa-message.c (balsa_message_set), (handle_mdn_request):

 ChangeLog           |  6 ++++++
 src/balsa-message.c | 29 +++++++++++++++--------------
 2 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6eeaa5ca3..e8d8ad488 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-07-13  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       balsa-message: Pass message headers to disposition-notify handler
+
+       * src/balsa-message.c (balsa_message_set), (handle_mdn_request):
+
 2019-07-11  Peter Bloomfield  <pbloomfield bellsouth net>
 
        message: Declare it final
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 323bed37b..242a2ec72 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -137,7 +137,8 @@ static void part_create_menu (BalsaPartInfo* info);
 static GtkNotebookClass *parent_class = NULL;
 
 /* stuff needed for sending Message Disposition Notifications */
-static void handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message);
+static void handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message,
+                               LibBalsaMessageHeaders *headers);
 static LibBalsaMessage *create_mdn_reply (const LibBalsaIdentity *mdn_ident,
                                           LibBalsaMessage *for_msg,
                                           gboolean manual);
@@ -1224,8 +1225,11 @@ balsa_message_set(BalsaMessage * bm, LibBalsaMailbox * mailbox, guint msgno)
      * present.
      *
      */
-    if (is_new && (libbalsa_message_get_headers(message)->dispnotify_to != NULL)) {
-        handle_mdn_request (balsa_get_parent_window(GTK_WIDGET(bm)), message);
+    if (is_new) {
+        LibBalsaMessageHeaders *headers = libbalsa_message_get_headers(message);
+
+        if (headers != NULL && headers->dispnotify_to != NULL)
+            handle_mdn_request(balsa_get_parent_window(GTK_WIDGET(bm)), message, headers);
     }
 
 #ifdef ENABLE_AUTOCRYPT
@@ -2411,9 +2415,10 @@ bm_get_mailbox(InternetAddressList * list)
 }
 
 static void
-handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message)
+handle_mdn_request(GtkWindow *parent,
+                   LibBalsaMessage *message,
+                   LibBalsaMessageHeaders *headers)
 {
-    LibBalsaMessageHeaders *headers;
     gboolean suspicious;
     InternetAddressList *use_from = NULL;
     InternetAddressList *list;
@@ -2423,16 +2428,12 @@ handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message)
     LibBalsaIdentity *mdn_ident = NULL;
     gint i, len;
 
-    headers = libbalsa_message_get_headers(message);
-
     /* Check if the dispnotify_to address is equal to the (in this order,
        if present) reply_to, from or sender address. */
-    if (headers != NULL) {
-        if (headers->reply_to != NULL) {
-            use_from = headers->reply_to;
-        } else if (headers->from != NULL) {
-            use_from = headers->from;
-        }
+    if (headers->reply_to != NULL) {
+        use_from = headers->reply_to;
+    } else if (headers->from != NULL) {
+        use_from = headers->from;
     }
     if (use_from == NULL) {
         InternetAddressList *sender;
@@ -2446,7 +2447,7 @@ handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message)
     /* note: neither Disposition-Notification-To: nor Reply-To:, From: or
        Sender: may be address groups */
     from = use_from ? internet_address_list_get_address (use_from, 0) : NULL;
-    dn = internet_address_list_get_address (headers->dispnotify_to, 0);
+    dn = internet_address_list_get_address(headers->dispnotify_to, 0);
     suspicious = !libbalsa_ia_rfc2821_equal(dn, from);
 
     /* Try to find "my" identity first in the to, then in the cc list */


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