amstream: Implement AMAudioStream::NewSegment.
[wine/zf.git] / dlls / directmanipulation / directmanipulation.c
blob9389302008cbbaaac96af2c759489136b8443183
1 /*
2 * Copyright 2019 Alistair Leslie-Hughes
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
18 #define COBJMACROS
20 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "oleidl.h"
25 #include "rpcproxy.h"
26 #include "wine/heap.h"
27 #include "wine/debug.h"
29 #include "directmanipulation.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(manipulation);
33 static HINSTANCE dm_instance;
35 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
37 TRACE("(%p, %u, %p)\n", instance, reason, reserved);
39 switch (reason)
41 case DLL_WINE_PREATTACH:
42 return FALSE; /* prefer native version */
43 case DLL_PROCESS_ATTACH:
44 dm_instance = instance;
45 DisableThreadLibraryCalls(instance);
46 break;
49 return TRUE;
52 HRESULT WINAPI DllRegisterServer(void)
54 return __wine_register_resources( dm_instance );
57 HRESULT WINAPI DllUnregisterServer(void)
59 return __wine_unregister_resources( dm_instance );
62 HRESULT WINAPI DllCanUnloadNow(void)
64 return S_FALSE;
68 struct directmanipulation
70 IDirectManipulationManager2 IDirectManipulationManager2_iface;
71 IDirectManipulationUpdateManager *updatemanager;
72 LONG ref;
75 struct directupdatemanager
77 IDirectManipulationUpdateManager IDirectManipulationUpdateManager_iface;
78 LONG ref;
81 static inline struct directmanipulation *impl_from_IDirectManipulationManager2(IDirectManipulationManager2 *iface)
83 return CONTAINING_RECORD(iface, struct directmanipulation, IDirectManipulationManager2_iface);
86 static inline struct directupdatemanager *impl_from_IDirectManipulationUpdateManager(IDirectManipulationUpdateManager *iface)
88 return CONTAINING_RECORD(iface, struct directupdatemanager, IDirectManipulationUpdateManager_iface);
91 static HRESULT WINAPI update_manager_QueryInterface(IDirectManipulationUpdateManager *iface, REFIID riid,void **ppv)
93 struct directupdatemanager *This = impl_from_IDirectManipulationUpdateManager(iface);
95 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppv);
97 if (IsEqualGUID(riid, &IID_IUnknown) ||
98 IsEqualGUID(riid, &IID_IDirectManipulationUpdateManager)) {
99 IUnknown_AddRef(iface);
100 *ppv = iface;
101 return S_OK;
104 FIXME("(%p)->(%s,%p), not found\n", This, debugstr_guid(riid), ppv);
105 return E_NOINTERFACE;
108 ULONG WINAPI update_manager_AddRef(IDirectManipulationUpdateManager *iface)
110 struct directupdatemanager *This = impl_from_IDirectManipulationUpdateManager(iface);
111 ULONG ref = InterlockedIncrement(&This->ref);
113 TRACE("(%p) ref=%u\n", This, ref);
115 return ref;
118 ULONG WINAPI update_manager_Release(IDirectManipulationUpdateManager *iface)
120 struct directupdatemanager *This = impl_from_IDirectManipulationUpdateManager(iface);
121 ULONG ref = InterlockedDecrement(&This->ref);
123 TRACE("(%p) ref=%u\n", This, ref);
125 if (!ref)
127 heap_free(This);
129 return ref;
132 static HRESULT WINAPI update_manager_RegisterWaitHandleCallback(IDirectManipulationUpdateManager *iface, HANDLE handle,
133 IDirectManipulationUpdateHandler *handler, DWORD *cookie)
135 struct directupdatemanager *This = impl_from_IDirectManipulationUpdateManager(iface);
136 FIXME("%p, %p, %p, %p\n", This, handle, handler, cookie);
137 return E_NOTIMPL;
140 static HRESULT WINAPI update_manager_UnregisterWaitHandleCallback(IDirectManipulationUpdateManager *iface, DWORD cookie)
142 struct directupdatemanager *This = impl_from_IDirectManipulationUpdateManager(iface);
143 FIXME("%p, %x\n", This, cookie);
144 return E_NOTIMPL;
147 static HRESULT WINAPI update_manager_Update(IDirectManipulationUpdateManager *iface, IDirectManipulationFrameInfoProvider *provider)
149 struct directupdatemanager *This = impl_from_IDirectManipulationUpdateManager(iface);
150 FIXME("%p, %p\n", This, provider);
151 return E_NOTIMPL;
154 struct IDirectManipulationUpdateManagerVtbl updatemanagerVtbl =
156 update_manager_QueryInterface,
157 update_manager_AddRef,
158 update_manager_Release,
159 update_manager_RegisterWaitHandleCallback,
160 update_manager_UnregisterWaitHandleCallback,
161 update_manager_Update
164 static HRESULT create_update_manager(IDirectManipulationUpdateManager **obj)
166 struct directupdatemanager *object;
168 object = heap_alloc(sizeof(*object));
169 if(!object)
170 return E_OUTOFMEMORY;
172 object->IDirectManipulationUpdateManager_iface.lpVtbl = &updatemanagerVtbl;
173 object->ref = 1;
175 *obj = &object->IDirectManipulationUpdateManager_iface;
177 return S_OK;
180 static HRESULT WINAPI direct_manip_QueryInterface(IDirectManipulationManager2 *iface, REFIID riid, void **ppv)
182 if (IsEqualGUID(riid, &IID_IUnknown) ||
183 IsEqualGUID(riid, &IID_IDirectManipulationManager) ||
184 IsEqualGUID(riid, &IID_IDirectManipulationManager2)) {
185 IUnknown_AddRef(iface);
186 *ppv = iface;
187 return S_OK;
190 FIXME("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ppv);
191 return E_NOINTERFACE;
194 static ULONG WINAPI direct_manip_AddRef(IDirectManipulationManager2 *iface)
196 struct directmanipulation *This = impl_from_IDirectManipulationManager2(iface);
197 ULONG ref = InterlockedIncrement(&This->ref);
199 TRACE("(%p) ref=%u\n", This, ref);
201 return ref;
204 static ULONG WINAPI direct_manip_Release(IDirectManipulationManager2 *iface)
206 struct directmanipulation *This = impl_from_IDirectManipulationManager2(iface);
207 ULONG ref = InterlockedDecrement(&This->ref);
209 TRACE("(%p) ref=%u\n", This, ref);
211 if (!ref)
213 if(This->updatemanager)
214 IDirectManipulationUpdateManager_Release(This->updatemanager);
215 heap_free(This);
217 return ref;
220 static HRESULT WINAPI direct_manip_Activate(IDirectManipulationManager2 *iface, HWND window)
222 struct directmanipulation *This = impl_from_IDirectManipulationManager2(iface);
223 FIXME("%p, %p\n", This, window);
224 return E_NOTIMPL;
227 static HRESULT WINAPI direct_manip_Deactivate(IDirectManipulationManager2 *iface, HWND window)
229 struct directmanipulation *This = impl_from_IDirectManipulationManager2(iface);
230 FIXME("%p, %p\n", This, window);
231 return E_NOTIMPL;
234 static HRESULT WINAPI direct_manip_RegisterHitTestTarget(IDirectManipulationManager2 *iface, HWND window,
235 HWND hittest, DIRECTMANIPULATION_HITTEST_TYPE type)
237 struct directmanipulation *This = impl_from_IDirectManipulationManager2(iface);
238 FIXME("%p, %p, %p, %d\n", This, window, hittest, type);
239 return E_NOTIMPL;
242 static HRESULT WINAPI direct_manip_ProcessInput(IDirectManipulationManager2 *iface, const MSG *msg, BOOL *handled)
244 struct directmanipulation *This = impl_from_IDirectManipulationManager2(iface);
245 FIXME("%p, %p, %p\n", This, msg, handled);
246 return E_NOTIMPL;
249 static HRESULT WINAPI direct_manip_GetUpdateManager(IDirectManipulationManager2 *iface, REFIID riid, void **obj)
251 struct directmanipulation *This = impl_from_IDirectManipulationManager2(iface);
252 HRESULT hr = E_FAIL;
254 TRACE("%p, %s, %p\n", This, debugstr_guid(riid), obj);
256 *obj = NULL;
257 if(IsEqualGUID(riid, &IID_IDirectManipulationUpdateManager))
259 if(!This->updatemanager)
261 hr = create_update_manager(&This->updatemanager);
263 else
265 hr = S_OK;
268 if(hr == S_OK)
270 IDirectManipulationUpdateManager_AddRef(This->updatemanager);
271 *obj = This->updatemanager;
274 else
275 FIXME("Interface %s currently not supported.\n", debugstr_guid(riid));
277 return hr;
280 static HRESULT WINAPI direct_manip_CreateViewport(IDirectManipulationManager2 *iface, IDirectManipulationFrameInfoProvider *frame,
281 HWND window, REFIID riid, void **obj)
283 struct directmanipulation *This = impl_from_IDirectManipulationManager2(iface);
284 FIXME("%p, %p, %p, %s, %p\n", This, frame, window, debugstr_guid(riid), obj);
285 return E_NOTIMPL;
288 static HRESULT WINAPI direct_manip_CreateContent(IDirectManipulationManager2 *iface, IDirectManipulationFrameInfoProvider *frame,
289 REFCLSID clsid, REFIID riid, void **obj)
291 struct directmanipulation *This = impl_from_IDirectManipulationManager2(iface);
292 FIXME("%p, %p, %s, %p\n", This, frame, debugstr_guid(riid), obj);
293 return E_NOTIMPL;
296 static HRESULT WINAPI direct_manip_CreateBehavior(IDirectManipulationManager2 *iface, REFCLSID clsid, REFIID riid, void **obj)
298 struct directmanipulation *This = impl_from_IDirectManipulationManager2(iface);
299 FIXME("%p, %s, %s, %p\n", This, debugstr_guid(clsid), debugstr_guid(riid), obj);
300 return E_NOTIMPL;
303 static const struct IDirectManipulationManager2Vtbl directmanipVtbl =
305 direct_manip_QueryInterface,
306 direct_manip_AddRef,
307 direct_manip_Release,
308 direct_manip_Activate,
309 direct_manip_Deactivate,
310 direct_manip_RegisterHitTestTarget,
311 direct_manip_ProcessInput,
312 direct_manip_GetUpdateManager,
313 direct_manip_CreateViewport,
314 direct_manip_CreateContent,
315 direct_manip_CreateBehavior
318 static HRESULT WINAPI DirectManipulation_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
320 struct directmanipulation *object;
321 HRESULT ret;
323 TRACE("(%p, %s, %p)\n", outer, debugstr_guid(riid), ppv);
325 *ppv = NULL;
327 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
328 if (!object)
329 return E_OUTOFMEMORY;
331 object->IDirectManipulationManager2_iface.lpVtbl = &directmanipVtbl;
332 object->ref = 1;
334 ret = direct_manip_QueryInterface(&object->IDirectManipulationManager2_iface, riid, ppv);
335 direct_manip_Release(&object->IDirectManipulationManager2_iface);
337 return ret;
340 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
342 *ppv = NULL;
344 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
345 *ppv = iface;
348 if(*ppv) {
349 IUnknown_AddRef((IUnknown*)*ppv);
350 return S_OK;
353 WARN("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
354 return E_NOINTERFACE;
357 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
359 TRACE("(%p)\n", iface);
360 return 2;
363 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
365 TRACE("(%p)\n", iface);
366 return 1;
369 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
371 TRACE("(%p)->(%x)\n", iface, fLock);
372 return S_OK;
375 static const IClassFactoryVtbl DirectFactoryVtbl = {
376 ClassFactory_QueryInterface,
377 ClassFactory_AddRef,
378 ClassFactory_Release,
379 DirectManipulation_CreateInstance,
380 ClassFactory_LockServer
383 static IClassFactory direct_factory = { &DirectFactoryVtbl };
385 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
387 if(IsEqualGUID(&CLSID_DirectManipulationManager, rclsid) ||
388 IsEqualGUID(&CLSID_DirectManipulationSharedManager, rclsid) ) {
389 TRACE("(CLSID_DirectManipulationManager %s %p)\n", debugstr_guid(riid), ppv);
390 return IClassFactory_QueryInterface(&direct_factory, riid, ppv);
393 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
394 return CLASS_E_CLASSNOTAVAILABLE;