Improve debug output for attachment handling
authorAndre Heinecke <aheinecke@gnupg.org>
Tue, 28 May 2019 08:14:44 +0000 (10:14 +0200)
committerAndre Heinecke <aheinecke@gnupg.org>
Tue, 28 May 2019 08:14:44 +0000 (10:14 +0200)
* src/mapihelp.cpp (mapi_create_attach_table): Debug attach
method and type.
* src/mimemaker.cpp (write_attachments): Log when attachments
are skipped.

src/mapihelp.cpp
src/mimemaker.cpp

index 96b5240..90005a5 100644 (file)
@@ -2539,11 +2539,12 @@ mapi_create_attach_table (LPMESSAGE message, int fast)
       log_debug ("%s:%s: attachment info:\n", SRCNAME, __func__);
       for (pos=0; !table[pos].end_of_table; pos++)
         {
-          log_debug ("\t%d mt=%d fname=`%s' ct=`%s' ct_parms=`%s'\n",
+          log_debug ("\t%d mt=%d fname=`%s' ct=`%s' ct_parms=`%s' method:%d\n",
                      table[pos].mapipos,
                      table[pos].attach_type,
                      anonstr (table[pos].filename), table[pos].content_type,
-                     table[pos].content_type_parms);
+                     table[pos].content_type_parms,
+                     table[pos].method);
         }
     }
 
index 79834b8..296209a 100644 (file)
@@ -1052,44 +1052,48 @@ write_attachments (sink_t sink,
               }
             xfree (buffer);
           }
-        else
-          {
-            if (!only_related && !warning_shown
+        else if (!only_related && !warning_shown
                 && table[idx].attach_type == ATTACHTYPE_UNKNOWN
                 && (table[idx].method == ATTACH_OLE
                     || table[idx].method == ATTACH_EMBEDDED_MSG))
+          {
+            char *fmt;
+            log_debug ("%s:%s: detected OLE attachment. Showing warning.",
+                       SRCNAME, __func__);
+            gpgrt_asprintf (&fmt, _("The attachment '%s' is an Outlook item "
+                                    "which is currently unsupported in crypto mails."),
+                            table[idx].filename ?
+                            table[idx].filename : _("Unknown"));
+            std::string msg = fmt;
+            msg += "\n\n";
+            xfree (fmt);
+
+            gpgrt_asprintf (&fmt, _("Please encrypt '%s' with Kleopatra "
+                                    "and attach it as a file."),
+                            table[idx].filename ?
+                            table[idx].filename : _("Unknown"));
+            msg += fmt;
+            xfree (fmt);
+
+            msg += "\n\n";
+            msg += _("Send anyway?");
+            warning_shown = true;
+
+            if (gpgol_message_box (get_active_hwnd (),
+                                   msg.c_str (),
+                                   _("Sorry, that's not possible, yet"),
+                                   MB_APPLMODAL | MB_YESNO) == IDNO)
               {
-                char *fmt;
-                log_debug ("%s:%s: detected OLE attachment. Showing warning.",
-                           SRCNAME, __func__);
-                gpgrt_asprintf (&fmt, _("The attachment '%s' is an Outlook item "
-                                        "which is currently unsupported in crypto mails."),
-                                table[idx].filename ?
-                                table[idx].filename : _("Unknown"));
-                std::string msg = fmt;
-                msg += "\n\n";
-                xfree (fmt);
-
-                gpgrt_asprintf (&fmt, _("Please encrypt '%s' with Kleopatra "
-                                        "and attach it as a file."),
-                                table[idx].filename ?
-                                table[idx].filename : _("Unknown"));
-                msg += fmt;
-                xfree (fmt);
-
-                msg += "\n\n";
-                msg += _("Send anyway?");
-                warning_shown = true;
-
-                if (gpgol_message_box (get_active_hwnd (),
-                                       msg.c_str (),
-                                       _("Sorry, that's not possible, yet"),
-                                       MB_APPLMODAL | MB_YESNO) == IDNO)
-                  {
-                    return -1;
-                  }
+                return -1;
               }
           }
+        else
+          {
+            log_debug ("%s:%s: Skipping unknown attachment at idx: %d type: %d"
+                       " with method: %d",
+                       SRCNAME, __func__, idx, table[idx].attach_type,
+                       table[idx].method);
+          }
       }
   return 0;
 }