win32u: Move NtUserGetAsyncKeyState implementation from user32.
[wine.git] / dlls / wmphoto / main.c
blob6de6119d212137c5fb43bcd0f8d9c7906ac9aa53
1 /*
2 * Copyright 2017 Vincent Povirk for CodeWeavers
3 * Copyright 2020 RĂ©mi Bernon for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "objbase.h"
27 #include "rpcproxy.h"
29 #include "wincodecs_private.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
34 extern HRESULT CDECL wmp_decoder_create(struct decoder_info *info, struct decoder **result);
36 HRESULT create_instance(const CLSID *clsid, const IID *iid, void **ppv)
38 return CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, iid, ppv);
41 HRESULT get_decoder_info(REFCLSID clsid, IWICBitmapDecoderInfo **info)
43 IWICImagingFactory* factory;
44 IWICComponentInfo *compinfo;
45 HRESULT hr;
47 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
48 &IID_IWICImagingFactory, (void **)&factory);
49 if (FAILED(hr))
50 return hr;
52 hr = IWICImagingFactory_CreateComponentInfo(factory, clsid, &compinfo);
53 if (FAILED(hr))
55 IWICImagingFactory_Release(factory);
56 return hr;
59 hr = IWICComponentInfo_QueryInterface(compinfo, &IID_IWICBitmapDecoderInfo,
60 (void **)info);
62 IWICComponentInfo_Release(compinfo);
63 IWICImagingFactory_Release(factory);
64 return hr;
67 struct class_factory
69 IClassFactory IClassFactory_iface;
72 static HRESULT WINAPI wmp_class_factory_QueryInterface(IClassFactory *iface, REFIID iid, void **out)
74 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
76 if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IClassFactory))
78 *out = iface;
79 IClassFactory_AddRef(iface);
80 return S_OK;
83 *out = NULL;
84 FIXME("%s not implemented.\n", debugstr_guid(iid));
85 return E_NOINTERFACE;
88 static ULONG WINAPI wmp_class_factory_AddRef(IClassFactory *iface) { return 2; }
90 static ULONG WINAPI wmp_class_factory_Release(IClassFactory *iface) { return 1; }
92 static HRESULT WINAPI wmp_class_factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID iid, void **out)
94 struct decoder_info decoder_info;
95 struct decoder *decoder;
96 HRESULT hr;
98 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
100 *out = NULL;
101 if (outer) return CLASS_E_NOAGGREGATION;
103 hr = wmp_decoder_create(&decoder_info, &decoder);
105 if (SUCCEEDED(hr))
106 hr = CommonDecoder_CreateInstance(decoder, &decoder_info, iid, out);
108 return hr;
111 static HRESULT WINAPI wmp_class_factory_LockServer(IClassFactory *iface, BOOL lock)
113 FIXME("iface %p, lock %d, stub!\n", iface, lock);
114 return S_OK;
117 static const IClassFactoryVtbl wmp_class_factory_vtbl =
119 wmp_class_factory_QueryInterface,
120 wmp_class_factory_AddRef,
121 wmp_class_factory_Release,
122 wmp_class_factory_CreateInstance,
123 wmp_class_factory_LockServer,
126 static struct class_factory wmp_class_factory = {{&wmp_class_factory_vtbl}};
128 HMODULE windowscodecs_module = 0;
130 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
132 TRACE("instance %p, reason %d, reserved %p\n", instance, reason, reserved);
134 switch (reason)
136 case DLL_PROCESS_ATTACH:
137 windowscodecs_module = instance;
138 DisableThreadLibraryCalls(instance);
139 break;
142 return TRUE;
145 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *out)
147 struct class_factory *factory;
149 TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid), debugstr_guid(iid), out);
151 if (IsEqualGUID(clsid, &CLSID_WICWmpDecoder)) factory = &wmp_class_factory;
152 else
154 FIXME("%s not implemented.\n", debugstr_guid(clsid));
155 return CLASS_E_CLASSNOTAVAILABLE;
158 return IClassFactory_QueryInterface(&factory->IClassFactory_iface, iid, out);