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 INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_CLOUD_ENHANCEMENT_TASK_STATE_NAPI_H
17 #define INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_CLOUD_ENHANCEMENT_TASK_STATE_NAPI_H
18 
19 #include <memory>
20 
21 #include "cloud_enhancement_napi.h"
22 #include "media_asset_data_handler.h"
23 #include "media_asset_manager_napi.h"
24 #include "media_library_napi.h"
25 #include "userfile_manager_types.h"
26 
27 namespace OHOS {
28 namespace Media {
29 
30 class CloudEnhancementTaskStateNapi {
31 public:
32     CloudEnhancementTaskStateNapi() = default;
33     ~CloudEnhancementTaskStateNapi() = default;
34     static napi_value NewCloudEnhancementTaskStateNapi(napi_env env, CloudEnhancementAsyncContext* context);
35     EXPORT static napi_value Init(napi_env env, napi_value exports);
36 
37 private:
38     EXPORT static napi_value Constructor(napi_env env, napi_callback_info info);
39     EXPORT static void Destructor(napi_env env, void* nativeObject, void* finalizeHint);
40 
41     EXPORT static napi_value JSGetTaskStage(napi_env env, napi_callback_info info);
42     EXPORT static napi_value JSGetTransferredFileSize(napi_env env, napi_callback_info info);
43     EXPORT static napi_value JSGetTotalFileSize(napi_env env, napi_callback_info info);
44     EXPORT static napi_value JSGetExpectedDuration(napi_env env, napi_callback_info info);
45     EXPORT static napi_value JSGetStatusCode(napi_env env, napi_callback_info info);
46 
47     CloudEnhancementTaskStage GetCloudEnhancementTaskStage() const;
48     void SetCloudEnhancementTaskStage(CloudEnhancementTaskStage cloudEnhancementTaskStage);
49 
50     int32_t GetTransferredFileSize() const;
51     void SetTransferredFileSize(int32_t transferredFileSize);
52 
53     int32_t GetTotalFileSize() const;
54     void SetTotalFileSize(int32_t totalFileSize);
55 
56     int32_t GetExpectedDuration() const;
57     void SetExpectedDuration(int32_t expectedDuration);
58 
59     int32_t GetStatusCode() const;
60     void SetStatusCode(int32_t statusCode);
61 
62     static thread_local napi_ref constructor_;
63     CloudEnhancementTaskStage cloudEnhancementTaskStage_ = CloudEnhancementTaskStage::TASK_STAGE_EXCEPTION;
64     static const int32_t UNDEFINED = -1;
65     int32_t transferredFileSize_ {UNDEFINED};
66     int32_t totalFileSize_ {UNDEFINED};
67     int32_t expectedDuration_ {UNDEFINED};
68     int32_t statusCode_ {UNDEFINED};
69 };
70 
71 } // Media
72 } // OHOS
73 #endif // INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_CLOUD_ENHANCEMENT_TASK_STATE_NAPI_H
74