wininet: Quiet a noisy fixme.
[wine] / dlls / mstask / factory.c
1 /*
2  * Copyright (C) 2008 Google (Roy Shea)
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "mstask_private.h"
20 #include "wine/debug.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(mstask);
23
24 static HRESULT WINAPI MSTASK_IClassFactory_QueryInterface(
25         LPCLASSFACTORY iface,
26         REFIID riid,
27         LPVOID *ppvObj)
28 {
29     ClassFactoryImpl *This = (ClassFactoryImpl *)iface;
30
31     TRACE("IID: %s\n",debugstr_guid(riid));
32     if (ppvObj == NULL)
33         return E_POINTER;
34
35     if (IsEqualGUID(riid, &IID_IUnknown) ||
36             IsEqualGUID(riid, &IID_IClassFactory))
37     {
38         *ppvObj = &This->lpVtbl;
39         IClassFactory_AddRef(iface);
40         return S_OK;
41     }
42
43     WARN("Unknown interface: %s\n", debugstr_guid(riid));
44     *ppvObj = NULL;
45     return E_NOINTERFACE;
46 }
47
48 static ULONG WINAPI MSTASK_IClassFactory_AddRef(LPCLASSFACTORY iface)
49 {
50     TRACE("\n");
51     InterlockedIncrement(&dll_ref);
52     return 2;
53 }
54
55 static ULONG WINAPI MSTASK_IClassFactory_Release(LPCLASSFACTORY iface)
56 {
57     TRACE("\n");
58     InterlockedDecrement(&dll_ref);
59     return 1;
60 }
61
62 static HRESULT WINAPI MSTASK_IClassFactory_CreateInstance(
63         LPCLASSFACTORY iface,
64         LPUNKNOWN pUnkOuter,
65         REFIID riid,
66         LPVOID *ppvObj)
67 {
68     HRESULT res;
69     IUnknown *punk = NULL;
70     *ppvObj = NULL;
71
72     TRACE("IID: %s\n",debugstr_guid(riid));
73
74     if (pUnkOuter)
75         return CLASS_E_NOAGGREGATION;
76
77     res = TaskSchedulerConstructor((LPVOID*) &punk);
78     if (FAILED(res))
79         return res;
80
81     res = ITaskScheduler_QueryInterface(punk, riid, ppvObj);
82     ITaskScheduler_Release(punk);
83     return res;
84 }
85
86 static HRESULT WINAPI MSTASK_IClassFactory_LockServer(
87         LPCLASSFACTORY iface,
88         BOOL fLock)
89 {
90     TRACE("\n");
91
92     if (fLock != FALSE)
93         MSTASK_IClassFactory_AddRef(iface);
94     else
95         MSTASK_IClassFactory_Release(iface);
96     return S_OK;
97 }
98
99 static const IClassFactoryVtbl IClassFactory_Vtbl =
100 {
101     MSTASK_IClassFactory_QueryInterface,
102     MSTASK_IClassFactory_AddRef,
103     MSTASK_IClassFactory_Release,
104     MSTASK_IClassFactory_CreateInstance,
105     MSTASK_IClassFactory_LockServer
106 };
107
108 ClassFactoryImpl MSTASK_ClassFactory = { &IClassFactory_Vtbl };