jwabits.pas 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. {******************************************************************************}
  2. { }
  3. { Background Intelligent Transfer Service API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: bits.h, released August 2001. The original Pascal }
  9. { code is: Bits.pas, released October 2001. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. // $Id: JwaBits.pas,v 1.7 2005/09/03 14:27:47 marquardt Exp $
  43. unit JwaBits;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "bits.h"'}
  47. {$HPPEMIT ''}
  48. {$I jediapilib.inc}
  49. interface
  50. uses
  51. JwaWindows, JwaBitsMsg;
  52. const
  53. BG_SIZE_UNKNOWN = Int64(-1);
  54. {$EXTERNALSYM BG_SIZE_UNKNOWN}
  55. //
  56. // =============================
  57. // Marshalled interfaces
  58. // =============================
  59. type
  60. _BG_FILE_PROGRESS = record
  61. BytesTotal: UINT64;
  62. BytesTransferred: UINT64;
  63. Completed: BOOL;
  64. end;
  65. {$EXTERNALSYM _BG_FILE_PROGRESS}
  66. BG_FILE_PROGRESS = _BG_FILE_PROGRESS;
  67. {$EXTERNALSYM BG_FILE_PROGRESS}
  68. TBgFileProgress = BG_FILE_PROGRESS;
  69. PBgFileProgress = ^BG_FILE_PROGRESS;
  70. const
  71. IID_IBackgroundCopyFile: TGUID = '{01B7BD23-FB88-4A77-8490-5891D3E4653A}';
  72. {$EXTERNALSYM IID_IBackgroundCopyFile}
  73. type
  74. IBackgroundCopyFile = interface(IUnknown)
  75. ['{01b7bd23-fb88-4a77-8490-5891d3e4653a}']
  76. function GetRemoteName(out pVal: LPWSTR): HRESULT; stdcall;
  77. function GetLocalName(out pVal: LPWSTR): HRESULT; stdcall;
  78. function GetProgress(out pVal: BG_FILE_PROGRESS): HRESULT; stdcall;
  79. end;
  80. {$EXTERNALSYM IBackgroundCopyFile}
  81. //--------------------------------------------------------------------
  82. //
  83. const
  84. IID_IEnumBackgroundCopyFiles: TGUID = '{CA51E165-C365-424C-8D41-24AAA4FF3C40}';
  85. {$EXTERNALSYM IID_IEnumBackgroundCopyFiles}
  86. type
  87. IEnumBackgroundCopyFiles = interface(IUnknown)
  88. ['{ca51e165-c365-424c-8d41-24aaa4ff3c40}']
  89. function Next(celt: ULONG; out rgelt: IBackgroundCopyFile; pceltFetched: PULONG): HRESULT; stdcall;
  90. function Skip(celt: ULONG): HRESULT; stdcall;
  91. function Reset: HRESULT; stdcall;
  92. function Clone(out ppenum: IEnumBackgroundCopyFiles): HRESULT; stdcall;
  93. function GetCount(out puCount: ULONG): HRESULT; stdcall;
  94. end;
  95. {$EXTERNALSYM IEnumBackgroundCopyFiles}
  96. //--------------------------------------------------------------------
  97. //
  98. type
  99. BG_ERROR_CONTEXT = (
  100. BG_ERROR_CONTEXT_NONE,
  101. BG_ERROR_CONTEXT_UNKNOWN,
  102. BG_ERROR_CONTEXT_GENERAL_QUEUE_MANAGER,
  103. BG_ERROR_CONTEXT_QUEUE_MANAGER_NOTIFICATION,
  104. BG_ERROR_CONTEXT_LOCAL_FILE,
  105. BG_ERROR_CONTEXT_REMOTE_FILE,
  106. BG_ERROR_CONTEXT_GENERAL_TRANSPORT,
  107. BG_ERROR_CONTEXT_REMOTE_APPLICATION);
  108. {$EXTERNALSYM BG_ERROR_CONTEXT}
  109. TBgErrorContext = BG_ERROR_CONTEXT;
  110. const
  111. IID_IBackgroundCopyError: TGUID = '{19C613A0-FCB8-4F28-81AE-897C3D078F81}';
  112. {$EXTERNALSYM IID_IBackgroundCopyError}
  113. type
  114. IBackgroundCopyError = interface(IUnknown)
  115. ['{19c613a0-fcb8-4f28-81ae-897c3d078f81}']
  116. function GetError(out pContext: BG_ERROR_CONTEXT; out pCode: HRESULT): HRESULT; stdcall;
  117. // Returns BG_E_FILE_NOT_AVAILABLE if no file is available
  118. function GetFile(out ppVal: IBackgroundCopyFile): HRESULT; stdcall;
  119. // Return a human readable description of the error.
  120. // Use CoTaskMemFree to free the description.
  121. function GetErrorDescription(LanguageId: DWORD; out pErrorDescription: LPWSTR): HRESULT; stdcall;
  122. // Return a human readable description of the error context.
  123. // Use CoTaskMemFree to free the description.
  124. function GetErrorContextDescription(LanguageId: DWORD; out pContextDescription: LPWSTR): HRESULT; stdcall;
  125. // Returns BG_E_PROTOCOL_NOT_AVAILABLE if no protocol is available
  126. function GetProtocol(out pProtocol: LPWSTR): HRESULT; stdcall;
  127. end;
  128. {$EXTERNALSYM IBackgroundCopyError}
  129. // ==============================================
  130. // Job Interface
  131. type
  132. _BG_FILE_INFO = record
  133. RemoteName: LPWSTR;
  134. LocalName: LPWSTR;
  135. end;
  136. {$EXTERNALSYM _BG_FILE_INFO}
  137. BG_FILE_INFO = _BG_FILE_INFO;
  138. {$EXTERNALSYM BG_FILE_INFO}
  139. TBgFileInfo = BG_FILE_INFO;
  140. PBgFileInfo = ^BG_FILE_INFO;
  141. _BG_JOB_PROGRESS = record
  142. BytesTotal: UINT64;
  143. BytesTransferred: UINT64;
  144. FilesTotal: ULONG;
  145. FilesTransferred: ULONG;
  146. end;
  147. {$EXTERNALSYM _BG_JOB_PROGRESS}
  148. BG_JOB_PROGRESS = _BG_JOB_PROGRESS;
  149. {$EXTERNALSYM BG_JOB_PROGRESS}
  150. TBgJobProgress = BG_JOB_PROGRESS;
  151. PBgJobProgress = ^BG_JOB_PROGRESS;
  152. _BG_JOB_TIMES = record
  153. CreationTime: FILETIME;
  154. ModificationTime: FILETIME;
  155. TransferCompletionTime: FILETIME;
  156. end;
  157. {$EXTERNALSYM _BG_JOB_TIMES}
  158. BG_JOB_TIMES = _BG_JOB_TIMES;
  159. {$EXTERNALSYM BG_JOB_TIMES}
  160. TBgJobTimes = BG_JOB_TIMES;
  161. PBgJobTimes = ^BG_JOB_TIMES;
  162. BG_JOB_PRIORITY = (
  163. BG_JOB_PRIORITY_FOREGROUND,
  164. BG_JOB_PRIORITY_HIGH,
  165. BG_JOB_PRIORITY_NORMAL,
  166. BG_JOB_PRIORITY_LOW);
  167. {$EXTERNALSYM BG_JOB_PRIORITY}
  168. TBgJobPriority = BG_JOB_PRIORITY;
  169. PBgJobPriority = ^BG_JOB_PRIORITY;
  170. BG_JOB_STATE = (
  171. BG_JOB_STATE_QUEUED,
  172. BG_JOB_STATE_CONNECTING,
  173. BG_JOB_STATE_TRANSFERRING,
  174. BG_JOB_STATE_SUSPENDED,
  175. BG_JOB_STATE_ERROR,
  176. BG_JOB_STATE_TRANSIENT_ERROR,
  177. BG_JOB_STATE_TRANSFERRED,
  178. BG_JOB_STATE_ACKNOWLEDGED,
  179. BG_JOB_STATE_CANCELLED);
  180. {$EXTERNALSYM BG_JOB_STATE}
  181. TBgJobState = BG_JOB_STATE;
  182. PBgJobState = ^BG_JOB_STATE;
  183. BG_JOB_TYPE = (
  184. BG_JOB_TYPE_DOWNLOAD,
  185. BG_JOB_TYPE_UPLOAD,
  186. BG_JOB_TYPE_UPLOAD_REPLY);
  187. {$EXTERNALSYM BG_JOB_TYPE}
  188. TBgJobType = BG_JOB_TYPE;
  189. BG_JOB_PROXY_USAGE = (
  190. BG_JOB_PROXY_USAGE_PRECONFIG,
  191. BG_JOB_PROXY_USAGE_NO_PROXY,
  192. BG_JOB_PROXY_USAGE_OVERRIDE);
  193. {$EXTERNALSYM BG_JOB_PROXY_USAGE}
  194. TBgJobProxyUsage = BG_JOB_PROXY_USAGE;
  195. PBgJobProxyUsage = ^BG_JOB_PROXY_USAGE;
  196. const
  197. IID_IBackgroundCopyJob: TGUID = '{37668D37-507E-4160-9316-26306D150B12}';
  198. {$EXTERNALSYM IID_IBackgroundCopyJob}
  199. type
  200. IBackgroundCopyJob = interface(IUnknown)
  201. ['{37668d37-507e-4160-9316-26306d150b12}']
  202. //--------------------------------------------------------------------
  203. //
  204. // Returns E_INVALIDARG if one of the filesets has
  205. // - local name is blank
  206. // - local name contains invalid characters
  207. // - remote name is blank
  208. // - remote name has invalid format
  209. //
  210. // Returns CO_E_NOT_SUPPORTED if
  211. // - remote URL contains unsupported protocol
  212. //
  213. function AddFileSet(cFileCount: ULONG; pFileSet: PBgFileInfo): HRESULT; stdcall;
  214. function AddFile(RemoteUrl, LocalName: LPCWSTR): HRESULT; stdcall;
  215. //
  216. // Gets an enumerator object for all files in the job.
  217. //
  218. function EnumFiles(out pEnum: IEnumBackgroundCopyFiles): HRESULT; stdcall;
  219. //
  220. // Pause all activity on the job. The service will take no action until one of
  221. // Resume(), Cancel(), Complete() is called.
  222. //
  223. // if already suspended, just returns S_OK.
  224. //
  225. function Suspend: HRESULT; stdcall;
  226. //
  227. // Enable downloading for this job. Job properties cannot be modified
  228. // after Resume() until the app calls Suspend().
  229. //
  230. // if already running, just returns S_OK.
  231. //
  232. function Resume: HRESULT; stdcall;
  233. //
  234. // Permanently stop the job. The service will delete the job metadata and downloaded files.
  235. //
  236. // If already cancelled or resumed, returns ???
  237. //
  238. function Cancel: HRESULT; stdcall;
  239. //
  240. // Acknowledges receipt of the job-complete notification. The service will delete
  241. // the job metadata and leave the downloaded files.
  242. //
  243. function Complete: HRESULT; stdcall;
  244. //--------------------------------------------------------------------
  245. function GetId(out pVal: GUID): HRESULT; stdcall;
  246. function GetType(out pVal: BG_JOB_TYPE): HRESULT; stdcall;
  247. function GetProgress(out pVal: BG_JOB_PROGRESS): HRESULT; stdcall;
  248. function GetTimes(out pVal: BG_JOB_TIMES): HRESULT; stdcall;
  249. function GetState(out pVal: BG_JOB_STATE): HRESULT; stdcall;
  250. function GetError(out ppError: IBackgroundCopyError): HRESULT; stdcall;
  251. //
  252. // The owner of the job, represented as a string.
  253. // Only the owner and admins are allowed to see or change the job.
  254. //
  255. function GetOwner(out pVal: LPWSTR): HRESULT; stdcall;
  256. //
  257. // name of the job, suitable for display in UI
  258. //
  259. function SetDisplayName(Val: LPCWSTR): HRESULT; stdcall;
  260. function GetDisplayName(out pVal: LPWSTR): HRESULT; stdcall;
  261. //
  262. // a field for use by the app
  263. //
  264. function SetDescription(Val: LPCWSTR): HRESULT; stdcall;
  265. function GetDescription(out pVal: LPWSTR): HRESULT; stdcall;
  266. //
  267. // the priority of the job in the queue.
  268. // default = PRIORITY_NORMAL
  269. // values not in BG_JOB_PRIORITY return E_NOTIMPL.
  270. //
  271. function SetPriority(Val: BG_JOB_PRIORITY): HRESULT; stdcall;
  272. function GetPriority(out pVal: BG_JOB_PRIORITY): HRESULT; stdcall;
  273. //
  274. // ignores extra flags?
  275. //
  276. function SetNotifyFlags(Val: ULONG): HRESULT; stdcall;
  277. function GetNotifyFlags(out pVal: ULONG): HRESULT; stdcall;
  278. // interface pointer that implements the IBackgroundCallback interface for notifications.
  279. // If the pointer becomes invalid, the service will try to create a new notification object
  280. // with the notify CLSID.
  281. function SetNotifyInterface(Val: IUnknown): HRESULT; stdcall;
  282. function GetNotifyInterface(out pVal: IUnknown): HRESULT; stdcall;
  283. function SetMinimumRetryDelay(Seconds: ULONG): HRESULT; stdcall;
  284. function GetMinimumRetryDelay(out Seconds: ULONG): HRESULT; stdcall;
  285. function SetNoProgressTimeout(Seconds: ULONG): HRESULT; stdcall;
  286. function GetNoProgressTimeout(out Seconds: ULONG): HRESULT; stdcall;
  287. function GetErrorCount(out Errors: ULONG): HRESULT; stdcall;
  288. function SetProxySettings(ProxyUsage: BG_JOB_PROXY_USAGE; ProxyList, ProxyBypassList: PWCHAR): HRESULT; stdcall;
  289. function GetProxySettings(pProxyUsage: BG_JOB_PROXY_USAGE; pProxyList, pProxyBypassList: LPWSTR): HRESULT; stdcall;
  290. function TakeOwnership(): HRESULT; stdcall;
  291. end;
  292. {$EXTERNALSYM IBackgroundCopyJob}
  293. // ==============================================
  294. // IEnumJobs Interface
  295. // This interface allows enumerating the jobs under a Job
  296. const
  297. IID_IEnumBackgroundCopyJobs: TGUID = '{1AF4F612-3B71-466F-8F58-7B6F73AC57AD}';
  298. {$EXTERNALSYM IID_IEnumBackgroundCopyJobs}
  299. type
  300. IEnumBackgroundCopyJobs = interface(IUnknown)
  301. ['{1af4f612-3b71-466f-8f58-7b6f73ac57ad}']
  302. function Next(celt: ULONG; out rgelt: IBackgroundCopyJob; pceltFetched: PULONG): HRESULT; stdcall;
  303. function Skip(celt: ULONG): HRESULT; stdcall;
  304. function Reset: HRESULT; stdcall;
  305. function Clone(out ppenum: IEnumBackgroundCopyJobs): HRESULT; stdcall;
  306. function GetCount(out puCount: ULONG): HRESULT; stdcall;
  307. end;
  308. {$EXTERNALSYM IEnumBackgroundCopyJobs}
  309. const
  310. BG_NOTIFY_JOB_TRANSFERRED = $0001;
  311. {$EXTERNALSYM BG_NOTIFY_JOB_TRANSFERRED}
  312. BG_NOTIFY_JOB_ERROR = $0002;
  313. {$EXTERNALSYM BG_NOTIFY_JOB_ERROR}
  314. BG_NOTIFY_DISABLE = $0004;
  315. {$EXTERNALSYM BG_NOTIFY_DISABLE}
  316. BG_NOTIFY_JOB_MODIFICATION = $0008;
  317. {$EXTERNALSYM BG_NOTIFY_JOB_MODIFICATION}
  318. // ==============================================
  319. // IBackgroundCallback Interface
  320. // This interface is implemented by the client and is used by the queue manager
  321. // to supply progress information to the client.
  322. const
  323. IID_IBackgroundCopyCallback: TGUID = '{97EA99C7-0186-4AD4-8DF9-C5B4E0ED6B22}';
  324. {$EXTERNALSYM IID_IBackgroundCopyCallback}
  325. type
  326. IBackgroundCopyCallback = interface(IUnknown)
  327. ['{97ea99c7-0186-4ad4-8df9-c5b4e0ed6b22}']
  328. //
  329. // A job has transferred successfully.
  330. //
  331. function JobTransferred(pJob: IBackgroundCopyJob): HRESULT; stdcall;
  332. //
  333. // An error occurred, and the service has suspended the job.
  334. // Fix the error and resume the job.
  335. // Get error details by calling (*pFailingJob)->GetStatus().
  336. //
  337. function JobError(pJob: IBackgroundCopyJob; pError: IBackgroundCopyError): HRESULT; stdcall;
  338. //
  339. // The job has been modified. Intendended for user interfaces.
  340. //
  341. function JobModification(pJob: IBackgroundCopyJob; dwReserved: DWORD): HRESULT; stdcall;
  342. end;
  343. {$EXTERNALSYM IBackgroundCopyCallback}
  344. //
  345. // IBackgroundCopyManager is the "root" interface to the background file copy component.
  346. //
  347. const
  348. BG_JOB_ENUM_ALL_USERS = $0001;
  349. {$EXTERNALSYM BG_JOB_ENUM_ALL_USERS}
  350. IID_IBackgroundCopyManager: TGUID = '{5CE34C0D-0DC9-4C1F-897C-DAA1B78CEE7C}';
  351. {$EXTERNALSYM IID_IBackgroundCopyManager}
  352. type
  353. IBackgroundCopyManager = interface(IUnknown)
  354. ['{5ce34c0d-0dc9-4c1f-897c-daa1b78cee7c}']
  355. function CreateJob(DisplayName: LPCWSTR; Type_: BG_JOB_TYPE; out pJobId: GUID; out ppJob: IBackgroundCopyJob): HRESULT; stdcall;
  356. function GetJob(const jobID: GUID; out ppJob: IBackgroundCopyJob): HRESULT; stdcall;
  357. //
  358. // Without this flag, jobs not owned by the caller are excluded from the enumeration.
  359. // With this flag, those jobs are included. Only works if the caller is an administrator.
  360. //
  361. function EnumJobs(dwFlags: DWORD; out ppEnum: IEnumBackgroundCopyJobs): HRESULT; stdcall;
  362. function GetErrorDescription(hResult: HRESULT; LanguageId: DWORD; out pErrorDescription: LPWSTR): HRESULT; stdcall;
  363. end;
  364. {$EXTERNALSYM IBackgroundCopyManager}
  365. //---------------------------------------------------------------------------
  366. const
  367. LIBID_BackgroundCopyManager: GUID = '{4991d34b-80a1-4291-83b6-3328366b9097}';
  368. {$EXTERNALSYM LIBID_BackgroundCopyManager}
  369. CLSID_BackgroundCopyManager: GUID = '{4991d34b-80a1-4291-83b6-3328366b9097}';
  370. {$EXTERNALSYM CLSID_BackgroundCopyManager}
  371. implementation
  372. end.