qmgr: Implement IBackgroundCopyJob_GetProgress.
[wine/hacks.git] / dlls / qmgr / job.c
blob8e3bce47a0d1f4fb498175de0c148ee4de4e5008
1 /*
2 * Background Copy Job Interface for BITS
4 * Copyright 2007 Google (Roy Shea)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "qmgr.h"
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
26 static void BackgroundCopyJobDestructor(BackgroundCopyJobImpl *This)
28 HeapFree(GetProcessHeap(), 0, This->displayName);
29 HeapFree(GetProcessHeap(), 0, This);
32 static ULONG WINAPI BITS_IBackgroundCopyJob_AddRef(IBackgroundCopyJob* iface)
34 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
35 return InterlockedIncrement(&This->ref);
38 static HRESULT WINAPI BITS_IBackgroundCopyJob_QueryInterface(
39 IBackgroundCopyJob* iface, REFIID riid, LPVOID *ppvObject)
41 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
42 TRACE("IID: %s\n", debugstr_guid(riid));
44 if (IsEqualGUID(riid, &IID_IUnknown)
45 || IsEqualGUID(riid, &IID_IBackgroundCopyJob))
47 *ppvObject = &This->lpVtbl;
48 BITS_IBackgroundCopyJob_AddRef(iface);
49 return S_OK;
52 *ppvObject = NULL;
53 return E_NOINTERFACE;
56 static ULONG WINAPI BITS_IBackgroundCopyJob_Release(IBackgroundCopyJob* iface)
58 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
59 ULONG ref = InterlockedDecrement(&This->ref);
61 if (ref == 0)
62 BackgroundCopyJobDestructor(This);
64 return ref;
67 /*** IBackgroundCopyJob methods ***/
69 static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFileSet(
70 IBackgroundCopyJob* iface,
71 ULONG cFileCount,
72 BG_FILE_INFO *pFileSet)
74 FIXME("Not implemented\n");
75 return E_NOTIMPL;
78 static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile(
79 IBackgroundCopyJob* iface,
80 LPCWSTR RemoteUrl,
81 LPCWSTR LocalName)
83 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
84 IBackgroundCopyFile *pFile;
85 BackgroundCopyFileImpl *file;
86 HRESULT res;
88 /* We should return E_INVALIDARG in these cases. */
89 FIXME("Check for valid filenames and supported protocols\n");
91 res = BackgroundCopyFileConstructor(RemoteUrl, LocalName, (LPVOID *) &pFile);
92 if (res != S_OK)
93 return res;
95 /* Add a reference to the file to file list */
96 IBackgroundCopyFile_AddRef(pFile);
97 file = (BackgroundCopyFileImpl *) pFile;
98 list_add_head(&This->files, &file->entryFromJob);
99 ++This->jobProgress.FilesTotal;
101 return S_OK;
104 static HRESULT WINAPI BITS_IBackgroundCopyJob_EnumFiles(
105 IBackgroundCopyJob* iface,
106 IEnumBackgroundCopyFiles **ppEnum)
108 TRACE("\n");
109 return EnumBackgroundCopyFilesConstructor((LPVOID *) ppEnum, iface);
112 static HRESULT WINAPI BITS_IBackgroundCopyJob_Suspend(
113 IBackgroundCopyJob* iface)
115 FIXME("Not implemented\n");
116 return E_NOTIMPL;
119 static HRESULT WINAPI BITS_IBackgroundCopyJob_Resume(
120 IBackgroundCopyJob* iface)
122 FIXME("Not implemented\n");
123 return E_NOTIMPL;
126 static HRESULT WINAPI BITS_IBackgroundCopyJob_Cancel(
127 IBackgroundCopyJob* iface)
129 FIXME("Not implemented\n");
130 return E_NOTIMPL;
133 static HRESULT WINAPI BITS_IBackgroundCopyJob_Complete(
134 IBackgroundCopyJob* iface)
136 FIXME("Not implemented\n");
137 return E_NOTIMPL;
140 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetId(
141 IBackgroundCopyJob* iface,
142 GUID *pVal)
144 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
145 memcpy(pVal, &This->jobId, sizeof *pVal);
146 return S_OK;
149 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetType(
150 IBackgroundCopyJob* iface,
151 BG_JOB_TYPE *pVal)
153 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
155 if (!pVal)
156 return E_INVALIDARG;
158 *pVal = This->type;
159 return S_OK;
162 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProgress(
163 IBackgroundCopyJob* iface,
164 BG_JOB_PROGRESS *pVal)
166 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
168 if (!pVal)
169 return E_INVALIDARG;
171 pVal->BytesTotal = This->jobProgress.BytesTotal;
172 pVal->BytesTransferred = This->jobProgress.BytesTransferred;
173 pVal->FilesTotal = This->jobProgress.FilesTotal;
174 pVal->FilesTransferred = This->jobProgress.FilesTransferred;
176 return S_OK;
179 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetTimes(
180 IBackgroundCopyJob* iface,
181 BG_JOB_TIMES *pVal)
183 FIXME("Not implemented\n");
184 return E_NOTIMPL;
187 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetState(
188 IBackgroundCopyJob* iface,
189 BG_JOB_STATE *pVal)
191 FIXME("Not implemented\n");
192 return E_NOTIMPL;
195 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetError(
196 IBackgroundCopyJob* iface,
197 IBackgroundCopyError **ppError)
199 FIXME("Not implemented\n");
200 return E_NOTIMPL;
203 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetOwner(
204 IBackgroundCopyJob* iface,
205 LPWSTR *pVal)
207 FIXME("Not implemented\n");
208 return E_NOTIMPL;
211 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDisplayName(
212 IBackgroundCopyJob* iface,
213 LPCWSTR Val)
215 FIXME("Not implemented\n");
216 return E_NOTIMPL;
219 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDisplayName(
220 IBackgroundCopyJob* iface,
221 LPWSTR *pVal)
223 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
224 int n;
226 if (!pVal)
227 return E_INVALIDARG;
229 n = (lstrlenW(This->displayName) + 1) * sizeof **pVal;
230 *pVal = CoTaskMemAlloc(n);
231 if (*pVal == NULL)
232 return E_OUTOFMEMORY;
233 memcpy(*pVal, This->displayName, n);
234 return S_OK;
237 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDescription(
238 IBackgroundCopyJob* iface,
239 LPCWSTR Val)
241 FIXME("Not implemented\n");
242 return E_NOTIMPL;
245 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDescription(
246 IBackgroundCopyJob* iface,
247 LPWSTR *pVal)
249 FIXME("Not implemented\n");
250 return E_NOTIMPL;
253 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetPriority(
254 IBackgroundCopyJob* iface,
255 BG_JOB_PRIORITY Val)
257 FIXME("Not implemented\n");
258 return E_NOTIMPL;
261 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetPriority(
262 IBackgroundCopyJob* iface,
263 BG_JOB_PRIORITY *pVal)
265 FIXME("Not implemented\n");
266 return E_NOTIMPL;
269 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyFlags(
270 IBackgroundCopyJob* iface,
271 ULONG Val)
273 FIXME("Not implemented\n");
274 return E_NOTIMPL;
277 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyFlags(
278 IBackgroundCopyJob* iface,
279 ULONG *pVal)
281 FIXME("Not implemented\n");
282 return E_NOTIMPL;
285 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyInterface(
286 IBackgroundCopyJob* iface,
287 IUnknown *Val)
289 FIXME("Not implemented\n");
290 return E_NOTIMPL;
293 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyInterface(
294 IBackgroundCopyJob* iface,
295 IUnknown **pVal)
297 FIXME("Not implemented\n");
298 return E_NOTIMPL;
301 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetMinimumRetryDelay(
302 IBackgroundCopyJob* iface,
303 ULONG Seconds)
305 FIXME("Not implemented\n");
306 return E_NOTIMPL;
309 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetMinimumRetryDelay(
310 IBackgroundCopyJob* iface,
311 ULONG *Seconds)
313 FIXME("Not implemented\n");
314 return E_NOTIMPL;
317 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNoProgressTimeout(
318 IBackgroundCopyJob* iface,
319 ULONG Seconds)
321 FIXME("Not implemented\n");
322 return E_NOTIMPL;
325 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNoProgressTimeout(
326 IBackgroundCopyJob* iface,
327 ULONG *Seconds)
329 FIXME("Not implemented\n");
330 return E_NOTIMPL;
333 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetErrorCount(
334 IBackgroundCopyJob* iface,
335 ULONG *Errors)
337 FIXME("Not implemented\n");
338 return E_NOTIMPL;
341 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetProxySettings(
342 IBackgroundCopyJob* iface,
343 BG_JOB_PROXY_USAGE ProxyUsage,
344 const WCHAR *ProxyList,
345 const WCHAR *ProxyBypassList)
347 FIXME("Not implemented\n");
348 return E_NOTIMPL;
351 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProxySettings(
352 IBackgroundCopyJob* iface,
353 BG_JOB_PROXY_USAGE *pProxyUsage,
354 LPWSTR *pProxyList,
355 LPWSTR *pProxyBypassList)
357 FIXME("Not implemented\n");
358 return E_NOTIMPL;
361 static HRESULT WINAPI BITS_IBackgroundCopyJob_TakeOwnership(
362 IBackgroundCopyJob* iface)
364 FIXME("Not implemented\n");
365 return E_NOTIMPL;
369 static const IBackgroundCopyJobVtbl BITS_IBackgroundCopyJob_Vtbl =
371 BITS_IBackgroundCopyJob_QueryInterface,
372 BITS_IBackgroundCopyJob_AddRef,
373 BITS_IBackgroundCopyJob_Release,
374 BITS_IBackgroundCopyJob_AddFileSet,
375 BITS_IBackgroundCopyJob_AddFile,
376 BITS_IBackgroundCopyJob_EnumFiles,
377 BITS_IBackgroundCopyJob_Suspend,
378 BITS_IBackgroundCopyJob_Resume,
379 BITS_IBackgroundCopyJob_Cancel,
380 BITS_IBackgroundCopyJob_Complete,
381 BITS_IBackgroundCopyJob_GetId,
382 BITS_IBackgroundCopyJob_GetType,
383 BITS_IBackgroundCopyJob_GetProgress,
384 BITS_IBackgroundCopyJob_GetTimes,
385 BITS_IBackgroundCopyJob_GetState,
386 BITS_IBackgroundCopyJob_GetError,
387 BITS_IBackgroundCopyJob_GetOwner,
388 BITS_IBackgroundCopyJob_SetDisplayName,
389 BITS_IBackgroundCopyJob_GetDisplayName,
390 BITS_IBackgroundCopyJob_SetDescription,
391 BITS_IBackgroundCopyJob_GetDescription,
392 BITS_IBackgroundCopyJob_SetPriority,
393 BITS_IBackgroundCopyJob_GetPriority,
394 BITS_IBackgroundCopyJob_SetNotifyFlags,
395 BITS_IBackgroundCopyJob_GetNotifyFlags,
396 BITS_IBackgroundCopyJob_SetNotifyInterface,
397 BITS_IBackgroundCopyJob_GetNotifyInterface,
398 BITS_IBackgroundCopyJob_SetMinimumRetryDelay,
399 BITS_IBackgroundCopyJob_GetMinimumRetryDelay,
400 BITS_IBackgroundCopyJob_SetNoProgressTimeout,
401 BITS_IBackgroundCopyJob_GetNoProgressTimeout,
402 BITS_IBackgroundCopyJob_GetErrorCount,
403 BITS_IBackgroundCopyJob_SetProxySettings,
404 BITS_IBackgroundCopyJob_GetProxySettings,
405 BITS_IBackgroundCopyJob_TakeOwnership,
408 HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
409 GUID *pJobId, LPVOID *ppObj)
411 HRESULT hr;
412 BackgroundCopyJobImpl *This;
413 int n;
415 TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, ppObj);
417 This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
418 if (!This)
419 return E_OUTOFMEMORY;
421 This->lpVtbl = &BITS_IBackgroundCopyJob_Vtbl;
422 This->ref = 1;
423 This->type = type;
425 n = (lstrlenW(displayName) + 1) * sizeof *displayName;
426 This->displayName = HeapAlloc(GetProcessHeap(), 0, n);
427 if (!This->displayName)
429 HeapFree(GetProcessHeap(), 0, This);
430 return E_OUTOFMEMORY;
432 memcpy(This->displayName, displayName, n);
434 hr = CoCreateGuid(&This->jobId);
435 if (FAILED(hr))
437 HeapFree(GetProcessHeap(), 0, This->displayName);
438 HeapFree(GetProcessHeap(), 0, This);
439 return hr;
441 memcpy(pJobId, &This->jobId, sizeof(GUID));
443 list_init(&This->files);
444 This->jobProgress.BytesTotal = 0;
445 This->jobProgress.BytesTransferred = 0;
446 This->jobProgress.FilesTotal = 0;
447 This->jobProgress.FilesTransferred = 0;
449 *ppObj = &This->lpVtbl;
450 return S_OK;