push 63c1876572cbb61a874995ad42ef27c14590d232
[wine/hacks.git] / dlls / mstask / task_scheduler.c
blobbd4cc1d9ff0a15769d5a8555b8b2044b36673b9d
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 static void TaskSchedulerDestructor(TaskSchedulerImpl *This)
26 TRACE("%p\n", This);
27 HeapFree(GetProcessHeap(), 0, This);
28 InterlockedDecrement(&dll_ref);
31 static HRESULT WINAPI MSTASK_ITaskScheduler_QueryInterface(
32 ITaskScheduler* iface,
33 REFIID riid,
34 void **ppvObject)
36 TaskSchedulerImpl * This = (TaskSchedulerImpl *)iface;
38 TRACE("IID: %s\n", debugstr_guid(riid));
40 if (IsEqualGUID(riid, &IID_IUnknown) ||
41 IsEqualGUID(riid, &IID_ITaskScheduler))
43 *ppvObject = &This->lpVtbl;
44 ITaskScheduler_AddRef(iface);
45 return S_OK;
48 *ppvObject = NULL;
49 return E_NOINTERFACE;
52 static ULONG WINAPI MSTASK_ITaskScheduler_AddRef(
53 ITaskScheduler* iface)
55 TaskSchedulerImpl *This = (TaskSchedulerImpl *)iface;
56 TRACE("\n");
57 return InterlockedIncrement(&This->ref);
60 static ULONG WINAPI MSTASK_ITaskScheduler_Release(
61 ITaskScheduler* iface)
63 TaskSchedulerImpl * This = (TaskSchedulerImpl *)iface;
64 ULONG ref;
65 TRACE("\n");
66 ref = InterlockedDecrement(&This->ref);
67 if (ref == 0)
68 TaskSchedulerDestructor(This);
69 return ref;
72 static HRESULT WINAPI MSTASK_ITaskScheduler_SetTargetComputer(
73 ITaskScheduler* iface,
74 LPCWSTR pwszComputer)
76 FIXME("%p, %s: stub\n", iface, debugstr_w(pwszComputer));
77 return E_NOTIMPL;
80 static HRESULT WINAPI MSTASK_ITaskScheduler_GetTargetComputer(
81 ITaskScheduler* iface,
82 LPWSTR *ppwszComputer)
84 FIXME("%p, %p: stub\n", iface, ppwszComputer);
85 return E_NOTIMPL;
88 static HRESULT WINAPI MSTASK_ITaskScheduler_Enum(
89 ITaskScheduler* iface,
90 IEnumWorkItems **ppEnumTasks)
92 FIXME("%p, %p: stub\n", iface, ppEnumTasks);
93 return E_NOTIMPL;
96 static HRESULT WINAPI MSTASK_ITaskScheduler_Activate(
97 ITaskScheduler* iface,
98 LPCWSTR pwszName,
99 REFIID riid,
100 IUnknown **ppunk)
102 FIXME("%p, %s, %s, %p: stub\n", iface, debugstr_w(pwszName),
103 debugstr_guid(riid), ppunk);
104 return E_NOTIMPL;
107 static HRESULT WINAPI MSTASK_ITaskScheduler_Delete(
108 ITaskScheduler* iface,
109 LPCWSTR pwszName)
111 FIXME("%p, %s: stub\n", iface, debugstr_w(pwszName));
112 return E_NOTIMPL;
115 static HRESULT WINAPI MSTASK_ITaskScheduler_NewWorkItem(
116 ITaskScheduler* iface,
117 LPCWSTR pwszTaskName,
118 REFCLSID rclsid,
119 REFIID riid,
120 IUnknown **ppunk)
122 HRESULT hr;
123 TRACE("(%p, %s, %s, %s, %p)\n", iface, debugstr_w(pwszTaskName),
124 debugstr_guid(rclsid) ,debugstr_guid(riid), ppunk);
126 if (!IsEqualGUID(rclsid, &CLSID_CTask))
127 return CLASS_E_CLASSNOTAVAILABLE;
129 if (!IsEqualGUID(riid, &IID_ITask))
130 return E_NOINTERFACE;
132 hr = TaskConstructor(pwszTaskName, (LPVOID *)ppunk);
133 return hr;
136 static HRESULT WINAPI MSTASK_ITaskScheduler_AddWorkItem(
137 ITaskScheduler* iface,
138 LPCWSTR pwszTaskName,
139 IScheduledWorkItem *pWorkItem)
141 FIXME("%p, %s, %p: stub\n", iface, debugstr_w(pwszTaskName), pWorkItem);
142 return E_NOTIMPL;
145 static HRESULT WINAPI MSTASK_ITaskScheduler_IsOfType(
146 ITaskScheduler* iface,
147 LPCWSTR pwszName,
148 REFIID riid)
150 FIXME("%p, %s, %s: stub\n", iface, debugstr_w(pwszName),
151 debugstr_guid(riid));
152 return E_NOTIMPL;
155 static const ITaskSchedulerVtbl MSTASK_ITaskSchedulerVtbl =
157 MSTASK_ITaskScheduler_QueryInterface,
158 MSTASK_ITaskScheduler_AddRef,
159 MSTASK_ITaskScheduler_Release,
160 MSTASK_ITaskScheduler_SetTargetComputer,
161 MSTASK_ITaskScheduler_GetTargetComputer,
162 MSTASK_ITaskScheduler_Enum,
163 MSTASK_ITaskScheduler_Activate,
164 MSTASK_ITaskScheduler_Delete,
165 MSTASK_ITaskScheduler_NewWorkItem,
166 MSTASK_ITaskScheduler_AddWorkItem,
167 MSTASK_ITaskScheduler_IsOfType
170 HRESULT TaskSchedulerConstructor(LPVOID *ppObj)
172 TaskSchedulerImpl *This;
173 TRACE("(%p)\n", ppObj);
175 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
176 if (!This)
177 return E_OUTOFMEMORY;
179 This->lpVtbl = &MSTASK_ITaskSchedulerVtbl;
180 This->ref = 1;
182 *ppObj = &This->lpVtbl;
183 InterlockedIncrement(&dll_ref);
184 return S_OK;