• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef WEB_DOWNLOAD_FFI_H
17 #define WEB_DOWNLOAD_FFI_H
18 
19 #include <cstdint>
20 
21 #include "cj_common_ffi.h"
22 #include "ffi_remote_data.h"
23 #include "webview_utils.h"
24 
25 extern "C" {
26 // WebDownloadItemImpl
27 FFI_EXPORT int64_t FfiOHOSWebDownloadItemImplConstructor();
28 FFI_EXPORT RetDataCString FfiOHOSWebDownloadItemImplGetGuid(int64_t id);
29 FFI_EXPORT int64_t FfiOHOSWebDownloadItemImplGetCurrentSpeed(int64_t id, int32_t* errCode);
30 FFI_EXPORT int64_t FfiOHOSWebDownloadItemImplGetPercentComplete(int64_t id, int32_t* errCode);
31 FFI_EXPORT int64_t FfiOHOSWebDownloadItemImplGetTotalBytes(int64_t id, int32_t* errCode);
32 FFI_EXPORT int64_t FfiOHOSWebDownloadItemImplGetReceivedBytes(int64_t id, int32_t* errCode);
33 FFI_EXPORT int32_t FfiOHOSWebDownloadItemImplGetState(int64_t id, int32_t* errCode);
34 FFI_EXPORT int32_t FfiOHOSWebDownloadItemImplGetLastErrorCode(int64_t id, int32_t* errCode);
35 FFI_EXPORT RetDataCString FfiOHOSWebDownloadItemImplGetMethod(int64_t id);
36 FFI_EXPORT RetDataCString FfiOHOSWebDownloadItemImplGetMimeType(int64_t id);
37 FFI_EXPORT RetDataCString FfiOHOSWebDownloadItemImplGetUrl(int64_t id);
38 FFI_EXPORT RetDataCString FfiOHOSWebDownloadItemImplGetSuggestedFileName(int64_t id);
39 FFI_EXPORT RetDataCString FfiOHOSWebDownloadItemImplGetFullPath(int64_t id);
40 FFI_EXPORT int32_t FfiOHOSWebDownloadItemImplStart(int64_t id, char* downloadPath);
41 FFI_EXPORT int32_t FfiOHOSWebDownloadItemImplCancel(int64_t id);
42 FFI_EXPORT int32_t FfiOHOSWebDownloadItemImplPause(int64_t id);
43 FFI_EXPORT int32_t FfiOHOSWebDownloadItemImplResume(int64_t id);
44 FFI_EXPORT CArrUI8 FfiOHOSWebDownloadItemImplSerialize(int64_t id, int32_t* errCode);
45 FFI_EXPORT int64_t FfiOHOSWebDownloadItemImplDeserialize(CArrUI8 serializedData, int32_t* errCode);
46 
47 // WebDownloadDelegateImpl
48 FFI_EXPORT int64_t FfiOHOSWebDownloadDelegateImplConstructor();
49 FFI_EXPORT void FfiOHOSWebDownloadDelegateImplOnBeforeDownload(int64_t id, void (*callback)(int64_t));
50 FFI_EXPORT void FfiOHOSWebDownloadDelegateImplOnDownloadUpdated(int64_t id, void (*callback)(int64_t));
51 FFI_EXPORT void FfiOHOSWebDownloadDelegateImplOnDownloadFinish(int64_t id, void (*callback)(int64_t));
52 FFI_EXPORT void FfiOHOSWebDownloadDelegateImplOnDownloadFailed(int64_t id, void (*callback)(int64_t));
53 
54 // WebDownloadManagerImpl
55 FFI_EXPORT void FfiOHOSWebDownloadManagerImplSetDownloadDelegate(int64_t delegateId);
56 FFI_EXPORT int32_t FfiOHOSWebDownloadManagerImplResumeDownload(int64_t itemId);
57 }
58 
59 #endif // WEB_DOWNLOAD_FFI_H