[git] GpgOL - branch, nomapi, updated. gpgol-1.4.0-117-gd90adfc

by Andre Heinecke cvs at cvs.gnupg.org
Thu Oct 20 14:19:38 CEST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, nomapi has been updated
       via  d90adfc3d5e7b8aed8040f483a91914771ba2429 (commit)
       via  318ba6646a5564fdbde2eec027b84f2b3825d6bb (commit)
       via  1c0f6b6ac6281c13bd004ba4118aa88a12c50dc2 (commit)
      from  cb089330c44f37412a47501660b09d09cc382c45 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d90adfc3d5e7b8aed8040f483a91914771ba2429
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Oct 20 14:17:49 2016 +0200

    Convert mimemaker to cpp
    
    * src/Makefile.am (GpgOL_SOURCES): Update.
    * src/mimemaker.c: Removed.
    * src/mimemaker.cpp: New.

diff --git a/src/Makefile.am b/src/Makefile.am
index 4f242df..ae4ad97 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -41,7 +41,7 @@ gpgol_SOURCES = \
 	message.cpp message.h       \
 	revert.cpp revert.h         \
 	mimeparser.c mimeparser.h   \
-	mimemaker.c mimemaker.h     \
+	mimemaker.cpp mimemaker.h     \
 	msgcache.c msgcache.h       \
 	engine.c engine.h           \
         engine-assuan.c engine-assuan.h \
diff --git a/src/mimemaker.c b/src/mimemaker.cpp
similarity index 96%
rename from src/mimemaker.c
rename to src/mimemaker.cpp
index 235b844..56c9d9a 100644
--- a/src/mimemaker.c
+++ b/src/mimemaker.cpp
@@ -41,8 +41,9 @@
 #include "mapihelp.h"
 #include "mimemaker.h"
 #include "oomhelp.h"
+#include "gpgolstr.h"
 
-static const char oid_mimetag[] =
+static const unsigned char oid_mimetag[] =
     {0x2A, 0x86, 0x48, 0x86, 0xf7, 0x14, 0x03, 0x0a, 0x04};
 
 /* The base-64 list used for base64 encoding. */
