qmgr: Implement IBackgroundCopyJob_AddFile.
[wine.git] / dlls / qmgr / job.c
blob3db3c79037048821dcaef2d67a42c8dc0be2b625
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 **pEnum)
108 FIXME("Not implemented\n");
109 return E_NOTIMPL;
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 FIXME("Not implemented\n");
167 return E_NOTIMPL;
170 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetTimes(
171 IBackgroundCopyJob* iface,
172 BG_JOB_TIMES *pVal)
174 FIXME("Not implemented\n");
175 return E_NOTIMPL;
178 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetState(
179 IBackgroundCopyJob* iface,
180 BG_JOB_STATE *pVal)
182 FIXME("Not implemented\n");
183 return E_NOTIMPL;
186 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetError(
187 IBackgroundCopyJob* iface,
188 IBackgroundCopyError **ppError)
190 FIXME("Not implemented\n");
191 return E_NOTIMPL;
194 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetOwner(
195 IBackgroundCopyJob* iface,
196 LPWSTR *pVal)
198 FIXME("Not implemented\n");
199 return E_NOTIMPL;
202 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDisplayName(
203 IBackgroundCopyJob* iface,
204 LPCWSTR Val)
206 FIXME("Not implemented\n");
207 return E_NOTIMPL;
210 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDisplayName(
211 IBackgroundCopyJob* iface,
212 LPWSTR *pVal)
214 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
215 int n;
217 if (!pVal)
218 return E_INVALIDARG;
220 n = (lstrlenW(This->displayName) + 1) * sizeof **pVal;
221 *pVal = CoTaskMemAlloc(n);
222 if (*pVal == NULL)
223 return E_OUTOFMEMORY;
224 memcpy(*pVal, This->displayName, n);
225 return S_OK;
228 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDescription(
229 IBackgroundCopyJob* iface,
230 LPCWSTR Val)
232 FIXME("Not implemented\n");
233 return E_NOTIMPL;
236 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDescription(
237 IBackgroundCopyJob* iface,
238 LPWSTR *pVal)
240 FIXME("Not implemented\n");
241 return E_NOTIMPL;
244 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetPriority(
245 IBackgroundCopyJob* iface,
246 BG_JOB_PRIORITY Val)
248 FIXME("Not implemented\n");
249 return E_NOTIMPL;
252 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetPriority(
253 IBackgroundCopyJob* iface,
254 BG_JOB_PRIORITY *pVal)
256 FIXME("Not implemented\n");
257 return E_NOTIMPL;
260 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyFlags(
261 IBackgroundCopyJob* iface,
262 ULONG Val)
264 FIXME("Not implemented\n");
265 return E_NOTIMPL;
268 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyFlags(
269 IBackgroundCopyJob* iface,
270 ULONG *pVal)
272 FIXME("Not implemented\n");
273 return E_NOTIMPL;
276 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyInterface(
277 IBackgroundCopyJob* iface,
278 IUnknown *Val)
280 FIXME("Not implemented\n");
281 return E_NOTIMPL;
284 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyInterface(
285 IBackgroundCopyJob* iface,
286 IUnknown **pVal)
288 FIXME("Not implemented\n");
289 return E_NOTIMPL;
292 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetMinimumRetryDelay(
293 IBackgroundCopyJob* iface,
294 ULONG Seconds)
296 FIXME("Not implemented\n");
297 return E_NOTIMPL;
300 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetMinimumRetryDelay(
301 IBackgroundCopyJob* iface,
302 ULONG *Seconds)
304 FIXME("Not implemented\n");
305 return E_NOTIMPL;
308 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNoProgressTimeout(
309 IBackgroundCopyJob* iface,
310 ULONG Seconds)
312 FIXME("Not implemented\n");
313 return E_NOTIMPL;
316 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNoProgressTimeout(
317 IBackgroundCopyJob* iface,
318 ULONG *Seconds)
320 FIXME("Not implemented\n");
321 return E_NOTIMPL;
324 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetErrorCount(
325 IBackgroundCopyJob* iface,
326 ULONG *Errors)
328 FIXME("Not implemented\n");
329 return E_NOTIMPL;
332 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetProxySettings(
333 IBackgroundCopyJob* iface,
334 BG_JOB_PROXY_USAGE ProxyUsage,
335 const WCHAR *ProxyList,
336 const WCHAR *ProxyBypassList)
338 FIXME("Not implemented\n");
339 return E_NOTIMPL;
342 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProxySettings(
343 IBackgroundCopyJob* iface,
344 BG_JOB_PROXY_USAGE *pProxyUsage,
345 LPWSTR *pProxyList,
346 LPWSTR *pProxyBypassList)
348 FIXME("Not implemented\n");
349 return E_NOTIMPL;
352 static HRESULT WINAPI BITS_IBackgroundCopyJob_TakeOwnership(
353 IBackgroundCopyJob* iface)
355 FIXME("Not implemented\n");
356 return E_NOTIMPL;
360 static const IBackgroundCopyJobVtbl BITS_IBackgroundCopyJob_Vtbl =
362 BITS_IBackgroundCopyJob_QueryInterface,
363 BITS_IBackgroundCopyJob_AddRef,
364 BITS_IBackgroundCopyJob_Release,
365 BITS_IBackgroundCopyJob_AddFileSet,
366 BITS_IBackgroundCopyJob_AddFile,
367 BITS_IBackgroundCopyJob_EnumFiles,
368 BITS_IBackgroundCopyJob_Suspend,
369 BITS_IBackgroundCopyJob_Resume,
370 BITS_IBackgroundCopyJob_Cancel,
371 BITS_IBackgroundCopyJob_Complete,
372 BITS_IBackgroundCopyJob_GetId,
373 BITS_IBackgroundCopyJob_GetType,
374 BITS_IBackgroundCopyJob_GetProgress,
375 BITS_IBackgroundCopyJob_GetTimes,
376 BITS_IBackgroundCopyJob_GetState,
377 BITS_IBackgroundCopyJob_GetError,
378 BITS_IBackgroundCopyJob_GetOwner,
379 BITS_IBackgroundCopyJob_SetDisplayName,
380 BITS_IBackgroundCopyJob_GetDisplayName,
381 BITS_IBackgroundCopyJob_SetDescription,
382 BITS_IBackgroundCopyJob_GetDescription,
383 BITS_IBackgroundCopyJob_SetPriority,
384 BITS_IBackgroundCopyJob_GetPriority,
385 BITS_IBackgroundCopyJob_SetNotifyFlags,
386 BITS_IBackgroundCopyJob_GetNotifyFlags,
387 BITS_IBackgroundCopyJob_SetNotifyInterface,
388 BITS_IBackgroundCopyJob_GetNotifyInterface,
389 BITS_IBackgroundCopyJob_SetMinimumRetryDelay,
390 BITS_IBackgroundCopyJob_GetMinimumRetryDelay,
391 BITS_IBackgroundCopyJob_SetNoProgressTimeout,
392 BITS_IBackgroundCopyJob_GetNoProgressTimeout,
393 BITS_IBackgroundCopyJob_GetErrorCount,
394 BITS_IBackgroundCopyJob_SetProxySettings,
395 BITS_IBackgroundCopyJob_GetProxySettings,
396 BITS_IBackgroundCopyJob_TakeOwnership,
399 HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
400 GUID *pJobId, LPVOID *ppObj)
402 HRESULT hr;
403 BackgroundCopyJobImpl *This;
404 int n;
406 TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, ppObj);
408 This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
409 if (!This)
410 return E_OUTOFMEMORY;
412 This->lpVtbl = &BITS_IBackgroundCopyJob_Vtbl;
413 This->ref = 1;
414 This->type = type;
416 n = (lstrlenW(displayName) + 1) * sizeof *displayName;
417 This->displayName = HeapAlloc(GetProcessHeap(), 0, n);
418 if (!This->displayName)
420 HeapFree(GetProcessHeap(), 0, This);
421 return E_OUTOFMEMORY;
423 memcpy(This->displayName, displayName, n);
425 hr = CoCreateGuid(&This->jobId);
426 if (FAILED(hr))
428 HeapFree(GetProcessHeap(), 0, This->displayName);
429 HeapFree(GetProcessHeap(), 0, This);
430 return hr;
432 memcpy(pJobId, &This->jobId, sizeof(GUID));
434 list_init(&This->files);
435 This->jobProgress.BytesTotal = BG_SIZE_UNKNOWN;
436 This->jobProgress.BytesTransferred = 0;
437 This->jobProgress.FilesTotal = 0;
438 This->jobProgress.FilesTransferred = 0;
440 *ppObj = &This->lpVtbl;
441 return S_OK;