2008-02-23 00:05:26 +01: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 23:56:28 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
|
2008-02-23 00:05:26 +01:00
|
|
|
#include "qmgr.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
|
|
|
|
|
|
|
static void BackgroundCopyJobDestructor(BackgroundCopyJobImpl *This)
|
|
|
|
{
|
2008-03-12 19:56:13 +01:00
|
|
|
DeleteCriticalSection(&This->cs);
|
2008-02-23 00:06:17 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->displayName);
|
2008-02-23 00:05:26 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
2008-03-19 23:02:02 +01:00
|
|
|
static ULONG WINAPI BITS_IBackgroundCopyJob_AddRef(IBackgroundCopyJob2 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
|
|
|
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_QueryInterface(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface, REFIID riid, LPVOID *ppvObject)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
|
|
|
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
|
|
|
TRACE("IID: %s\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
2008-03-19 23:02:02 +01:00
|
|
|
|| IsEqualGUID(riid, &IID_IBackgroundCopyJob)
|
|
|
|
|| IsEqualGUID(riid, &IID_IBackgroundCopyJob2))
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
|
|
|
*ppvObject = &This->lpVtbl;
|
|
|
|
BITS_IBackgroundCopyJob_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2008-03-19 23:02:02 +01:00
|
|
|
static ULONG WINAPI BITS_IBackgroundCopyJob_Release(IBackgroundCopyJob2 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
|
|
|
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
if (ref == 0)
|
|
|
|
BackgroundCopyJobDestructor(This);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IBackgroundCopyJob methods ***/
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFileSet(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG cFileCount,
|
|
|
|
BG_FILE_INFO *pFileSet)
|
|
|
|
{
|
2008-03-14 23:51:40 +01:00
|
|
|
ULONG i;
|
|
|
|
for (i = 0; i < cFileCount; ++i)
|
|
|
|
{
|
|
|
|
HRESULT hr = IBackgroundCopyJob_AddFile(iface, pFileSet[i].RemoteName,
|
|
|
|
pFileSet[i].LocalName);
|
2008-10-08 01:33:25 +02:00
|
|
|
if (FAILED(hr))
|
2008-03-14 23:51:40 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
LPCWSTR RemoteUrl,
|
|
|
|
LPCWSTR LocalName)
|
|
|
|
{
|
2008-02-27 02:51:20 +01:00
|
|
|
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
|
|
|
IBackgroundCopyFile *pFile;
|
|
|
|
BackgroundCopyFileImpl *file;
|
|
|
|
HRESULT res;
|
|
|
|
|
|
|
|
/* We should return E_INVALIDARG in these cases. */
|
|
|
|
FIXME("Check for valid filenames and supported protocols\n");
|
|
|
|
|
2008-03-12 19:56:13 +01:00
|
|
|
res = BackgroundCopyFileConstructor(This, RemoteUrl, LocalName, (LPVOID *) &pFile);
|
2008-02-27 02:51:20 +01:00
|
|
|
if (res != S_OK)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
/* Add a reference to the file to file list */
|
|
|
|
IBackgroundCopyFile_AddRef(pFile);
|
|
|
|
file = (BackgroundCopyFileImpl *) pFile;
|
2008-03-12 19:56:13 +01:00
|
|
|
EnterCriticalSection(&This->cs);
|
2008-02-27 02:51:20 +01:00
|
|
|
list_add_head(&This->files, &file->entryFromJob);
|
2008-03-13 23:54:35 +01:00
|
|
|
This->jobProgress.BytesTotal = BG_SIZE_UNKNOWN;
|
2008-02-27 02:51:20 +01:00
|
|
|
++This->jobProgress.FilesTotal;
|
2008-03-12 19:56:13 +01:00
|
|
|
LeaveCriticalSection(&This->cs);
|
2008-02-27 02:51:20 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_EnumFiles(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-28 06:04:07 +01:00
|
|
|
IEnumBackgroundCopyFiles **ppEnum)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2008-02-28 06:04:07 +01:00
|
|
|
TRACE("\n");
|
|
|
|
return EnumBackgroundCopyFilesConstructor((LPVOID *) ppEnum, iface);
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_Suspend(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_Resume(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2008-03-05 01:01:43 +01:00
|
|
|
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
2008-03-12 19:56:13 +01:00
|
|
|
HRESULT rv = S_OK;
|
2008-03-05 01:01:43 +01:00
|
|
|
|
2008-03-12 19:56:13 +01:00
|
|
|
EnterCriticalSection(&globalMgr.cs);
|
2008-03-05 01:01:43 +01:00
|
|
|
if (This->state == BG_JOB_STATE_CANCELLED
|
|
|
|
|| This->state == BG_JOB_STATE_ACKNOWLEDGED)
|
|
|
|
{
|
2008-03-12 19:56:13 +01:00
|
|
|
rv = BG_E_INVALID_STATE;
|
2008-03-05 01:01:43 +01:00
|
|
|
}
|
2008-03-12 19:56:13 +01:00
|
|
|
else if (This->jobProgress.FilesTransferred == This->jobProgress.FilesTotal)
|
2008-03-05 01:01:43 +01:00
|
|
|
{
|
2008-03-12 19:56:13 +01:00
|
|
|
rv = BG_E_EMPTY;
|
2008-03-05 01:01:43 +01:00
|
|
|
}
|
2008-03-12 19:56:13 +01:00
|
|
|
else if (This->state != BG_JOB_STATE_CONNECTING
|
|
|
|
&& This->state != BG_JOB_STATE_TRANSFERRING)
|
|
|
|
{
|
|
|
|
This->state = BG_JOB_STATE_QUEUED;
|
2008-03-13 23:54:01 +01:00
|
|
|
SetEvent(globalMgr.jobEvent);
|
2008-03-12 19:56:13 +01:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&globalMgr.cs);
|
2008-03-05 01:01:43 +01:00
|
|
|
|
2008-03-12 19:56:13 +01:00
|
|
|
return rv;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_Cancel(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_Complete(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2008-03-13 23:56:28 +01:00
|
|
|
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
|
|
|
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-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetId(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
GUID *pVal)
|
|
|
|
{
|
2008-02-23 00:07:12 +01:00
|
|
|
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
2008-03-08 16:37:09 +01:00
|
|
|
*pVal = This->jobId;
|
2008-02-23 00:07:12 +01:00
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetType(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_TYPE *pVal)
|
|
|
|
{
|
2008-02-26 02:40:57 +01:00
|
|
|
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
|
|
|
|
|
|
|
if (!pVal)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pVal = This->type;
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProgress(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_PROGRESS *pVal)
|
|
|
|
{
|
2008-03-04 01:48:08 +01:00
|
|
|
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
|
|
|
|
|
|
|
if (!pVal)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2008-03-12 19:56:13 +01:00
|
|
|
EnterCriticalSection(&This->cs);
|
2008-03-04 01:48:08 +01:00
|
|
|
pVal->BytesTotal = This->jobProgress.BytesTotal;
|
|
|
|
pVal->BytesTransferred = This->jobProgress.BytesTransferred;
|
|
|
|
pVal->FilesTotal = This->jobProgress.FilesTotal;
|
|
|
|
pVal->FilesTransferred = This->jobProgress.FilesTransferred;
|
2008-03-12 19:56:13 +01:00
|
|
|
LeaveCriticalSection(&This->cs);
|
2008-03-04 01:48:08 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetTimes(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_TIMES *pVal)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetState(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_STATE *pVal)
|
|
|
|
{
|
2008-03-05 01:01:43 +01:00
|
|
|
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
|
|
|
|
|
|
|
if (!pVal)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2008-03-12 19:56:13 +01:00
|
|
|
/* Don't think we need a critical section for this */
|
2008-03-05 01:01:43 +01:00
|
|
|
*pVal = This->state;
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetError(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
IBackgroundCopyError **ppError)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetOwner(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
LPWSTR *pVal)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDisplayName(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
LPCWSTR Val)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDisplayName(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
LPWSTR *pVal)
|
|
|
|
{
|
2008-02-26 02:41:35 +01:00
|
|
|
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
|
|
|
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-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDescription(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
LPCWSTR Val)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDescription(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
LPWSTR *pVal)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetPriority(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_PRIORITY Val)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetPriority(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_PRIORITY *pVal)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyFlags(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG Val)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyFlags(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG *pVal)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyInterface(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
IUnknown *Val)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyInterface(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
IUnknown **pVal)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetMinimumRetryDelay(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG Seconds)
|
|
|
|
{
|
2009-01-07 13:22:19 +01:00
|
|
|
FIXME("%u\n", Seconds);
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetMinimumRetryDelay(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG *Seconds)
|
|
|
|
{
|
2009-01-07 13:22:19 +01:00
|
|
|
FIXME("%p\n", Seconds);
|
|
|
|
*Seconds = 30;
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNoProgressTimeout(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG Seconds)
|
|
|
|
{
|
2009-01-07 13:22:19 +01:00
|
|
|
FIXME("%u\n", Seconds);
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNoProgressTimeout(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG *Seconds)
|
|
|
|
{
|
2009-01-07 13:22:19 +01:00
|
|
|
FIXME("%p\n", Seconds);
|
|
|
|
*Seconds = 900;
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetErrorCount(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG *Errors)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetProxySettings(
|
2008-03-19 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01: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 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface,
|
2008-02-23 00:05:26 +01: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 23:02:02 +01:00
|
|
|
IBackgroundCopyJob2 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-03-19 23:02:02 +01: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-09 00:20:22 +02:00
|
|
|
LPWSTR *prog,
|
|
|
|
LPWSTR *params)
|
2008-03-19 23:02:02 +01: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 10:40:18 +01:00
|
|
|
return S_OK;
|
2008-03-19 23:02:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_RemoveCredentials(
|
|
|
|
IBackgroundCopyJob2 *iface,
|
|
|
|
BG_AUTH_TARGET target,
|
|
|
|
BG_AUTH_SCHEME scheme)
|
|
|
|
{
|
|
|
|
FIXME("Not implemented\n");
|
2009-01-15 10:40:18 +01:00
|
|
|
return S_OK;
|
2008-03-19 23:02:02 +01:00
|
|
|
}
|
2008-02-23 00:05:26 +01:00
|
|
|
|
2008-03-19 23:02:02 +01:00
|
|
|
static const IBackgroundCopyJob2Vtbl BITS_IBackgroundCopyJob_Vtbl =
|
2008-02-23 00:05:26 +01: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 23:02:02 +01: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-23 00:05:26 +01:00
|
|
|
};
|
2008-02-23 00:06:17 +01:00
|
|
|
|
|
|
|
HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
|
|
|
|
GUID *pJobId, LPVOID *ppObj)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
BackgroundCopyJobImpl *This;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, ppObj);
|
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->lpVtbl = &BITS_IBackgroundCopyJob_Vtbl;
|
2008-03-12 19:56:13 +01:00
|
|
|
InitializeCriticalSection(&This->cs);
|
2008-02-23 00:06:17 +01:00
|
|
|
This->ref = 1;
|
|
|
|
This->type = type;
|
|
|
|
|
|
|
|
n = (lstrlenW(displayName) + 1) * sizeof *displayName;
|
|
|
|
This->displayName = HeapAlloc(GetProcessHeap(), 0, n);
|
|
|
|
if (!This->displayName)
|
|
|
|
{
|
2008-03-12 19:56:13 +01:00
|
|
|
DeleteCriticalSection(&This->cs);
|
2008-02-23 00:06:17 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
memcpy(This->displayName, displayName, n);
|
|
|
|
|
|
|
|
hr = CoCreateGuid(&This->jobId);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2008-03-12 19:56:13 +01:00
|
|
|
DeleteCriticalSection(&This->cs);
|
2008-02-23 00:06:17 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->displayName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return hr;
|
|
|
|
}
|
2008-03-08 16:37:09 +01:00
|
|
|
*pJobId = This->jobId;
|
2008-02-23 00:06:17 +01:00
|
|
|
|
2008-02-27 02:51:20 +01:00
|
|
|
list_init(&This->files);
|
2008-03-04 01:48:08 +01:00
|
|
|
This->jobProgress.BytesTotal = 0;
|
2008-02-27 02:51:20 +01:00
|
|
|
This->jobProgress.BytesTransferred = 0;
|
|
|
|
This->jobProgress.FilesTotal = 0;
|
|
|
|
This->jobProgress.FilesTransferred = 0;
|
|
|
|
|
2008-03-05 01:01:43 +01:00
|
|
|
This->state = BG_JOB_STATE_SUSPENDED;
|
|
|
|
|
2008-02-23 00:06:17 +01:00
|
|
|
*ppObj = &This->lpVtbl;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-03-13 23:54:35 +01: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;
|
|
|
|
}
|
|
|
|
}
|