@@ -73,7 +74,7 @@ int
 sink_std_write (sink_t sink, const void *data, size_t datalen)
 {
   HRESULT hr;
-  LPSTREAM stream = sink->cb_data;
+  LPSTREAM stream = static_cast<LPSTREAM>(sink->cb_data);
 
   if (!stream)
     {
@@ -83,7 +84,7 @@ sink_std_write (sink_t sink, const void *data, size_t datalen)
   if (!data)
     return 0;  /* Flush - nothing to do here.  */
 
-  hr = IStream_Write (stream, data, datalen, NULL);
+  hr = stream->Write(data, datalen, NULL);
   if (hr)
     {
       log_error ("%s:%s: Write failed: hr=%#lx", SRCNAME, __func__, hr);
@@ -97,7 +98,7 @@ int
 sink_file_write (sink_t sink, const void *data, size_t datalen)
 {
   HANDLE hFile = sink->cb_data;
-  DWORD written = NULL;
+  DWORD written = 0;
 
   if (!hFile || hFile == INVALID_HANDLE_VALUE)
     {
@@ -152,7 +153,7 @@ create_mapi_attachment (LPMESSAGE message, sink_t sink)
 
   sink->cb_data = NULL;
   sink->writefnc = NULL;
-  hr = IMessage_CreateAttach (message, NULL, 0, &pos, &att);
+  hr = message->CreateAttach(NULL, 0, &pos, &att);
   if (hr)
     {
       log_error ("%s:%s: can't create attachment: hr=%#lx\n",
@@ -185,7 +186,7 @@ create_mapi_attachment (LPMESSAGE message, sink_t sink)
 
   /* We better insert a short filename. */
   prop.ulPropTag = PR_ATTACH_FILENAME_A;
-  prop.Value.lpszA = MIMEATTACHFILENAME;
+  prop.Value.lpszA = GpgOLStr (MIMEATTACHFILENAME);
   hr = HrSetOneProp ((LPMAPIPROP)att, &prop);
   if (hr)
     {
@@ -205,7 +206,7 @@ create_mapi_attachment (LPMESSAGE message, sink_t sink)
   if (!hr)
     {
       prop.ulPropTag = PR_ATTACH_MIME_TAG_A;
-      prop.Value.lpszA = "multipart/signed";
+      prop.Value.lpszA = GpgOLStr("multipart/signed");
       hr = HrSetOneProp ((LPMAPIPROP)att, &prop);
     }
   if (hr)
@@ -216,8 +217,8 @@ create_mapi_attachment (LPMESSAGE message, sink_t sink)
     }
 
   punk = NULL;
-  hr = IAttach_OpenProperty (att, PR_ATTACH_DATA_BIN, &IID_IStream, 0,
-                             (MAPI_CREATE|MAPI_MODIFY), &punk);
+  hr = att->OpenProperty(PR_ATTACH_DATA_BIN, &IID_IStream, 0,
+                         (MAPI_CREATE|MAPI_MODIFY), &punk);
   if (FAILED (hr))
     {
       log_error ("%s:%s: can't create output stream: hr=%#lx\n",
@@ -229,7 +230,7 @@ create_mapi_attachment (LPMESSAGE message, sink_t sink)
   return att;
 
  failure:
-  IAttach_Release (att);
+  gpgol_release (att);
   return NULL;
 }
 
@@ -252,7 +253,7 @@ write_buffer (sink_t sink, const void *data, size_t datalen)
 int
 write_buffer_for_cb (void *opaque, const void *data, size_t datalen)
 {
-  sink_t sink = opaque;
+  sink_t sink = (sink_t) opaque;
   sink->enc_counter += datalen;
   return write_buffer (sink, data, datalen) ? -1 : datalen;
 }
@@ -318,7 +319,7 @@ write_b64 (sink_t sink, const void *data, size_t datalen)
   log_debug ("  writing base64 of length %d\n", (int)datalen);
   idx = quads = 0;
   outlen = 0;
-  for (p = data; datalen; p++, datalen--)
+  for (p = (const unsigned char*)data; datalen; p++, datalen--)
     {
       inbuf[idx++] = *p;
       if (idx > 2)
@@ -419,7 +420,7 @@ write_qp (sink_t sink, const void *data, size_t datalen)
 
   log_debug ("  writing qp of length %d\n", (int)datalen);
   outidx = 0;
-  for (p = data; datalen; p++, datalen--)
+  for (p = (const unsigned char*) data; datalen; p++, datalen--)
     {
       if ((datalen > 1 && *p == '\r' && p[1] == '\n') || *p == '\n')
         {
@@ -507,7 +508,7 @@ write_plain (sink_t sink, const void *data, size_t datalen)
 
   log_debug ("  writing ascii of length %d\n", (int)datalen);
   outidx = 0;
-  for (p = data; datalen; p++, datalen--)
+  for (p = (const unsigned char*) data; datalen; p++, datalen--)
     {
       if ((datalen > 1 && *p == '\r' && p[1] == '\n') || *p == '\n')
         {
@@ -725,7 +726,7 @@ infer_content_encoding (const void *data, size_t datalen)
   ntotal = datalen;
   len = maxlen = lowbin = highbin = 0;
   need_qp = 0;
-  for (p = data; datalen; p++, datalen--)
+  for (p = (const unsigned char*) data; datalen; p++, datalen--)
     {
       len++;
       if ((*p & 0x80))
@@ -1012,7 +1013,7 @@ delete_all_attachments (LPMESSAGE message, mapi_attach_item_t *table)
             && table[idx].filename
             && !strcmp (table[idx].filename, MIMEATTACHFILENAME))
           continue;
-        hr = IMessage_DeleteAttach (message, table[idx].mapipos, 0, NULL, 0);
+        hr = message->DeleteAttach (table[idx].mapipos, 0, NULL, 0);
         if (hr)
           {
             log_error ("%s:%s: DeleteAttach failed: hr=%#lx\n",
@@ -1033,30 +1034,30 @@ static int
 close_mapi_attachment (LPATTACH *attach, sink_t sink)
 {
   HRESULT hr;
-  LPSTREAM stream = sink? sink->cb_data : NULL;
+  LPSTREAM stream = sink ? (LPSTREAM) sink->cb_data : NULL;
 
   if (!stream)
     {
       log_error ("%s:%s: sink not setup", SRCNAME, __func__);
       return -1;
     }
-  hr = IStream_Commit (stream, 0);
+  hr = stream->Commit (0);
   if (hr)
     {
       log_error ("%s:%s: Commiting output stream failed: hr=%#lx",
                  SRCNAME, __func__, hr);
       return -1;
     }
-  IStream_Release (stream);
+  gpgol_release (stream);
   sink->cb_data = NULL;
-  hr = IAttach_SaveChanges (*attach, 0);
+  hr = (*attach)->SaveChanges (0);
   if (hr)
     {
       log_error ("%s:%s: SaveChanges of the attachment failed: hr=%#lx\n",
                  SRCNAME, __func__, hr);
       return -1;
     }
-  IAttach_Release (*attach);
+  gpgol_release ((*attach));
   *attach = NULL;
   return 0;
 }
@@ -1069,18 +1070,18 @@ close_mapi_attachment (LPATTACH *attach, sink_t sink)
 static void
 cancel_mapi_attachment (LPATTACH *attach, sink_t sink)
 {
-  LPSTREAM stream = sink? sink->cb_data : NULL;
+  LPSTREAM stream = sink ? (LPSTREAM) sink->cb_data : NULL;
 
   if (stream)
     {
-      IStream_Revert (stream);
-      IStream_Release (stream);
+      stream->Revert();
+      gpgol_release (stream);
       sink->cb_data = NULL;
     }
   if (*attach)
     {
       /* Fixme: Should we try to delete it or is there a Revert method? */
-      IAttach_Release (*attach);
+      gpgol_release ((*attach));
       *attach = NULL;
     }
 }
@@ -1097,8 +1098,8 @@ finalize_message (LPMESSAGE message, mapi_attach_item_t *att_table,
 
   /* Set the message class.  */
   prop.ulPropTag = PR_MESSAGE_CLASS_A;
-  prop.Value.lpszA = "IPM.Note.SMIME.MultipartSigned";
-  hr = IMessage_SetProps (message, 1, &prop, NULL);
+  prop.Value.lpszA = GpgOLStr ("IPM.Note.SMIME.MultipartSigned");
+  hr = message->SetProps(1, &prop, NULL);
   if (hr)
     {
       log_error ("%s:%s: error setting the message class: hr=%#lx\n",
@@ -1143,7 +1144,7 @@ static int
 sink_hashing_write (sink_t hashsink, const void *data, size_t datalen)
 {
   int rc;
-  engine_filter_t filter = hashsink->cb_data;
+  engine_filter_t filter = (engine_filter_t) hashsink->cb_data;
 
   if (!filter || !hashsink->extrasink)
     {
@@ -1163,12 +1164,12 @@ sink_hashing_write (sink_t hashsink, const void *data, size_t datalen)
 static int
 collect_signature (void *opaque, const void *data, size_t datalen)
 {
-  struct databuf_s *db = opaque;
+  struct databuf_s *db = (databuf_s *)opaque;
 
   if (db->len + datalen >= db->size)
     {
       db->size += datalen + 1024;
-      db->buf = xrealloc (db->buf, db->size);
+      db->buf = (char*) xrealloc (db->buf, db->size);
     }
   memcpy (db->buf + db->len, data, datalen);
   db->len += datalen;
@@ -1402,10 +1403,10 @@ do_mime_sign (LPMESSAGE message, HWND hwnd, protocol_t protocol,
   {
     HRESULT hr;
     LARGE_INTEGER off;
-    LPSTREAM stream = sink->cb_data;
+    LPSTREAM stream = (LPSTREAM) sink->cb_data;
 
     off.QuadPart = 0;
-    hr = IStream_Seek (stream, off, STREAM_SEEK_SET, NULL);
+    hr = stream->Seek (off, STREAM_SEEK_SET, NULL);
     if (hr)
       {
         log_error ("%s:%s: seeking back to the begin failed: hr=%#lx",
@@ -1417,7 +1418,7 @@ do_mime_sign (LPMESSAGE message, HWND hwnd, protocol_t protocol,
                                protocol, 1, boundary,
                                protocol == PROTOCOL_SMIME? "sha1":"pgp-sha1");
 
-    hr = IStream_Write (stream, top_header, strlen (top_header), NULL);
+    hr = stream->Write (top_header, strlen (top_header), NULL);
     if (hr)
       {
         log_error ("%s:%s: writing fixed micalg failed: hr=%#lx",
@@ -1427,7 +1428,7 @@ do_mime_sign (LPMESSAGE message, HWND hwnd, protocol_t protocol,
 
     /* Better seek again to the end. */
     off.QuadPart = 0;
-    hr = IStream_Seek (stream, off, STREAM_SEEK_END, NULL);
+    hr = stream->Seek (off, STREAM_SEEK_END, NULL);
     if (hr)
       {
         log_error ("%s:%s: seeking back to the end failed: hr=%#lx",
@@ -1491,7 +1492,7 @@ mime_sign (LPMESSAGE message, HWND hwnd, protocol_t protocol,
 int
 sink_encryption_write (sink_t encsink, const void *data, size_t datalen)
 {
-  engine_filter_t filter = encsink->cb_data;
+  engine_filter_t filter = (engine_filter_t) encsink->cb_data;
 
   if (!filter)
     {
@@ -1874,7 +1875,7 @@ mime_sign_encrypt (LPMESSAGE message, HWND hwnd,
   hr = OpenStreamOnFile (MAPIAllocateBuffer, MAPIFreeBuffer,
                          (SOF_UNIQUEFILENAME | STGM_DELETEONRELEASE
                           | STGM_CREATE | STGM_READWRITE),
-                         NULL, "GPG", &tmpstream);
+                         NULL, GpgOLStr("GPG"), &tmpstream);
   if (FAILED (hr))
     {
       log_error ("%s:%s: can't create temp file: hr=%#lx\n",
@@ -1953,7 +1954,7 @@ mime_sign_encrypt (LPMESSAGE message, HWND hwnd,
     char buffer[4096];
 
     off.QuadPart = 0;
-    hr = IStream_Seek (tmpstream, off, STREAM_SEEK_SET, NULL);
+    hr = tmpstream->Seek (off, STREAM_SEEK_SET, NULL);
     if (hr)
       {
         log_error ("%s:%s: seeking back to the begin failed: hr=%#lx",
@@ -1964,7 +1965,7 @@ mime_sign_encrypt (LPMESSAGE message, HWND hwnd,
 
     for (;;)
       {
-        hr = IStream_Read (tmpstream, buffer, sizeof buffer, &nread);
+        hr = tmpstream->Read (buffer, sizeof buffer, &nread);
         if (hr)
           {
             log_error ("%s:%s: IStream::Read failed: hr=%#lx",
@@ -2017,8 +2018,7 @@ mime_sign_encrypt (LPMESSAGE message, HWND hwnd,
     log_debug ("%s:%s: failed rc=%d (%s) <%s>", SRCNAME, __func__, rc,
                gpg_strerror (rc), gpg_strsource (rc));
   engine_cancel (filter);
-  if (tmpstream)
-    IStream_Release (tmpstream);
+  gpgol_release (tmpstream);
   mapi_release_attach_table (att_table);
   xfree (my_sender);
   return result;

commit 318ba6646a5564fdbde2eec027b84f2b3825d6bb
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Oct 20 14:16:48 2016 +0200

    Convert body encoding using mlang
    
    * src/mail.cpp (Mail::update_body): Convert bodies.

diff --git a/src/mail.cpp b/src/mail.cpp
index efe5a29..4a5c67e 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -33,6 +33,7 @@
 #include "parsecontroller.h"
 #include "gpgolstr.h"
 #include "windowmessages.h"
+#include "mlang-charset.h"
 
 #include <gpgme++/tofuinfo.h>
 #include <gpgme++/verificationresult.h>
@@ -555,23 +556,28 @@ Mail::update_body()
   const auto html = m_parser->get_html_body();
   if (!html.empty())
     {
-      if (put_oom_string (m_mailitem, "HTMLBody", html.c_str()))
+      char *converted = ansi_charset_to_utf8 (m_parser->get_html_charset().c_str(),
+                                              html.c_str(), html.size());
+      int ret = put_oom_string (m_mailitem, "HTMLBody", converted ? converted : "");
+      xfree (converted);
+      if (ret)
         {
           log_error ("%s:%s: Failed to modify html body of item.",
                      SRCNAME, __func__);
-          return;
         }
+      return;
     }
-  else
+  const auto body = m_parser->get_body();
+  char *converted = ansi_charset_to_utf8 (m_parser->get_body_charset().c_str(),
+                                          body.c_str(), body.size());
+  int ret = put_oom_string (m_mailitem, "Body", converted ? converted : "");
+  xfree (converted);
+  if (ret)
     {
-      const auto body = m_parser->get_body();
-      if (put_oom_string (m_mailitem, "Body", body.c_str()))
-        {
-          log_error ("%s:%s: Failed to modify body of item.",
-                     SRCNAME, __func__);
-          return;
-        }
+      log_error ("%s:%s: Failed to modify body of item.",
+                 SRCNAME, __func__);
     }
+  return;
 }
 
 void

commit 1c0f6b6ac6281c13bd004ba4118aa88a12c50dc2
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Oct 20 14:14:36 2016 +0200

    Use const input ptr for mlang conversion
    
    * src/mlang-charset.cpp, src/mlang-charset.h (ansi_charset_to_utf8):
    Take input as const.
    
    --
    Internally we cast the constness away anyway but this is just
    because microsoft created bad API it does not actually modify
    the input.

diff --git a/src/mlang-charset.cpp b/src/mlang-charset.cpp
index 128a428..0e60492 100644
--- a/src/mlang-charset.cpp
+++ b/src/mlang-charset.cpp
@@ -30,7 +30,7 @@ DEFINE_GUID (IID_IMultiLanguage, 0x275c23e1,0x3747,0x11d0,0x9f,
 
 #include "mlang-charset.h"
 
-char *ansi_charset_to_utf8 (const char *charset, char *input,
+char *ansi_charset_to_utf8 (const char *charset, const char *input,
                             size_t inlen)
 {
   LPMULTILANGUAGE multilang = NULL;
@@ -79,7 +79,7 @@ char *ansi_charset_to_utf8 (const char *charset, char *input,
                                               mime_info.uiInternetEncoding;
 
   /** Get the size of the result */
-  err = multilang->ConvertStringToUnicode(&mode, enc, input,
+  err = multilang->ConvertStringToUnicode(&mode, enc, const_cast<char*>(input),
                                           &uinlen, NULL, &wlen);
   if (FAILED (err))
     {
@@ -90,8 +90,8 @@ char *ansi_charset_to_utf8 (const char *charset, char *input,
   }
   buf = (wchar_t*) xmalloc(sizeof(wchar_t) * (wlen + 1));
 
-  err = multilang->ConvertStringToUnicode(&mode, enc, input, &uinlen,
-                                          buf, &wlen);
+  err = multilang->ConvertStringToUnicode(&mode, enc, const_cast<char*>(input),
+                                          &uinlen, buf, &wlen);
   gpgol_release (multilang);
   if (FAILED (err))
     {
diff --git a/src/mlang-charset.h b/src/mlang-charset.h
index 470ec02..d912c55 100644
--- a/src/mlang-charset.h
+++ b/src/mlang-charset.h
@@ -36,7 +36,7 @@ extern "C" {
   * @returns NULL on error or an UTF-8 encoded NULL terminated string.
   */
 
-char *ansi_charset_to_utf8 (const char *charset, char *input,
+char *ansi_charset_to_utf8 (const char *charset, const char *input,
                             size_t inlen);
 #ifdef __cplusplus
 }

-----------------------------------------------------------------------

Summary of changes:
 src/Makefile.am                    |  2 +-
 src/mail.cpp                       | 26 ++++++++-----
 src/{mimemaker.c => mimemaker.cpp} | 80 +++++++++++++++++++-------------------
 src/mlang-charset.cpp              |  8 ++--
 src/mlang-charset.h                |  2 +-
 5 files changed, 62 insertions(+), 56 deletions(-)
 rename src/{mimemaker.c => mimemaker.cpp} (96%)


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list