1 /* 2 * Queue Manager definitions 3 * 4 * Copyright 2007 Google (Roy Shea) 5 * 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. 10 * 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. 15 * 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 19 */ 20 21 #ifndef __QMGR_H__ 22 #define __QMGR_H__ 23 24 #include "windef.h" 25 #define COBJMACROS 26 #include "bits.h" 27 #include "bits1_5.h" 28 #include "bits2_0.h" 29 #include "bits2_5.h" 30 #include "bits3_0.h" 31 32 #include <string.h> 33 #include "wine/list.h" 34 #include "wine/unicode.h" 35 36 /* Background copy job vtbl and related data */ 37 typedef struct 38 { 39 IBackgroundCopyJob3 IBackgroundCopyJob3_iface; 40 IBackgroundCopyJobHttpOptions IBackgroundCopyJobHttpOptions_iface; 41 LONG ref; 42 LPWSTR displayName; 43 LPWSTR description; 44 BG_JOB_TYPE type; 45 GUID jobId; 46 struct list files; 47 BG_JOB_PROGRESS jobProgress; 48 BG_JOB_STATE state; 49 ULONG notify_flags; 50 IBackgroundCopyCallback2 *callback; 51 BOOL callback2; /* IBackgroundCopyCallback2 is supported in addition to IBackgroundCopyCallback */ 52 /* Protects file list, and progress */ 53 CRITICAL_SECTION cs; 54 struct list entryFromQmgr; 55 struct 56 { 57 WCHAR *headers; 58 ULONG flags; 59 BG_AUTH_CREDENTIALS creds[BG_AUTH_TARGET_PROXY][BG_AUTH_SCHEME_PASSPORT]; 60 } http_options; 61 struct 62 { 63 BG_ERROR_CONTEXT context; 64 HRESULT code; 65 IBackgroundCopyFile2 *file; 66 } error; 67 HANDLE wait; 68 HANDLE cancel; 69 HANDLE done; 70 } BackgroundCopyJobImpl; 71 72 /* Background copy file vtbl and related data */ 73 typedef struct 74 { 75 IBackgroundCopyFile2 IBackgroundCopyFile2_iface; 76 LONG ref; 77 BG_FILE_INFO info; 78 BG_FILE_PROGRESS fileProgress; 79 WCHAR tempFileName[MAX_PATH]; 80 struct list entryFromJob; 81 BackgroundCopyJobImpl *owner; 82 DWORD read_size; 83 } BackgroundCopyFileImpl; 84 85 /* Background copy manager vtbl and related data */ 86 typedef struct 87 { 88 IBackgroundCopyManager IBackgroundCopyManager_iface; 89 /* Protects job list, job states, and jobEvent */ 90 CRITICAL_SECTION cs; 91 HANDLE jobEvent; 92 struct list jobs; 93 } BackgroundCopyManagerImpl; 94 95 typedef struct 96 { 97 IClassFactory IClassFactory_iface; 98 } ClassFactoryImpl; 99 100 extern HANDLE stop_event DECLSPEC_HIDDEN; 101 extern ClassFactoryImpl BITS_ClassFactory DECLSPEC_HIDDEN; 102 extern BackgroundCopyManagerImpl globalMgr DECLSPEC_HIDDEN; 103 104 HRESULT BackgroundCopyManagerConstructor(LPVOID *ppObj) DECLSPEC_HIDDEN; 105 HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, 106 GUID *pJobId, BackgroundCopyJobImpl **job) DECLSPEC_HIDDEN; 107 HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, 108 IEnumBackgroundCopyJobs **enumjob) DECLSPEC_HIDDEN; 109 HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner, 110 LPCWSTR remoteName, LPCWSTR localName, 111 BackgroundCopyFileImpl **file) DECLSPEC_HIDDEN; 112 HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl*, IEnumBackgroundCopyFiles**) DECLSPEC_HIDDEN; 113 DWORD WINAPI fileTransfer(void *param) DECLSPEC_HIDDEN; 114 void processJob(BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN; 115 BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN; 116 BOOL transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE from, BG_JOB_STATE to) DECLSPEC_HIDDEN; 117 118 /* Little helper functions */ 119 static inline WCHAR *strdupW(const WCHAR *src) 120 { 121 WCHAR *dst = HeapAlloc(GetProcessHeap(), 0, (strlenW(src) + 1) * sizeof(WCHAR)); 122 if (dst) strcpyW(dst, src); 123 return dst; 124 } 125 126 static inline WCHAR *co_strdupW(const WCHAR *src) 127 { 128 WCHAR *dst = CoTaskMemAlloc((strlenW(src) + 1) * sizeof(WCHAR)); 129 if (dst) strcpyW(dst, src); 130 return dst; 131 } 132 133 static inline HRESULT return_strval(const WCHAR *str, WCHAR **ret) 134 { 135 int len; 136 137 if (!ret) return E_INVALIDARG; 138 139 len = strlenW(str); 140 *ret = CoTaskMemAlloc((len+1)*sizeof(WCHAR)); 141 if (!*ret) return E_OUTOFMEMORY; 142 strcpyW(*ret, str); 143 return S_OK; 144 } 145 146 #endif /* __QMGR_H__ */ 147