dmscript: Mark internal symbols with hidden visibility.
[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 struct ClassFactoryImpl
25 {
26     IClassFactory IClassFactory_iface;
27     LONG ref;
28 };
29
30 static inline ClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
31 {
32     return CONTAINING_RECORD(iface, ClassFactoryImpl, IClassFactory_iface);
33 }
34
35 static HRESULT WINAPI MSTASK_IClassFactory_QueryInterface(
36         LPCLASSFACTORY iface,
37         REFIID riid,
38         LPVOID *ppvObj)
39 {
40     ClassFactoryImpl *This = impl_from_IClassFactory(iface);
41
42     TRACE("IID: %s\n",debugstr_guid(riid));
43     if (ppvObj == NULL)
44         return E_POINTER;
45
46     if (IsEqualGUID(riid, &IID_IUnknown) ||
47             IsEqualGUID(riid, &IID_IClassFactory))
48     {
49         *ppvObj = &This->IClassFactory_iface;
50         IClassFactory_AddRef(iface);
51         return S_OK;
52     }
53
54     WARN("Unknown interface: %s\n", debugstr_guid(riid));
55     *ppvObj = NULL;
56     return E_NOINTERFACE;
57 }
58
59 static ULONG WINAPI MSTASK_IClassFactory_AddRef(LPCLASSFACTORY iface)
60 {
61     TRACE("\n");
62     InterlockedIncrement(&dll_ref);
63     return 2;
64 }
65
66 static ULONG WINAPI MSTASK_IClassFactory_Release(LPCLASSFACTORY iface)
67 {
68     TRACE("\n");
69     InterlockedDecrement(&dll_ref);
70     return 1;
71 }
72
73 static HRESULT WINAPI MSTASK_IClassFactory_CreateInstance(
74         LPCLASSFACTORY iface,
75         LPUNKNOWN pUnkOuter,
76         REFIID riid,
77         LPVOID *ppvObj)
78 {
79     HRESULT res;
80     IUnknown *punk = NULL;
81     *ppvObj = NULL;
82
83     TRACE("IID: %s\n",debugstr_guid(riid));
84
85     if (pUnkOuter)
86         return CLASS_E_NOAGGREGATION;
87
88     res = TaskSchedulerConstructor((LPVOID*) &punk);
89     if (FAILED(res))
90         return res;
91
92     res = ITaskScheduler_QueryInterface(punk, riid, ppvObj);
93     ITaskScheduler_Release(punk);
94     return res;
95 }
96
97 static HRESULT WINAPI MSTASK_IClassFactory_LockServer(
98         LPCLASSFACTORY iface,
99         BOOL fLock)
100 {
101     TRACE("\n");
102
103     if (fLock != FALSE)
104         MSTASK_IClassFactory_AddRef(iface);
105     else
106         MSTASK_IClassFactory_Release(iface);
107     return S_OK;
108 }
109
110 static const IClassFactoryVtbl IClassFactory_Vtbl =
111 {
112     MSTASK_IClassFactory_QueryInterface,
113     MSTASK_IClassFactory_AddRef,
114     MSTASK_IClassFactory_Release,
115     MSTASK_IClassFactory_CreateInstance,
116     MSTASK_IClassFactory_LockServer
117 };
118
119 ClassFactoryImpl MSTASK_ClassFactory = { { &IClassFactory_Vtbl } };