secur32/tests: Use importlib for functions available since Windows XP.
[wine.git] / dlls / windowscodecs / metadataquery.c
blob10bf295b65530fa76c890286ce99ec621819c09e
1 /*
2 * Copyright 2016 Andrew Eikum for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "objbase.h"
29 #include "wincodecs_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
35 typedef struct {
36 IWICMetadataQueryReader IWICMetadataQueryReader_iface;
38 LONG ref;
40 IWICMetadataBlockReader *block;
41 } QueryReader;
43 static inline QueryReader *impl_from_IWICMetadataQueryReader(IWICMetadataQueryReader *iface)
45 return CONTAINING_RECORD(iface, QueryReader, IWICMetadataQueryReader_iface);
48 static HRESULT WINAPI mqr_QueryInterface(IWICMetadataQueryReader *iface, REFIID riid,
49 void **ppvObject)
51 QueryReader *This = impl_from_IWICMetadataQueryReader(iface);
53 TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ppvObject);
55 if (IsEqualGUID(riid, &IID_IUnknown) ||
56 IsEqualGUID(riid, &IID_IWICMetadataQueryReader))
57 *ppvObject = &This->IWICMetadataQueryReader_iface;
58 else
59 *ppvObject = NULL;
61 if (*ppvObject)
63 IUnknown_AddRef((IUnknown*)*ppvObject);
64 return S_OK;
67 return E_NOINTERFACE;
70 static ULONG WINAPI mqr_AddRef(IWICMetadataQueryReader *iface)
72 QueryReader *This = impl_from_IWICMetadataQueryReader(iface);
73 ULONG ref = InterlockedIncrement(&This->ref);
74 TRACE("(%p) refcount=%u\n", This, ref);
75 return ref;
78 static ULONG WINAPI mqr_Release(IWICMetadataQueryReader *iface)
80 QueryReader *This = impl_from_IWICMetadataQueryReader(iface);
81 ULONG ref = InterlockedDecrement(&This->ref);
82 TRACE("(%p) refcount=%u\n", This, ref);
83 if (!ref)
85 IWICMetadataBlockReader_Release(This->block);
86 HeapFree(GetProcessHeap(), 0, This);
88 return ref;
91 static HRESULT WINAPI mqr_GetContainerFormat(IWICMetadataQueryReader *iface,
92 GUID *pguidContainerFormat)
94 QueryReader *This = impl_from_IWICMetadataQueryReader(iface);
95 FIXME("(%p,%p)\n", This, pguidContainerFormat);
96 return E_NOTIMPL;
99 static HRESULT WINAPI mqr_GetLocation(IWICMetadataQueryReader *iface,
100 UINT cchMaxLength, WCHAR *wzNamespace, UINT *pcchActualLength)
102 QueryReader *This = impl_from_IWICMetadataQueryReader(iface);
103 FIXME("(%p,%u,%p,%p)\n", This, cchMaxLength, wzNamespace, pcchActualLength);
104 return E_NOTIMPL;
107 static HRESULT WINAPI mqr_GetMetadataByName(IWICMetadataQueryReader *iface,
108 LPCWSTR wzName, PROPVARIANT *pvarValue)
110 QueryReader *This = impl_from_IWICMetadataQueryReader(iface);
111 FIXME("(%p,%s,%p)\n", This, wine_dbgstr_w(wzName), pvarValue);
112 return E_NOTIMPL;
115 static HRESULT WINAPI mqr_GetEnumerator(IWICMetadataQueryReader *iface,
116 IEnumString **ppIEnumString)
118 QueryReader *This = impl_from_IWICMetadataQueryReader(iface);
119 FIXME("(%p,%p)\n", This, ppIEnumString);
120 return E_NOTIMPL;
123 static IWICMetadataQueryReaderVtbl mqr_vtbl = {
124 mqr_QueryInterface,
125 mqr_AddRef,
126 mqr_Release,
127 mqr_GetContainerFormat,
128 mqr_GetLocation,
129 mqr_GetMetadataByName,
130 mqr_GetEnumerator
133 HRESULT MetadataQueryReader_CreateInstance(IWICMetadataBlockReader *mbr, IWICMetadataQueryReader **out)
135 QueryReader *obj;
137 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj));
138 if (!obj)
139 return E_OUTOFMEMORY;
141 obj->IWICMetadataQueryReader_iface.lpVtbl = &mqr_vtbl;
142 obj->ref = 1;
144 IWICMetadataBlockReader_AddRef(mbr);
145 obj->block = mbr;
147 *out = &obj->IWICMetadataQueryReader_iface;
149 return S_OK;