• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 JS_COORDINATION_MANAGER_H
17 #define JS_COORDINATION_MANAGER_H
18 
19 #include <mutex>
20 #include <string>
21 
22 #include "js_event_target.h"
23 
24 namespace OHOS {
25 namespace Msdp {
26 namespace DeviceStatus {
27 class JsCoordinationManager : public JsEventTarget {
28 public:
29     JsCoordinationManager() = default;
30     DISALLOW_COPY_AND_MOVE(JsCoordinationManager);
31     ~JsCoordinationManager() = default;
32 
33     napi_value Prepare(napi_env env, bool isCompatible, napi_value handle = nullptr);
34     napi_value Unprepare(napi_env env, bool isCompatible, napi_value handle = nullptr);
35     napi_value Activate(napi_env env, const std::string &remoteNetworkDescriptor,
36         int32_t startDeviceId, bool isCompatible, napi_value handle = nullptr);
37     napi_value ActivateCooperateWithOptions(napi_env env, const std::string &remoteNetworkDescriptor,
38         int32_t startDeviceId, const CooperateOptions &cooperateOptions, napi_value handle = nullptr);
39     napi_value Deactivate(napi_env env, bool isUnchained, bool isCompatible, napi_value handle = nullptr);
40     napi_value GetCrossingSwitchState(napi_env env, const std::string &networkId,
41         bool isCompatible, napi_value handle = nullptr);
42     void ResetEnv();
43     void RegisterListener(napi_env env, const std::string &type, napi_value handle);
44     void UnregisterListener(napi_env env, const std::string &type, napi_value handle = nullptr);
45     void RegisterListener(napi_env env, const std::string &type, const std::string &networkId, napi_value handle);
46     void UnregisterListener(napi_env env, const std::string &type, const std::string &networkId,
47         napi_value handle = nullptr);
48 };
49 } // namespace DeviceStatus
50 } // namespace Msdp
51 } // namespace OHOS
52 #endif // JS_COORDINATION_MANAGER_H
53