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
26 #define WIN32_NO_STATUS
28 #define COM_NO_WINDOWS_H
39 #include <wine/list.h>
40 #include <wine/debug.h>
41 #include <wine/unicode.h>
43 WINE_DEFAULT_DEBUG_CHANNEL(qmgr
);
45 /* Background copy job vtbl and related data */
48 IBackgroundCopyJob2 IBackgroundCopyJob2_iface
;
55 BG_JOB_PROGRESS jobProgress
;
58 IBackgroundCopyCallback2
*callback
;
59 BOOL callback2
; /* IBackgroundCopyCallback2 is supported in addition to IBackgroundCopyCallback */
60 /* Protects file list, and progress */
62 struct list entryFromQmgr
;
63 } BackgroundCopyJobImpl
;
65 /* Background copy file vtbl and related data */
68 IBackgroundCopyFile IBackgroundCopyFile_iface
;
71 BG_FILE_PROGRESS fileProgress
;
72 WCHAR tempFileName
[MAX_PATH
];
73 struct list entryFromJob
;
74 BackgroundCopyJobImpl
*owner
;
75 } BackgroundCopyFileImpl
;
77 /* Background copy manager vtbl and related data */
80 IBackgroundCopyManager IBackgroundCopyManager_iface
;
81 /* Protects job list, job states, and jobEvent */
85 } BackgroundCopyManagerImpl
;
89 IClassFactory IClassFactory_iface
;
92 extern HANDLE stop_event DECLSPEC_HIDDEN
;
93 extern ClassFactoryImpl BITS_ClassFactory DECLSPEC_HIDDEN
;
94 extern BackgroundCopyManagerImpl globalMgr DECLSPEC_HIDDEN
;
96 HRESULT
BackgroundCopyManagerConstructor(LPVOID
*ppObj
) DECLSPEC_HIDDEN
;
97 HRESULT
BackgroundCopyJobConstructor(LPCWSTR displayName
, BG_JOB_TYPE type
,
98 GUID
*pJobId
, BackgroundCopyJobImpl
**job
) DECLSPEC_HIDDEN
;
99 HRESULT
enum_copy_job_create(BackgroundCopyManagerImpl
*qmgr
,
100 IEnumBackgroundCopyJobs
**enumjob
) DECLSPEC_HIDDEN
;
101 HRESULT
BackgroundCopyFileConstructor(BackgroundCopyJobImpl
*owner
,
102 LPCWSTR remoteName
, LPCWSTR localName
,
103 BackgroundCopyFileImpl
**file
) DECLSPEC_HIDDEN
;
104 HRESULT
EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl
*, IEnumBackgroundCopyFiles
**) DECLSPEC_HIDDEN
;
105 DWORD WINAPI
fileTransfer(void *param
) DECLSPEC_HIDDEN
;
106 void processJob(BackgroundCopyJobImpl
*job
) DECLSPEC_HIDDEN
;
107 BOOL
processFile(BackgroundCopyFileImpl
*file
, BackgroundCopyJobImpl
*job
) DECLSPEC_HIDDEN
;
109 /* Little helper functions */
111 qmgr_strdup(const char *s
)
113 size_t n
= strlen(s
) + 1;
114 char *d
= HeapAlloc(GetProcessHeap(), 0, n
);
115 return d
? memcpy(d
, s
, n
) : NULL
;
118 static inline HRESULT
return_strval(const WCHAR
*str
, WCHAR
**ret
)
122 if (!ret
) return E_INVALIDARG
;
125 *ret
= CoTaskMemAlloc((len
+1)*sizeof(WCHAR
));
126 if (!*ret
) return E_OUTOFMEMORY
;
132 transitionJobState(BackgroundCopyJobImpl
*job
, BG_JOB_STATE fromState
,
133 BG_JOB_STATE toState
)
136 EnterCriticalSection(&globalMgr
.cs
);
137 if (job
->state
== fromState
)
139 job
->state
= toState
;
142 LeaveCriticalSection(&globalMgr
.cs
);
146 #endif /* __QMGR_H__ */