jwabits.pas 16 KB

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