dmband: Set DMUS_PATCH_PMSG bank LSB/MSB from instrument patch.
[wine.git] / dlls / mstask / factory.c
blob260a93066f4eca09a6b589f8c542789699aa072c
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 <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "objbase.h"
26 #include "taskschd.h"
27 #include "mstask.h"
28 #include "mstask_private.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(mstask);
33 struct ClassFactoryImpl
35 IClassFactory IClassFactory_iface;
36 LONG ref;
39 static inline ClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
41 return CONTAINING_RECORD(iface, ClassFactoryImpl, IClassFactory_iface);
44 static HRESULT WINAPI MSTASK_IClassFactory_QueryInterface(
45 LPCLASSFACTORY iface,
46 REFIID riid,
47 LPVOID *ppvObj)
49 ClassFactoryImpl *This = impl_from_IClassFactory(iface);
51 TRACE("IID: %s\n",debugstr_guid(riid));
52 if (ppvObj == NULL)
53 return E_POINTER;
55 if (IsEqualGUID(riid, &IID_IUnknown) ||
56 IsEqualGUID(riid, &IID_IClassFactory))
58 *ppvObj = &This->IClassFactory_iface;
59 IClassFactory_AddRef(iface);
60 return S_OK;
63 WARN("Unknown interface: %s\n", debugstr_guid(riid));
64 *ppvObj = NULL;
65 return E_NOINTERFACE;
68 static ULONG WINAPI MSTASK_IClassFactory_AddRef(IClassFactory *face)
70 TRACE("\n");
71 InterlockedIncrement(&dll_ref);
72 return 2;
75 static ULONG WINAPI MSTASK_IClassFactory_Release(IClassFactory *iface)
77 TRACE("\n");
78 InterlockedDecrement(&dll_ref);
79 return 1;
82 static HRESULT WINAPI MSTASK_IClassFactory_CreateInstance(
83 IClassFactory *iface,
84 IUnknown *pUnkOuter,
85 REFIID riid,
86 LPVOID *ppvObj)
88 HRESULT res;
89 IUnknown *punk = NULL;
90 *ppvObj = NULL;
92 TRACE("IID: %s\n",debugstr_guid(riid));
94 if (pUnkOuter)
95 return CLASS_E_NOAGGREGATION;
97 res = TaskSchedulerConstructor((LPVOID*) &punk);
98 if (FAILED(res))
99 return res;
101 res = IUnknown_QueryInterface(punk, riid, ppvObj);
102 IUnknown_Release(punk);
103 return res;
106 static HRESULT WINAPI MSTASK_IClassFactory_LockServer(
107 IClassFactory *iface,
108 BOOL fLock)
110 TRACE("\n");
112 if (fLock)
113 IClassFactory_AddRef(iface);
114 else
115 IClassFactory_Release(iface);
116 return S_OK;
119 static const IClassFactoryVtbl IClassFactory_Vtbl =
121 MSTASK_IClassFactory_QueryInterface,
122 MSTASK_IClassFactory_AddRef,
123 MSTASK_IClassFactory_Release,
124 MSTASK_IClassFactory_CreateInstance,
125 MSTASK_IClassFactory_LockServer
128 ClassFactoryImpl MSTASK_ClassFactory = { { &IClassFactory_Vtbl } };