2008-02-22 23:05:26 +00:00
|
|
|
/*
|
|
|
|
* Background Copy Job Interface for BITS
|
|
|
|
*
|
|
|
|
* Copyright 2007 Google (Roy Shea)
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2008-03-13 22:56:28 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
|
2008-02-22 23:05:26 +00:00
|
|
|
#include "qmgr.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
|
|
|
|
|
|
|
static void BackgroundCopyJobDestructor(BackgroundCopyJobImpl *This)
|
|
|
|
{
|
2011-11-14 14:10:44 +00:00
|
|
|
This->cs.DebugInfo->Spare[0] = 0;
|
2008-03-12 18:56:13 +00:00
|
|
|
DeleteCriticalSection(&This->cs);
|
2008-02-22 23:06:17 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->displayName);
|
2008-02-22 23:05:26 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
2013-01-17 18:39:26 +00:00
|
|
|
static inline BackgroundCopyJobImpl *impl_from_IBackgroundCopyJob2(IBackgroundCopyJob2 *iface)
|
2008-02-22 23:05:26 +00:00
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
return CONTAINING_RECORD(iface, BackgroundCopyJobImpl, IBackgroundCopyJob2_iface);
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_QueryInterface(
|
2013-01-17 18:39:26 +00:00
|
|
|
IBackgroundCopyJob2 *iface, REFIID riid, void **obj)
|
2008-02-22 23:05:26 +00:00
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
2008-02-22 23:05:26 +00:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
2008-03-19 22:02:02 +00:00
|
|
|
|| IsEqualGUID(riid, &IID_IBackgroundCopyJob)
|
|
|
|
|| IsEqualGUID(riid, &IID_IBackgroundCopyJob2))
|
2008-02-22 23:05:26 +00:00
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
*obj = iface;
|
|
|
|
IBackgroundCopyJob2_AddRef(iface);
|
2008-02-22 23:05:26 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-17 18:39:26 +00:00
|
|
|
*obj = NULL;
|
2008-02-22 23:05:26 +00:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2013-01-17 18:39:26 +00:00
|
|
|
static ULONG WINAPI BITS_IBackgroundCopyJob_AddRef(IBackgroundCopyJob2 *iface)
|
|
|
|
{
|
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2008-03-19 22:02:02 +00:00
|
|
|
static ULONG WINAPI BITS_IBackgroundCopyJob_Release(IBackgroundCopyJob2 *iface)
|
2008-02-22 23:05:26 +00:00
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
|
2008-02-22 23:05:26 +00:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2013-01-17 18:39:26 +00:00
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
2008-02-22 23:05:26 +00:00
|
|
|
if (ref == 0)
|
|
|
|
BackgroundCopyJobDestructor(This);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IBackgroundCopyJob methods ***/
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFileSet(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
ULONG cFileCount,
|
|
|
|
BG_FILE_INFO *pFileSet)
|
|
|
|
{
|
2008-03-14 22:51:40 +00:00
|
|
|
ULONG i;
|
|
|
|
for (i = 0; i < cFileCount; ++i)
|
|
|
|
{
|
2012-08-24 08:52:18 +00:00
|
|
|
HRESULT hr = IBackgroundCopyJob2_AddFile(iface, pFileSet[i].RemoteName,
|
2008-03-14 22:51:40 +00:00
|
|
|
pFileSet[i].LocalName);
|
2008-10-07 23:33:25 +00:00
|
|
|
if (FAILED(hr))
|
2008-03-14 22:51:40 +00:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
return S_OK;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
LPCWSTR RemoteUrl,
|
|
|
|
LPCWSTR LocalName)
|
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
|
2008-02-27 01:51:20 +00:00
|
|
|
BackgroundCopyFileImpl *file;
|
|
|
|
HRESULT res;
|
|
|
|
|
|
|
|
/* We should return E_INVALIDARG in these cases. */
|
|
|
|
FIXME("Check for valid filenames and supported protocols\n");
|
|
|
|
|
2013-01-18 04:38:49 +00:00
|
|
|
res = BackgroundCopyFileConstructor(This, RemoteUrl, LocalName, &file);
|
2008-02-27 01:51:20 +00:00
|
|
|
if (res != S_OK)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
/* Add a reference to the file to file list */
|
2013-01-18 04:38:49 +00:00
|
|
|
IBackgroundCopyFile_AddRef(&file->IBackgroundCopyFile_iface);
|
2008-03-12 18:56:13 +00:00
|
|
|
EnterCriticalSection(&This->cs);
|
2008-02-27 01:51:20 +00:00
|
|
|
list_add_head(&This->files, &file->entryFromJob);
|
2008-03-13 22:54:35 +00:00
|
|
|
This->jobProgress.BytesTotal = BG_SIZE_UNKNOWN;
|
2008-02-27 01:51:20 +00:00
|
|
|
++This->jobProgress.FilesTotal;
|
2008-03-12 18:56:13 +00:00
|
|
|
LeaveCriticalSection(&This->cs);
|
2008-02-27 01:51:20 +00:00
|
|
|
|
|
|
|
return S_OK;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_EnumFiles(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2013-01-17 18:39:26 +00:00
|
|
|
IEnumBackgroundCopyFiles **enum_files)
|
2008-02-22 23:05:26 +00:00
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, enum_files);
|
|
|
|
return EnumBackgroundCopyFilesConstructor(This, enum_files);
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_Suspend(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface)
|
2008-02-22 23:05:26 +00:00
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_Resume(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface)
|
2008-02-22 23:05:26 +00:00
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
|
2008-03-12 18:56:13 +00:00
|
|
|
HRESULT rv = S_OK;
|
2008-03-05 00:01:43 +00:00
|
|
|
|
2008-03-12 18:56:13 +00:00
|
|
|
EnterCriticalSection(&globalMgr.cs);
|
2008-03-05 00:01:43 +00:00
|
|
|
if (This->state == BG_JOB_STATE_CANCELLED
|
|
|
|
|| This->state == BG_JOB_STATE_ACKNOWLEDGED)
|
|
|
|
{
|
2008-03-12 18:56:13 +00:00
|
|
|
rv = BG_E_INVALID_STATE;
|
2008-03-05 00:01:43 +00:00
|
|
|
}
|
2008-03-12 18:56:13 +00:00
|
|
|
else if (This->jobProgress.FilesTransferred == This->jobProgress.FilesTotal)
|
2008-03-05 00:01:43 +00:00
|
|
|
{
|
2008-03-12 18:56:13 +00:00
|
|
|
rv = BG_E_EMPTY;
|
2008-03-05 00:01:43 +00:00
|
|
|
}
|
2008-03-12 18:56:13 +00:00
|
|
|
else if (This->state != BG_JOB_STATE_CONNECTING
|
|
|
|
&& This->state != BG_JOB_STATE_TRANSFERRING)
|
|
|
|
{
|
|
|
|
This->state = BG_JOB_STATE_QUEUED;
|
2008-03-13 22:54:01 +00:00
|
|
|
SetEvent(globalMgr.jobEvent);
|
2008-03-12 18:56:13 +00:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&globalMgr.cs);
|
2008-03-05 00:01:43 +00:00
|
|
|
|
2008-03-12 18:56:13 +00:00
|
|
|
return rv;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_Cancel(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface)
|
2008-02-22 23:05:26 +00:00
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_Complete(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface)
|
2008-02-22 23:05:26 +00:00
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
|
2008-03-13 22:56:28 +00:00
|
|
|
HRESULT rv = S_OK;
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->cs);
|
|
|
|
|
|
|
|
if (This->state == BG_JOB_STATE_CANCELLED
|
|
|
|
|| This->state == BG_JOB_STATE_ACKNOWLEDGED)
|
|
|
|
{
|
|
|
|
rv = BG_E_INVALID_STATE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BackgroundCopyFileImpl *file;
|
|
|
|
LIST_FOR_EACH_ENTRY(file, &This->files, BackgroundCopyFileImpl, entryFromJob)
|
|
|
|
{
|
|
|
|
if (file->fileProgress.Completed)
|
|
|
|
{
|
|
|
|
if (!MoveFileExW(file->tempFileName, file->info.LocalName,
|
|
|
|
(MOVEFILE_COPY_ALLOWED
|
|
|
|
| MOVEFILE_REPLACE_EXISTING
|
|
|
|
| MOVEFILE_WRITE_THROUGH)))
|
|
|
|
{
|
|
|
|
ERR("Couldn't rename file %s -> %s\n",
|
|
|
|
debugstr_w(file->tempFileName),
|
|
|
|
debugstr_w(file->info.LocalName));
|
|
|
|
rv = BG_S_PARTIAL_COMPLETE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rv = BG_S_PARTIAL_COMPLETE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
This->state = BG_JOB_STATE_ACKNOWLEDGED;
|
|
|
|
LeaveCriticalSection(&This->cs);
|
|
|
|
|
|
|
|
return rv;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetId(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
GUID *pVal)
|
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
|
2008-03-08 15:37:09 +00:00
|
|
|
*pVal = This->jobId;
|
2008-02-22 23:07:12 +00:00
|
|
|
return S_OK;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetType(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
BG_JOB_TYPE *pVal)
|
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
|
2008-02-26 01:40:57 +00:00
|
|
|
|
|
|
|
if (!pVal)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pVal = This->type;
|
|
|
|
return S_OK;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProgress(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
BG_JOB_PROGRESS *pVal)
|
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
|
2008-03-04 00:48:08 +00:00
|
|
|
|
|
|
|
if (!pVal)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2008-03-12 18:56:13 +00:00
|
|
|
EnterCriticalSection(&This->cs);
|
2008-03-04 00:48:08 +00:00
|
|
|
pVal->BytesTotal = This->jobProgress.BytesTotal;
|
|
|
|
pVal->BytesTransferred = This->jobProgress.BytesTransferred;
|
|
|
|
pVal->FilesTotal = This->jobProgress.FilesTotal;
|
|
|
|
pVal->FilesTransferred = This->jobProgress.FilesTransferred;
|
2008-03-12 18:56:13 +00:00
|
|
|
LeaveCriticalSection(&This->cs);
|
2008-03-04 00:48:08 +00:00
|
|
|
|
|
|
|
return S_OK;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetTimes(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
BG_JOB_TIMES *pVal)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetState(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
BG_JOB_STATE *pVal)
|
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
|
2008-03-05 00:01:43 +00:00
|
|
|
|
|
|
|
if (!pVal)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2008-03-12 18:56:13 +00:00
|
|
|
/* Don't think we need a critical section for this */
|
2008-03-05 00:01:43 +00:00
|
|
|
*pVal = This->state;
|
|
|
|
return S_OK;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetError(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
IBackgroundCopyError **ppError)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetOwner(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
LPWSTR *pVal)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDisplayName(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
LPCWSTR Val)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDisplayName(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
LPWSTR *pVal)
|
|
|
|
{
|
2013-01-17 18:39:26 +00:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
|
2008-02-26 01:41:35 +00:00
|
|
|
int n;
|
|
|
|
|
|
|
|
if (!pVal)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
n = (lstrlenW(This->displayName) + 1) * sizeof **pVal;
|
|
|
|
*pVal = CoTaskMemAlloc(n);
|
|
|
|
if (*pVal == NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
memcpy(*pVal, This->displayName, n);
|
|
|
|
return S_OK;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDescription(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
LPCWSTR Val)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDescription(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
LPWSTR *pVal)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetPriority(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
BG_JOB_PRIORITY Val)
|
|
|
|
{
|
2009-05-19 15:28:14 +00:00
|
|
|
FIXME("(%p,0x%08x) stub\n", iface, Val);
|
|
|
|
return S_OK;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetPriority(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
BG_JOB_PRIORITY *pVal)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyFlags(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
ULONG Val)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyFlags(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
ULONG *pVal)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyInterface(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
IUnknown *Val)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyInterface(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
IUnknown **pVal)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetMinimumRetryDelay(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
ULONG Seconds)
|
|
|
|
{
|
2009-01-07 12:22:19 +00:00
|
|
|
FIXME("%u\n", Seconds);
|
|
|
|
return S_OK;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetMinimumRetryDelay(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
ULONG *Seconds)
|
|
|
|
{
|
2009-01-07 12:22:19 +00:00
|
|
|
FIXME("%p\n", Seconds);
|
|
|
|
*Seconds = 30;
|
|
|
|
return S_OK;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNoProgressTimeout(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
ULONG Seconds)
|
|
|
|
{
|
2009-01-07 12:22:19 +00:00
|
|
|
FIXME("%u\n", Seconds);
|
|
|
|
return S_OK;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNoProgressTimeout(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
ULONG *Seconds)
|
|
|
|
{
|
2009-01-07 12:22:19 +00:00
|
|
|
FIXME("%p\n", Seconds);
|
|
|
|
*Seconds = 900;
|
|
|
|
return S_OK;
|
2008-02-22 23:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetErrorCount(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
ULONG *Errors)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetProxySettings(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
BG_JOB_PROXY_USAGE ProxyUsage,
|
|
|
|
const WCHAR *ProxyList,
|
|
|
|
const WCHAR *ProxyBypassList)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProxySettings(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-22 23:05:26 +00:00
|
|
|
BG_JOB_PROXY_USAGE *pProxyUsage,
|
|
|
|
LPWSTR *pProxyList,
|
|
|
|
LPWSTR *pProxyBypassList)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_TakeOwnership(
|
2008-03-19 22:02:02 +00:00
|
|
|
IBackgroundCopyJob2 *iface)
|
2008-02-22 23:05:26 +00:00
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-03-19 22:02:02 +00:00
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyCmdLine(
|
|
|
|
IBackgroundCopyJob2 *iface,
|
|
|
|
LPCWSTR prog,
|
|
|
|
LPCWSTR params)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyCmdLine(
|
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-09-08 22:20:22 +00:00
|
|
|
LPWSTR *prog,
|
|
|
|
LPWSTR *params)
|
2008-03-19 22:02:02 +00:00
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetReplyProgress(
|
|
|
|
IBackgroundCopyJob2 *iface,
|
|
|
|
BG_JOB_REPLY_PROGRESS *progress)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetReplyData(
|
|
|
|
IBackgroundCopyJob2 *iface,
|
|
|
|
byte **pBuffer,
|
|
|
|
UINT64 *pLength)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetReplyFileName(
|
|
|
|
IBackgroundCopyJob2 *iface,
|
|
|
|
LPCWSTR filename)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetReplyFileName(
|
|
|
|
IBackgroundCopyJob2 *iface,
|
|
|
|
LPWSTR *pFilename)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetCredentials(
|
|
|
|
IBackgroundCopyJob2 *iface,
|
|
|
|
BG_AUTH_CREDENTIALS *cred)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
2009-01-15 09:40:18 +00:00
|
|
|
return S_OK;
|
2008-03-19 22:02:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_RemoveCredentials(
|
|
|
|
IBackgroundCopyJob2 *iface,
|
|
|
|
BG_AUTH_TARGET target,
|
|
|
|
BG_AUTH_SCHEME scheme)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
2009-01-15 09:40:18 +00:00
|
|
|
return S_OK;
|
2008-03-19 22:02:02 +00:00
|
|
|
}
|
2008-02-22 23:05:26 +00:00
|
|
|
|
2008-03-19 22:02:02 +00:00
|
|
|
static const IBackgroundCopyJob2Vtbl BITS_IBackgroundCopyJob_Vtbl =
|
2008-02-22 23:05:26 +00:00
|
|
|
{
|
|
|
|
BITS_IBackgroundCopyJob_QueryInterface,
|
|
|
|
BITS_IBackgroundCopyJob_AddRef,
|
|
|
|
BITS_IBackgroundCopyJob_Release,
|
|
|
|
BITS_IBackgroundCopyJob_AddFileSet,
|
|
|
|
BITS_IBackgroundCopyJob_AddFile,
|
|
|
|
BITS_IBackgroundCopyJob_EnumFiles,
|
|
|
|
BITS_IBackgroundCopyJob_Suspend,
|
|
|
|
BITS_IBackgroundCopyJob_Resume,
|
|
|
|
BITS_IBackgroundCopyJob_Cancel,
|
|
|
|
BITS_IBackgroundCopyJob_Complete,
|
|
|
|
BITS_IBackgroundCopyJob_GetId,
|
|
|
|
BITS_IBackgroundCopyJob_GetType,
|
|
|
|
BITS_IBackgroundCopyJob_GetProgress,
|
|
|
|
BITS_IBackgroundCopyJob_GetTimes,
|
|
|
|
BITS_IBackgroundCopyJob_GetState,
|
|
|
|
BITS_IBackgroundCopyJob_GetError,
|
|
|
|
BITS_IBackgroundCopyJob_GetOwner,
|
|
|
|
BITS_IBackgroundCopyJob_SetDisplayName,
|
|
|
|
BITS_IBackgroundCopyJob_GetDisplayName,
|
|
|
|
BITS_IBackgroundCopyJob_SetDescription,
|
|
|
|
BITS_IBackgroundCopyJob_GetDescription,
|
|
|
|
BITS_IBackgroundCopyJob_SetPriority,
|
|
|
|
BITS_IBackgroundCopyJob_GetPriority,
|
|
|
|
BITS_IBackgroundCopyJob_SetNotifyFlags,
|
|
|
|
BITS_IBackgroundCopyJob_GetNotifyFlags,
|
|
|
|
BITS_IBackgroundCopyJob_SetNotifyInterface,
|
|
|
|
BITS_IBackgroundCopyJob_GetNotifyInterface,
|
|
|
|
BITS_IBackgroundCopyJob_SetMinimumRetryDelay,
|
|
|
|
BITS_IBackgroundCopyJob_GetMinimumRetryDelay,
|
|
|
|
BITS_IBackgroundCopyJob_SetNoProgressTimeout,
|
|
|
|
BITS_IBackgroundCopyJob_GetNoProgressTimeout,
|
|
|
|
BITS_IBackgroundCopyJob_GetErrorCount,
|
|
|
|
BITS_IBackgroundCopyJob_SetProxySettings,
|
|
|
|
BITS_IBackgroundCopyJob_GetProxySettings,
|
|
|
|
BITS_IBackgroundCopyJob_TakeOwnership,
|
2008-03-19 22:02:02 +00:00
|
|
|
BITS_IBackgroundCopyJob_SetNotifyCmdLine,
|
|
|
|
BITS_IBackgroundCopyJob_GetNotifyCmdLine,
|
|
|
|
BITS_IBackgroundCopyJob_GetReplyProgress,
|
|
|
|
BITS_IBackgroundCopyJob_GetReplyData,
|
|
|
|
BITS_IBackgroundCopyJob_SetReplyFileName,
|
|
|
|
BITS_IBackgroundCopyJob_GetReplyFileName,
|
|
|
|
BITS_IBackgroundCopyJob_SetCredentials,
|
|
|
|
BITS_IBackgroundCopyJob_RemoveCredentials
|
2008-02-22 23:05:26 +00:00
|
|
|
};
|
2008-02-22 23:06:17 +00:00
|
|
|
|
2013-01-17 18:39:26 +00:00
|
|
|
HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID *job_id, BackgroundCopyJobImpl **job)
|
2008-02-22 23:06:17 +00:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
BackgroundCopyJobImpl *This;
|
|
|
|
int n;
|
|
|
|
|
2013-01-17 18:39:26 +00:00
|
|
|
TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, job);
|
2008-02-22 23:06:17 +00:00
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2013-01-17 18:39:26 +00:00
|
|
|
This->IBackgroundCopyJob2_iface.lpVtbl = &BITS_IBackgroundCopyJob_Vtbl;
|
2008-03-12 18:56:13 +00:00
|
|
|
InitializeCriticalSection(&This->cs);
|
2011-11-14 14:10:44 +00:00
|
|
|
This->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BackgroundCopyJobImpl.cs");
|
|
|
|
|
2008-02-22 23:06:17 +00:00
|
|
|
This->ref = 1;
|
|
|
|
This->type = type;
|
|
|
|
|
|
|
|
n = (lstrlenW(displayName) + 1) * sizeof *displayName;
|
|
|
|
This->displayName = HeapAlloc(GetProcessHeap(), 0, n);
|
|
|
|
if (!This->displayName)
|
|
|
|
{
|
2011-11-14 14:10:44 +00:00
|
|
|
This->cs.DebugInfo->Spare[0] = 0;
|
2008-03-12 18:56:13 +00:00
|
|
|
DeleteCriticalSection(&This->cs);
|
2008-02-22 23:06:17 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
memcpy(This->displayName, displayName, n);
|
|
|
|
|
|
|
|
hr = CoCreateGuid(&This->jobId);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2011-11-14 14:10:44 +00:00
|
|
|
This->cs.DebugInfo->Spare[0] = 0;
|
2008-03-12 18:56:13 +00:00
|
|
|
DeleteCriticalSection(&This->cs);
|
2008-02-22 23:06:17 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->displayName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return hr;
|
|
|
|
}
|
2013-01-17 18:39:26 +00:00
|
|
|
*job_id = This->jobId;
|
2008-02-22 23:06:17 +00:00
|
|
|
|
2008-02-27 01:51:20 +00:00
|
|
|
list_init(&This->files);
|
2008-03-04 00:48:08 +00:00
|
|
|
This->jobProgress.BytesTotal = 0;
|
2008-02-27 01:51:20 +00:00
|
|
|
This->jobProgress.BytesTransferred = 0;
|
|
|
|
This->jobProgress.FilesTotal = 0;
|
|
|
|
This->jobProgress.FilesTransferred = 0;
|
|
|
|
|
2008-03-05 00:01:43 +00:00
|
|
|
This->state = BG_JOB_STATE_SUSPENDED;
|
|
|
|
|
2013-01-17 18:39:26 +00:00
|
|
|
*job = This;
|
2008-02-22 23:06:17 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
2008-03-13 22:54:35 +00:00
|
|
|
|
|
|
|
void processJob(BackgroundCopyJobImpl *job)
|
|
|
|
{
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
BackgroundCopyFileImpl *file;
|
|
|
|
BOOL done = TRUE;
|
|
|
|
|
|
|
|
EnterCriticalSection(&job->cs);
|
|
|
|
LIST_FOR_EACH_ENTRY(file, &job->files, BackgroundCopyFileImpl, entryFromJob)
|
|
|
|
if (!file->fileProgress.Completed)
|
|
|
|
{
|
|
|
|
done = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&job->cs);
|
|
|
|
if (done)
|
|
|
|
{
|
|
|
|
transitionJobState(job, BG_JOB_STATE_QUEUED, BG_JOB_STATE_TRANSFERRED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!processFile(file, job))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|