mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:35:43 +00:00
- Add some headers from Wine
- Import qmgr from Wine (not included yet to build) svn path=/trunk/; revision=39240
This commit is contained in:
parent
15a996c26b
commit
2ab5d20abb
20 changed files with 2959 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
|||
<property name="BASEADDRESS_PWRCFG" value="0x587e0000" />
|
||||
<property name="BASEADDRESS_MMSYS" value="0x588a0000" />
|
||||
<property name="BASEADDRESS_JOY" value="0x589b0000" />
|
||||
<property name="BASEADDRESS_QMGR" value="0x59620000" />
|
||||
<property name="BASEADDRESS_UXTHEME" value="0x5ad70000" />
|
||||
<property name="BASEADDRESS_VDMDBG" value="0x5b0d0000" />
|
||||
<property name="BASEADDRESS_UNTFS" value="0x5b340000" />
|
||||
|
|
215
reactos/dll/win32/qmgr/enum_files.c
Normal file
215
reactos/dll/win32/qmgr/enum_files.c
Normal file
|
@ -0,0 +1,215 @@
|
|||
/*
|
||||
* Queue Manager (BITS) File Enumerator
|
||||
*
|
||||
* Copyright 2007, 2008 Google (Roy Shea, Dan Hipschman)
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "qmgr.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
||||
|
||||
static void EnumBackgroundCopyFilesDestructor(EnumBackgroundCopyFilesImpl *This)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
for(i = 0; i < This->numFiles; i++)
|
||||
IBackgroundCopyFile_Release(This->files[i]);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This->files);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_AddRef(
|
||||
IEnumBackgroundCopyFiles* iface)
|
||||
{
|
||||
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
|
||||
return InterlockedIncrement(&This->ref);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_QueryInterface(
|
||||
IEnumBackgroundCopyFiles* iface,
|
||||
REFIID riid,
|
||||
void **ppvObject)
|
||||
{
|
||||
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
|
||||
TRACE("IID: %s\n", debugstr_guid(riid));
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown)
|
||||
|| IsEqualGUID(riid, &IID_IEnumBackgroundCopyFiles))
|
||||
{
|
||||
*ppvObject = &This->lpVtbl;
|
||||
BITS_IEnumBackgroundCopyFiles_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_Release(
|
||||
IEnumBackgroundCopyFiles* iface)
|
||||
{
|
||||
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
if (ref == 0)
|
||||
EnumBackgroundCopyFilesDestructor(This);
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
/* Return reference to one or more files in the file enumerator */
|
||||
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Next(
|
||||
IEnumBackgroundCopyFiles* iface,
|
||||
ULONG celt,
|
||||
IBackgroundCopyFile **rgelt,
|
||||
ULONG *pceltFetched)
|
||||
{
|
||||
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
|
||||
ULONG fetched;
|
||||
ULONG i;
|
||||
IBackgroundCopyFile *file;
|
||||
|
||||
/* Despite documented behavior, Windows (tested on XP) is not verifying
|
||||
that the caller set pceltFetched to zero. No check here. */
|
||||
|
||||
fetched = min(celt, This->numFiles - This->indexFiles);
|
||||
if (pceltFetched)
|
||||
*pceltFetched = fetched;
|
||||
else
|
||||
{
|
||||
/* We need to initialize this array if the caller doesn't request
|
||||
the length because length_is will default to celt. */
|
||||
for (i = 0; i < celt; i++)
|
||||
rgelt[i] = NULL;
|
||||
|
||||
/* pceltFetched can only be NULL if celt is 1 */
|
||||
if (celt != 1)
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
/* Fill in the array of objects */
|
||||
for (i = 0; i < fetched; i++)
|
||||
{
|
||||
file = This->files[This->indexFiles++];
|
||||
IBackgroundCopyFile_AddRef(file);
|
||||
rgelt[i] = file;
|
||||
}
|
||||
|
||||
return fetched == celt ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
/* Skip over one or more files in the file enumerator */
|
||||
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Skip(
|
||||
IEnumBackgroundCopyFiles* iface,
|
||||
ULONG celt)
|
||||
{
|
||||
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
|
||||
|
||||
if (celt > This->numFiles - This->indexFiles)
|
||||
{
|
||||
This->indexFiles = This->numFiles;
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
This->indexFiles += celt;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Reset(
|
||||
IEnumBackgroundCopyFiles* iface)
|
||||
{
|
||||
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
|
||||
This->indexFiles = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Clone(
|
||||
IEnumBackgroundCopyFiles* iface,
|
||||
IEnumBackgroundCopyFiles **ppenum)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_GetCount(
|
||||
IEnumBackgroundCopyFiles* iface,
|
||||
ULONG *puCount)
|
||||
{
|
||||
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
|
||||
*puCount = This->numFiles;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const IEnumBackgroundCopyFilesVtbl BITS_IEnumBackgroundCopyFiles_Vtbl =
|
||||
{
|
||||
BITS_IEnumBackgroundCopyFiles_QueryInterface,
|
||||
BITS_IEnumBackgroundCopyFiles_AddRef,
|
||||
BITS_IEnumBackgroundCopyFiles_Release,
|
||||
BITS_IEnumBackgroundCopyFiles_Next,
|
||||
BITS_IEnumBackgroundCopyFiles_Skip,
|
||||
BITS_IEnumBackgroundCopyFiles_Reset,
|
||||
BITS_IEnumBackgroundCopyFiles_Clone,
|
||||
BITS_IEnumBackgroundCopyFiles_GetCount
|
||||
};
|
||||
|
||||
HRESULT EnumBackgroundCopyFilesConstructor(LPVOID *ppObj, IBackgroundCopyJob2 *iCopyJob)
|
||||
{
|
||||
EnumBackgroundCopyFilesImpl *This;
|
||||
BackgroundCopyFileImpl *file;
|
||||
BackgroundCopyJobImpl *job = (BackgroundCopyJobImpl *) iCopyJob;
|
||||
ULONG i;
|
||||
|
||||
TRACE("%p, %p)\n", ppObj, job);
|
||||
|
||||
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
|
||||
if (!This)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
This->lpVtbl = &BITS_IEnumBackgroundCopyFiles_Vtbl;
|
||||
This->ref = 1;
|
||||
|
||||
/* Create array of files */
|
||||
This->indexFiles = 0;
|
||||
EnterCriticalSection(&job->cs);
|
||||
This->numFiles = list_count(&job->files);
|
||||
This->files = NULL;
|
||||
if (This->numFiles > 0)
|
||||
{
|
||||
This->files = HeapAlloc(GetProcessHeap(), 0,
|
||||
This->numFiles * sizeof This->files[0]);
|
||||
if (!This->files)
|
||||
{
|
||||
LeaveCriticalSection(&job->cs);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
LIST_FOR_EACH_ENTRY(file, &job->files, BackgroundCopyFileImpl, entryFromJob)
|
||||
{
|
||||
file->lpVtbl->AddRef((IBackgroundCopyFile *) file);
|
||||
This->files[i] = (IBackgroundCopyFile *) file;
|
||||
++i;
|
||||
}
|
||||
LeaveCriticalSection(&job->cs);
|
||||
|
||||
*ppObj = &This->lpVtbl;
|
||||
return S_OK;
|
||||
}
|
213
reactos/dll/win32/qmgr/enum_jobs.c
Normal file
213
reactos/dll/win32/qmgr/enum_jobs.c
Normal file
|
@ -0,0 +1,213 @@
|
|||
/*
|
||||
* Queue Manager (BITS) Job Enumerator
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "qmgr.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
||||
|
||||
static void EnumBackgroundCopyJobsDestructor(EnumBackgroundCopyJobsImpl *This)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
for(i = 0; i < This->numJobs; i++)
|
||||
IBackgroundCopyJob_Release(This->jobs[i]);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This->jobs);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
static ULONG WINAPI BITS_IEnumBackgroundCopyJobs_AddRef(
|
||||
IEnumBackgroundCopyJobs* iface)
|
||||
{
|
||||
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface;
|
||||
return InterlockedIncrement(&This->ref);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_QueryInterface(
|
||||
IEnumBackgroundCopyJobs* iface,
|
||||
REFIID riid,
|
||||
void **ppvObject)
|
||||
{
|
||||
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface;
|
||||
TRACE("IID: %s\n", debugstr_guid(riid));
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown)
|
||||
|| IsEqualGUID(riid, &IID_IEnumBackgroundCopyJobs))
|
||||
{
|
||||
*ppvObject = &This->lpVtbl;
|
||||
BITS_IEnumBackgroundCopyJobs_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI BITS_IEnumBackgroundCopyJobs_Release(
|
||||
IEnumBackgroundCopyJobs* iface)
|
||||
{
|
||||
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface;
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
if (ref == 0)
|
||||
EnumBackgroundCopyJobsDestructor(This);
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Next(
|
||||
IEnumBackgroundCopyJobs* iface,
|
||||
ULONG celt,
|
||||
IBackgroundCopyJob **rgelt,
|
||||
ULONG *pceltFetched)
|
||||
{
|
||||
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface;
|
||||
ULONG fetched;
|
||||
ULONG i;
|
||||
IBackgroundCopyJob *job;
|
||||
|
||||
fetched = min(celt, This->numJobs - This->indexJobs);
|
||||
if (pceltFetched)
|
||||
*pceltFetched = fetched;
|
||||
else
|
||||
{
|
||||
/* We need to initialize this array if the caller doesn't request
|
||||
the length because length_is will default to celt. */
|
||||
for (i = 0; i < celt; ++i)
|
||||
rgelt[i] = NULL;
|
||||
|
||||
/* pceltFetched can only be NULL if celt is 1 */
|
||||
if (celt != 1)
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
/* Fill in the array of objects */
|
||||
for (i = 0; i < fetched; ++i)
|
||||
{
|
||||
job = This->jobs[This->indexJobs++];
|
||||
IBackgroundCopyJob_AddRef(job);
|
||||
rgelt[i] = job;
|
||||
}
|
||||
|
||||
return fetched == celt ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Skip(
|
||||
IEnumBackgroundCopyJobs* iface,
|
||||
ULONG celt)
|
||||
{
|
||||
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface;
|
||||
|
||||
if (This->numJobs - This->indexJobs < celt)
|
||||
{
|
||||
This->indexJobs = This->numJobs;
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
This->indexJobs += celt;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Reset(
|
||||
IEnumBackgroundCopyJobs* iface)
|
||||
{
|
||||
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface;
|
||||
This->indexJobs = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Clone(
|
||||
IEnumBackgroundCopyJobs* iface,
|
||||
IEnumBackgroundCopyJobs **ppenum)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_GetCount(
|
||||
IEnumBackgroundCopyJobs* iface,
|
||||
ULONG *puCount)
|
||||
{
|
||||
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface;
|
||||
*puCount = This->numJobs;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const IEnumBackgroundCopyJobsVtbl BITS_IEnumBackgroundCopyJobs_Vtbl =
|
||||
{
|
||||
BITS_IEnumBackgroundCopyJobs_QueryInterface,
|
||||
BITS_IEnumBackgroundCopyJobs_AddRef,
|
||||
BITS_IEnumBackgroundCopyJobs_Release,
|
||||
BITS_IEnumBackgroundCopyJobs_Next,
|
||||
BITS_IEnumBackgroundCopyJobs_Skip,
|
||||
BITS_IEnumBackgroundCopyJobs_Reset,
|
||||
BITS_IEnumBackgroundCopyJobs_Clone,
|
||||
BITS_IEnumBackgroundCopyJobs_GetCount
|
||||
};
|
||||
|
||||
HRESULT EnumBackgroundCopyJobsConstructor(LPVOID *ppObj,
|
||||
IBackgroundCopyManager* copyManager)
|
||||
{
|
||||
BackgroundCopyManagerImpl *qmgr = (BackgroundCopyManagerImpl *) copyManager;
|
||||
EnumBackgroundCopyJobsImpl *This;
|
||||
BackgroundCopyJobImpl *job;
|
||||
ULONG i;
|
||||
|
||||
TRACE("%p, %p)\n", ppObj, copyManager);
|
||||
|
||||
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
|
||||
if (!This)
|
||||
return E_OUTOFMEMORY;
|
||||
This->lpVtbl = &BITS_IEnumBackgroundCopyJobs_Vtbl;
|
||||
This->ref = 1;
|
||||
|
||||
/* Create array of jobs */
|
||||
This->indexJobs = 0;
|
||||
|
||||
EnterCriticalSection(&qmgr->cs);
|
||||
This->numJobs = list_count(&qmgr->jobs);
|
||||
|
||||
if (0 < This->numJobs)
|
||||
{
|
||||
This->jobs = HeapAlloc(GetProcessHeap(), 0,
|
||||
This->numJobs * sizeof *This->jobs);
|
||||
if (!This->jobs)
|
||||
{
|
||||
LeaveCriticalSection(&qmgr->cs);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
This->jobs = NULL;
|
||||
|
||||
i = 0;
|
||||
LIST_FOR_EACH_ENTRY(job, &qmgr->jobs, BackgroundCopyJobImpl, entryFromQmgr)
|
||||
{
|
||||
IBackgroundCopyJob *iJob = (IBackgroundCopyJob *) job;
|
||||
IBackgroundCopyJob_AddRef(iJob);
|
||||
This->jobs[i++] = iJob;
|
||||
}
|
||||
LeaveCriticalSection(&qmgr->cs);
|
||||
|
||||
*ppObj = &This->lpVtbl;
|
||||
return S_OK;
|
||||
}
|
96
reactos/dll/win32/qmgr/factory.c
Normal file
96
reactos/dll/win32/qmgr/factory.c
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Class factory interface for Queue Manager (BITS)
|
||||
*
|
||||
* Copyright (C) 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
|
||||
*/
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "qmgr.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
||||
|
||||
static ULONG WINAPI
|
||||
BITS_IClassFactory_AddRef(LPCLASSFACTORY iface)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI
|
||||
BITS_IClassFactory_QueryInterface(LPCLASSFACTORY iface, REFIID riid,
|
||||
LPVOID *ppvObj)
|
||||
{
|
||||
ClassFactoryImpl *This = (ClassFactoryImpl *) iface;
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IClassFactory))
|
||||
{
|
||||
*ppvObj = &This->lpVtbl;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*ppvObj = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI
|
||||
BITS_IClassFactory_Release(LPCLASSFACTORY iface)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI
|
||||
BITS_IClassFactory_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter,
|
||||
REFIID riid, LPVOID *ppvObj)
|
||||
{
|
||||
HRESULT res;
|
||||
IUnknown *punk = NULL;
|
||||
|
||||
TRACE("IID: %s\n", debugstr_guid(riid));
|
||||
|
||||
if (pUnkOuter)
|
||||
return CLASS_E_NOAGGREGATION;
|
||||
|
||||
res = BackgroundCopyManagerConstructor(pUnkOuter, (LPVOID*) &punk);
|
||||
if (FAILED(res))
|
||||
return res;
|
||||
|
||||
res = IUnknown_QueryInterface(punk, riid, ppvObj);
|
||||
IUnknown_Release(punk);
|
||||
return res;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI
|
||||
BITS_IClassFactory_LockServer(LPCLASSFACTORY iface, BOOL fLock)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static const IClassFactoryVtbl BITS_IClassFactory_Vtbl =
|
||||
{
|
||||
BITS_IClassFactory_QueryInterface,
|
||||
BITS_IClassFactory_AddRef,
|
||||
BITS_IClassFactory_Release,
|
||||
BITS_IClassFactory_CreateInstance,
|
||||
BITS_IClassFactory_LockServer
|
||||
};
|
||||
|
||||
ClassFactoryImpl BITS_ClassFactory =
|
||||
{
|
||||
&BITS_IClassFactory_Vtbl
|
||||
};
|
451
reactos/dll/win32/qmgr/file.c
Normal file
451
reactos/dll/win32/qmgr/file.c
Normal file
|
@ -0,0 +1,451 @@
|
|||
/*
|
||||
* Queue Manager (BITS) File
|
||||
*
|
||||
* Copyright 2007, 2008 Google (Roy Shea, Dan Hipschman)
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
#include "winreg.h"
|
||||
#include "ole2.h"
|
||||
#include "urlmon.h"
|
||||
#include "wininet.h"
|
||||
|
||||
#include "qmgr.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
||||
|
||||
static void BackgroundCopyFileDestructor(BackgroundCopyFileImpl *This)
|
||||
{
|
||||
IBackgroundCopyJob_Release((IBackgroundCopyJob *) This->owner);
|
||||
HeapFree(GetProcessHeap(), 0, This->info.LocalName);
|
||||
HeapFree(GetProcessHeap(), 0, This->info.RemoteName);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
static ULONG WINAPI BITS_IBackgroundCopyFile_AddRef(IBackgroundCopyFile* iface)
|
||||
{
|
||||
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
|
||||
return InterlockedIncrement(&This->ref);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyFile_QueryInterface(
|
||||
IBackgroundCopyFile* iface,
|
||||
REFIID riid,
|
||||
void **ppvObject)
|
||||
{
|
||||
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown)
|
||||
|| IsEqualGUID(riid, &IID_IBackgroundCopyFile))
|
||||
{
|
||||
*ppvObject = &This->lpVtbl;
|
||||
BITS_IBackgroundCopyFile_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
static ULONG WINAPI BITS_IBackgroundCopyFile_Release(
|
||||
IBackgroundCopyFile* iface)
|
||||
{
|
||||
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
if (ref == 0)
|
||||
BackgroundCopyFileDestructor(This);
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
/* Get the remote name of a background copy file */
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyFile_GetRemoteName(
|
||||
IBackgroundCopyFile* iface,
|
||||
LPWSTR *pVal)
|
||||
{
|
||||
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
|
||||
int n = (lstrlenW(This->info.RemoteName) + 1) * sizeof(WCHAR);
|
||||
|
||||
*pVal = CoTaskMemAlloc(n);
|
||||
if (!*pVal)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
memcpy(*pVal, This->info.RemoteName, n);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyFile_GetLocalName(
|
||||
IBackgroundCopyFile* iface,
|
||||
LPWSTR *pVal)
|
||||
{
|
||||
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
|
||||
int n = (lstrlenW(This->info.LocalName) + 1) * sizeof(WCHAR);
|
||||
|
||||
*pVal = CoTaskMemAlloc(n);
|
||||
if (!*pVal)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
memcpy(*pVal, This->info.LocalName, n);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyFile_GetProgress(
|
||||
IBackgroundCopyFile* iface,
|
||||
BG_FILE_PROGRESS *pVal)
|
||||
{
|
||||
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
|
||||
|
||||
EnterCriticalSection(&This->owner->cs);
|
||||
pVal->BytesTotal = This->fileProgress.BytesTotal;
|
||||
pVal->BytesTransferred = This->fileProgress.BytesTransferred;
|
||||
pVal->Completed = This->fileProgress.Completed;
|
||||
LeaveCriticalSection(&This->owner->cs);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const IBackgroundCopyFileVtbl BITS_IBackgroundCopyFile_Vtbl =
|
||||
{
|
||||
BITS_IBackgroundCopyFile_QueryInterface,
|
||||
BITS_IBackgroundCopyFile_AddRef,
|
||||
BITS_IBackgroundCopyFile_Release,
|
||||
BITS_IBackgroundCopyFile_GetRemoteName,
|
||||
BITS_IBackgroundCopyFile_GetLocalName,
|
||||
BITS_IBackgroundCopyFile_GetProgress
|
||||
};
|
||||
|
||||
HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
|
||||
LPCWSTR remoteName, LPCWSTR localName,
|
||||
LPVOID *ppObj)
|
||||
{
|
||||
BackgroundCopyFileImpl *This;
|
||||
int n;
|
||||
|
||||
TRACE("(%s,%s,%p)\n", debugstr_w(remoteName),
|
||||
debugstr_w(localName), ppObj);
|
||||
|
||||
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
|
||||
if (!This)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
n = (lstrlenW(remoteName) + 1) * sizeof(WCHAR);
|
||||
This->info.RemoteName = HeapAlloc(GetProcessHeap(), 0, n);
|
||||
if (!This->info.RemoteName)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
memcpy(This->info.RemoteName, remoteName, n);
|
||||
|
||||
n = (lstrlenW(localName) + 1) * sizeof(WCHAR);
|
||||
This->info.LocalName = HeapAlloc(GetProcessHeap(), 0, n);
|
||||
if (!This->info.LocalName)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, This->info.RemoteName);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
memcpy(This->info.LocalName, localName, n);
|
||||
|
||||
This->lpVtbl = &BITS_IBackgroundCopyFile_Vtbl;
|
||||
This->ref = 1;
|
||||
|
||||
This->fileProgress.BytesTotal = BG_SIZE_UNKNOWN;
|
||||
This->fileProgress.BytesTransferred = 0;
|
||||
This->fileProgress.Completed = FALSE;
|
||||
This->owner = owner;
|
||||
IBackgroundCopyJob_AddRef((IBackgroundCopyJob *) owner);
|
||||
|
||||
*ppObj = &This->lpVtbl;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static DWORD CALLBACK copyProgressCallback(LARGE_INTEGER totalSize,
|
||||
LARGE_INTEGER totalTransferred,
|
||||
LARGE_INTEGER streamSize,
|
||||
LARGE_INTEGER streamTransferred,
|
||||
DWORD streamNum,
|
||||
DWORD reason,
|
||||
HANDLE srcFile,
|
||||
HANDLE dstFile,
|
||||
LPVOID obj)
|
||||
{
|
||||
BackgroundCopyFileImpl *file = obj;
|
||||
BackgroundCopyJobImpl *job = file->owner;
|
||||
ULONG64 diff;
|
||||
|
||||
EnterCriticalSection(&job->cs);
|
||||
diff = (file->fileProgress.BytesTotal == BG_SIZE_UNKNOWN
|
||||
? totalTransferred.QuadPart
|
||||
: totalTransferred.QuadPart - file->fileProgress.BytesTransferred);
|
||||
file->fileProgress.BytesTotal = totalSize.QuadPart;
|
||||
file->fileProgress.BytesTransferred = totalTransferred.QuadPart;
|
||||
job->jobProgress.BytesTransferred += diff;
|
||||
LeaveCriticalSection(&job->cs);
|
||||
|
||||
return (job->state == BG_JOB_STATE_TRANSFERRING
|
||||
? PROGRESS_CONTINUE
|
||||
: PROGRESS_CANCEL);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const IBindStatusCallbackVtbl *lpVtbl;
|
||||
BackgroundCopyFileImpl *file;
|
||||
LONG ref;
|
||||
} DLBindStatusCallback;
|
||||
|
||||
static ULONG WINAPI DLBindStatusCallback_AddRef(IBindStatusCallback *iface)
|
||||
{
|
||||
DLBindStatusCallback *This = (DLBindStatusCallback *) iface;
|
||||
return InterlockedIncrement(&This->ref);
|
||||
}
|
||||
|
||||
static ULONG WINAPI DLBindStatusCallback_Release(IBindStatusCallback *iface)
|
||||
{
|
||||
DLBindStatusCallback *This = (DLBindStatusCallback *) iface;
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
if (ref == 0)
|
||||
{
|
||||
IBackgroundCopyFile_Release((IBackgroundCopyFile *) This->file);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DLBindStatusCallback_QueryInterface(
|
||||
IBindStatusCallback *iface,
|
||||
REFIID riid,
|
||||
void **ppvObject)
|
||||
{
|
||||
DLBindStatusCallback *This = (DLBindStatusCallback *) iface;
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown)
|
||||
|| IsEqualGUID(riid, &IID_IBindStatusCallback))
|
||||
{
|
||||
*ppvObject = &This->lpVtbl;
|
||||
DLBindStatusCallback_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DLBindStatusCallback_GetBindInfo(
|
||||
IBindStatusCallback *iface,
|
||||
DWORD *grfBINDF,
|
||||
BINDINFO *pbindinfo)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DLBindStatusCallback_GetPriority(
|
||||
IBindStatusCallback *iface,
|
||||
LONG *pnPriority)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DLBindStatusCallback_OnDataAvailable(
|
||||
IBindStatusCallback *iface,
|
||||
DWORD grfBSCF,
|
||||
DWORD dwSize,
|
||||
FORMATETC *pformatetc,
|
||||
STGMEDIUM *pstgmed)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DLBindStatusCallback_OnLowResource(
|
||||
IBindStatusCallback *iface,
|
||||
DWORD reserved)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DLBindStatusCallback_OnObjectAvailable(
|
||||
IBindStatusCallback *iface,
|
||||
REFIID riid,
|
||||
IUnknown *punk)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DLBindStatusCallback_OnProgress(
|
||||
IBindStatusCallback *iface,
|
||||
ULONG progress,
|
||||
ULONG progressMax,
|
||||
ULONG statusCode,
|
||||
LPCWSTR statusText)
|
||||
{
|
||||
DLBindStatusCallback *This = (DLBindStatusCallback *) iface;
|
||||
BackgroundCopyFileImpl *file = This->file;
|
||||
BackgroundCopyJobImpl *job = file->owner;
|
||||
ULONG64 diff;
|
||||
|
||||
EnterCriticalSection(&job->cs);
|
||||
diff = (file->fileProgress.BytesTotal == BG_SIZE_UNKNOWN
|
||||
? progress
|
||||
: progress - file->fileProgress.BytesTransferred);
|
||||
file->fileProgress.BytesTotal = progressMax ? progressMax : BG_SIZE_UNKNOWN;
|
||||
file->fileProgress.BytesTransferred = progress;
|
||||
job->jobProgress.BytesTransferred += diff;
|
||||
LeaveCriticalSection(&job->cs);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DLBindStatusCallback_OnStartBinding(
|
||||
IBindStatusCallback *iface,
|
||||
DWORD dwReserved,
|
||||
IBinding *pib)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DLBindStatusCallback_OnStopBinding(
|
||||
IBindStatusCallback *iface,
|
||||
HRESULT hresult,
|
||||
LPCWSTR szError)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static const IBindStatusCallbackVtbl DLBindStatusCallback_Vtbl =
|
||||
{
|
||||
DLBindStatusCallback_QueryInterface,
|
||||
DLBindStatusCallback_AddRef,
|
||||
DLBindStatusCallback_Release,
|
||||
DLBindStatusCallback_OnStartBinding,
|
||||
DLBindStatusCallback_GetPriority,
|
||||
DLBindStatusCallback_OnLowResource,
|
||||
DLBindStatusCallback_OnProgress,
|
||||
DLBindStatusCallback_OnStopBinding,
|
||||
DLBindStatusCallback_GetBindInfo,
|
||||
DLBindStatusCallback_OnDataAvailable,
|
||||
DLBindStatusCallback_OnObjectAvailable
|
||||
};
|
||||
|
||||
static DLBindStatusCallback *DLBindStatusCallbackConstructor(
|
||||
BackgroundCopyFileImpl *file)
|
||||
{
|
||||
DLBindStatusCallback *This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
|
||||
if (!This)
|
||||
return NULL;
|
||||
|
||||
This->lpVtbl = &DLBindStatusCallback_Vtbl;
|
||||
IBackgroundCopyFile_AddRef((IBackgroundCopyFile *) file);
|
||||
This->file = file;
|
||||
This->ref = 1;
|
||||
return This;
|
||||
}
|
||||
|
||||
BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job)
|
||||
{
|
||||
static const WCHAR prefix[] = {'B','I','T', 0};
|
||||
IBindStatusCallback *callbackObj;
|
||||
WCHAR tmpDir[MAX_PATH];
|
||||
WCHAR tmpName[MAX_PATH];
|
||||
HRESULT hr;
|
||||
|
||||
if (!GetTempPathW(MAX_PATH, tmpDir))
|
||||
{
|
||||
ERR("Couldn't create temp file name: %d\n", GetLastError());
|
||||
/* Guessing on what state this should give us */
|
||||
transitionJobState(job, BG_JOB_STATE_QUEUED, BG_JOB_STATE_TRANSIENT_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!GetTempFileNameW(tmpDir, prefix, 0, tmpName))
|
||||
{
|
||||
ERR("Couldn't create temp file: %d\n", GetLastError());
|
||||
/* Guessing on what state this should give us */
|
||||
transitionJobState(job, BG_JOB_STATE_QUEUED, BG_JOB_STATE_TRANSIENT_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
callbackObj = (IBindStatusCallback *) DLBindStatusCallbackConstructor(file);
|
||||
if (!callbackObj)
|
||||
{
|
||||
ERR("Out of memory\n");
|
||||
transitionJobState(job, BG_JOB_STATE_QUEUED, BG_JOB_STATE_TRANSIENT_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&job->cs);
|
||||
file->fileProgress.BytesTotal = BG_SIZE_UNKNOWN;
|
||||
file->fileProgress.BytesTransferred = 0;
|
||||
file->fileProgress.Completed = FALSE;
|
||||
LeaveCriticalSection(&job->cs);
|
||||
|
||||
TRACE("Transferring: %s -> %s -> %s\n",
|
||||
debugstr_w(file->info.RemoteName),
|
||||
debugstr_w(tmpName),
|
||||
debugstr_w(file->info.LocalName));
|
||||
|
||||
transitionJobState(job, BG_JOB_STATE_QUEUED, BG_JOB_STATE_TRANSFERRING);
|
||||
|
||||
DeleteUrlCacheEntryW(file->info.RemoteName);
|
||||
hr = URLDownloadToFileW(NULL, file->info.RemoteName, tmpName, 0, callbackObj);
|
||||
IBindStatusCallback_Release(callbackObj);
|
||||
if (hr == INET_E_DOWNLOAD_FAILURE)
|
||||
{
|
||||
TRACE("URLDownload failed, trying local file copy\n");
|
||||
if (!CopyFileExW(file->info.RemoteName, tmpName, copyProgressCallback,
|
||||
file, NULL, 0))
|
||||
{
|
||||
ERR("Local file copy failed: error %d\n", GetLastError());
|
||||
transitionJobState(job, BG_JOB_STATE_TRANSFERRING, BG_JOB_STATE_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if (FAILED(hr))
|
||||
{
|
||||
ERR("URLDownload failed: eh 0x%08x\n", hr);
|
||||
transitionJobState(job, BG_JOB_STATE_TRANSFERRING, BG_JOB_STATE_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (transitionJobState(job, BG_JOB_STATE_TRANSFERRING, BG_JOB_STATE_QUEUED))
|
||||
{
|
||||
lstrcpyW(file->tempFileName, tmpName);
|
||||
|
||||
EnterCriticalSection(&job->cs);
|
||||
file->fileProgress.Completed = TRUE;
|
||||
job->jobProgress.FilesTransferred++;
|
||||
LeaveCriticalSection(&job->cs);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteFileW(tmpName);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
639
reactos/dll/win32/qmgr/job.c
Normal file
639
reactos/dll/win32/qmgr/job.c
Normal file
|
@ -0,0 +1,639 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
#include "qmgr.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
||||
|
||||
static void BackgroundCopyJobDestructor(BackgroundCopyJobImpl *This)
|
||||
{
|
||||
DeleteCriticalSection(&This->cs);
|
||||
HeapFree(GetProcessHeap(), 0, This->displayName);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
static ULONG WINAPI BITS_IBackgroundCopyJob_AddRef(IBackgroundCopyJob2 *iface)
|
||||
{
|
||||
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
||||
return InterlockedIncrement(&This->ref);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_QueryInterface(
|
||||
IBackgroundCopyJob2 *iface, REFIID riid, LPVOID *ppvObject)
|
||||
{
|
||||
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
||||
TRACE("IID: %s\n", debugstr_guid(riid));
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown)
|
||||
|| IsEqualGUID(riid, &IID_IBackgroundCopyJob)
|
||||
|| IsEqualGUID(riid, &IID_IBackgroundCopyJob2))
|
||||
{
|
||||
*ppvObject = &This->lpVtbl;
|
||||
BITS_IBackgroundCopyJob_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI BITS_IBackgroundCopyJob_Release(IBackgroundCopyJob2 *iface)
|
||||
{
|
||||
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
if (ref == 0)
|
||||
BackgroundCopyJobDestructor(This);
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
/*** IBackgroundCopyJob methods ***/
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFileSet(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
ULONG cFileCount,
|
||||
BG_FILE_INFO *pFileSet)
|
||||
{
|
||||
ULONG i;
|
||||
for (i = 0; i < cFileCount; ++i)
|
||||
{
|
||||
HRESULT hr = IBackgroundCopyJob_AddFile(iface, pFileSet[i].RemoteName,
|
||||
pFileSet[i].LocalName);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
LPCWSTR RemoteUrl,
|
||||
LPCWSTR LocalName)
|
||||
{
|
||||
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");
|
||||
|
||||
res = BackgroundCopyFileConstructor(This, RemoteUrl, LocalName, (LPVOID *) &pFile);
|
||||
if (res != S_OK)
|
||||
return res;
|
||||
|
||||
/* Add a reference to the file to file list */
|
||||
IBackgroundCopyFile_AddRef(pFile);
|
||||
file = (BackgroundCopyFileImpl *) pFile;
|
||||
EnterCriticalSection(&This->cs);
|
||||
list_add_head(&This->files, &file->entryFromJob);
|
||||
This->jobProgress.BytesTotal = BG_SIZE_UNKNOWN;
|
||||
++This->jobProgress.FilesTotal;
|
||||
LeaveCriticalSection(&This->cs);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_EnumFiles(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
IEnumBackgroundCopyFiles **ppEnum)
|
||||
{
|
||||
TRACE("\n");
|
||||
return EnumBackgroundCopyFilesConstructor((LPVOID *) ppEnum, iface);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_Suspend(
|
||||
IBackgroundCopyJob2 *iface)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_Resume(
|
||||
IBackgroundCopyJob2 *iface)
|
||||
{
|
||||
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
||||
HRESULT rv = S_OK;
|
||||
|
||||
EnterCriticalSection(&globalMgr.cs);
|
||||
if (This->state == BG_JOB_STATE_CANCELLED
|
||||
|| This->state == BG_JOB_STATE_ACKNOWLEDGED)
|
||||
{
|
||||
rv = BG_E_INVALID_STATE;
|
||||
}
|
||||
else if (This->jobProgress.FilesTransferred == This->jobProgress.FilesTotal)
|
||||
{
|
||||
rv = BG_E_EMPTY;
|
||||
}
|
||||
else if (This->state != BG_JOB_STATE_CONNECTING
|
||||
&& This->state != BG_JOB_STATE_TRANSFERRING)
|
||||
{
|
||||
This->state = BG_JOB_STATE_QUEUED;
|
||||
SetEvent(globalMgr.jobEvent);
|
||||
}
|
||||
LeaveCriticalSection(&globalMgr.cs);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_Cancel(
|
||||
IBackgroundCopyJob2 *iface)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_Complete(
|
||||
IBackgroundCopyJob2 *iface)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetId(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
GUID *pVal)
|
||||
{
|
||||
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
||||
*pVal = This->jobId;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetType(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
BG_JOB_TYPE *pVal)
|
||||
{
|
||||
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
||||
|
||||
if (!pVal)
|
||||
return E_INVALIDARG;
|
||||
|
||||
*pVal = This->type;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProgress(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
BG_JOB_PROGRESS *pVal)
|
||||
{
|
||||
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
||||
|
||||
if (!pVal)
|
||||
return E_INVALIDARG;
|
||||
|
||||
EnterCriticalSection(&This->cs);
|
||||
pVal->BytesTotal = This->jobProgress.BytesTotal;
|
||||
pVal->BytesTransferred = This->jobProgress.BytesTransferred;
|
||||
pVal->FilesTotal = This->jobProgress.FilesTotal;
|
||||
pVal->FilesTransferred = This->jobProgress.FilesTransferred;
|
||||
LeaveCriticalSection(&This->cs);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetTimes(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
BG_JOB_TIMES *pVal)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetState(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
BG_JOB_STATE *pVal)
|
||||
{
|
||||
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
||||
|
||||
if (!pVal)
|
||||
return E_INVALIDARG;
|
||||
|
||||
/* Don't think we need a critical section for this */
|
||||
*pVal = This->state;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetError(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
IBackgroundCopyError **ppError)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetOwner(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
LPWSTR *pVal)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDisplayName(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
LPCWSTR Val)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDisplayName(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
LPWSTR *pVal)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDescription(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
LPCWSTR Val)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDescription(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
LPWSTR *pVal)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetPriority(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
BG_JOB_PRIORITY Val)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetPriority(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
BG_JOB_PRIORITY *pVal)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyFlags(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
ULONG Val)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyFlags(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
ULONG *pVal)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyInterface(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
IUnknown *Val)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyInterface(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
IUnknown **pVal)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetMinimumRetryDelay(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
ULONG Seconds)
|
||||
{
|
||||
FIXME("%u\n", Seconds);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetMinimumRetryDelay(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
ULONG *Seconds)
|
||||
{
|
||||
FIXME("%p\n", Seconds);
|
||||
*Seconds = 30;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNoProgressTimeout(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
ULONG Seconds)
|
||||
{
|
||||
FIXME("%u\n", Seconds);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNoProgressTimeout(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
ULONG *Seconds)
|
||||
{
|
||||
FIXME("%p\n", Seconds);
|
||||
*Seconds = 900;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetErrorCount(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
ULONG *Errors)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_SetProxySettings(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
BG_JOB_PROXY_USAGE ProxyUsage,
|
||||
const WCHAR *ProxyList,
|
||||
const WCHAR *ProxyBypassList)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProxySettings(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
BG_JOB_PROXY_USAGE *pProxyUsage,
|
||||
LPWSTR *pProxyList,
|
||||
LPWSTR *pProxyBypassList)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_TakeOwnership(
|
||||
IBackgroundCopyJob2 *iface)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
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,
|
||||
LPWSTR *prog,
|
||||
LPWSTR *params)
|
||||
{
|
||||
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");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_RemoveCredentials(
|
||||
IBackgroundCopyJob2 *iface,
|
||||
BG_AUTH_TARGET target,
|
||||
BG_AUTH_SCHEME scheme)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const IBackgroundCopyJob2Vtbl BITS_IBackgroundCopyJob_Vtbl =
|
||||
{
|
||||
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,
|
||||
BITS_IBackgroundCopyJob_SetNotifyCmdLine,
|
||||
BITS_IBackgroundCopyJob_GetNotifyCmdLine,
|
||||
BITS_IBackgroundCopyJob_GetReplyProgress,
|
||||
BITS_IBackgroundCopyJob_GetReplyData,
|
||||
BITS_IBackgroundCopyJob_SetReplyFileName,
|
||||
BITS_IBackgroundCopyJob_GetReplyFileName,
|
||||
BITS_IBackgroundCopyJob_SetCredentials,
|
||||
BITS_IBackgroundCopyJob_RemoveCredentials
|
||||
};
|
||||
|
||||
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;
|
||||
InitializeCriticalSection(&This->cs);
|
||||
This->ref = 1;
|
||||
This->type = type;
|
||||
|
||||
n = (lstrlenW(displayName) + 1) * sizeof *displayName;
|
||||
This->displayName = HeapAlloc(GetProcessHeap(), 0, n);
|
||||
if (!This->displayName)
|
||||
{
|
||||
DeleteCriticalSection(&This->cs);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
memcpy(This->displayName, displayName, n);
|
||||
|
||||
hr = CoCreateGuid(&This->jobId);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
DeleteCriticalSection(&This->cs);
|
||||
HeapFree(GetProcessHeap(), 0, This->displayName);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
return hr;
|
||||
}
|
||||
*pJobId = This->jobId;
|
||||
|
||||
list_init(&This->files);
|
||||
This->jobProgress.BytesTotal = 0;
|
||||
This->jobProgress.BytesTransferred = 0;
|
||||
This->jobProgress.FilesTotal = 0;
|
||||
This->jobProgress.FilesTransferred = 0;
|
||||
|
||||
This->state = BG_JOB_STATE_SUSPENDED;
|
||||
|
||||
*ppObj = &This->lpVtbl;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
194
reactos/dll/win32/qmgr/qmgr.c
Normal file
194
reactos/dll/win32/qmgr/qmgr.c
Normal file
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
* Queue Manager (BITS) core functions
|
||||
*
|
||||
* Copyright 2007, 2008 Google (Roy Shea, Dan Hipschman)
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "qmgr.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
||||
|
||||
/* Add a reference to the iface pointer */
|
||||
static ULONG WINAPI BITS_IBackgroundCopyManager_AddRef(
|
||||
IBackgroundCopyManager* iface)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Attempt to provide a new interface to interact with iface */
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyManager_QueryInterface(
|
||||
IBackgroundCopyManager* iface,
|
||||
REFIID riid,
|
||||
LPVOID *ppvObject)
|
||||
{
|
||||
BackgroundCopyManagerImpl * This = (BackgroundCopyManagerImpl *)iface;
|
||||
|
||||
TRACE("IID: %s\n", debugstr_guid(riid));
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
||||
IsEqualGUID(riid, &IID_IBackgroundCopyManager))
|
||||
{
|
||||
*ppvObject = &This->lpVtbl;
|
||||
BITS_IBackgroundCopyManager_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
/* Release an interface to iface */
|
||||
static ULONG WINAPI BITS_IBackgroundCopyManager_Release(
|
||||
IBackgroundCopyManager* iface)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*** IBackgroundCopyManager interface methods ***/
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyManager_CreateJob(
|
||||
IBackgroundCopyManager* iface,
|
||||
LPCWSTR DisplayName,
|
||||
BG_JOB_TYPE Type,
|
||||
GUID *pJobId,
|
||||
IBackgroundCopyJob **ppJob)
|
||||
{
|
||||
BackgroundCopyManagerImpl * This = (BackgroundCopyManagerImpl *) iface;
|
||||
BackgroundCopyJobImpl *job;
|
||||
HRESULT hres;
|
||||
TRACE("\n");
|
||||
|
||||
hres = BackgroundCopyJobConstructor(DisplayName, Type, pJobId,
|
||||
(LPVOID *) ppJob);
|
||||
if (FAILED(hres))
|
||||
return hres;
|
||||
|
||||
/* Add a reference to the job to job list */
|
||||
IBackgroundCopyJob_AddRef(*ppJob);
|
||||
job = (BackgroundCopyJobImpl *) *ppJob;
|
||||
EnterCriticalSection(&This->cs);
|
||||
list_add_head(&This->jobs, &job->entryFromQmgr);
|
||||
LeaveCriticalSection(&This->cs);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyManager_GetJob(
|
||||
IBackgroundCopyManager* iface,
|
||||
REFGUID jobID,
|
||||
IBackgroundCopyJob **ppJob)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyManager_EnumJobs(
|
||||
IBackgroundCopyManager* iface,
|
||||
DWORD dwFlags,
|
||||
IEnumBackgroundCopyJobs **ppEnum)
|
||||
{
|
||||
TRACE("\n");
|
||||
return EnumBackgroundCopyJobsConstructor((LPVOID *) ppEnum, iface);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyManager_GetErrorDescription(
|
||||
IBackgroundCopyManager* iface,
|
||||
HRESULT hResult,
|
||||
DWORD LanguageId,
|
||||
LPWSTR *pErrorDescription)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
static const IBackgroundCopyManagerVtbl BITS_IBackgroundCopyManager_Vtbl =
|
||||
{
|
||||
BITS_IBackgroundCopyManager_QueryInterface,
|
||||
BITS_IBackgroundCopyManager_AddRef,
|
||||
BITS_IBackgroundCopyManager_Release,
|
||||
BITS_IBackgroundCopyManager_CreateJob,
|
||||
BITS_IBackgroundCopyManager_GetJob,
|
||||
BITS_IBackgroundCopyManager_EnumJobs,
|
||||
BITS_IBackgroundCopyManager_GetErrorDescription
|
||||
};
|
||||
|
||||
BackgroundCopyManagerImpl globalMgr = {
|
||||
&BITS_IBackgroundCopyManager_Vtbl,
|
||||
{ NULL, -1, 0, 0, 0, 0 },
|
||||
NULL,
|
||||
LIST_INIT(globalMgr.jobs)
|
||||
};
|
||||
|
||||
/* Constructor for instances of background copy manager */
|
||||
HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj)
|
||||
{
|
||||
TRACE("(%p,%p)\n", pUnkOuter, ppObj);
|
||||
*ppObj = &globalMgr;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
DWORD WINAPI fileTransfer(void *param)
|
||||
{
|
||||
BackgroundCopyManagerImpl *qmgr = &globalMgr;
|
||||
HANDLE events[2];
|
||||
|
||||
events[0] = stop_event;
|
||||
events[1] = qmgr->jobEvent;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
BackgroundCopyJobImpl *job, *jobCur;
|
||||
BOOL haveJob = FALSE;
|
||||
|
||||
/* Check if it's the stop_event */
|
||||
if (WaitForMultipleObjects(2, events, FALSE, INFINITE) == WAIT_OBJECT_0)
|
||||
return 0;
|
||||
|
||||
/* Note that other threads may add files to the job list, but only
|
||||
this thread ever deletes them so we don't need to worry about jobs
|
||||
magically disappearing from the list. */
|
||||
EnterCriticalSection(&qmgr->cs);
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(job, jobCur, &qmgr->jobs, BackgroundCopyJobImpl, entryFromQmgr)
|
||||
{
|
||||
if (job->state == BG_JOB_STATE_ACKNOWLEDGED || job->state == BG_JOB_STATE_CANCELLED)
|
||||
{
|
||||
list_remove(&job->entryFromQmgr);
|
||||
IBackgroundCopyJob_Release((IBackgroundCopyJob *) job);
|
||||
}
|
||||
else if (job->state == BG_JOB_STATE_QUEUED)
|
||||
{
|
||||
haveJob = TRUE;
|
||||
break;
|
||||
}
|
||||
else if (job->state == BG_JOB_STATE_CONNECTING
|
||||
|| job->state == BG_JOB_STATE_TRANSFERRING)
|
||||
{
|
||||
ERR("Invalid state for job %p: %d\n", job, job->state);
|
||||
}
|
||||
}
|
||||
|
||||
if (!haveJob)
|
||||
ResetEvent(qmgr->jobEvent);
|
||||
|
||||
LeaveCriticalSection(&qmgr->cs);
|
||||
|
||||
if (haveJob)
|
||||
processJob(job);
|
||||
}
|
||||
}
|
138
reactos/dll/win32/qmgr/qmgr.h
Normal file
138
reactos/dll/win32/qmgr/qmgr.h
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Queue Manager definitions
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef __QMGR_H__
|
||||
#define __QMGR_H__
|
||||
|
||||
#include "windef.h"
|
||||
#include "objbase.h"
|
||||
|
||||
#define COBJMACROS
|
||||
#include "bits1_5.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "wine/list.h"
|
||||
|
||||
/* Background copy job vtbl and related data */
|
||||
typedef struct
|
||||
{
|
||||
const IBackgroundCopyJob2Vtbl *lpVtbl;
|
||||
LONG ref;
|
||||
LPWSTR displayName;
|
||||
BG_JOB_TYPE type;
|
||||
GUID jobId;
|
||||
struct list files;
|
||||
BG_JOB_PROGRESS jobProgress;
|
||||
BG_JOB_STATE state;
|
||||
/* Protects file list, and progress */
|
||||
CRITICAL_SECTION cs;
|
||||
struct list entryFromQmgr;
|
||||
} BackgroundCopyJobImpl;
|
||||
|
||||
/* Enum background copy jobs vtbl and related data */
|
||||
typedef struct
|
||||
{
|
||||
const IEnumBackgroundCopyJobsVtbl *lpVtbl;
|
||||
LONG ref;
|
||||
IBackgroundCopyJob **jobs;
|
||||
ULONG numJobs;
|
||||
ULONG indexJobs;
|
||||
} EnumBackgroundCopyJobsImpl;
|
||||
|
||||
/* Enum background copy files vtbl and related data */
|
||||
typedef struct
|
||||
{
|
||||
const IEnumBackgroundCopyFilesVtbl *lpVtbl;
|
||||
LONG ref;
|
||||
IBackgroundCopyFile **files;
|
||||
ULONG numFiles;
|
||||
ULONG indexFiles;
|
||||
} EnumBackgroundCopyFilesImpl;
|
||||
|
||||
/* Background copy file vtbl and related data */
|
||||
typedef struct
|
||||
{
|
||||
const IBackgroundCopyFileVtbl *lpVtbl;
|
||||
LONG ref;
|
||||
BG_FILE_INFO info;
|
||||
BG_FILE_PROGRESS fileProgress;
|
||||
WCHAR tempFileName[MAX_PATH];
|
||||
struct list entryFromJob;
|
||||
BackgroundCopyJobImpl *owner;
|
||||
} BackgroundCopyFileImpl;
|
||||
|
||||
/* Background copy manager vtbl and related data */
|
||||
typedef struct
|
||||
{
|
||||
const IBackgroundCopyManagerVtbl *lpVtbl;
|
||||
/* Protects job list, job states, and jobEvent */
|
||||
CRITICAL_SECTION cs;
|
||||
HANDLE jobEvent;
|
||||
struct list jobs;
|
||||
} BackgroundCopyManagerImpl;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const IClassFactoryVtbl *lpVtbl;
|
||||
} ClassFactoryImpl;
|
||||
|
||||
extern HANDLE stop_event;
|
||||
extern ClassFactoryImpl BITS_ClassFactory;
|
||||
extern BackgroundCopyManagerImpl globalMgr;
|
||||
|
||||
HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj);
|
||||
HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
|
||||
GUID *pJobId, LPVOID *ppObj);
|
||||
HRESULT EnumBackgroundCopyJobsConstructor(LPVOID *ppObj,
|
||||
IBackgroundCopyManager* copyManager);
|
||||
HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
|
||||
LPCWSTR remoteName, LPCWSTR localName,
|
||||
LPVOID *ppObj);
|
||||
HRESULT EnumBackgroundCopyFilesConstructor(LPVOID *ppObj,
|
||||
IBackgroundCopyJob2 *copyJob);
|
||||
DWORD WINAPI fileTransfer(void *param);
|
||||
void processJob(BackgroundCopyJobImpl *job);
|
||||
BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job);
|
||||
|
||||
/* Little helper functions */
|
||||
static inline char *
|
||||
qmgr_strdup(const char *s)
|
||||
{
|
||||
size_t n = strlen(s) + 1;
|
||||
char *d = HeapAlloc(GetProcessHeap(), 0, n);
|
||||
return d ? memcpy(d, s, n) : NULL;
|
||||
}
|
||||
|
||||
static inline BOOL
|
||||
transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE fromState,
|
||||
BG_JOB_STATE toState)
|
||||
{
|
||||
BOOL rv = FALSE;
|
||||
EnterCriticalSection(&globalMgr.cs);
|
||||
if (job->state == fromState)
|
||||
{
|
||||
job->state = toState;
|
||||
rv = TRUE;
|
||||
}
|
||||
LeaveCriticalSection(&globalMgr.cs);
|
||||
return rv;
|
||||
}
|
||||
|
||||
#endif /* __QMGR_H__ */
|
16
reactos/dll/win32/qmgr/qmgr.inf
Normal file
16
reactos/dll/win32/qmgr/qmgr.inf
Normal file
|
@ -0,0 +1,16 @@
|
|||
[version]
|
||||
Signature="$CHICAGO$"
|
||||
|
||||
[RegisterDll]
|
||||
AddReg = Qmgr.Reg
|
||||
|
||||
[UnregisterDll]
|
||||
DelReg = Qmgr.Reg
|
||||
|
||||
[Qmgr.Reg]
|
||||
HKCR,"AppID\BITS","AppID",,"%CLSID_BackgroundCopyQMgr%"
|
||||
HKCR,"AppID\%CLSID_BackgroundCopyQMgr%","LocalService",,"BITS"
|
||||
HKCR,"CLSID\%CLSID_BackgroundCopyManager%","AppID",,"%CLSID_BackgroundCopyQMgr%"
|
||||
|
||||
HKLM,"Software\Microsoft\Windows NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"BITS"
|
||||
HKLM,"System\CurrentControlSet\Services\BITS\Parameters","ServiceDll",0x00020000,"qmgr.dll"
|
31
reactos/dll/win32/qmgr/qmgr.rbuild
Normal file
31
reactos/dll/win32/qmgr/qmgr.rbuild
Normal file
|
@ -0,0 +1,31 @@
|
|||
<group>
|
||||
<module name="qmgr" type="win32dll" baseaddress="${BASEADDRESS_QMGR}" installbase="system32" installname="qmgr.dll" allowwarnings="true">
|
||||
<autoregister infsection="OleControlDlls" type="DllRegisterServer" />
|
||||
<importlibrary definition="qmgr.spec" />
|
||||
<include base="qmgr">.</include>
|
||||
<include base="qmgr" root="intermediate">.</include>
|
||||
<include base="ReactOS">include/reactos/wine</include>
|
||||
<define name="__WINESRC__" />
|
||||
<dependency>qmgr_local_header</dependency>
|
||||
<library>wine</library>
|
||||
<library>uuid</library>
|
||||
<library>wininet</library>
|
||||
<library>urlmon</library>
|
||||
<library>ole32</library>
|
||||
<library>advapi32</library>
|
||||
<library>kernel32</library>
|
||||
<library>ntdll</library>
|
||||
<file>enum_files.c</file>
|
||||
<file>enum_jobs.c</file>
|
||||
<file>factory.c</file>
|
||||
<file>file.c</file>
|
||||
<file>job.c</file>
|
||||
<file>qmgr.c</file>
|
||||
<file>qmgr_main.c</file>
|
||||
<file>service.c</file>
|
||||
<file>rsrc.rc</file>
|
||||
</module>
|
||||
<module name="qmgr_local_header" type="idlheader">
|
||||
<file>qmgr_local.idl</file>
|
||||
</module>
|
||||
</group>
|
3
reactos/dll/win32/qmgr/qmgr.spec
Normal file
3
reactos/dll/win32/qmgr/qmgr.spec
Normal file
|
@ -0,0 +1,3 @@
|
|||
@ stdcall -private DllRegisterServer()
|
||||
@ stdcall -private DllUnregisterServer()
|
||||
@ stdcall -private ServiceMain(long ptr)
|
22
reactos/dll/win32/qmgr/qmgr_local.idl
Normal file
22
reactos/dll/win32/qmgr/qmgr_local.idl
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2007, 2008 Google (Roy Shea, Dan Hipschman)
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "bits.idl"
|
||||
|
||||
#define DO_NO_IMPORTS
|
||||
#include "bits1_5.idl"
|
179
reactos/dll/win32/qmgr/qmgr_main.c
Normal file
179
reactos/dll/win32/qmgr/qmgr_main.c
Normal file
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* Main DLL interface to Queue Manager (BITS)
|
||||
*
|
||||
* Background Intelligent Transfer Service (BITS) interface. Dll is named
|
||||
* qmgr for backwards compatibility with early versions of 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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "objbase.h"
|
||||
#include "winuser.h"
|
||||
#include "winreg.h"
|
||||
#include "advpub.h"
|
||||
#include "olectl.h"
|
||||
#include "winsvc.h"
|
||||
|
||||
#include "bits.h"
|
||||
#include "qmgr.h"
|
||||
#include "initguid.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
||||
|
||||
/* Handle to the base address of this DLL */
|
||||
static HINSTANCE hInst;
|
||||
|
||||
/* Other GUIDs used by this module */
|
||||
DEFINE_GUID(CLSID_BackgroundCopyQMgr, 0x69AD4AEE, 0x51BE, 0x439b, 0xA9,0x2C, 0x86,0xAE,0x49,0x0E,0x8B,0x30);
|
||||
|
||||
/* Entry point for DLL */
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
|
||||
|
||||
switch (fdwReason)
|
||||
{
|
||||
case DLL_WINE_PREATTACH:
|
||||
return FALSE; /* prefer native version */
|
||||
case DLL_PROCESS_ATTACH:
|
||||
DisableThreadLibraryCalls(hinstDLL);
|
||||
hInst = hinstDLL;
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static HRESULT init_register_strtable(STRTABLEA *strtable)
|
||||
{
|
||||
#define CLSID_EXPANSION_ENTRY(id) { "CLSID_" #id, &CLSID_ ## id }
|
||||
static const struct {
|
||||
const char *name;
|
||||
const CLSID *clsid;
|
||||
} expns[] = {
|
||||
CLSID_EXPANSION_ENTRY(BackgroundCopyQMgr),
|
||||
CLSID_EXPANSION_ENTRY(BackgroundCopyManager)
|
||||
};
|
||||
#undef CLSID_EXPANSION_ENTRY
|
||||
static STRENTRYA pse[sizeof expns / sizeof expns[0]];
|
||||
DWORD i;
|
||||
|
||||
strtable->cEntries = sizeof pse / sizeof pse[0];
|
||||
strtable->pse = pse;
|
||||
for (i = 0; i < strtable->cEntries; i++) {
|
||||
static const char dummy_sample[] = "{12345678-1234-1234-1234-123456789012}";
|
||||
const CLSID *clsid = expns[i].clsid;
|
||||
pse[i].pszName = qmgr_strdup(expns[i].name);
|
||||
pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, sizeof dummy_sample);
|
||||
if (!pse[i].pszName || !pse[i].pszValue)
|
||||
return E_OUTOFMEMORY;
|
||||
sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
||||
clsid->Data1, clsid->Data2, clsid->Data3, clsid->Data4[0],
|
||||
clsid->Data4[1], clsid->Data4[2], clsid->Data4[3], clsid->Data4[4],
|
||||
clsid->Data4[5], clsid->Data4[6], clsid->Data4[7]);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void cleanup_register_strtable(STRTABLEA *strtable)
|
||||
{
|
||||
DWORD i;
|
||||
for (i = 0; i < strtable->cEntries; i++) {
|
||||
HeapFree(GetProcessHeap(), 0, strtable->pse[i].pszName);
|
||||
HeapFree(GetProcessHeap(), 0, strtable->pse[i].pszValue);
|
||||
if (!strtable->pse[i].pszName || !strtable->pse[i].pszValue)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static HRESULT register_service(BOOL do_register)
|
||||
{
|
||||
static const WCHAR name[] = { 'B','I','T','S', 0 };
|
||||
static const WCHAR path[] = { 's','v','c','h','o','s','t','.','e','x','e',
|
||||
' ','-','k',' ','n','e','t','s','v','c','s', 0 };
|
||||
SC_HANDLE scm, service;
|
||||
|
||||
scm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||
if (!scm)
|
||||
return SELFREG_E_CLASS;
|
||||
|
||||
if (do_register)
|
||||
service = CreateServiceW(scm, name, name, SERVICE_ALL_ACCESS,
|
||||
SERVICE_WIN32_OWN_PROCESS,
|
||||
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
|
||||
path, NULL, NULL, NULL, NULL, NULL);
|
||||
else
|
||||
service = OpenServiceW(scm, name, DELETE);
|
||||
|
||||
|
||||
CloseServiceHandle(scm);
|
||||
if (service)
|
||||
{
|
||||
if (!do_register) DeleteService(service);
|
||||
CloseServiceHandle(service);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* Use an INF file to register or unregister the DLL */
|
||||
static HRESULT register_server(BOOL do_register)
|
||||
{
|
||||
HRESULT hr;
|
||||
STRTABLEA strtable;
|
||||
HMODULE hAdvpack;
|
||||
HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
|
||||
static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
|
||||
|
||||
TRACE("(%x)\n", do_register);
|
||||
|
||||
hr = register_service(do_register);
|
||||
if (FAILED(hr)) {
|
||||
ERR("register_service failed: %d\n", GetLastError());
|
||||
return hr;
|
||||
}
|
||||
|
||||
hAdvpack = LoadLibraryW(wszAdvpack);
|
||||
pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
|
||||
|
||||
hr = init_register_strtable(&strtable);
|
||||
if (SUCCEEDED(hr))
|
||||
hr = pRegInstall(hInst, do_register ? "RegisterDll" : "UnregisterDll",
|
||||
&strtable);
|
||||
cleanup_register_strtable(&strtable);
|
||||
|
||||
if (FAILED(hr))
|
||||
ERR("RegInstall failed: %08x\n", hr);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT WINAPI DllRegisterServer(void)
|
||||
{
|
||||
return register_server(TRUE);
|
||||
}
|
||||
|
||||
HRESULT WINAPI DllUnregisterServer(void)
|
||||
{
|
||||
return register_server(FALSE);
|
||||
}
|
20
reactos/dll/win32/qmgr/rsrc.rc
Normal file
20
reactos/dll/win32/qmgr/rsrc.rc
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* @makedep: qmgr.inf */
|
||||
REGINST REGINST qmgr.inf
|
156
reactos/dll/win32/qmgr/service.c
Normal file
156
reactos/dll/win32/qmgr/service.c
Normal file
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* ServiceMain function for qmgr running within svchost
|
||||
*
|
||||
* Copyright 2007 (C) 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
|
||||
*/
|
||||
|
||||
#include "windef.h"
|
||||
#include "objbase.h"
|
||||
#include "winsvc.h"
|
||||
#include "bits.h"
|
||||
|
||||
#include "qmgr.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
||||
|
||||
HANDLE stop_event = NULL;
|
||||
|
||||
static SERVICE_STATUS_HANDLE status_handle;
|
||||
static SERVICE_STATUS status;
|
||||
|
||||
static VOID
|
||||
UpdateStatus(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint)
|
||||
{
|
||||
status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
||||
status.dwCurrentState = dwCurrentState;
|
||||
if (dwCurrentState == SERVICE_START_PENDING)
|
||||
status.dwControlsAccepted = 0;
|
||||
else
|
||||
status.dwControlsAccepted
|
||||
= (SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_PAUSE_CONTINUE
|
||||
| SERVICE_ACCEPT_SHUTDOWN);
|
||||
status.dwWin32ExitCode = 0;
|
||||
status.dwServiceSpecificExitCode = 0;
|
||||
status.dwCheckPoint = 0;
|
||||
status.dwWaitHint = dwWaitHint;
|
||||
|
||||
if (!SetServiceStatus(status_handle, &status)) {
|
||||
ERR("failed to set service status\n");
|
||||
SetEvent(stop_event);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle incoming ControlService signals */
|
||||
static DWORD WINAPI
|
||||
ServiceHandler(DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context)
|
||||
{
|
||||
switch (ctrl) {
|
||||
case SERVICE_CONTROL_STOP:
|
||||
case SERVICE_CONTROL_SHUTDOWN:
|
||||
TRACE("shutting down service\n");
|
||||
UpdateStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
|
||||
SetEvent(stop_event);
|
||||
break;
|
||||
default:
|
||||
FIXME("ignoring handle service ctrl %x\n", ctrl);
|
||||
UpdateStatus(status.dwCurrentState, NO_ERROR, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
/* Main thread of the service */
|
||||
static BOOL
|
||||
StartCount(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
DWORD dwReg;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
|
||||
hr = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_NONE,
|
||||
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE,
|
||||
NULL);
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
|
||||
hr = CoRegisterClassObject(&CLSID_BackgroundCopyManager,
|
||||
(IUnknown *) &BITS_ClassFactory,
|
||||
CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE,
|
||||
&dwReg);
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Service entry point */
|
||||
VOID WINAPI
|
||||
ServiceMain(DWORD dwArgc, LPWSTR *lpszArgv)
|
||||
{
|
||||
HANDLE fileTxThread;
|
||||
static const WCHAR qmgr_nameW[] = {'B','I','T','S',0};
|
||||
DWORD threadId;
|
||||
TRACE("\n");
|
||||
|
||||
stop_event = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||
if (!stop_event) {
|
||||
ERR("failed to create stop_event\n");
|
||||
return;
|
||||
}
|
||||
|
||||
status_handle = RegisterServiceCtrlHandlerExW(qmgr_nameW, ServiceHandler, NULL);
|
||||
if (!status_handle) {
|
||||
ERR("failed to register handler: %u\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateStatus(SERVICE_START_PENDING, NO_ERROR, 3000);
|
||||
if (!StartCount()) {
|
||||
ERR("failed starting service thread\n");
|
||||
UpdateStatus(SERVICE_STOPPED, NO_ERROR, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
globalMgr.jobEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||
if (!globalMgr.jobEvent) {
|
||||
ERR("Couldn't create event: error %d\n", GetLastError());
|
||||
UpdateStatus(SERVICE_STOPPED, NO_ERROR, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
fileTxThread = CreateThread(NULL, 0, fileTransfer, NULL, 0, &threadId);
|
||||
if (!fileTxThread)
|
||||
{
|
||||
ERR("Failed starting file transfer thread\n");
|
||||
UpdateStatus(SERVICE_STOPPED, NO_ERROR, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateStatus(SERVICE_RUNNING, NO_ERROR, 0);
|
||||
|
||||
WaitForSingleObject(fileTxThread, INFINITE);
|
||||
UpdateStatus(SERVICE_STOPPED, NO_ERROR, 0);
|
||||
CloseHandle(stop_event);
|
||||
TRACE("service stoped\n");
|
||||
}
|
|
@ -301,6 +301,9 @@
|
|||
<directory name="pstorec">
|
||||
<xi:include href="pstorec/pstorec.rbuild" />
|
||||
</directory>
|
||||
<!--directory name="qmgr">
|
||||
<xi:include href="qmgr/qmgr.rbuild" />
|
||||
</directory-->
|
||||
<directory name="rasapi32">
|
||||
<xi:include href="rasapi32/rasapi32.rbuild" />
|
||||
</directory>
|
||||
|
|
411
reactos/include/psdk/bits.idl
Normal file
411
reactos/include/psdk/bits.idl
Normal file
|
@ -0,0 +1,411 @@
|
|||
/*
|
||||
* Background Intelligent Transfer Service (BITS) interface
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DO_NO_IMPORTS
|
||||
import "unknwn.idl";
|
||||
#endif
|
||||
|
||||
cpp_quote("#include \"bitsmsg.h\"")
|
||||
cpp_quote("#define BG_SIZE_UNKNOWN (UINT64)(-1)")
|
||||
cpp_quote("#define BG_NOTIFY_JOB_TRANSFERRED 0x0001")
|
||||
cpp_quote("#define BG_NOTIFY_JOB_ERROR 0x0002")
|
||||
cpp_quote("#define BG_NOTIFY_DISABLE 0x0004")
|
||||
cpp_quote("#define BG_NOTIFY_JOB_MODIFICATION 0x0008")
|
||||
|
||||
|
||||
#define BG_ENUM_SIZEIS(maxcount) maxcount
|
||||
#define BG_ENUM_LENGTHIS(maxcount,lengthptr) lengthptr ? *lengthptr : maxcount
|
||||
|
||||
[
|
||||
uuid(01b7bd23-fb88-4a77-8490-5891d3e4653a),
|
||||
odl
|
||||
]
|
||||
interface IBackgroundCopyFile : IUnknown
|
||||
{
|
||||
typedef struct _BG_FILE_PROGRESS {
|
||||
UINT64 BytesTotal;
|
||||
UINT64 BytesTransferred;
|
||||
BOOL Completed;
|
||||
} BG_FILE_PROGRESS;
|
||||
|
||||
HRESULT GetRemoteName(
|
||||
[out] LPWSTR *pVal
|
||||
);
|
||||
|
||||
HRESULT GetLocalName(
|
||||
[out] LPWSTR *pVal
|
||||
);
|
||||
|
||||
HRESULT GetProgress(
|
||||
[out] BG_FILE_PROGRESS *pVal
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
[
|
||||
uuid(ca51e165-c365-424c-8d41-24aaa4ff3c40),
|
||||
odl
|
||||
]
|
||||
interface IEnumBackgroundCopyFiles: IUnknown
|
||||
{
|
||||
HRESULT Next(
|
||||
[in] ULONG celt,
|
||||
[out,size_is(BG_ENUM_SIZEIS(celt)),length_is(BG_ENUM_LENGTHIS(celt,pceltFetched))] IBackgroundCopyFile **rgelt,
|
||||
[in,out,unique] ULONG *pceltFetched
|
||||
);
|
||||
|
||||
HRESULT Skip(
|
||||
[in] ULONG celt
|
||||
);
|
||||
|
||||
HRESULT Reset();
|
||||
|
||||
HRESULT Clone(
|
||||
[out] IEnumBackgroundCopyFiles **ppenum
|
||||
);
|
||||
|
||||
HRESULT GetCount(
|
||||
[out] ULONG *puCount
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
[
|
||||
uuid(19c613a0-fcb8-4f28-81ae-897c3d078f81),
|
||||
odl
|
||||
]
|
||||
interface IBackgroundCopyError : IUnknown
|
||||
{
|
||||
typedef enum {
|
||||
BG_ERROR_CONTEXT_NONE = 0,
|
||||
BG_ERROR_CONTEXT_UNKNOWN = 1,
|
||||
BG_ERROR_CONTEXT_GENERAL_QUEUE_MANAGER = 2,
|
||||
BG_ERROR_CONTEXT_QUEUE_MANAGER_NOTIFICATION =3,
|
||||
BG_ERROR_CONTEXT_LOCAL_FILE = 4,
|
||||
BG_ERROR_CONTEXT_REMOTE_FILE = 5,
|
||||
BG_ERROR_CONTEXT_GENERAL_TRANSPORT = 6,
|
||||
BG_ERROR_CONTEXT_REMOTE_APPLICATION =7,
|
||||
} BG_ERROR_CONTEXT;
|
||||
|
||||
HRESULT GetError(
|
||||
[out,ref] BG_ERROR_CONTEXT *pContext,
|
||||
[out,ref] HRESULT *pCode
|
||||
);
|
||||
|
||||
HRESULT GetFile(
|
||||
[out] IBackgroundCopyFile **pVal
|
||||
);
|
||||
|
||||
HRESULT GetErrorDescription(
|
||||
[in] DWORD LanguageId,
|
||||
[out,ref] LPWSTR *pErrorDescription
|
||||
);
|
||||
|
||||
HRESULT GetErrorContextDescription(
|
||||
[in] DWORD LanguageId,
|
||||
[out,ref] LPWSTR *pContextDescription
|
||||
);
|
||||
|
||||
HRESULT GetProtocol(
|
||||
[out,ref] LPWSTR *pProtocol
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[
|
||||
uuid(37668d37-507e-4160-9316-26306d150b12),
|
||||
odl
|
||||
]
|
||||
interface IBackgroundCopyJob : IUnknown
|
||||
{
|
||||
typedef struct _BG_FILE_INFO {
|
||||
LPWSTR RemoteName;
|
||||
LPWSTR LocalName;
|
||||
} BG_FILE_INFO;
|
||||
|
||||
typedef struct _BG_JOB_PROGRESS {
|
||||
UINT64 BytesTotal;
|
||||
UINT64 BytesTransferred;
|
||||
ULONG FilesTotal;
|
||||
ULONG FilesTransferred;
|
||||
} BG_JOB_PROGRESS;
|
||||
|
||||
typedef struct _BG_JOB_TIMES {
|
||||
FILETIME CreationTime;
|
||||
FILETIME ModificationTime;
|
||||
FILETIME TransferCompletionTime;
|
||||
} BG_JOB_TIMES;
|
||||
|
||||
typedef enum {
|
||||
BG_JOB_PRIORITY_FOREGROUND = 0,
|
||||
BG_JOB_PRIORITY_HIGH = 1,
|
||||
BG_JOB_PRIORITY_NORMAL = 2,
|
||||
BG_JOB_PRIORITY_LOW = 3
|
||||
} BG_JOB_PRIORITY;
|
||||
|
||||
typedef enum {
|
||||
BG_JOB_STATE_QUEUED = 0,
|
||||
BG_JOB_STATE_CONNECTING = 1,
|
||||
BG_JOB_STATE_TRANSFERRING = 2,
|
||||
BG_JOB_STATE_SUSPENDED = 3,
|
||||
BG_JOB_STATE_ERROR = 4,
|
||||
BG_JOB_STATE_TRANSIENT_ERROR = 5,
|
||||
BG_JOB_STATE_TRANSFERRED = 6,
|
||||
BG_JOB_STATE_ACKNOWLEDGED = 7,
|
||||
BG_JOB_STATE_CANCELLED = 8
|
||||
} BG_JOB_STATE;
|
||||
|
||||
typedef enum {
|
||||
BG_JOB_TYPE_DOWNLOAD = 0,
|
||||
BG_JOB_TYPE_UPLOAD = 1,
|
||||
BG_JOB_TYPE_UPLOAD_REPLY = 2
|
||||
} BG_JOB_TYPE;
|
||||
|
||||
typedef enum {
|
||||
BG_JOB_PROXY_USAGE_PRECONFIG,
|
||||
BG_JOB_PROXY_USAGE_NO_PROXY,
|
||||
BG_JOB_PROXY_USAGE_OVERRIDE,
|
||||
BG_JOB_PROXY_USAGE_AUTODETECT
|
||||
} BG_JOB_PROXY_USAGE;
|
||||
|
||||
|
||||
HRESULT AddFileSet(
|
||||
[in] ULONG cFileCount,
|
||||
[in,size_is(cFileCount)] BG_FILE_INFO *pFileSet
|
||||
);
|
||||
|
||||
HRESULT AddFile(
|
||||
[in] LPCWSTR RemoteUrl,
|
||||
[in] LPCWSTR LocalName
|
||||
);
|
||||
|
||||
HRESULT EnumFiles(
|
||||
[out] IEnumBackgroundCopyFiles **pEnum
|
||||
);
|
||||
|
||||
HRESULT Suspend();
|
||||
|
||||
HRESULT Resume();
|
||||
|
||||
HRESULT Cancel();
|
||||
|
||||
HRESULT Complete();
|
||||
|
||||
HRESULT GetId(
|
||||
[out] GUID *pVal
|
||||
);
|
||||
|
||||
HRESULT GetType(
|
||||
[out] BG_JOB_TYPE *pVal
|
||||
);
|
||||
|
||||
HRESULT GetProgress(
|
||||
[out] BG_JOB_PROGRESS *pVal
|
||||
);
|
||||
|
||||
HRESULT GetTimes(
|
||||
[out] BG_JOB_TIMES *pVal
|
||||
);
|
||||
|
||||
HRESULT GetState(
|
||||
[out] BG_JOB_STATE *pVal
|
||||
);
|
||||
|
||||
HRESULT GetError(
|
||||
[out] IBackgroundCopyError **ppError
|
||||
);
|
||||
|
||||
HRESULT GetOwner(
|
||||
[out] LPWSTR *pVal
|
||||
);
|
||||
|
||||
HRESULT SetDisplayName(
|
||||
[in] LPCWSTR Val
|
||||
);
|
||||
|
||||
HRESULT GetDisplayName(
|
||||
[out] LPWSTR *pVal
|
||||
);
|
||||
|
||||
HRESULT SetDescription(
|
||||
[in] LPCWSTR Val
|
||||
);
|
||||
|
||||
HRESULT GetDescription(
|
||||
[out] LPWSTR *pVal
|
||||
);
|
||||
|
||||
HRESULT SetPriority(
|
||||
[in] BG_JOB_PRIORITY Val
|
||||
);
|
||||
|
||||
HRESULT GetPriority(
|
||||
[out] BG_JOB_PRIORITY *pVal
|
||||
);
|
||||
|
||||
HRESULT SetNotifyFlags(
|
||||
[in] ULONG Val
|
||||
);
|
||||
|
||||
HRESULT GetNotifyFlags(
|
||||
[out] ULONG *pVal
|
||||
);
|
||||
|
||||
HRESULT SetNotifyInterface(
|
||||
[in] IUnknown *Val
|
||||
);
|
||||
|
||||
HRESULT GetNotifyInterface(
|
||||
[out] IUnknown ** pVal
|
||||
);
|
||||
|
||||
HRESULT SetMinimumRetryDelay(
|
||||
[in] ULONG Seconds
|
||||
);
|
||||
|
||||
HRESULT GetMinimumRetryDelay(
|
||||
[out] ULONG *Seconds
|
||||
);
|
||||
|
||||
HRESULT SetNoProgressTimeout(
|
||||
[in] ULONG Seconds
|
||||
);
|
||||
|
||||
HRESULT GetNoProgressTimeout(
|
||||
[out] ULONG *Seconds
|
||||
);
|
||||
|
||||
HRESULT GetErrorCount(
|
||||
[out] ULONG *Errors
|
||||
);
|
||||
|
||||
HRESULT SetProxySettings(
|
||||
[in] BG_JOB_PROXY_USAGE ProxyUsage,
|
||||
[in,string,unique] const WCHAR *ProxyList,
|
||||
[in,string,unique] const WCHAR *ProxyBypassList
|
||||
);
|
||||
|
||||
HRESULT GetProxySettings(
|
||||
[out] BG_JOB_PROXY_USAGE *pProxyUsage,
|
||||
[out] LPWSTR *pProxyList,
|
||||
[out] LPWSTR *pProxyBypassList
|
||||
);
|
||||
|
||||
HRESULT TakeOwnership();
|
||||
}
|
||||
|
||||
[
|
||||
uuid(1af4f612-3b71-466f-8f58-7b6f73ac57ad),
|
||||
odl
|
||||
]
|
||||
interface IEnumBackgroundCopyJobs : IUnknown
|
||||
{
|
||||
HRESULT Next(
|
||||
[in] ULONG celt,
|
||||
[out,size_is(BG_ENUM_SIZEIS(celt)),length_is(BG_ENUM_LENGTHIS(celt,pceltFetched))] IBackgroundCopyJob **rgelt,
|
||||
[in,out,unique] ULONG *pceltFetched
|
||||
);
|
||||
|
||||
HRESULT Skip(
|
||||
[in] ULONG celt
|
||||
);
|
||||
|
||||
HRESULT Reset();
|
||||
|
||||
HRESULT Clone(
|
||||
[out] IEnumBackgroundCopyJobs **ppenum
|
||||
);
|
||||
|
||||
HRESULT GetCount(
|
||||
[out] ULONG *puCount
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
[
|
||||
uuid(97ea99c7-0186-4ad4-8df9-c5b4e0ed6b22),
|
||||
odl
|
||||
]
|
||||
interface IBackgroundCopyCallback : IUnknown
|
||||
{
|
||||
HRESULT JobTransferred(
|
||||
[in] IBackgroundCopyJob *pJob
|
||||
);
|
||||
|
||||
HRESULT JobError(
|
||||
[in] IBackgroundCopyJob *pJob,
|
||||
[in] IBackgroundCopyError *pError
|
||||
);
|
||||
|
||||
HRESULT JobModification(
|
||||
[in] IBackgroundCopyJob *pJob,
|
||||
[in] DWORD dwReserved
|
||||
);
|
||||
}
|
||||
|
||||
[
|
||||
uuid(5ce34c0d-0dc9-4c1f-897c-daa1b78cee7c),
|
||||
odl
|
||||
]
|
||||
interface IBackgroundCopyManager : IUnknown
|
||||
{
|
||||
cpp_quote("#define BG_JOB_ENUM_ALL_USERS 0x0001")
|
||||
|
||||
HRESULT CreateJob(
|
||||
[in] LPCWSTR DisplayName,
|
||||
[in] BG_JOB_TYPE Type,
|
||||
[out] GUID *pJobId,
|
||||
[out] IBackgroundCopyJob **ppJob
|
||||
);
|
||||
|
||||
HRESULT GetJob(
|
||||
[in] REFGUID jobID,
|
||||
[out] IBackgroundCopyJob **ppJob
|
||||
);
|
||||
|
||||
HRESULT EnumJobs(
|
||||
[in] DWORD dwFlags,
|
||||
[out] IEnumBackgroundCopyJobs **ppEnum
|
||||
);
|
||||
HRESULT GetErrorDescription(
|
||||
[in] HRESULT hResult,
|
||||
[in] DWORD LanguageId,
|
||||
[out] LPWSTR *pErrorDescription);
|
||||
}
|
||||
|
||||
|
||||
[
|
||||
uuid(1deeb74f-7915-4560-b558-918c83f176a6),
|
||||
version(1.0)
|
||||
]
|
||||
library BackgroundCopyManager
|
||||
{
|
||||
[
|
||||
uuid(4991d34b-80a1-4291-83b6-3328366b9097),
|
||||
]
|
||||
coclass BackgroundCopyManager
|
||||
{
|
||||
[default] interface IBackgroundCopyManager;
|
||||
};
|
||||
|
||||
interface IBackgroundCopyCallback;
|
||||
}
|
88
reactos/include/psdk/bits1_5.idl
Normal file
88
reactos/include/psdk/bits1_5.idl
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Background Intelligent Transfer Service (BITS) 1.5 interface
|
||||
*
|
||||
* Copyright 2008 Google (Dan Hipschman)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DO_NO_IMPORTS
|
||||
import "bits.idl";
|
||||
#endif
|
||||
|
||||
[
|
||||
uuid(54b50739-686f-45eb-9dff-d6a9a0faa9af),
|
||||
odl
|
||||
]
|
||||
interface IBackgroundCopyJob2 : IBackgroundCopyJob
|
||||
{
|
||||
HRESULT SetNotifyCmdLine([unique] LPCWSTR prog, [unique] LPCWSTR params);
|
||||
HRESULT GetNotifyCmdLine([out] LPWSTR *prog, [out] LPWSTR *params);
|
||||
|
||||
typedef struct _BG_JOB_REPLY_PROGRESS
|
||||
{
|
||||
UINT64 BytesTotal;
|
||||
UINT64 BytesTransferred;
|
||||
} BG_JOB_REPLY_PROGRESS;
|
||||
|
||||
HRESULT GetReplyProgress([in, out] BG_JOB_REPLY_PROGRESS *progress);
|
||||
HRESULT GetReplyData([out, size_is( , (unsigned long) *pLength)] byte **pBuffer,
|
||||
[in, out, unique] UINT64 *pLength);
|
||||
HRESULT SetReplyFileName([unique] LPCWSTR filename);
|
||||
HRESULT GetReplyFileName([out] LPWSTR *pFilename);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BG_AUTH_TARGET_SERVER = 1,
|
||||
BG_AUTH_TARGET_PROXY
|
||||
} BG_AUTH_TARGET;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BG_AUTH_SCHEME_BASIC = 1,
|
||||
BG_AUTH_SCHEME_DIGEST,
|
||||
BG_AUTH_SCHEME_NTLM,
|
||||
BG_AUTH_SCHEME_NEGOTIATE,
|
||||
BG_AUTH_SCHEME_PASSPORT
|
||||
} BG_AUTH_SCHEME;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LPWSTR UserName;
|
||||
LPWSTR Password;
|
||||
} BG_BASIC_CREDENTIALS;
|
||||
typedef BG_BASIC_CREDENTIALS *PBG_BASIC_CREDENTIALS;
|
||||
|
||||
typedef [switch_type(BG_AUTH_SCHEME)] union
|
||||
{
|
||||
[case(BG_AUTH_SCHEME_BASIC, BG_AUTH_SCHEME_DIGEST, BG_AUTH_SCHEME_NTLM,
|
||||
BG_AUTH_SCHEME_NEGOTIATE, BG_AUTH_SCHEME_PASSPORT)]
|
||||
BG_BASIC_CREDENTIALS Basic;
|
||||
[default]
|
||||
;
|
||||
} BG_AUTH_CREDENTIALS_UNION;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BG_AUTH_TARGET Target;
|
||||
BG_AUTH_SCHEME Scheme;
|
||||
[switch_is(Scheme)] BG_AUTH_CREDENTIALS_UNION Credentials;
|
||||
} BG_AUTH_CREDENTIALS;
|
||||
typedef BG_AUTH_CREDENTIALS *PBG_AUTH_CREDENTIALS;
|
||||
|
||||
HRESULT SetCredentials(BG_AUTH_CREDENTIALS *cred);
|
||||
HRESULT RemoveCredentials(BG_AUTH_TARGET target, BG_AUTH_SCHEME scheme);
|
||||
}
|
81
reactos/include/psdk/bitsmsg.h
Normal file
81
reactos/include/psdk/bitsmsg.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Standard return values that may be generated by 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
|
||||
*/
|
||||
|
||||
#ifndef __WINE_BITMSG_H__
|
||||
#define __WINE_BITMSG_H__
|
||||
|
||||
#define BG_S_PARTIAL_COMPLETE 0x00200017
|
||||
#define BG_S_UNABLE_TO_DELETE_FILES 0x0020001A
|
||||
#define BG_S_OVERRIDDEN_BY_POLICY 0x00200055
|
||||
|
||||
#define BG_E_HTTP_ERROR_400 0x80190190
|
||||
#define BG_E_HTTP_ERROR_401 0x80190191
|
||||
#define BG_E_HTTP_ERROR_404 0x80190194
|
||||
#define BG_E_HTTP_ERROR_407 0x80190197
|
||||
#define BG_E_HTTP_ERROR_414 0x8019019E
|
||||
#define BG_E_HTTP_ERROR_501 0x801901F5
|
||||
#define BG_E_HTTP_ERROR_503 0x801901F7
|
||||
#define BG_E_HTTP_ERROR_504 0x801901F8
|
||||
#define BG_E_HTTP_ERROR_505 0x801901F9
|
||||
|
||||
#define BG_E_NOT_FOUND 0x80200001
|
||||
#define BG_E_INVALID_STATE 0x80200002
|
||||
#define BG_E_EMPTY 0x80200003
|
||||
#define BG_E_FILE_NOT_AVAILABLE 0x80200004
|
||||
#define BG_E_PROTOCOL_NOT_AVAILABLE 0x80200005
|
||||
#define BG_E_DESTINATION_LOCKED 0x8020000D
|
||||
#define BG_E_VOLUME_CHANGED 0x8020000E
|
||||
#define BG_E_ERROR_INFORMATION_UNAVAILABLE 0x8020000F
|
||||
#define BG_E_NETWORK_DISCONNECTED 0x80200010
|
||||
#define BG_E_MISSING_FILE_SIZE 0x80200011
|
||||
#define BG_E_INSUFFICIENT_HTTP_SUPPORT 0x80200012
|
||||
#define BG_E_INSUFFICIENT_RANGE_SUPPORT 0x80200013
|
||||
#define BG_E_REMOTE_NOT_SUPPORTED 0x80200014
|
||||
#define BG_E_NEW_OWNER_DIFF_MAPPING 0x80200015
|
||||
#define BG_E_NEW_OWNER_NO_FILE_ACCESS 0x80200016
|
||||
#define BG_E_PROXY_LIST_TOO_LARGE 0x80200018
|
||||
#define BG_E_PROXY_BYPASS_LIST_TOO_LARGE 0x80200019
|
||||
#define BG_E_TOO_MANY_FILES 0x8020001C
|
||||
#define BG_E_LOCAL_FILE_CHANGED 0x8020001D
|
||||
#define BG_E_TOO_LARGE 0x80200020
|
||||
#define BG_E_STRING_TOO_LONG 0x80200021
|
||||
#define BG_E_CLIENT_SERVER_PROTOCOL_MISMATCH 0x80200022
|
||||
#define BG_E_SERVER_EXECUTE_ENABLED 0x80200023
|
||||
#define BG_E_USERNAME_TOO_LARGE 0x80200025
|
||||
#define BG_E_PASSWORD_TOO_LARGE 0x80200026
|
||||
#define BG_E_INVALID_AUTH_TARGET 0x80200027
|
||||
#define BG_E_INVALID_AUTH_SCHEME 0x80200028
|
||||
#define BG_E_INVALID_RANGE 0x8020002B
|
||||
#define BG_E_OVERLAPPING_RANGES 0x8020002C
|
||||
#define BG_E_BLOCKED_BY_POLICY 0x8020003E
|
||||
#define BG_E_INVALID_PROXY_INFO 0x8020003F
|
||||
#define BG_E_INVALID_CREDENTIALS 0x80200040
|
||||
#define BG_E_RECORD_DELETED 0x80200042
|
||||
#define BG_E_UPNP_ERROR 0x80200045
|
||||
#define BG_E_PEERCACHING_DISABLED 0x80200047
|
||||
#define BG_E_BUSYCACHERECORD 0x80200048
|
||||
#define BG_E_TOO_MANY_JOBS_PER_USER 0x80200049
|
||||
#define BG_E_TOO_MANY_JOBS_PER_MACHINE 0x80200050
|
||||
#define BG_E_TOO_MANY_FILES_IN_JOB 0x80200051
|
||||
#define BG_E_TOO_MANY_RANGES_IN_FILE 0x80200052
|
||||
#define BG_E_VALIDATION_FAILED 0x80200053
|
||||
#define BG_E_MAXDOWNLOAD_TIMEOUT 0x80200054
|
||||
|
||||
#endif /* #ifndef __WINE_BITMSG_H__ */
|
|
@ -4,6 +4,8 @@
|
|||
<file>activaut.idl</file>
|
||||
<file>activdbg.idl</file>
|
||||
<file>activscp.idl</file>
|
||||
<file>bits1_5.idl</file>
|
||||
<file>bits.idl</file>
|
||||
<file>control.idl</file>
|
||||
<file>ctxtcall.idl</file>
|
||||
<file>dimm.idl</file>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue