mshtml: Added nsIURI::GetPrePath implementation.
[wine.git] / dlls / qmgr / qmgr.h
blob8f2281d5f0d8f4112ef6e65d75847f02214ed4de
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"
26 #define COBJMACROS
27 #include "objbase.h"
29 #include "bits1_5.h"
30 #include "bits3_0.h"
32 #include <string.h>
33 #include "wine/list.h"
34 #include "wine/unicode.h"
36 /* Background copy job vtbl and related data */
37 typedef struct
39 IBackgroundCopyJob2 IBackgroundCopyJob2_iface;
40 LONG ref;
41 LPWSTR displayName;
42 LPWSTR description;
43 BG_JOB_TYPE type;
44 GUID jobId;
45 struct list files;
46 BG_JOB_PROGRESS jobProgress;
47 BG_JOB_STATE state;
48 ULONG notify_flags;
49 IBackgroundCopyCallback2 *callback;
50 BOOL callback2; /* IBackgroundCopyCallback2 is supported in addition to IBackgroundCopyCallback */
51 /* Protects file list, and progress */
52 CRITICAL_SECTION cs;
53 struct list entryFromQmgr;
54 } BackgroundCopyJobImpl;
56 /* Background copy file vtbl and related data */
57 typedef struct
59 IBackgroundCopyFile IBackgroundCopyFile_iface;
60 LONG ref;
61 BG_FILE_INFO info;
62 BG_FILE_PROGRESS fileProgress;
63 WCHAR tempFileName[MAX_PATH];
64 struct list entryFromJob;
65 BackgroundCopyJobImpl *owner;
66 } BackgroundCopyFileImpl;
68 /* Background copy manager vtbl and related data */
69 typedef struct
71 IBackgroundCopyManager IBackgroundCopyManager_iface;
72 /* Protects job list, job states, and jobEvent */
73 CRITICAL_SECTION cs;
74 HANDLE jobEvent;
75 struct list jobs;
76 } BackgroundCopyManagerImpl;
78 typedef struct
80 IClassFactory IClassFactory_iface;
81 } ClassFactoryImpl;
83 extern HANDLE stop_event DECLSPEC_HIDDEN;
84 extern ClassFactoryImpl BITS_ClassFactory DECLSPEC_HIDDEN;
85 extern BackgroundCopyManagerImpl globalMgr DECLSPEC_HIDDEN;
87 HRESULT BackgroundCopyManagerConstructor(LPVOID *ppObj) DECLSPEC_HIDDEN;
88 HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
89 GUID *pJobId, BackgroundCopyJobImpl **job) DECLSPEC_HIDDEN;
90 HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr,
91 IEnumBackgroundCopyJobs **enumjob) DECLSPEC_HIDDEN;
92 HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
93 LPCWSTR remoteName, LPCWSTR localName,
94 BackgroundCopyFileImpl **file) DECLSPEC_HIDDEN;
95 HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl*, IEnumBackgroundCopyFiles**) DECLSPEC_HIDDEN;
96 DWORD WINAPI fileTransfer(void *param) DECLSPEC_HIDDEN;
97 void processJob(BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN;
98 BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN;
100 /* Little helper functions */
101 static inline char *
102 qmgr_strdup(const char *s)
104 size_t n = strlen(s) + 1;
105 char *d = HeapAlloc(GetProcessHeap(), 0, n);
106 return d ? memcpy(d, s, n) : NULL;
109 static inline HRESULT return_strval(const WCHAR *str, WCHAR **ret)
111 int len;
113 if (!ret) return E_INVALIDARG;
115 len = strlenW(str);
116 *ret = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
117 if (!*ret) return E_OUTOFMEMORY;
118 strcpyW(*ret, str);
119 return S_OK;
122 static inline BOOL
123 transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE fromState,
124 BG_JOB_STATE toState)
126 BOOL rv = FALSE;
127 EnterCriticalSection(&globalMgr.cs);
128 if (job->state == fromState)
130 job->state = toState;
131 rv = TRUE;
133 LeaveCriticalSection(&globalMgr.cs);
134 return rv;
137 #endif /* __QMGR_H__ */