[git] GpgOL - branch, master, updated. gpgol-1.2.0-2-gd48a6f0

by Andre Heinecke cvs at cvs.gnupg.org
Tue Jul 22 18:58:30 CEST 2014


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, master has been updated
       via  d48a6f0a26fd03b760791332a17b12fd7a6110c1 (commit)
      from  bcc002d266e0bbe6a817c74db377218a66dbe105 (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 d48a6f0a26fd03b760791332a17b12fd7a6110c1
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Jul 22 18:53:57 2014 +0200

    Look up SMTP Address by property
    
        Use the PropertyAccessor interface to look up the
        "hidden" SMTP Address property.
    
        * src/oomhelp.cpp (get_pa_string): New. Get a string using
        the property accessor of an object.
        (get_oom_recipients): Prefer the PR_SMTP_ADDRESS property over
        the direct Address.
        * src/oomhelp.h (PR_SMTP_ADDRESS): New define.
        * NEWS: Mention this.
    
    --
        The direct usage of the Address property of a Recipient
        resulted in failures in case the Address Type was not SMTP.
    
        This commit has only been tested with SMTP Addresses.
    
        The PR_SMTP_ADDRESS value is documented on:
        http://msdn.microsoft.com/en-us/library/office/
        ff868695%28v=office.15%29.aspx

diff --git a/NEWS b/NEWS
index f5d6f9f..2b9e3a1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 Noteworthy changes for version 1.2.1 (unreleased)
 =================================================
 
+ * Fixed recipient lookup problems when using exchange or active
+ directory.
 
 Noteworthy changes for version 1.2.0 (2013-08-19)
 =================================================
diff --git a/src/oomhelp.cpp b/src/oomhelp.cpp
index a0e25ff..0ac567d 100644
--- a/src/oomhelp.cpp
+++ b/src/oomhelp.cpp
@@ -789,6 +789,78 @@ get_oom_context_window (LPDISPATCH context)
   return ret;
 }
 
+
+/* Get a property string by using the PropertyAccessor of pDisp
+ * returns NULL on error or a newly allocated result. */
+char *
+get_pa_string (LPDISPATCH pDisp, const char *property)
+{
+  LPDISPATCH propertyAccessor;
+  VARIANT rVariant,
+          cVariant[1];
+  BSTR b_property;
+  DISPID dispid;
+  DISPPARAMS dispparams;
+  HRESULT hr;
+  EXCEPINFO execpinfo;
+  wchar_t *w_property;
+  unsigned int argErr = 0;
+  char *result = NULL;
+
+  propertyAccessor = get_oom_object (pDisp, "PropertyAccessor");
+  if (!propertyAccessor)
+    {
+      log_error ("%s:%s: Failed to look up property accessor.",
+                 SRCNAME, __func__);
+      /* Fall back to address field on error. */
+      return NULL;
+    }
+
+  dispid = lookup_oom_dispid (propertyAccessor, "GetProperty");
+
+  if (dispid == DISPID_UNKNOWN)
+  {
+    log_error ("%s:%s: could not find GetProperty DISPID",
+               SRCNAME, __func__);
+    return NULL;
+  }
+
+  /* Prepare the parameter */
+  w_property = utf8_to_wchar (property);
+  b_property = SysAllocString (w_property);
+  xfree (w_property);
+
+  cVariant[0].vt = VT_BSTR;
+  cVariant[0].bstrVal = b_property;
+  dispparams.rgvarg = cVariant;
+  dispparams.cArgs = 1;
+  dispparams.cNamedArgs = 0;
+  VariantInit (&rVariant);
+
+  hr = propertyAccessor->Invoke (dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT,
+                                 DISPATCH_METHOD, &dispparams,
+                                 &rVariant, &execpinfo, &argErr);
+  if (hr != S_OK)
+    {
+      log_debug ("%s:%s: error: invoking GetPrperty p=%p vt=%d hr=0x%x argErr=0x%x",
+                 SRCNAME, __func__,
+                 rVariant.pdispVal, rVariant.vt, (unsigned int)hr,
+                 (unsigned int)argErr);
+      dump_excepinfo (execpinfo);
+    }
+  else if (rVariant.vt != VT_BSTR)
+    log_debug ("%s:%s: Property `%s' is not a string (vt=%d)",
+               SRCNAME, __func__, property, rVariant.vt);
+  else if (rVariant.bstrVal)
+    result = wchar_to_utf8 (rVariant.bstrVal);
+
+  SysFreeString (b_property);
+  RELDISP (propertyAccessor);
+  VariantClear (&rVariant);
+
+  return result;
+}
+
 /* Gets a malloced NULL terminated array of recipent strings from
    an OOM recipients Object. */
 char **
@@ -820,7 +892,26 @@ get_oom_recipients (LPDISPATCH recipients)
                      SRCNAME, __func__, i);
           break;
         }
-      recipientAddrs[i-1] = get_oom_string (recipient, "Address");
+      else
+        {
+          char *address,
+               *resolved;
+          address = get_oom_string (recipient, "Address");
+          log_debug ("%s:%s: Looking up smtp address for %s;",
+                     SRCNAME, __func__, address);
+          resolved = get_pa_string (recipient, PR_SMTP_ADDRESS);
+          if (resolved)
+            {
+              xfree (address);
+              recipientAddrs[i-1] = resolved;
+              log_debug ("%s:%s: Resolved address is %s;",
+                         SRCNAME, __func__, resolved);
+              continue;
+            }
+          log_debug ("%s:%s: Failed to look up SMTP Address;",
+                     SRCNAME, __func__);
+          recipientAddrs[i-1] = address;
+        }
     }
   return recipientAddrs;
 }
diff --git a/src/oomhelp.h b/src/oomhelp.h
index 7858b42..1919973 100644
--- a/src/oomhelp.h
+++ b/src/oomhelp.h
@@ -67,6 +67,9 @@ DEFINE_OLEGUID(IID_IUnknown,                  0x00000000, 0, 0);
 DEFINE_OLEGUID(IID_IDispatch,                 0x00020400, 0, 0);
 DEFINE_OLEGUID(IID_IOleWindow,                0x00000114, 0, 0);
 
+#ifndef PR_SMTP_ADDRESS
+#define PR_SMTP_ADDRESS "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
+#endif
 
 #ifdef __cplusplus
 extern "C" {

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

Summary of changes:
 NEWS            |    2 ++
 src/oomhelp.cpp |   93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/oomhelp.h   |    3 ++
 3 files changed, 97 insertions(+), 1 deletion(-)


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




More information about the Gnupg-commits mailing list