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
33 #include "wine/list.h"
34 #include "wine/unicode.h"
36 /* Background copy job vtbl and related data */
39 IBackgroundCopyJob2 IBackgroundCopyJob2_iface
;
46 BG_JOB_PROGRESS jobProgress
;
49 IBackgroundCopyCallback2
*callback
;
50 BOOL callback2
; /* IBackgroundCopyCallback2 is supported in addition to IBackgroundCopyCallback */
51 /* Protects file list, and progress */
53 struct list entryFromQmgr
;
54 } BackgroundCopyJobImpl
;
56 /* Background copy file vtbl and related data */
59 IBackgroundCopyFile IBackgroundCopyFile_iface
;
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 */
71 IBackgroundCopyManager IBackgroundCopyManager_iface
;
72 /* Protects job list, job states, and jobEvent */
76 } BackgroundCopyManagerImpl
;
80 IClassFactory IClassFactory_iface
;
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 */
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
)
113 if (!ret
) return E_INVALIDARG
;
116 *ret
= CoTaskMemAlloc((len
+1)*sizeof(WCHAR
));
117 if (!*ret
) return E_OUTOFMEMORY
;
123 transitionJobState(BackgroundCopyJobImpl
*job
, BG_JOB_STATE fromState
,
124 BG_JOB_STATE toState
)
127 EnterCriticalSection(&globalMgr
.cs
);
128 if (job
->state
== fromState
)
130 job
->state
= toState
;
133 LeaveCriticalSection(&globalMgr
.cs
);
137 #endif /* __QMGR_H__ */