[PATCH 4/5] inetcomm: Support LPSTR to LPWSTR conversion in GetProp

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Thu Jun 30 03:59:00 CDT 2016


Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
 dlls/inetcomm/inetcomm_private.h | 16 ++++++++++++++++
 dlls/inetcomm/mimeole.c          | 12 +++++++++++-
 dlls/inetcomm/tests/mimeole.c    | 14 ++++++++++++++
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/dlls/inetcomm/inetcomm_private.h b/dlls/inetcomm/inetcomm_private.h
index 55aaf47..97a4b6d 100644
--- a/dlls/inetcomm/inetcomm_private.h
+++ b/dlls/inetcomm/inetcomm_private.h
@@ -82,3 +82,19 @@ HRESULT MimeInternational_Construct(IMimeInternational **internat) DECLSPEC_HIDD
 HRESULT SMTPTransportCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
 HRESULT IMAPTransportCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
 HRESULT POP3TransportCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN;
+
+static inline WCHAR *heap_strdupAtoW(const char *str)
+{
+    LPWSTR ret = NULL;
+
+    if(str) {
+        DWORD len;
+
+        len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
+        ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(WCHAR));
+        if(ret)
+            MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
+    }
+
+    return ret;
+}
diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c
index c61656c..aab4bc6 100644
--- a/dlls/inetcomm/mimeole.c
+++ b/dlls/inetcomm/mimeole.c
@@ -785,7 +785,17 @@ static HRESULT WINAPI MimeBody_GetProp(
     hr = find_prop(This, pszName, &header);
     if(hr == S_OK)
     {
-        PropVariantCopy(pValue, &header->value);
+        TRACE("type %d->%d\n", header->value.vt, pValue->vt);
+
+        if(pValue->vt == header->value.vt)
+            PropVariantCopy(pValue, &header->value);
+        else
+        {
+            if(header->value.vt == VT_LPSTR &&  pValue->vt == VT_LPWSTR)
+                pValue->u.pwszVal = heap_strdupAtoW(header->value.u.pszVal);
+            else
+                FIXME("Conversion not currently supported (%d->%d)\n", header->value.vt, pValue->vt);
+        }
     }
 
     return hr;
diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c
index 46fd1d5..84b2c8d 100644
--- a/dlls/inetcomm/tests/mimeole.c
+++ b/dlls/inetcomm/tests/mimeole.c
@@ -335,6 +335,7 @@ static void test_CreateMessage(void)
 static void test_MessageSetProp(void)
 {
     static const char topic[] = "wine topic";
+    static const WCHAR topicW[] = {'w','i','n','e',' ','t','o','p','i','c',0};
     HRESULT hr;
     IMimeMessage *msg;
     IMimeBody *body;
@@ -370,6 +371,7 @@ static void test_MessageSetProp(void)
     hr = IMimeBody_GetProp(body, "Wine-Topic", 0, &prop);
     ok(hr == MIME_E_NOT_FOUND, "ret %08x\n", hr);
 
+    prop.vt = VT_LPSTR;
     hr = IMimeBody_GetProp(body, "Thread-Topic", 0, &prop);
     ok(hr == S_OK, "ret %08x\n", hr);
     if(hr == S_OK)
@@ -386,6 +388,7 @@ static void test_MessageSetProp(void)
     ok(hr == S_OK, "ret %08x\n", hr);
     PropVariantClear(&prop);
 
+    prop.vt = VT_LPSTR;
     hr = IMimeBody_GetProp(body, PIDTOSTR(PID_HDR_SUBJECT), 0, &prop);
     ok(hr == S_OK, "ret %08x\n", hr);
     if(hr == S_OK)
@@ -396,6 +399,7 @@ static void test_MessageSetProp(void)
     }
 
     /* Using the name or PID returns the same result. */
+    prop.vt = VT_LPSTR;
     hr = IMimeBody_GetProp(body, "Subject", 0, &prop);
     ok(hr == S_OK, "ret %08x\n", hr);
     if(hr == S_OK)
@@ -405,6 +409,16 @@ static void test_MessageSetProp(void)
         PropVariantClear(&prop);
     }
 
+    prop.vt = VT_LPWSTR;
+    hr = IMimeBody_GetProp(body, "Subject", 0, &prop);
+    ok(hr == S_OK, "ret %08x\n", hr);
+    if(hr == S_OK)
+    {
+        ok(prop.vt == VT_LPWSTR, "type %d\n", prop.vt);
+        ok(!lstrcmpW(prop.u.pwszVal, topicW), "got %s\n", wine_dbgstr_w(prop.u.pwszVal));
+        PropVariantClear(&prop);
+    }
+
     prop.vt = VT_LPSTR;
     prop.u.pszVal = CoTaskMemAlloc(strlen(topic)+1);
     strcpy(prop.u.pszVal, topic);
-- 
1.9.1




More information about the wine-patches mailing list