qmgr: COM cleanup for the IEnumBackgroundCopyJobs iface.
[wine/wine-gecko.git] / dlls / qmgr / qmgr.h
blob4bd1e34c6dc0398be7ca92170c37709e51c471f4
1 /*
2 * Queue Manager definitions
4 * Copyright 2007 Google (Roy Shea)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __QMGR_H__
22 #define __QMGR_H__
24 #include "windef.h"
25 #include "objbase.h"
27 #define COBJMACROS
28 #include "bits1_5.h"
30 #include <string.h>
31 #include "wine/list.h"
33 /* Background copy job vtbl and related data */
34 typedef struct
36 const IBackgroundCopyJob2Vtbl *lpVtbl;
37 LONG ref;
38 LPWSTR displayName;
39 BG_JOB_TYPE type;
40 GUID jobId;
41 struct list files;
42 BG_JOB_PROGRESS jobProgress;
43 BG_JOB_STATE state;
44 /* Protects file list, and progress */
45 CRITICAL_SECTION cs;
46 struct list entryFromQmgr;
47 } BackgroundCopyJobImpl;
49 /* Enum background copy files vtbl and related data */
50 typedef struct
52 const IEnumBackgroundCopyFilesVtbl *lpVtbl;
53 LONG ref;
54 IBackgroundCopyFile **files;
55 ULONG numFiles;
56 ULONG indexFiles;
57 } EnumBackgroundCopyFilesImpl;
59 /* Background copy file vtbl and related data */
60 typedef struct
62 const IBackgroundCopyFileVtbl *lpVtbl;
63 LONG ref;
64 BG_FILE_INFO info;
65 BG_FILE_PROGRESS fileProgress;
66 WCHAR tempFileName[MAX_PATH];
67 struct list entryFromJob;
68 BackgroundCopyJobImpl *owner;
69 } BackgroundCopyFileImpl;
71 /* Background copy manager vtbl and related data */
72 typedef struct
74 IBackgroundCopyManager IBackgroundCopyManager_iface;
75 /* Protects job list, job states, and jobEvent */
76 CRITICAL_SECTION cs;
77 HANDLE jobEvent;
78 struct list jobs;
79 } BackgroundCopyManagerImpl;
81 typedef struct
83 IClassFactory IClassFactory_iface;
84 } ClassFactoryImpl;
86 extern HANDLE stop_event DECLSPEC_HIDDEN;
87 extern ClassFactoryImpl BITS_ClassFactory DECLSPEC_HIDDEN;
88 extern BackgroundCopyManagerImpl globalMgr DECLSPEC_HIDDEN;
90 HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN;
91 HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
92 GUID *pJobId, LPVOID *ppObj) DECLSPEC_HIDDEN;
93 HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr,
94 IEnumBackgroundCopyJobs **enumjob) DECLSPEC_HIDDEN;
95 HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
96 LPCWSTR remoteName, LPCWSTR localName,
97 LPVOID *ppObj) DECLSPEC_HIDDEN;
98 HRESULT EnumBackgroundCopyFilesConstructor(LPVOID *ppObj,
99 IBackgroundCopyJob2 *copyJob) DECLSPEC_HIDDEN;
100 DWORD WINAPI fileTransfer(void *param) DECLSPEC_HIDDEN;
101 void processJob(BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN;
102 BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN;
104 /* Little helper functions */
105 static inline char *
106 qmgr_strdup(const char *s)
108 size_t n = strlen(s) + 1;
109 char *d = HeapAlloc(GetProcessHeap(), 0, n);
110 return d ? memcpy(d, s, n) : NULL;
113 static inline BOOL
114 transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE fromState,
115 BG_JOB_STATE toState)
117 BOOL rv = FALSE;
118 EnterCriticalSection(&globalMgr.cs);
119 if (job->state == fromState)
121 job->state = toState;
122 rv = TRUE;
124 LeaveCriticalSection(&globalMgr.cs);
125 return rv;
128 #endif /* __QMGR_H__ */