• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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 OHOS_FILEMGMT_CLOUD_FILE_NAPI_H
17 #define OHOS_FILEMGMT_CLOUD_FILE_NAPI_H
18 
19 #include <memory>
20 
21 #include "download_callback_middle_napi.h"
22 #include "download_progress_napi.h"
23 #include "filemgmt_libn.h"
24 
25 namespace OHOS::FileManagement::CloudSync {
26 class CloudFileDownloadNapi : public LibN::NExporter {
27 public:
CloudFileDownloadNapi(napi_env env,napi_value exports)28     CloudFileDownloadNapi(napi_env env, napi_value exports) : NExporter(env, exports) {}
29     ~CloudFileDownloadNapi() = default;
30 
31     bool Export() override;
32     bool ToExport(std::vector<napi_property_descriptor> props);
33     virtual void SetClassName(std::string classname);
34     std::string GetClassName() override;
35     static napi_value Constructor(napi_env env, napi_callback_info info);
36     static napi_value Start(napi_env env, napi_callback_info info);
37     static napi_value On(napi_env env, napi_callback_info info);
38     static napi_value Off(napi_env env, napi_callback_info info);
39     static napi_value Stop(napi_env env, napi_callback_info info);
40 
41 private:
42     inline static std::string className_ = "Download";
43 };
44 
45 class CloudDownloadCallbackImplNapi : public CloudDlCallbackMiddleNapi {
46 public:
CloudDownloadCallbackImplNapi(napi_env env)47     explicit CloudDownloadCallbackImplNapi(napi_env env) : CloudDlCallbackMiddleNapi(env) {}
48     int32_t StartDownloadInner(const std::string &uri);
49     int32_t StopDownloadInner(const std::string &uri);
50 };
51 
52 struct DownloadEntity {
53     std::shared_ptr<CloudDownloadCallbackImplNapi> callbackImpl{nullptr};
54 };
55 
56 } // namespace OHOS::FileManagement::CloudSync
57 #endif // OHOS_FILEMGMT_CLOUD_FILE_NAPI_H