user32: If a dialog has no tab-accessible controls, set focus to first control (with...
[wine/multimedia.git] / dlls / mstask / factory.c
blob9dc1e2932db35d4c01883c40af622919fa55b813
1 /*
2 * Copyright (C) 2008 Google (Roy Shea)
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 "mstask_private.h"
20 #include "wine/debug.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(mstask);
24 struct ClassFactoryImpl
26 IClassFactory IClassFactory_iface;
27 LONG ref;
30 static inline ClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
32 return CONTAINING_RECORD(iface, ClassFactoryImpl, IClassFactory_iface);
35 static HRESULT WINAPI MSTASK_IClassFactory_QueryInterface(
36 LPCLASSFACTORY iface,
37 REFIID riid,
38 LPVOID *ppvObj)
40 ClassFactoryImpl *This = impl_from_IClassFactory(iface);
42 TRACE("IID: %s\n",debugstr_guid(riid));
43 if (ppvObj == NULL)
44 return E_POINTER;
46 if (IsEqualGUID(riid, &IID_IUnknown) ||
47 IsEqualGUID(riid, &IID_IClassFactory))
49 *ppvObj = &This->IClassFactory_iface;
50 IClassFactory_AddRef(iface);
51 return S_OK;
54 WARN("Unknown interface: %s\n", debugstr_guid(riid));
55 *ppvObj = NULL;
56 return E_NOINTERFACE;
59 static ULONG WINAPI MSTASK_IClassFactory_AddRef(LPCLASSFACTORY iface)
61 TRACE("\n");
62 InterlockedIncrement(&dll_ref);
63 return 2;
66 static ULONG WINAPI MSTASK_IClassFactory_Release(LPCLASSFACTORY iface)
68 TRACE("\n");
69 InterlockedDecrement(&dll_ref);
70 return 1;
73 static HRESULT WINAPI MSTASK_IClassFactory_CreateInstance(
74 LPCLASSFACTORY iface,
75 LPUNKNOWN pUnkOuter,
76 REFIID riid,
77 LPVOID *ppvObj)
79 HRESULT res;
80 IUnknown *punk = NULL;
81 *ppvObj = NULL;
83 TRACE("IID: %s\n",debugstr_guid(riid));
85 if (pUnkOuter)
86 return CLASS_E_NOAGGREGATION;
88 res = TaskSchedulerConstructor((LPVOID*) &punk);
89 if (FAILED(res))
90 return res;
92 res = ITaskScheduler_QueryInterface(punk, riid, ppvObj);
93 ITaskScheduler_Release(punk);
94 return res;
97 static HRESULT WINAPI MSTASK_IClassFactory_LockServer(
98 LPCLASSFACTORY iface,
99 BOOL fLock)
101 TRACE("\n");
103 if (fLock != FALSE)
104 MSTASK_IClassFactory_AddRef(iface);
105 else
106 MSTASK_IClassFactory_Release(iface);
107 return S_OK;
110 static const IClassFactoryVtbl IClassFactory_Vtbl =
112 MSTASK_IClassFactory_QueryInterface,
113 MSTASK_IClassFactory_AddRef,
114 MSTASK_IClassFactory_Release,
115 MSTASK_IClassFactory_CreateInstance,
116 MSTASK_IClassFactory_LockServer
119 ClassFactoryImpl MSTASK_ClassFactory = { { &IClassFactory_Vtbl } };