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