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
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);
56 static ULONG WINAPI BITS_IBackgroundCopyJob_Release(IBackgroundCopyJob* iface)
58 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
59 ULONG ref = InterlockedDecrement(&This->ref);
62 BackgroundCopyJobDestructor(This);
67 /*** IBackgroundCopyJob methods ***/
69 static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFileSet(
70 IBackgroundCopyJob* iface,
72 BG_FILE_INFO *pFileSet)
74 FIXME("Not implemented\n");
78 static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile(
79 IBackgroundCopyJob* iface,
83 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
84 IBackgroundCopyFile *pFile;
85 BackgroundCopyFileImpl *file;
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);
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;
104 static HRESULT WINAPI BITS_IBackgroundCopyJob_EnumFiles(
105 IBackgroundCopyJob* iface,
106 IEnumBackgroundCopyFiles **ppEnum)
109 return EnumBackgroundCopyFilesConstructor((LPVOID *) ppEnum, iface);
112 static HRESULT WINAPI BITS_IBackgroundCopyJob_Suspend(
113 IBackgroundCopyJob* iface)
115 FIXME("Not implemented\n");
119 static HRESULT WINAPI BITS_IBackgroundCopyJob_Resume(
120 IBackgroundCopyJob* iface)
122 FIXME("Not implemented\n");
126 static HRESULT WINAPI BITS_IBackgroundCopyJob_Cancel(
127 IBackgroundCopyJob* iface)
129 FIXME("Not implemented\n");
133 static HRESULT WINAPI BITS_IBackgroundCopyJob_Complete(
134 IBackgroundCopyJob* iface)
136 FIXME("Not implemented\n");
140 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetId(
141 IBackgroundCopyJob* iface,
144 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
145 memcpy(pVal, &This->jobId, sizeof *pVal);
149 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetType(
150 IBackgroundCopyJob* iface,
153 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
162 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProgress(
163 IBackgroundCopyJob* iface,
164 BG_JOB_PROGRESS *pVal)
166 FIXME("Not implemented\n");
170 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetTimes(
171 IBackgroundCopyJob* iface,
174 FIXME("Not implemented\n");
178 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetState(
179 IBackgroundCopyJob* iface,
182 FIXME("Not implemented\n");
186 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetError(
187 IBackgroundCopyJob* iface,
188 IBackgroundCopyError **ppError)
190 FIXME("Not implemented\n");
194 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetOwner(
195 IBackgroundCopyJob* iface,
198 FIXME("Not implemented\n");
202 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDisplayName(
203 IBackgroundCopyJob* iface,
206 FIXME("Not implemented\n");
210 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDisplayName(
211 IBackgroundCopyJob* iface,
214 BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
220 n = (lstrlenW(This->displayName) + 1) * sizeof **pVal;
221 *pVal = CoTaskMemAlloc(n);
223 return E_OUTOFMEMORY;
224 memcpy(*pVal, This->displayName, n);
228 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDescription(
229 IBackgroundCopyJob* iface,
232 FIXME("Not implemented\n");
236 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDescription(
237 IBackgroundCopyJob* iface,
240 FIXME("Not implemented\n");
244 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetPriority(
245 IBackgroundCopyJob* iface,
248 FIXME("Not implemented\n");
252 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetPriority(
253 IBackgroundCopyJob* iface,
254 BG_JOB_PRIORITY *pVal)
256 FIXME("Not implemented\n");
260 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyFlags(
261 IBackgroundCopyJob* iface,
264 FIXME("Not implemented\n");
268 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyFlags(
269 IBackgroundCopyJob* iface,
272 FIXME("Not implemented\n");
276 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyInterface(
277 IBackgroundCopyJob* iface,
280 FIXME("Not implemented\n");
284 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyInterface(
285 IBackgroundCopyJob* iface,
288 FIXME("Not implemented\n");
292 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetMinimumRetryDelay(
293 IBackgroundCopyJob* iface,
296 FIXME("Not implemented\n");
300 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetMinimumRetryDelay(
301 IBackgroundCopyJob* iface,
304 FIXME("Not implemented\n");
308 static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNoProgressTimeout(
309 IBackgroundCopyJob* iface,
312 FIXME("Not implemented\n");
316 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNoProgressTimeout(
317 IBackgroundCopyJob* iface,
320 FIXME("Not implemented\n");
324 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetErrorCount(
325 IBackgroundCopyJob* iface,
328 FIXME("Not implemented\n");
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");
342 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProxySettings(
343 IBackgroundCopyJob* iface,
344 BG_JOB_PROXY_USAGE *pProxyUsage,
346 LPWSTR *pProxyBypassList)
348 FIXME("Not implemented\n");
352 static HRESULT WINAPI BITS_IBackgroundCopyJob_TakeOwnership(
353 IBackgroundCopyJob* iface)
355 FIXME("Not implemented\n");
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)
403 BackgroundCopyJobImpl *This;
406 TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, ppObj);
408 This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
410 return E_OUTOFMEMORY;
412 This->lpVtbl = &BITS_IBackgroundCopyJob_Vtbl;
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);
428 HeapFree(GetProcessHeap(), 0, This->displayName);
429 HeapFree(GetProcessHeap(), 0, This);
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;