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