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 BackgroundCopyJobImpl
*This
= (BackgroundCopyJobImpl
*) iface
;
171 pVal
->BytesTotal
= This
->jobProgress
.BytesTotal
;
172 pVal
->BytesTransferred
= This
->jobProgress
.BytesTransferred
;
173 pVal
->FilesTotal
= This
->jobProgress
.FilesTotal
;
174 pVal
->FilesTransferred
= This
->jobProgress
.FilesTransferred
;
179 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetTimes(
180 IBackgroundCopyJob
* iface
,
183 FIXME("Not implemented\n");
187 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetState(
188 IBackgroundCopyJob
* iface
,
191 FIXME("Not implemented\n");
195 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetError(
196 IBackgroundCopyJob
* iface
,
197 IBackgroundCopyError
**ppError
)
199 FIXME("Not implemented\n");
203 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetOwner(
204 IBackgroundCopyJob
* iface
,
207 FIXME("Not implemented\n");
211 static HRESULT WINAPI
BITS_IBackgroundCopyJob_SetDisplayName(
212 IBackgroundCopyJob
* iface
,
215 FIXME("Not implemented\n");
219 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetDisplayName(
220 IBackgroundCopyJob
* iface
,
223 BackgroundCopyJobImpl
*This
= (BackgroundCopyJobImpl
*) iface
;
229 n
= (lstrlenW(This
->displayName
) + 1) * sizeof **pVal
;
230 *pVal
= CoTaskMemAlloc(n
);
232 return E_OUTOFMEMORY
;
233 memcpy(*pVal
, This
->displayName
, n
);
237 static HRESULT WINAPI
BITS_IBackgroundCopyJob_SetDescription(
238 IBackgroundCopyJob
* iface
,
241 FIXME("Not implemented\n");
245 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetDescription(
246 IBackgroundCopyJob
* iface
,
249 FIXME("Not implemented\n");
253 static HRESULT WINAPI
BITS_IBackgroundCopyJob_SetPriority(
254 IBackgroundCopyJob
* iface
,
257 FIXME("Not implemented\n");
261 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetPriority(
262 IBackgroundCopyJob
* iface
,
263 BG_JOB_PRIORITY
*pVal
)
265 FIXME("Not implemented\n");
269 static HRESULT WINAPI
BITS_IBackgroundCopyJob_SetNotifyFlags(
270 IBackgroundCopyJob
* iface
,
273 FIXME("Not implemented\n");
277 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetNotifyFlags(
278 IBackgroundCopyJob
* iface
,
281 FIXME("Not implemented\n");
285 static HRESULT WINAPI
BITS_IBackgroundCopyJob_SetNotifyInterface(
286 IBackgroundCopyJob
* iface
,
289 FIXME("Not implemented\n");
293 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetNotifyInterface(
294 IBackgroundCopyJob
* iface
,
297 FIXME("Not implemented\n");
301 static HRESULT WINAPI
BITS_IBackgroundCopyJob_SetMinimumRetryDelay(
302 IBackgroundCopyJob
* iface
,
305 FIXME("Not implemented\n");
309 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetMinimumRetryDelay(
310 IBackgroundCopyJob
* iface
,
313 FIXME("Not implemented\n");
317 static HRESULT WINAPI
BITS_IBackgroundCopyJob_SetNoProgressTimeout(
318 IBackgroundCopyJob
* iface
,
321 FIXME("Not implemented\n");
325 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetNoProgressTimeout(
326 IBackgroundCopyJob
* iface
,
329 FIXME("Not implemented\n");
333 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetErrorCount(
334 IBackgroundCopyJob
* iface
,
337 FIXME("Not implemented\n");
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");
351 static HRESULT WINAPI
BITS_IBackgroundCopyJob_GetProxySettings(
352 IBackgroundCopyJob
* iface
,
353 BG_JOB_PROXY_USAGE
*pProxyUsage
,
355 LPWSTR
*pProxyBypassList
)
357 FIXME("Not implemented\n");
361 static HRESULT WINAPI
BITS_IBackgroundCopyJob_TakeOwnership(
362 IBackgroundCopyJob
* iface
)
364 FIXME("Not implemented\n");
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
)
412 BackgroundCopyJobImpl
*This
;
415 TRACE("(%s,%d,%p)\n", debugstr_w(displayName
), type
, ppObj
);
417 This
= HeapAlloc(GetProcessHeap(), 0, sizeof *This
);
419 return E_OUTOFMEMORY
;
421 This
->lpVtbl
= &BITS_IBackgroundCopyJob_Vtbl
;
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
);
437 HeapFree(GetProcessHeap(), 0, This
->displayName
);
438 HeapFree(GetProcessHeap(), 0, This
);
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
;