Dmitry Timoshkov : windowscodecs: Implement WICMapShortNameToGuid.

Alexandre Julliard julliard at winehq.org
Wed Jun 21 16:43:44 CDT 2017


Module: wine
Branch: master
Commit: e1eed88401befee456852b6df3f213123c79c2bd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e1eed88401befee456852b6df3f213123c79c2bd

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Tue Jun 20 12:37:15 2017 +0800

windowscodecs: Implement WICMapShortNameToGuid.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/windowscodecs/metadataquery.c    | 20 +++++++++++++++++++
 dlls/windowscodecs/tests/metadata.c   | 36 +++++++++++++++++++++++++++++++++++
 dlls/windowscodecs/windowscodecs.spec |  2 +-
 include/wincodec.idl                  |  1 +
 4 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/dlls/windowscodecs/metadataquery.c b/dlls/windowscodecs/metadataquery.c
index 6d8efa0..a7eedc0 100644
--- a/dlls/windowscodecs/metadataquery.c
+++ b/dlls/windowscodecs/metadataquery.c
@@ -277,3 +277,23 @@ HRESULT WINAPI WICMapGuidToShortName(REFGUID guid, UINT len, WCHAR *name, UINT *
 
     return WINCODEC_ERR_PROPERTYNOTFOUND;
 }
+
+HRESULT WINAPI WICMapShortNameToGuid(PCWSTR name, GUID *guid)
+{
+    UINT i;
+
+    TRACE("%s,%p\n", debugstr_w(name), guid);
+
+    if (!name || !guid) return E_INVALIDARG;
+
+    for (i = 0; i < sizeof(guid2name)/sizeof(guid2name[0]); i++)
+    {
+        if (!lstrcmpiW(name, guid2name[i].name))
+        {
+            *guid = *guid2name[i].guid;
+            return S_OK;
+        }
+    }
+
+    return WINCODEC_ERR_PROPERTYNOTFOUND;
+}
diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c
index 4e9d691..f70ddad 100644
--- a/dlls/windowscodecs/tests/metadata.c
+++ b/dlls/windowscodecs/tests/metadata.c
@@ -2017,11 +2017,47 @@ static void test_WICMapGuidToShortName(void)
     ok(hr == E_INVALIDARG, "got %#x\n", hr);
 }
 
+static void test_WICMapShortNameToGuid(void)
+{
+    static const WCHAR unkW[] = { 'u','n','k',0 };
+    static const WCHAR xmpW[] = { 'x','m','p',0 };
+    static const WCHAR XmPW[] = { 'X','m','P',0 };
+    static const WCHAR unknownW[] = { 'u','n','k','n','o','w','n',0 };
+    HRESULT hr;
+    GUID guid;
+
+    hr = WICMapShortNameToGuid(NULL, NULL);
+    ok(hr == E_INVALIDARG, "got %#x\n", hr);
+
+    hr = WICMapShortNameToGuid(NULL, &guid);
+    ok(hr == E_INVALIDARG, "got %#x\n", hr);
+
+    hr = WICMapShortNameToGuid(unknownW, NULL);
+    ok(hr == E_INVALIDARG, "got %#x\n", hr);
+
+    hr = WICMapShortNameToGuid(unkW, &guid);
+    ok(hr == WINCODEC_ERR_PROPERTYNOTFOUND, "got %#x\n", hr);
+
+    hr = WICMapShortNameToGuid(unknownW, &guid);
+    ok(hr == S_OK, "got %#x\n", hr);
+    ok(IsEqualGUID(&guid, &GUID_MetadataFormatUnknown), "got %s\n", wine_dbgstr_guid(&guid));
+
+    hr = WICMapShortNameToGuid(xmpW, &guid);
+    ok(hr == S_OK, "got %#x\n", hr);
+    ok(IsEqualGUID(&guid, &GUID_MetadataFormatXMP), "got %s\n", wine_dbgstr_guid(&guid));
+
+    guid = GUID_NULL;
+    hr = WICMapShortNameToGuid(XmPW, &guid);
+    ok(hr == S_OK, "got %#x\n", hr);
+    ok(IsEqualGUID(&guid, &GUID_MetadataFormatXMP), "got %s\n", wine_dbgstr_guid(&guid));
+}
+
 START_TEST(metadata)
 {
     CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
 
     test_WICMapGuidToShortName();
+    test_WICMapShortNameToGuid();
     test_metadata_unknown();
     test_metadata_tEXt();
     test_metadata_gAMA();
diff --git a/dlls/windowscodecs/windowscodecs.spec b/dlls/windowscodecs/windowscodecs.spec
index 0972aed..ace3b33 100644
--- a/dlls/windowscodecs/windowscodecs.spec
+++ b/dlls/windowscodecs/windowscodecs.spec
@@ -111,7 +111,7 @@
 @ stub WICGetMetadataContentSize
 @ stdcall WICMapGuidToShortName(ptr long ptr ptr)
 @ stub WICMapSchemaToName
-@ stub WICMapShortNameToGuid
+@ stdcall WICMapShortNameToGuid(wstr ptr)
 @ stub WICMatchMetadataContent
 @ stub WICSerializeMetadataContent
 @ stdcall WICSetEncoderFormat_Proxy(ptr ptr ptr ptr)
diff --git a/include/wincodec.idl b/include/wincodec.idl
index 5c46aed..55f22d5 100644
--- a/include/wincodec.idl
+++ b/include/wincodec.idl
@@ -1052,6 +1052,7 @@ interface IWICEnumMetadataItem : IUnknown
 cpp_quote("HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst);")
 
 cpp_quote("HRESULT WINAPI WICMapGuidToShortName(REFGUID,UINT,WCHAR *,UINT *);")
+cpp_quote("HRESULT WINAPI WICMapShortNameToGuid(PCWSTR,GUID *);")
 
 cpp_quote("DEFINE_GUID(CLSID_WICBmpDecoder, 0x6b462062,0x7cbf,0x400d,0x9f,0xdb,0x81,0x3d,0xd1,0x0f,0x27,0x78);")
 cpp_quote("DEFINE_GUID(CLSID_WICPngDecoder, 0x389ea17b,0x5078,0x4cde,0xb6,0xef,0x25,0xc1,0x51,0x75,0xc7,0x51);")




More information about the wine-cvs mailing list