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);
|
|
|
|
|
2015-06-12 15:07:22 +02:00
|
|
|
BOOL transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE from, BG_JOB_STATE to)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
EnterCriticalSection(&globalMgr.cs);
|
|
|
|
if (job->state == from)
|
|
|
|
{
|
|
|
|
job->state = to;
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&globalMgr.cs);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-05 10:35:09 +02:00
|
|
|
struct copy_error
|
|
|
|
{
|
|
|
|
IBackgroundCopyError IBackgroundCopyError_iface;
|
|
|
|
LONG refs;
|
|
|
|
BG_ERROR_CONTEXT context;
|
|
|
|
HRESULT code;
|
|
|
|
IBackgroundCopyFile2 *file;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct copy_error *impl_from_IBackgroundCopyError(IBackgroundCopyError *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct copy_error, IBackgroundCopyError_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI copy_error_QueryInterface(
|
|
|
|
IBackgroundCopyError *iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **obj)
|
|
|
|
{
|
|
|
|
struct copy_error *error = impl_from_IBackgroundCopyError(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", error, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IBackgroundCopyError))
|
|
|
|
{
|
|
|
|
*obj = &error->IBackgroundCopyError_iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*obj = NULL;
|
|
|
|
WARN("interface %s not supported\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IBackgroundCopyError_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI copy_error_AddRef(
|
|
|
|
IBackgroundCopyError *iface)
|
|
|
|
{
|
|
|
|
struct copy_error *error = impl_from_IBackgroundCopyError(iface);
|
|
|
|
LONG refs = InterlockedIncrement(&error->refs);
|
|
|
|
TRACE("(%p)->(%d)\n", error, refs);
|
|
|
|
return refs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI copy_error_Release(
|
|
|
|
IBackgroundCopyError *iface)
|
|
|
|
{
|
|
|
|
struct copy_error *error = impl_from_IBackgroundCopyError(iface);
|
|
|
|
LONG refs = InterlockedDecrement(&error->refs);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", error, refs);
|
|
|
|
|
|
|
|
if (!refs)
|
|
|
|
{
|
|
|
|
if (error->file) IBackgroundCopyFile2_Release(error->file);
|
|
|
|
HeapFree(GetProcessHeap(), 0, error);
|
|
|
|
}
|
|
|
|
return refs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI copy_error_GetError(
|
|
|
|
IBackgroundCopyError *iface,
|
|
|
|
BG_ERROR_CONTEXT *pContext,
|
|
|
|
HRESULT *pCode)
|
|
|
|
{
|
|
|
|
struct copy_error *error = impl_from_IBackgroundCopyError(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", error, pContext, pCode);
|
|
|
|
|
|
|
|
*pContext = error->context;
|
|
|
|
*pCode = error->code;
|
|
|
|
|
|
|
|
TRACE("returning context %u error code 0x%08x\n", error->context, error->code);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI copy_error_GetFile(
|
|
|
|
IBackgroundCopyError *iface,
|
|
|
|
IBackgroundCopyFile **pVal)
|
|
|
|
{
|
|
|
|
struct copy_error *error = impl_from_IBackgroundCopyError(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", error, pVal);
|
|
|
|
|
|
|
|
if (error->file)
|
|
|
|
{
|
|
|
|
IBackgroundCopyFile2_AddRef(error->file);
|
|
|
|
*pVal = (IBackgroundCopyFile *)error->file;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
*pVal = NULL;
|
|
|
|
return BG_E_FILE_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI copy_error_GetErrorDescription(
|
|
|
|
IBackgroundCopyError *iface,
|
|
|
|
DWORD LanguageId,
|
|
|
|
LPWSTR *pErrorDescription)
|
|
|
|
{
|
|
|
|
struct copy_error *error = impl_from_IBackgroundCopyError(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", error, pErrorDescription);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI copy_error_GetErrorContextDescription(
|
|
|
|
IBackgroundCopyError *iface,
|
|
|
|
DWORD LanguageId,
|
|
|
|
LPWSTR *pContextDescription)
|
|
|
|
{
|
|
|
|
struct copy_error *error = impl_from_IBackgroundCopyError(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", error, pContextDescription);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI copy_error_GetProtocol(
|
|
|
|
IBackgroundCopyError *iface,
|
|
|
|
LPWSTR *pProtocol)
|
|
|
|
{
|
|
|
|
struct copy_error *error = impl_from_IBackgroundCopyError(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", error, pProtocol);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBackgroundCopyErrorVtbl copy_error_vtbl =
|
|
|
|
{
|
|
|
|
copy_error_QueryInterface,
|
|
|
|
copy_error_AddRef,
|
|
|
|
copy_error_Release,
|
|
|
|
copy_error_GetError,
|
|
|
|
copy_error_GetFile,
|
|
|
|
copy_error_GetErrorDescription,
|
|
|
|
copy_error_GetErrorContextDescription,
|
|
|
|
copy_error_GetProtocol
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT create_copy_error(
|
|
|
|
BG_ERROR_CONTEXT context,
|
|
|
|
HRESULT code,
|
|
|
|
IBackgroundCopyFile2 *file,
|
|
|
|
IBackgroundCopyError **obj)
|
|
|
|
{
|
|
|
|
struct copy_error *error;
|
|
|
|
|
|
|
|
TRACE("context %u code %08x file %p\n", context, code, file);
|
|
|
|
|
|
|
|
if (!(error = HeapAlloc(GetProcessHeap(), 0, sizeof(*error) ))) return E_OUTOFMEMORY;
|
|
|
|
error->IBackgroundCopyError_iface.lpVtbl = ©_error_vtbl;
|
|
|
|
error->refs = 1;
|
|
|
|
error->context = context;
|
|
|
|
error->code = code;
|
|
|
|
error->file = file;
|
|
|
|
if (error->file) IBackgroundCopyFile2_AddRef(error->file);
|
|
|
|
|
|
|
|
*obj = &error->IBackgroundCopyError_iface;
|
|
|
|
TRACE("returning iface %p\n", *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:42:31 +01:00
|
|
|
static inline BOOL is_job_done(const BackgroundCopyJobImpl *job)
|
|
|
|
{
|
|
|
|
return job->state == BG_JOB_STATE_CANCELLED || job->state == BG_JOB_STATE_ACKNOWLEDGED;
|
|
|
|
}
|
|
|
|
|
2015-06-05 10:34:21 +02:00
|
|
|
static inline BackgroundCopyJobImpl *impl_from_IBackgroundCopyJob3(IBackgroundCopyJob3 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
return CONTAINING_RECORD(iface, BackgroundCopyJobImpl, IBackgroundCopyJob3_iface);
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_QueryInterface(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface, REFIID riid, void **obj)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-01-17 19:39:26 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
2008-02-23 00:05:26 +01:00
|
|
|
|
2015-06-05 10:34:21 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IBackgroundCopyJob) ||
|
|
|
|
IsEqualGUID(riid, &IID_IBackgroundCopyJob2) ||
|
|
|
|
IsEqualGUID(riid, &IID_IBackgroundCopyJob3))
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
*obj = &This->IBackgroundCopyJob3_iface;
|
|
|
|
}
|
2015-06-12 15:05:11 +02:00
|
|
|
else if (IsEqualGUID(riid, &IID_IBackgroundCopyJobHttpOptions))
|
|
|
|
{
|
|
|
|
*obj = &This->IBackgroundCopyJobHttpOptions_iface;
|
|
|
|
}
|
2015-06-05 10:34:21 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3_AddRef(iface);
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2015-06-05 10:34:21 +02:00
|
|
|
static ULONG WINAPI BackgroundCopyJob_AddRef(IBackgroundCopyJob3 *iface)
|
2013-01-17 19:39:26 +01:00
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-01-17 19:39:26 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2015-06-05 10:34:21 +02:00
|
|
|
static ULONG WINAPI BackgroundCopyJob_Release(IBackgroundCopyJob3 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2015-06-12 15:06:26 +02:00
|
|
|
ULONG i, j, ref = InterlockedDecrement(&This->ref);
|
2008-02-23 00:05:26 +01:00
|
|
|
|
2013-01-17 19:39:26 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
2008-02-23 00:05:26 +01:00
|
|
|
if (ref == 0)
|
2013-01-18 05:39:15 +01:00
|
|
|
{
|
|
|
|
This->cs.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&This->cs);
|
2013-11-28 06:31:24 +01:00
|
|
|
if (This->callback)
|
|
|
|
IBackgroundCopyCallback2_Release(This->callback);
|
2013-01-18 05:39:15 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->displayName);
|
2013-11-25 07:42:31 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->description);
|
2015-06-12 15:05:11 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->http_options.headers);
|
2015-06-12 15:06:26 +02:00
|
|
|
for (i = 0; i < BG_AUTH_TARGET_PROXY; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < BG_AUTH_SCHEME_PASSPORT; j++)
|
|
|
|
{
|
|
|
|
BG_AUTH_CREDENTIALS *cred = &This->http_options.creds[i][j];
|
|
|
|
HeapFree(GetProcessHeap(), 0, cred->Credentials.Basic.UserName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, cred->Credentials.Basic.Password);
|
|
|
|
}
|
|
|
|
}
|
2015-06-12 15:06:59 +02:00
|
|
|
CloseHandle(This->wait);
|
|
|
|
CloseHandle(This->cancel);
|
|
|
|
CloseHandle(This->done);
|
2013-01-18 05:39:15 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
2008-02-23 00:05:26 +01:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IBackgroundCopyJob methods ***/
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_AddFileSet(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG cFileCount,
|
|
|
|
BG_FILE_INFO *pFileSet)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-12-03 20:30:32 +01:00
|
|
|
HRESULT hr = S_OK;
|
2008-03-14 23:51:40 +01:00
|
|
|
ULONG i;
|
2013-11-25 07:43:50 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d %p)\n", This, cFileCount, pFileSet);
|
|
|
|
|
2013-12-03 20:30:32 +01:00
|
|
|
EnterCriticalSection(&This->cs);
|
|
|
|
|
2008-03-14 23:51:40 +01:00
|
|
|
for (i = 0; i < cFileCount; ++i)
|
|
|
|
{
|
2013-12-03 20:30:32 +01:00
|
|
|
BackgroundCopyFileImpl *file;
|
|
|
|
|
|
|
|
/* We should return E_INVALIDARG in these cases. */
|
|
|
|
FIXME("Check for valid filenames and supported protocols\n");
|
|
|
|
|
|
|
|
hr = BackgroundCopyFileConstructor(This, pFileSet[i].RemoteName, pFileSet[i].LocalName, &file);
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
|
|
|
/* Add a reference to the file to file list */
|
|
|
|
list_add_head(&This->files, &file->entryFromJob);
|
|
|
|
This->jobProgress.BytesTotal = BG_SIZE_UNKNOWN;
|
|
|
|
++This->jobProgress.FilesTotal;
|
2008-03-14 23:51:40 +01:00
|
|
|
}
|
2013-12-03 20:30:32 +01:00
|
|
|
|
|
|
|
LeaveCriticalSection(&This->cs);
|
|
|
|
|
|
|
|
return hr;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_AddFile(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
LPCWSTR RemoteUrl,
|
|
|
|
LPCWSTR LocalName)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-12-03 20:30:32 +01:00
|
|
|
BG_FILE_INFO file;
|
2008-02-27 02:51:20 +01:00
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
TRACE("(%p)->(%s %s)\n", This, debugstr_w(RemoteUrl), debugstr_w(LocalName));
|
2008-02-27 02:51:20 +01:00
|
|
|
|
2013-12-03 20:30:32 +01:00
|
|
|
file.RemoteName = (LPWSTR)RemoteUrl;
|
|
|
|
file.LocalName = (LPWSTR)LocalName;
|
2015-06-05 10:34:21 +02:00
|
|
|
return IBackgroundCopyJob3_AddFileSet(iface, 1, &file);
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_EnumFiles(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2013-01-17 19:39:26 +01:00
|
|
|
IEnumBackgroundCopyFiles **enum_files)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-01-17 19:39:26 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, enum_files);
|
|
|
|
return EnumBackgroundCopyFilesConstructor(This, enum_files);
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_Suspend(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p): stub\n", This);
|
2008-02-23 00:05:26 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_Resume(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2008-03-12 19:56:13 +01:00
|
|
|
HRESULT rv = S_OK;
|
2008-03-05 01:01:43 +01:00
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
2008-03-12 19:56:13 +01:00
|
|
|
EnterCriticalSection(&globalMgr.cs);
|
2013-11-25 07:42:31 +01:00
|
|
|
if (is_job_done(This))
|
2008-03-05 01:01:43 +01:00
|
|
|
{
|
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;
|
2016-09-14 10:06:11 +02:00
|
|
|
This->error.context = 0;
|
|
|
|
This->error.code = S_OK;
|
2016-05-17 10:53:06 +02:00
|
|
|
if (This->error.file)
|
|
|
|
{
|
|
|
|
IBackgroundCopyFile2_Release(This->error.file);
|
|
|
|
This->error.file = NULL;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_Cancel(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2015-06-12 15:06:59 +02:00
|
|
|
HRESULT rv = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->cs);
|
|
|
|
|
|
|
|
if (is_job_done(This))
|
|
|
|
{
|
|
|
|
rv = BG_E_INVALID_STATE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BackgroundCopyFileImpl *file;
|
|
|
|
|
|
|
|
if (This->state == BG_JOB_STATE_CONNECTING || This->state == BG_JOB_STATE_TRANSFERRING)
|
|
|
|
{
|
|
|
|
This->state = BG_JOB_STATE_CANCELLED;
|
|
|
|
SetEvent(This->cancel);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&This->cs);
|
|
|
|
WaitForSingleObject(This->done, INFINITE);
|
|
|
|
EnterCriticalSection(&This->cs);
|
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(file, &This->files, BackgroundCopyFileImpl, entryFromJob)
|
|
|
|
{
|
|
|
|
if (file->tempFileName[0] && !DeleteFileW(file->tempFileName))
|
|
|
|
{
|
|
|
|
WARN("Couldn't delete %s (%u)\n", debugstr_w(file->tempFileName), GetLastError());
|
|
|
|
rv = BG_S_UNABLE_TO_DELETE_FILES;
|
|
|
|
}
|
|
|
|
if (file->info.LocalName && !DeleteFileW(file->info.LocalName))
|
|
|
|
{
|
|
|
|
WARN("Couldn't delete %s (%u)\n", debugstr_w(file->info.LocalName), GetLastError());
|
|
|
|
rv = BG_S_UNABLE_TO_DELETE_FILES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
This->state = BG_JOB_STATE_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&This->cs);
|
|
|
|
return rv;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_Complete(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2008-03-13 23:56:28 +01:00
|
|
|
HRESULT rv = S_OK;
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
2008-03-13 23:56:28 +01:00
|
|
|
EnterCriticalSection(&This->cs);
|
|
|
|
|
2013-11-25 07:42:31 +01:00
|
|
|
if (is_job_done(This))
|
2008-03-13 23:56:28 +01:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetId(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
GUID *pVal)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, pVal);
|
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
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetType(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_TYPE *pVal)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2008-02-26 02:40:57 +01:00
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, pVal);
|
|
|
|
|
2008-02-26 02:40:57 +01:00
|
|
|
if (!pVal)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pVal = This->type;
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetProgress(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_PROGRESS *pVal)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2008-03-04 01:48:08 +01:00
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, pVal);
|
|
|
|
|
2008-03-04 01:48:08 +01:00
|
|
|
if (!pVal)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2008-03-12 19:56:13 +01:00
|
|
|
EnterCriticalSection(&This->cs);
|
2015-06-23 18:59:40 +02:00
|
|
|
*pVal = This->jobProgress;
|
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
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetTimes(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_TIMES *pVal)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", This, pVal);
|
2008-02-23 00:05:26 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetState(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_STATE *pVal)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2008-03-05 01:01:43 +01:00
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, pVal);
|
|
|
|
|
2008-03-05 01:01:43 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetError(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
IBackgroundCopyError **ppError)
|
|
|
|
{
|
2015-06-05 10:35:09 +02:00
|
|
|
BackgroundCopyJobImpl *job = impl_from_IBackgroundCopyJob3(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", job, ppError);
|
|
|
|
|
|
|
|
if (!job->error.context) return BG_E_ERROR_INFORMATION_UNAVAILABLE;
|
|
|
|
|
|
|
|
return create_copy_error(job->error.context, job->error.code, job->error.file, ppError);
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetOwner(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
LPWSTR *pVal)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", This, pVal);
|
2008-02-23 00:05:26 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_SetDisplayName(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
LPCWSTR Val)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%s): stub\n", This, debugstr_w(Val));
|
2008-02-23 00:05:26 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetDisplayName(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
LPWSTR *pVal)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2008-02-26 02:41:35 +01:00
|
|
|
|
2013-11-25 07:42:50 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, pVal);
|
2008-02-26 02:41:35 +01:00
|
|
|
|
2013-11-25 07:42:50 +01:00
|
|
|
return return_strval(This->displayName, pVal);
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_SetDescription(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
LPCWSTR Val)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:42:31 +01:00
|
|
|
static const int max_description_len = 1024;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(Val));
|
|
|
|
|
|
|
|
if (!Val) return E_INVALIDARG;
|
|
|
|
|
2019-06-19 10:28:11 +02:00
|
|
|
len = lstrlenW(Val);
|
2013-11-25 07:42:31 +01:00
|
|
|
if (len > max_description_len) return BG_E_STRING_TOO_LONG;
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->cs);
|
|
|
|
|
|
|
|
if (is_job_done(This))
|
|
|
|
{
|
|
|
|
hr = BG_E_INVALID_STATE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->description);
|
|
|
|
if ((This->description = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR))))
|
2019-06-19 10:28:11 +02:00
|
|
|
lstrcpyW(This->description, Val);
|
2013-11-25 07:42:31 +01:00
|
|
|
else
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&This->cs);
|
|
|
|
|
|
|
|
return hr;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetDescription(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
LPWSTR *pVal)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:42:50 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pVal);
|
|
|
|
|
|
|
|
return return_strval(This->description, pVal);
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_SetPriority(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_PRIORITY Val)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%d): stub\n", This, Val);
|
2009-05-19 17:28:14 +02:00
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetPriority(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_PRIORITY *pVal)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", This, pVal);
|
2008-02-23 00:05:26 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_SetNotifyFlags(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG Val)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-27 13:49:55 +01:00
|
|
|
static const ULONG valid_flags = BG_NOTIFY_JOB_TRANSFERRED |
|
|
|
|
BG_NOTIFY_JOB_ERROR |
|
|
|
|
BG_NOTIFY_DISABLE |
|
|
|
|
BG_NOTIFY_JOB_MODIFICATION |
|
|
|
|
BG_NOTIFY_FILE_TRANSFERRED;
|
|
|
|
|
|
|
|
TRACE("(%p)->(0x%x)\n", This, Val);
|
|
|
|
|
2013-11-28 06:31:24 +01:00
|
|
|
if (is_job_done(This)) return BG_E_INVALID_STATE;
|
2013-11-27 13:49:55 +01:00
|
|
|
if (Val & ~valid_flags) return E_NOTIMPL;
|
|
|
|
This->notify_flags = Val;
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetNotifyFlags(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG *pVal)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-27 13:49:55 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pVal);
|
|
|
|
|
|
|
|
if (!pVal) return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pVal = This->notify_flags;
|
|
|
|
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_SetNotifyInterface(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
IUnknown *Val)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-28 06:31:24 +01:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, Val);
|
|
|
|
|
|
|
|
if (is_job_done(This)) return BG_E_INVALID_STATE;
|
|
|
|
|
|
|
|
if (This->callback)
|
|
|
|
{
|
|
|
|
IBackgroundCopyCallback2_Release(This->callback);
|
|
|
|
This->callback = NULL;
|
|
|
|
This->callback2 = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Val)
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(Val, &IID_IBackgroundCopyCallback2, (void**)&This->callback);
|
|
|
|
if (FAILED(hr))
|
|
|
|
hr = IUnknown_QueryInterface(Val, &IID_IBackgroundCopyCallback, (void**)&This->callback);
|
|
|
|
else
|
|
|
|
This->callback2 = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetNotifyInterface(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
IUnknown **pVal)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-28 06:31:24 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pVal);
|
|
|
|
|
|
|
|
if (!pVal) return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pVal = (IUnknown*)This->callback;
|
|
|
|
if (*pVal)
|
|
|
|
IUnknown_AddRef(*pVal);
|
|
|
|
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_SetMinimumRetryDelay(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *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
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetMinimumRetryDelay(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG *Seconds)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", This, Seconds);
|
2009-01-07 13:22:19 +01:00
|
|
|
*Seconds = 30;
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_SetNoProgressTimeout(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG Seconds)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%d): stub\n", This, Seconds);
|
2009-01-07 13:22:19 +01:00
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetNoProgressTimeout(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG *Seconds)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", This, Seconds);
|
2009-01-07 13:22:19 +01:00
|
|
|
*Seconds = 900;
|
|
|
|
return S_OK;
|
2008-02-23 00:05:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetErrorCount(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
ULONG *Errors)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", This, Errors);
|
2008-02-23 00:05:26 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_SetProxySettings(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_PROXY_USAGE ProxyUsage,
|
|
|
|
const WCHAR *ProxyList,
|
|
|
|
const WCHAR *ProxyBypassList)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%d %s %s): stub\n", This, ProxyUsage, debugstr_w(ProxyList), debugstr_w(ProxyBypassList));
|
2008-02-23 00:05:26 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetProxySettings(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-02-23 00:05:26 +01:00
|
|
|
BG_JOB_PROXY_USAGE *pProxyUsage,
|
|
|
|
LPWSTR *pProxyList,
|
|
|
|
LPWSTR *pProxyBypassList)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%p %p %p): stub\n", This, pProxyUsage, pProxyList, pProxyBypassList);
|
2008-02-23 00:05:26 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_TakeOwnership(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface)
|
2008-02-23 00:05:26 +01:00
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p): stub\n", This);
|
2008-02-23 00:05:26 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_SetNotifyCmdLine(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-03-19 23:02:02 +01:00
|
|
|
LPCWSTR prog,
|
|
|
|
LPCWSTR params)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%s %s): stub\n", This, debugstr_w(prog), debugstr_w(params));
|
2008-03-19 23:02:02 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetNotifyCmdLine(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-09-09 00:20:22 +02:00
|
|
|
LPWSTR *prog,
|
|
|
|
LPWSTR *params)
|
2008-03-19 23:02:02 +01:00
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%p %p): stub\n", This, prog, params);
|
2008-03-19 23:02:02 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetReplyProgress(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-03-19 23:02:02 +01:00
|
|
|
BG_JOB_REPLY_PROGRESS *progress)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", This, progress);
|
2008-03-19 23:02:02 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetReplyData(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-03-19 23:02:02 +01:00
|
|
|
byte **pBuffer,
|
|
|
|
UINT64 *pLength)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%p %p): stub\n", This, pBuffer, pLength);
|
2008-03-19 23:02:02 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_SetReplyFileName(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-03-19 23:02:02 +01:00
|
|
|
LPCWSTR filename)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%s): stub\n", This, debugstr_w(filename));
|
2008-03-19 23:02:02 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetReplyFileName(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-03-19 23:02:02 +01:00
|
|
|
LPWSTR *pFilename)
|
|
|
|
{
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
2013-11-25 07:43:50 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", This, pFilename);
|
2008-03-19 23:02:02 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2015-06-12 15:06:26 +02:00
|
|
|
static int index_from_target(BG_AUTH_TARGET target)
|
|
|
|
{
|
|
|
|
if (!target || target > BG_AUTH_TARGET_PROXY) return -1;
|
|
|
|
return target - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int index_from_scheme(BG_AUTH_SCHEME scheme)
|
|
|
|
{
|
|
|
|
if (!scheme || scheme > BG_AUTH_SCHEME_PASSPORT) return -1;
|
|
|
|
return scheme - 1;
|
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_SetCredentials(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-03-19 23:02:02 +01:00
|
|
|
BG_AUTH_CREDENTIALS *cred)
|
|
|
|
{
|
2015-06-12 15:06:26 +02:00
|
|
|
BackgroundCopyJobImpl *job = impl_from_IBackgroundCopyJob3(iface);
|
|
|
|
BG_AUTH_CREDENTIALS *new_cred;
|
|
|
|
int idx_target, idx_scheme;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", job, cred);
|
|
|
|
|
|
|
|
if ((idx_target = index_from_target(cred->Target)) < 0) return BG_E_INVALID_AUTH_TARGET;
|
|
|
|
if ((idx_scheme = index_from_scheme(cred->Scheme)) < 0) return BG_E_INVALID_AUTH_SCHEME;
|
|
|
|
new_cred = &job->http_options.creds[idx_target][idx_scheme];
|
|
|
|
|
|
|
|
EnterCriticalSection(&job->cs);
|
|
|
|
|
|
|
|
new_cred->Target = cred->Target;
|
|
|
|
new_cred->Scheme = cred->Scheme;
|
|
|
|
|
|
|
|
if (cred->Credentials.Basic.UserName)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, new_cred->Credentials.Basic.UserName);
|
|
|
|
new_cred->Credentials.Basic.UserName = strdupW(cred->Credentials.Basic.UserName);
|
|
|
|
}
|
|
|
|
if (cred->Credentials.Basic.Password)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, new_cred->Credentials.Basic.Password);
|
|
|
|
new_cred->Credentials.Basic.Password = strdupW(cred->Credentials.Basic.Password);
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&job->cs);
|
2009-01-15 10:40:18 +01:00
|
|
|
return S_OK;
|
2008-03-19 23:02:02 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 07:43:50 +01:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_RemoveCredentials(
|
2015-06-05 10:34:21 +02:00
|
|
|
IBackgroundCopyJob3 *iface,
|
2008-03-19 23:02:02 +01:00
|
|
|
BG_AUTH_TARGET target,
|
|
|
|
BG_AUTH_SCHEME scheme)
|
|
|
|
{
|
2015-06-12 15:06:26 +02:00
|
|
|
BackgroundCopyJobImpl *job = impl_from_IBackgroundCopyJob3(iface);
|
|
|
|
BG_AUTH_CREDENTIALS *new_cred;
|
|
|
|
int idx_target, idx_scheme;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %u)\n", job, target, scheme);
|
|
|
|
|
|
|
|
if ((idx_target = index_from_target(target)) < 0) return BG_E_INVALID_AUTH_TARGET;
|
|
|
|
if ((idx_scheme = index_from_scheme(scheme)) < 0) return BG_E_INVALID_AUTH_SCHEME;
|
|
|
|
new_cred = &job->http_options.creds[idx_target][idx_scheme];
|
|
|
|
|
|
|
|
EnterCriticalSection(&job->cs);
|
|
|
|
|
|
|
|
new_cred->Target = new_cred->Scheme = 0;
|
|
|
|
HeapFree(GetProcessHeap(), 0, new_cred->Credentials.Basic.UserName);
|
|
|
|
new_cred->Credentials.Basic.UserName = NULL;
|
|
|
|
HeapFree(GetProcessHeap(), 0, new_cred->Credentials.Basic.Password);
|
|
|
|
new_cred->Credentials.Basic.Password = NULL;
|
|
|
|
|
|
|
|
LeaveCriticalSection(&job->cs);
|
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
|
|
|
|
2015-06-05 10:34:21 +02:00
|
|
|
static HRESULT WINAPI BackgroundCopyJob_ReplaceRemotePrefix(
|
|
|
|
IBackgroundCopyJob3 *iface,
|
|
|
|
LPCWSTR OldPrefix,
|
|
|
|
LPCWSTR NewPrefix)
|
|
|
|
{
|
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
|
|
|
FIXME("(%p)->(%s %s): stub\n", This, debugstr_w(OldPrefix), debugstr_w(NewPrefix));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BackgroundCopyJob_AddFileWithRanges(
|
|
|
|
IBackgroundCopyJob3 *iface,
|
|
|
|
LPCWSTR RemoteUrl,
|
|
|
|
LPCWSTR LocalName,
|
|
|
|
DWORD RangeCount,
|
|
|
|
BG_FILE_RANGE Ranges[])
|
|
|
|
{
|
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
|
|
|
FIXME("(%p)->(%s %s %u %p): stub\n", This, debugstr_w(RemoteUrl), debugstr_w(LocalName), RangeCount, Ranges);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BackgroundCopyJob_SetFileACLFlags(
|
|
|
|
IBackgroundCopyJob3 *iface,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
|
|
|
FIXME("(%p)->(%x): stub\n", This, Flags);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BackgroundCopyJob_GetFileACLFlags(
|
|
|
|
IBackgroundCopyJob3 *iface,
|
|
|
|
DWORD *Flags)
|
|
|
|
{
|
|
|
|
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob3(iface);
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, Flags);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBackgroundCopyJob3Vtbl BackgroundCopyJob3Vtbl =
|
2013-11-25 07:43:50 +01:00
|
|
|
{
|
|
|
|
BackgroundCopyJob_QueryInterface,
|
|
|
|
BackgroundCopyJob_AddRef,
|
|
|
|
BackgroundCopyJob_Release,
|
|
|
|
BackgroundCopyJob_AddFileSet,
|
|
|
|
BackgroundCopyJob_AddFile,
|
|
|
|
BackgroundCopyJob_EnumFiles,
|
|
|
|
BackgroundCopyJob_Suspend,
|
|
|
|
BackgroundCopyJob_Resume,
|
|
|
|
BackgroundCopyJob_Cancel,
|
|
|
|
BackgroundCopyJob_Complete,
|
|
|
|
BackgroundCopyJob_GetId,
|
|
|
|
BackgroundCopyJob_GetType,
|
|
|
|
BackgroundCopyJob_GetProgress,
|
|
|
|
BackgroundCopyJob_GetTimes,
|
|
|
|
BackgroundCopyJob_GetState,
|
|
|
|
BackgroundCopyJob_GetError,
|
|
|
|
BackgroundCopyJob_GetOwner,
|
|
|
|
BackgroundCopyJob_SetDisplayName,
|
|
|
|
BackgroundCopyJob_GetDisplayName,
|
|
|
|
BackgroundCopyJob_SetDescription,
|
|
|
|
BackgroundCopyJob_GetDescription,
|
|
|
|
BackgroundCopyJob_SetPriority,
|
|
|
|
BackgroundCopyJob_GetPriority,
|
|
|
|
BackgroundCopyJob_SetNotifyFlags,
|
|
|
|
BackgroundCopyJob_GetNotifyFlags,
|
|
|
|
BackgroundCopyJob_SetNotifyInterface,
|
|
|
|
BackgroundCopyJob_GetNotifyInterface,
|
|
|
|
BackgroundCopyJob_SetMinimumRetryDelay,
|
|
|
|
BackgroundCopyJob_GetMinimumRetryDelay,
|
|
|
|
BackgroundCopyJob_SetNoProgressTimeout,
|
|
|
|
BackgroundCopyJob_GetNoProgressTimeout,
|
|
|
|
BackgroundCopyJob_GetErrorCount,
|
|
|
|
BackgroundCopyJob_SetProxySettings,
|
|
|
|
BackgroundCopyJob_GetProxySettings,
|
|
|
|
BackgroundCopyJob_TakeOwnership,
|
|
|
|
BackgroundCopyJob_SetNotifyCmdLine,
|
|
|
|
BackgroundCopyJob_GetNotifyCmdLine,
|
|
|
|
BackgroundCopyJob_GetReplyProgress,
|
|
|
|
BackgroundCopyJob_GetReplyData,
|
|
|
|
BackgroundCopyJob_SetReplyFileName,
|
|
|
|
BackgroundCopyJob_GetReplyFileName,
|
|
|
|
BackgroundCopyJob_SetCredentials,
|
2015-06-05 10:34:21 +02:00
|
|
|
BackgroundCopyJob_RemoveCredentials,
|
|
|
|
BackgroundCopyJob_ReplaceRemotePrefix,
|
|
|
|
BackgroundCopyJob_AddFileWithRanges,
|
|
|
|
BackgroundCopyJob_SetFileACLFlags,
|
|
|
|
BackgroundCopyJob_GetFileACLFlags
|
2008-02-23 00:05:26 +01:00
|
|
|
};
|
2008-02-23 00:06:17 +01:00
|
|
|
|
2015-06-12 15:05:11 +02:00
|
|
|
static inline BackgroundCopyJobImpl *impl_from_IBackgroundCopyJobHttpOptions(
|
|
|
|
IBackgroundCopyJobHttpOptions *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BackgroundCopyJobImpl, IBackgroundCopyJobHttpOptions_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI http_options_QueryInterface(
|
|
|
|
IBackgroundCopyJobHttpOptions *iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
|
|
|
BackgroundCopyJobImpl *job = impl_from_IBackgroundCopyJobHttpOptions(iface);
|
|
|
|
return IBackgroundCopyJob3_QueryInterface(&job->IBackgroundCopyJob3_iface, riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI http_options_AddRef(
|
|
|
|
IBackgroundCopyJobHttpOptions *iface)
|
|
|
|
{
|
|
|
|
BackgroundCopyJobImpl *job = impl_from_IBackgroundCopyJobHttpOptions(iface);
|
|
|
|
return IBackgroundCopyJob3_AddRef(&job->IBackgroundCopyJob3_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI http_options_Release(
|
|
|
|
IBackgroundCopyJobHttpOptions *iface)
|
|
|
|
{
|
|
|
|
BackgroundCopyJobImpl *job = impl_from_IBackgroundCopyJobHttpOptions(iface);
|
|
|
|
return IBackgroundCopyJob3_Release(&job->IBackgroundCopyJob3_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI http_options_SetClientCertificateByID(
|
|
|
|
IBackgroundCopyJobHttpOptions *iface,
|
|
|
|
BG_CERT_STORE_LOCATION StoreLocation,
|
|
|
|
LPCWSTR StoreName,
|
|
|
|
BYTE *pCertHashBlob)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI http_options_SetClientCertificateByName(
|
|
|
|
IBackgroundCopyJobHttpOptions *iface,
|
|
|
|
BG_CERT_STORE_LOCATION StoreLocation,
|
|
|
|
LPCWSTR StoreName,
|
|
|
|
LPCWSTR SubjectName)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI http_options_RemoveClientCertificate(
|
|
|
|
IBackgroundCopyJobHttpOptions *iface)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI http_options_GetClientCertificate(
|
|
|
|
IBackgroundCopyJobHttpOptions *iface,
|
|
|
|
BG_CERT_STORE_LOCATION *pStoreLocation,
|
|
|
|
LPWSTR *pStoreName,
|
|
|
|
BYTE **ppCertHashBlob,
|
|
|
|
LPWSTR *pSubjectName)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI http_options_SetCustomHeaders(
|
|
|
|
IBackgroundCopyJobHttpOptions *iface,
|
|
|
|
LPCWSTR RequestHeaders)
|
|
|
|
{
|
2015-06-12 15:05:59 +02:00
|
|
|
BackgroundCopyJobImpl *job = impl_from_IBackgroundCopyJobHttpOptions(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", iface, debugstr_w(RequestHeaders));
|
|
|
|
|
|
|
|
EnterCriticalSection(&job->cs);
|
|
|
|
|
|
|
|
if (RequestHeaders)
|
|
|
|
{
|
|
|
|
WCHAR *headers = strdupW(RequestHeaders);
|
|
|
|
if (!headers)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&job->cs);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, job->http_options.headers);
|
|
|
|
job->http_options.headers = headers;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, job->http_options.headers);
|
|
|
|
job->http_options.headers = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&job->cs);
|
|
|
|
return S_OK;
|
2015-06-12 15:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI http_options_GetCustomHeaders(
|
|
|
|
IBackgroundCopyJobHttpOptions *iface,
|
|
|
|
LPWSTR *pRequestHeaders)
|
|
|
|
{
|
2015-06-12 15:05:59 +02:00
|
|
|
BackgroundCopyJobImpl *job = impl_from_IBackgroundCopyJobHttpOptions(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", iface, pRequestHeaders);
|
|
|
|
|
|
|
|
EnterCriticalSection(&job->cs);
|
|
|
|
|
|
|
|
if (job->http_options.headers)
|
|
|
|
{
|
|
|
|
WCHAR *headers = co_strdupW(job->http_options.headers);
|
|
|
|
if (!headers)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&job->cs);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
*pRequestHeaders = headers;
|
|
|
|
LeaveCriticalSection(&job->cs);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pRequestHeaders = NULL;
|
|
|
|
LeaveCriticalSection(&job->cs);
|
|
|
|
return S_FALSE;
|
2015-06-12 15:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI http_options_SetSecurityFlags(
|
|
|
|
IBackgroundCopyJobHttpOptions *iface,
|
|
|
|
ULONG Flags)
|
|
|
|
{
|
2015-06-12 15:05:31 +02:00
|
|
|
BackgroundCopyJobImpl *job = impl_from_IBackgroundCopyJobHttpOptions(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(0x%08x)\n", iface, Flags);
|
|
|
|
|
|
|
|
job->http_options.flags = Flags;
|
|
|
|
return S_OK;
|
2015-06-12 15:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI http_options_GetSecurityFlags(
|
|
|
|
IBackgroundCopyJobHttpOptions *iface,
|
|
|
|
ULONG *pFlags)
|
|
|
|
{
|
2015-06-12 15:05:31 +02:00
|
|
|
BackgroundCopyJobImpl *job = impl_from_IBackgroundCopyJobHttpOptions(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", iface, pFlags);
|
|
|
|
|
|
|
|
*pFlags = job->http_options.flags;
|
|
|
|
return S_OK;
|
2015-06-12 15:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IBackgroundCopyJobHttpOptionsVtbl http_options_vtbl =
|
|
|
|
{
|
|
|
|
http_options_QueryInterface,
|
|
|
|
http_options_AddRef,
|
|
|
|
http_options_Release,
|
|
|
|
http_options_SetClientCertificateByID,
|
|
|
|
http_options_SetClientCertificateByName,
|
|
|
|
http_options_RemoveClientCertificate,
|
|
|
|
http_options_GetClientCertificate,
|
|
|
|
http_options_SetCustomHeaders,
|
|
|
|
http_options_GetCustomHeaders,
|
|
|
|
http_options_SetSecurityFlags,
|
|
|
|
http_options_GetSecurityFlags
|
|
|
|
};
|
|
|
|
|
2013-01-17 19:39:26 +01:00
|
|
|
HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID *job_id, BackgroundCopyJobImpl **job)
|
2008-02-23 00:06:17 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
BackgroundCopyJobImpl *This;
|
|
|
|
|
2013-01-17 19:39:26 +01:00
|
|
|
TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, job);
|
2008-02-23 00:06:17 +01:00
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2015-06-05 10:34:21 +02:00
|
|
|
This->IBackgroundCopyJob3_iface.lpVtbl = &BackgroundCopyJob3Vtbl;
|
2015-06-12 15:05:11 +02:00
|
|
|
This->IBackgroundCopyJobHttpOptions_iface.lpVtbl = &http_options_vtbl;
|
2008-03-12 19:56:13 +01:00
|
|
|
InitializeCriticalSection(&This->cs);
|
2011-11-14 15:10:44 +01:00
|
|
|
This->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BackgroundCopyJobImpl.cs");
|
|
|
|
|
2008-02-23 00:06:17 +01:00
|
|
|
This->ref = 1;
|
|
|
|
This->type = type;
|
|
|
|
|
2015-06-23 14:14:53 +02:00
|
|
|
This->displayName = strdupW(displayName);
|
2008-02-23 00:06:17 +01:00
|
|
|
if (!This->displayName)
|
|
|
|
{
|
2011-11-14 15:10:44 +01:00
|
|
|
This->cs.DebugInfo->Spare[0] = 0;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoCreateGuid(&This->jobId);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2011-11-14 15:10:44 +01:00
|
|
|
This->cs.DebugInfo->Spare[0] = 0;
|
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;
|
|
|
|
}
|
2013-01-17 19:39:26 +01:00
|
|
|
*job_id = 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;
|
2013-11-25 07:42:31 +01:00
|
|
|
This->description = NULL;
|
2013-11-27 13:49:55 +01:00
|
|
|
This->notify_flags = BG_NOTIFY_JOB_ERROR | BG_NOTIFY_JOB_TRANSFERRED;
|
2013-11-28 06:31:24 +01:00
|
|
|
This->callback = NULL;
|
|
|
|
This->callback2 = FALSE;
|
2008-03-05 01:01:43 +01:00
|
|
|
|
2015-06-05 10:35:09 +02:00
|
|
|
This->error.context = 0;
|
2016-09-14 10:06:11 +02:00
|
|
|
This->error.code = S_OK;
|
2015-06-05 10:35:09 +02:00
|
|
|
This->error.file = NULL;
|
|
|
|
|
2015-06-12 15:05:11 +02:00
|
|
|
memset(&This->http_options, 0, sizeof(This->http_options));
|
|
|
|
|
2015-06-12 15:06:59 +02:00
|
|
|
This->wait = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
This->cancel = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
This->done = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
|
2013-01-17 19:39:26 +01:00
|
|
|
*job = This;
|
2013-11-25 07:43:50 +01:00
|
|
|
|
|
|
|
TRACE("created job %s:%p\n", debugstr_guid(&This->jobId), This);
|
|
|
|
|
2008-02-23 00:06:17 +01:00
|
|
|
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);
|
2019-11-07 19:26:26 +01:00
|
|
|
if (job->callback && (job->notify_flags & BG_NOTIFY_JOB_TRANSFERRED))
|
|
|
|
IBackgroundCopyCallback2_JobTransferred(job->callback, (IBackgroundCopyJob*)&job->IBackgroundCopyJob3_iface);
|
2008-03-13 23:54:35 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!processFile(file, job))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|