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