2007-12-20 04:02:23 +00:00
|
|
|
/*
|
|
|
|
* 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
|
2008-03-19 22:02:02 +00:00
|
|
|
#include "bits1_5.h"
|
2007-12-20 04:02:23 +00:00
|
|
|
|
2008-02-11 19:09:02 +00:00
|
|
|
#include <string.h>
|
2008-02-27 01:51:20 +00:00
|
|
|
#include "wine/list.h"
|
2008-02-11 19:09:02 +00:00
|
|
|
|
2008-02-22 23:05:26 +00:00
|
|
|
/* Background copy job vtbl and related data */
|
|
|
|
typedef struct
|
|
|
|
{
|
2008-03-19 22:02:02 +00:00
|
|
|
const IBackgroundCopyJob2Vtbl *lpVtbl;
|
2008-02-22 23:05:26 +00:00
|
|
|
LONG ref;
|
2008-02-22 23:06:17 +00:00
|
|
|
LPWSTR displayName;
|
|
|
|
BG_JOB_TYPE type;
|
|
|
|
GUID jobId;
|
2008-02-27 01:51:20 +00:00
|
|
|
struct list files;
|
|
|
|
BG_JOB_PROGRESS jobProgress;
|
2008-03-05 00:01:43 +00:00
|
|
|
BG_JOB_STATE state;
|
2008-03-12 18:56:13 +00:00
|
|
|
/* Protects file list, and progress */
|
|
|
|
CRITICAL_SECTION cs;
|
2008-02-29 03:01:29 +00:00
|
|
|
struct list entryFromQmgr;
|
2008-02-22 23:05:26 +00:00
|
|
|
} BackgroundCopyJobImpl;
|
|
|
|
|
2008-02-26 01:42:46 +00:00
|
|
|
/* Enum background copy jobs vtbl and related data */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const IEnumBackgroundCopyJobsVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
2008-03-04 00:46:08 +00:00
|
|
|
IBackgroundCopyJob **jobs;
|
|
|
|
ULONG numJobs;
|
|
|
|
ULONG indexJobs;
|
2008-02-26 01:42:46 +00:00
|
|
|
} EnumBackgroundCopyJobsImpl;
|
|
|
|
|
2008-02-27 01:52:04 +00:00
|
|
|
/* Enum background copy files vtbl and related data */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const IEnumBackgroundCopyFilesVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
IBackgroundCopyFile **files;
|
|
|
|
ULONG numFiles;
|
|
|
|
ULONG indexFiles;
|
|
|
|
} EnumBackgroundCopyFilesImpl;
|
|
|
|
|
2008-02-27 01:50:43 +00:00
|
|
|
/* Background copy file vtbl and related data */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const IBackgroundCopyFileVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
BG_FILE_INFO info;
|
2008-02-29 03:00:12 +00:00
|
|
|
BG_FILE_PROGRESS fileProgress;
|
2008-03-13 22:54:35 +00:00
|
|
|
WCHAR tempFileName[MAX_PATH];
|
2008-02-27 01:51:20 +00:00
|
|
|
struct list entryFromJob;
|
2008-03-12 18:56:13 +00:00
|
|
|
BackgroundCopyJobImpl *owner;
|
2008-02-27 01:50:43 +00:00
|
|
|
} BackgroundCopyFileImpl;
|
|
|
|
|
2007-12-20 04:02:23 +00:00
|
|
|
/* Background copy manager vtbl and related data */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const IBackgroundCopyManagerVtbl *lpVtbl;
|
2008-03-13 22:54:01 +00:00
|
|
|
/* Protects job list, job states, and jobEvent */
|
2008-03-07 03:04:35 +00:00
|
|
|
CRITICAL_SECTION cs;
|
2008-03-13 22:54:01 +00:00
|
|
|
HANDLE jobEvent;
|
2008-02-29 03:01:29 +00:00
|
|
|
struct list jobs;
|
2007-12-20 04:02:23 +00:00
|
|
|
} BackgroundCopyManagerImpl;
|
|
|
|
|
2008-01-22 19:55:16 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2011-07-20 13:43:49 +00:00
|
|
|
IClassFactory IClassFactory_iface;
|
2008-01-22 19:55:16 +00:00
|
|
|
} ClassFactoryImpl;
|
|
|
|
|
2011-05-13 15:51:15 +00:00
|
|
|
extern HANDLE stop_event DECLSPEC_HIDDEN;
|
|
|
|
extern ClassFactoryImpl BITS_ClassFactory DECLSPEC_HIDDEN;
|
|
|
|
extern BackgroundCopyManagerImpl globalMgr DECLSPEC_HIDDEN;
|
2008-01-22 19:55:16 +00:00
|
|
|
|
2011-05-13 15:51:15 +00:00
|
|
|
HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN;
|
2008-02-22 23:06:17 +00:00
|
|
|
HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
|
2011-05-13 15:51:15 +00:00
|
|
|
GUID *pJobId, LPVOID *ppObj) DECLSPEC_HIDDEN;
|
2008-02-26 01:42:46 +00:00
|
|
|
HRESULT EnumBackgroundCopyJobsConstructor(LPVOID *ppObj,
|
2011-05-13 15:51:15 +00:00
|
|
|
IBackgroundCopyManager* copyManager) DECLSPEC_HIDDEN;
|
2008-03-12 18:56:13 +00:00
|
|
|
HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
|
|
|
|
LPCWSTR remoteName, LPCWSTR localName,
|
2011-05-13 15:51:15 +00:00
|
|
|
LPVOID *ppObj) DECLSPEC_HIDDEN;
|
2008-02-27 01:52:04 +00:00
|
|
|
HRESULT EnumBackgroundCopyFilesConstructor(LPVOID *ppObj,
|
2011-05-13 15:51:15 +00:00
|
|
|
IBackgroundCopyJob2 *copyJob) DECLSPEC_HIDDEN;
|
|
|
|
DWORD WINAPI fileTransfer(void *param) DECLSPEC_HIDDEN;
|
|
|
|
void processJob(BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN;
|
|
|
|
BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN;
|
2007-12-20 04:02:23 +00:00
|
|
|
|
2008-02-11 19:09:02 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2008-03-13 22:54:35 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2007-12-20 04:02:23 +00:00
|
|
|
#endif /* __QMGR_H__ */
|