1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 use shared::basetsd::UINT64;
7 use shared::guiddef::{GUID, REFGUID};
8 use shared::minwindef::{BOOL, DWORD, FILETIME, ULONG};
9 use um::unknwnbase::{IUnknown, IUnknownVtbl};
10 use um::winnt::{HRESULT, LPCWSTR, LPWSTR, WCHAR};
11 RIDL!{#[uuid(0x4991d34b, 0x80a1, 0x4291, 0x83, 0xb6, 0x33, 0x28, 0x36, 0x6b, 0x90, 0x97)]
12 class BackgroundCopyManager;}
13 pub const BG_SIZE_UNKNOWN: UINT64 = -1i64 as u64;
14 STRUCT!{struct BG_FILE_PROGRESS {
15     BytesTotal: UINT64,
16     BytesTransferred: UINT64,
17     Completed: BOOL,
18 }}
19 RIDL!{#[uuid(0x01b7bd23, 0xfb88, 0x4a77, 0x84, 0x90, 0x58, 0x91, 0xd3, 0xe4, 0x65, 0x3a)]
20 interface IBackgroundCopyFile(IBackgroundCopyFileVtbl): IUnknown(IUnknownVtbl) {
21     fn GetRemoteName(
22         pVal: *mut LPWSTR,
23     ) -> HRESULT,
24     fn GetLocalName(
25         pVal: *mut LPWSTR,
26     ) -> HRESULT,
27     fn GetProgress(
28         pVal: *mut BG_FILE_PROGRESS,
29     ) -> HRESULT,
30 }}
31 RIDL!{#[uuid(0xca51e165, 0xc365, 0x424c, 0x8d, 0x41, 0x24, 0xaa, 0xa4, 0xff, 0x3c, 0x40)]
32 interface IEnumBackgroundCopyFiles(IEnumBackgroundCopyFilesVtbl): IUnknown(IUnknownVtbl) {
33     fn Next(
34         celt: ULONG,
35         rgelt: *mut *mut IBackgroundCopyFile,
36         pceltFetched: *mut ULONG,
37     ) -> HRESULT,
38     fn Skip(
39         celt: ULONG,
40     ) -> HRESULT,
41     fn Reset() -> HRESULT,
42     fn Clone(
43         ppenum: *mut *mut IEnumBackgroundCopyFiles,
44     ) -> HRESULT,
45     fn GetCount(
46         puCount: *mut ULONG,
47     ) -> HRESULT,
48 }}
49 ENUM!{enum BG_ERROR_CONTEXT {
50     BG_ERROR_CONTEXT_NONE = 0,
51     BG_ERROR_CONTEXT_UNKNOWN = 1,
52     BG_ERROR_CONTEXT_GENERAL_QUEUE_MANAGER = 2,
53     BG_ERROR_CONTEXT_QUEUE_MANAGER_NOTIFICATION = 3,
54     BG_ERROR_CONTEXT_LOCAL_FILE = 4,
55     BG_ERROR_CONTEXT_REMOTE_FILE = 5,
56     BG_ERROR_CONTEXT_GENERAL_TRANSPORT = 6,
57     BG_ERROR_CONTEXT_REMOTE_APPLICATION = 7,
58 }}
59 RIDL!{#[uuid(0x19c613a0, 0xfcb8, 0x4f28, 0x81, 0xae, 0x89, 0x7c, 0x3d, 0x07, 0x8f, 0x81)]
60 interface IBackgroundCopyError(IBackgroundCopyErrorVtbl): IUnknown(IUnknownVtbl) {
61     fn GetError(
62         pContext: *mut BG_ERROR_CONTEXT,
63         pCode: *mut HRESULT,
64     ) -> HRESULT,
65     fn GetFile(
66         pVal: *mut *mut IBackgroundCopyFile,
67     ) -> HRESULT,
68     fn GetErrorDescription(
69         LanguageId: DWORD,
70         pErrorDescription: *mut LPWSTR,
71     ) -> HRESULT,
72     fn GetErrorContextDescription(
73         LanguageId: DWORD,
74         pContextDescription: *mut LPWSTR,
75     ) -> HRESULT,
76     fn GetProtocol(
77         pProtocol: *mut LPWSTR,
78     ) -> HRESULT,
79 }}
80 STRUCT!{struct BG_FILE_INFO {
81     RemoteName: LPWSTR,
82     LocalName: LPWSTR,
83 }}
84 STRUCT!{struct BG_JOB_PROGRESS {
85     BytesTotal: UINT64,
86     BytesTransferred: UINT64,
87     FilesTotal: ULONG,
88     FilesTransferred: ULONG,
89 }}
90 STRUCT!{struct BG_JOB_TIMES {
91     CreationTime: FILETIME,
92     ModificationTime: FILETIME,
93     TransferCompletionTime: FILETIME,
94 }}
95 ENUM!{enum BG_JOB_PRIORITY {
96     BG_JOB_PRIORITY_FOREGROUND = 0,
97     BG_JOB_PRIORITY_HIGH = BG_JOB_PRIORITY_FOREGROUND + 1,
98     BG_JOB_PRIORITY_NORMAL = BG_JOB_PRIORITY_HIGH + 1,
99     BG_JOB_PRIORITY_LOW = BG_JOB_PRIORITY_NORMAL + 1,
100 }}
101 ENUM!{enum BG_JOB_STATE {
102     BG_JOB_STATE_QUEUED = 0,
103     BG_JOB_STATE_CONNECTING = BG_JOB_STATE_QUEUED + 1,
104     BG_JOB_STATE_TRANSFERRING = BG_JOB_STATE_CONNECTING + 1,
105     BG_JOB_STATE_SUSPENDED = BG_JOB_STATE_TRANSFERRING + 1,
106     BG_JOB_STATE_ERROR = BG_JOB_STATE_SUSPENDED + 1,
107     BG_JOB_STATE_TRANSIENT_ERROR = BG_JOB_STATE_ERROR + 1,
108     BG_JOB_STATE_TRANSFERRED = BG_JOB_STATE_TRANSIENT_ERROR + 1,
109     BG_JOB_STATE_ACKNOWLEDGED = BG_JOB_STATE_TRANSFERRED + 1,
110     BG_JOB_STATE_CANCELLED = BG_JOB_STATE_ACKNOWLEDGED + 1,
111 }}
112 ENUM!{enum BG_JOB_TYPE {
113     BG_JOB_TYPE_DOWNLOAD = 0,
114     BG_JOB_TYPE_UPLOAD = BG_JOB_TYPE_DOWNLOAD + 1,
115     BG_JOB_TYPE_UPLOAD_REPLY = BG_JOB_TYPE_UPLOAD + 1,
116 }}
117 ENUM!{enum BG_JOB_PROXY_USAGE {
118     BG_JOB_PROXY_USAGE_PRECONFIG = 0,
119     BG_JOB_PROXY_USAGE_NO_PROXY = BG_JOB_PROXY_USAGE_PRECONFIG + 1,
120     BG_JOB_PROXY_USAGE_OVERRIDE = BG_JOB_PROXY_USAGE_NO_PROXY + 1,
121     BG_JOB_PROXY_USAGE_AUTODETECT = BG_JOB_PROXY_USAGE_OVERRIDE + 1,
122 }}
123 RIDL!{#[uuid(0x37668d37, 0x507e, 0x4160, 0x93, 0x16, 0x26, 0x30, 0x6d, 0x15, 0x0b, 0x12)]
124 interface IBackgroundCopyJob(IBackgroundCopyJobVtbl): IUnknown(IUnknownVtbl) {
125     fn AddFileSet(
126         cFileCount: ULONG,
127         pFileSet: *mut BG_FILE_INFO,
128     ) -> HRESULT,
129     fn AddFile(
130         RemoteUrl: LPCWSTR,
131         LocalName: LPCWSTR,
132     ) -> HRESULT,
133     fn EnumFiles(
134         pErrorDescription: *mut *mut IEnumBackgroundCopyFiles,
135     ) -> HRESULT,
136     fn Suspend() -> HRESULT,
137     fn Resume() -> HRESULT,
138     fn Cancel() -> HRESULT,
139     fn Complete() -> HRESULT,
140     fn GetId(
141         pVal: *mut GUID,
142     ) -> HRESULT,
143     fn GetType(
144         pVal: *mut BG_JOB_TYPE,
145     ) -> HRESULT,
146     fn GetProgress(
147         pVal: *mut BG_JOB_PROGRESS,
148     ) -> HRESULT,
149     fn GetTimes(
150         pVal: *mut BG_JOB_TIMES,
151     ) -> HRESULT,
152     fn GetState(
153         pVal: *mut BG_JOB_STATE,
154     ) -> HRESULT,
155     fn GetError(
156         ppError: *mut *mut IBackgroundCopyError,
157     ) -> HRESULT,
158     fn GetOwner(
159         pVal: *mut LPWSTR,
160     ) -> HRESULT,
161     fn SetDisplayName(
162         Val: LPCWSTR,
163     ) -> HRESULT,
164     fn GetDisplayName(
165         pVal: *mut LPWSTR,
166     ) -> HRESULT,
167     fn SetDescription(
168         Val: LPCWSTR,
169     ) -> HRESULT,
170     fn GetDescription(
171         pVal: *mut LPWSTR,
172     ) -> HRESULT,
173     fn SetPriority(
174         Val: BG_JOB_PRIORITY,
175     ) -> HRESULT,
176     fn GetPriority(
177         pVal: *mut BG_JOB_PRIORITY,
178     ) -> HRESULT,
179     fn SetNotifyFlags(
180         Val: ULONG,
181     ) -> HRESULT,
182     fn GetNotifyFlags(
183         pVal: *mut ULONG,
184     ) -> HRESULT,
185     fn SetNotifyInterface(
186         Val: *mut IUnknown,
187     ) -> HRESULT,
188     fn GetNotifyInterface(
189         pVal: *mut *mut IUnknown,
190     ) -> HRESULT,
191     fn SetMinimumRetryDelay(
192         Seconds: ULONG,
193     ) -> HRESULT,
194     fn GetMinimumRetryDelay(
195         Seconds: *mut ULONG,
196     ) -> HRESULT,
197     fn SetNoProgressTimeout(
198         Seconds: ULONG,
199     ) -> HRESULT,
200     fn GetNoProgressTimeout(
201         Seconds: *mut ULONG,
202     ) -> HRESULT,
203     fn GetErrorCount(
204         Errors: *mut ULONG,
205     ) -> HRESULT,
206     fn SetProxySettings(
207         ProxyUsage: BG_JOB_PROXY_USAGE,
208         ProxyList: *const WCHAR,
209         ProxyBypassList: *const WCHAR,
210     ) -> HRESULT,
211     fn GetProxySettings(
212         pProxyUsage: *mut BG_JOB_PROXY_USAGE,
213         pProxyList: *mut LPWSTR,
214         pProxyBypassListpProxyList: *mut LPWSTR,
215     ) -> HRESULT,
216     fn TakeOwnership() -> HRESULT,
217 }}
218 RIDL!{#[uuid(0x1af4f612, 0x3b71, 0x466f, 0x8f, 0x58, 0x7b, 0x6f, 0x73, 0xac, 0x57, 0xad)]
219 interface IEnumBackgroundCopyJobs(IEnumBackgroundCopyJobsVtbl): IUnknown(IUnknownVtbl) {
220     fn Next(
221         celt: ULONG,
222         rgelt: *mut *mut IBackgroundCopyJob,
223         pceltFetched: *mut ULONG,
224     ) -> HRESULT,
225     fn Skip(
226         celt: ULONG,
227     ) -> HRESULT,
228     fn Reset() -> HRESULT,
229     fn Clone(
230         ppenum: *mut *mut IEnumBackgroundCopyJobs,
231     ) -> HRESULT,
232     fn GetCount(
233         puCount: *mut ULONG,
234     ) -> HRESULT,
235 }}
236 pub const BG_NOTIFY_JOB_TRANSFERRED: DWORD = 0x0001;
237 pub const BG_NOTIFY_JOB_ERROR: DWORD = 0x0002;
238 pub const BG_NOTIFY_DISABLE: DWORD = 0x0004;
239 pub const BG_NOTIFY_JOB_MODIFICATION: DWORD = 0x0008;
240 pub const BG_NOTIFY_FILE_TRANSFERRED: DWORD = 0x0010;
241 pub const BG_NOTIFY_FILE_RANGES_TRANSFERRED: DWORD = 0x0020;
242 RIDL!{#[uuid(0x97ea99c7, 0x0186, 0x4ad4, 0x8d, 0xf9, 0xc5, 0xb4, 0xe0, 0xed, 0x6b, 0x22)]
243 interface IBackgroundCopyCallback(IBackgroundCopyCallbackVtbl): IUnknown(IUnknownVtbl) {
244     fn JobTransferred(
245         pJob: *mut IBackgroundCopyJob,
246     ) -> HRESULT,
247     fn JobError(
248         pJob: *mut IBackgroundCopyJob,
249         pError: *mut IBackgroundCopyError,
250     ) -> HRESULT,
251     fn JobModification(
252         pJob: *mut IBackgroundCopyJob,
253         dwReserved: DWORD,
254     ) -> HRESULT,
255 }}
256 RIDL!{#[uuid(0xca29d251, 0xb4bb, 0x4679, 0xa3, 0xd9, 0xae, 0x80, 0x06, 0x11, 0x9d, 0x54)]
257 interface AsyncIBackgroundCopyCallback(AsyncIBackgroundCopyCallbackVtbl): IUnknown(IUnknownVtbl) {
258     fn Begin_JobTransferred(
259         pJob: *mut IBackgroundCopyJob,
260     ) -> HRESULT,
261     fn Finish_JobTransferred() -> HRESULT,
262     fn Begin_JobError(
263         pJob: *mut IBackgroundCopyJob,
264         pError: *mut IBackgroundCopyError,
265     ) -> HRESULT,
266     fn Finish_JobError() -> HRESULT,
267     fn Begin_JobModification(
268         pJob: *mut IBackgroundCopyJob,
269         dwReserved: DWORD,
270     ) -> HRESULT,
271     fn Finish_JobModification() -> HRESULT,
272 }}
273 pub const BG_JOB_ENUM_ALL_USERS: DWORD = 0x0001;
274 RIDL!{#[uuid(0x5ce34c0d, 0x0dc9, 0x4c1f, 0x89, 0x7c, 0xda, 0xa1, 0xb7, 0x8c, 0xee, 0x7c)]
275 interface IBackgroundCopyManager(IBackgroundCopyManagerVtbl): IUnknown(IUnknownVtbl) {
276     fn CreateJob(
277         DisplayName: LPCWSTR,
278         Type: BG_JOB_TYPE,
279         pJobId: *mut GUID,
280         ppJob: *mut *mut IBackgroundCopyJob,
281     ) -> HRESULT,
282     fn GetJob(
283         jobID: REFGUID,
284         ppJob: *mut *mut IBackgroundCopyJob,
285     ) -> HRESULT,
286     fn EnumJobs(
287         dwFlags: DWORD,
288         ppEnum: *mut *mut IEnumBackgroundCopyJobs,
289     ) -> HRESULT,
290     fn GetErrorDescription(
291         hResult: HRESULT,
292         LanguageId: DWORD,
293         pErrorDescription: *mut LPWSTR,
294     ) -> HRESULT,
295 }}
296