d3d10: COM cleanup for the ID3D10Effect iface.
[wine] / dlls / mstask / task_scheduler.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 "corerror.h"
20 #include "mstask_private.h"
21 #include "wine/debug.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(mstask);
24
25 typedef struct
26 {
27     ITaskScheduler ITaskScheduler_iface;
28     LONG ref;
29 } TaskSchedulerImpl;
30
31 static inline TaskSchedulerImpl *impl_from_ITaskScheduler(ITaskScheduler *iface)
32 {
33     return CONTAINING_RECORD(iface, TaskSchedulerImpl, ITaskScheduler_iface);
34 }
35
36 static void TaskSchedulerDestructor(TaskSchedulerImpl *This)
37 {
38     TRACE("%p\n", This);
39     HeapFree(GetProcessHeap(), 0, This);
40     InterlockedDecrement(&dll_ref);
41 }
42
43 static HRESULT WINAPI MSTASK_ITaskScheduler_QueryInterface(
44         ITaskScheduler* iface,
45         REFIID riid,
46         void **ppvObject)
47 {
48     TaskSchedulerImpl * This = impl_from_ITaskScheduler(iface);
49
50     TRACE("IID: %s\n", debugstr_guid(riid));
51
52     if (IsEqualGUID(riid, &IID_IUnknown) ||
53             IsEqualGUID(riid, &IID_ITaskScheduler))
54     {
55         *ppvObject = &This->ITaskScheduler_iface;
56         ITaskScheduler_AddRef(iface);
57         return S_OK;
58     }
59
60     *ppvObject = NULL;
61     return E_NOINTERFACE;
62 }
63
64 static ULONG WINAPI MSTASK_ITaskScheduler_AddRef(
65         ITaskScheduler* iface)
66 {
67     TaskSchedulerImpl *This = impl_from_ITaskScheduler(iface);
68     TRACE("\n");
69     return InterlockedIncrement(&This->ref);
70 }
71
72 static ULONG WINAPI MSTASK_ITaskScheduler_Release(
73         ITaskScheduler* iface)
74 {
75     TaskSchedulerImpl * This = impl_from_ITaskScheduler(iface);
76     ULONG ref;
77     TRACE("\n");
78     ref = InterlockedDecrement(&This->ref);
79     if (ref == 0)
80         TaskSchedulerDestructor(This);
81     return ref;
82 }
83
84 static HRESULT WINAPI MSTASK_ITaskScheduler_SetTargetComputer(
85         ITaskScheduler* iface,
86         LPCWSTR pwszComputer)
87 {
88     FIXME("%p, %s: stub\n", iface, debugstr_w(pwszComputer));
89     return E_NOTIMPL;
90 }
91
92 static HRESULT WINAPI MSTASK_ITaskScheduler_GetTargetComputer(
93         ITaskScheduler* iface,
94         LPWSTR *ppwszComputer)
95 {
96     FIXME("%p, %p: stub\n", iface, ppwszComputer);
97     return E_NOTIMPL;
98 }
99
100 static HRESULT WINAPI MSTASK_ITaskScheduler_Enum(
101         ITaskScheduler* iface,
102         IEnumWorkItems **ppEnumTasks)
103 {
104     FIXME("%p, %p: stub\n", iface, ppEnumTasks);
105     return E_NOTIMPL;
106 }
107
108 static HRESULT WINAPI MSTASK_ITaskScheduler_Activate(
109         ITaskScheduler* iface,
110         LPCWSTR pwszName,
111         REFIID riid,
112         IUnknown **ppunk)
113 {
114     TRACE("%p, %s, %s, %p: stub\n", iface, debugstr_w(pwszName),
115             debugstr_guid(riid), ppunk);
116     FIXME("Partial stub always returning COR_E_FILENOTFOUND\n");
117     return COR_E_FILENOTFOUND;
118 }
119
120 static HRESULT WINAPI MSTASK_ITaskScheduler_Delete(
121         ITaskScheduler* iface,
122         LPCWSTR pwszName)
123 {
124     FIXME("%p, %s: stub\n", iface, debugstr_w(pwszName));
125     return E_NOTIMPL;
126 }
127
128 static HRESULT WINAPI MSTASK_ITaskScheduler_NewWorkItem(
129         ITaskScheduler* iface,
130         LPCWSTR pwszTaskName,
131         REFCLSID rclsid,
132         REFIID riid,
133         IUnknown **ppunk)
134 {
135     HRESULT hr;
136     TRACE("(%p, %s, %s, %s, %p)\n", iface, debugstr_w(pwszTaskName),
137             debugstr_guid(rclsid) ,debugstr_guid(riid),  ppunk);
138
139     if (!IsEqualGUID(rclsid, &CLSID_CTask))
140         return CLASS_E_CLASSNOTAVAILABLE;
141
142     if (!IsEqualGUID(riid, &IID_ITask))
143         return E_NOINTERFACE;
144
145     hr = TaskConstructor(pwszTaskName, (LPVOID *)ppunk);
146     return hr;
147 }
148
149 static HRESULT WINAPI MSTASK_ITaskScheduler_AddWorkItem(
150         ITaskScheduler* iface,
151         LPCWSTR pwszTaskName,
152         IScheduledWorkItem *pWorkItem)
153 {
154     FIXME("%p, %s, %p: stub\n", iface, debugstr_w(pwszTaskName), pWorkItem);
155     return E_NOTIMPL;
156 }
157
158 static HRESULT WINAPI MSTASK_ITaskScheduler_IsOfType(
159         ITaskScheduler* iface,
160         LPCWSTR pwszName,
161         REFIID riid)
162 {
163     FIXME("%p, %s, %s: stub\n", iface, debugstr_w(pwszName),
164             debugstr_guid(riid));
165     return E_NOTIMPL;
166 }
167
168 static const ITaskSchedulerVtbl MSTASK_ITaskSchedulerVtbl =
169 {
170     MSTASK_ITaskScheduler_QueryInterface,
171     MSTASK_ITaskScheduler_AddRef,
172     MSTASK_ITaskScheduler_Release,
173     MSTASK_ITaskScheduler_SetTargetComputer,
174     MSTASK_ITaskScheduler_GetTargetComputer,
175     MSTASK_ITaskScheduler_Enum,
176     MSTASK_ITaskScheduler_Activate,
177     MSTASK_ITaskScheduler_Delete,
178     MSTASK_ITaskScheduler_NewWorkItem,
179     MSTASK_ITaskScheduler_AddWorkItem,
180     MSTASK_ITaskScheduler_IsOfType
181 };
182
183 HRESULT TaskSchedulerConstructor(LPVOID *ppObj)
184 {
185     TaskSchedulerImpl *This;
186     TRACE("(%p)\n", ppObj);
187
188     This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
189     if (!This)
190         return E_OUTOFMEMORY;
191
192     This->ITaskScheduler_iface.lpVtbl = &MSTASK_ITaskSchedulerVtbl;
193     This->ref = 1;
194
195     *ppObj = &This->ITaskScheduler_iface;
196     InterlockedIncrement(&dll_ref);
197     return S_OK;
198 }