• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2023 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 CLOUD_DATA_JS_CONFIG_H
17 #define CLOUD_DATA_JS_CONFIG_H
18 
19 #include "cloud_manager.h"
20 #include "js_const_properties.h"
21 
22 namespace OHOS::CloudData {
23 class JsConfig {
24 public:
25     JsConfig();
26     ~JsConfig();
27     static napi_value InitConfig(napi_env env, napi_value exports);
28     static napi_value New(napi_env env, napi_callback_info info);
29 
30     enum {
31         /* exported js ClearAction  is (CloudData::ClearAction-1) */
32         CLEAR_CLOUD_INFO = 0,
33         CLEAR_CLOUD_DATA_AND_INFO = 1,
34     };
35 
36     struct ExtraData {
37         std::string eventId;
38         std::string extraData;
39     };
40 
ValidSubscribeType(int32_t type)41     static inline bool ValidSubscribeType(int32_t type)
42     {
43         return (CLEAR_CLOUD_INFO <= type) && (type <= CLEAR_CLOUD_DATA_AND_INFO);
44     }
45 
VerifyExtraData(const ExtraData & data)46     static inline bool VerifyExtraData(const ExtraData &data)
47     {
48         return (!data.eventId.empty()) && (!data.extraData.empty());
49     }
50 
51     static napi_value EnableCloud(napi_env env, napi_callback_info info);
52     static napi_value DisableCloud(napi_env env, napi_callback_info info);
53     static napi_value ChangeAppCloudSwitch(napi_env env, napi_callback_info info);
54     static napi_value Clean(napi_env env, napi_callback_info info);
55     static napi_value NotifyDataChange(napi_env env, napi_callback_info info);
56     static napi_value QueryStatistics(napi_env env, napi_callback_info info);
57     static napi_value SetGlobalCloudStrategy(napi_env env, napi_callback_info info);
58     static napi_value QueryLastSyncInfo(napi_env env, napi_callback_info info);
59 };
60 
61 } // namespace OHOS::CloudData
62 #endif //CLOUD_DATA_JS_CONFIG_H