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 JS_COOPERATE_MANAGER_H 17 #define JS_COOPERATE_MANAGER_H 18 19 #include <mutex> 20 #include <string> 21 22 #include "js_event_cooperate_target.h" 23 24 namespace OHOS { 25 namespace Msdp { 26 namespace DeviceStatus { 27 class JsCooperateManager : public JsEventCooperateTarget { 28 public: 29 JsCooperateManager() = default; 30 DISALLOW_COPY_AND_MOVE(JsCooperateManager); 31 ~JsCooperateManager() = default; 32 33 napi_value Enable(napi_env env, bool enable, napi_value handle = nullptr); 34 napi_value Start(napi_env env, const std::string &remoteNetworkDescriptor, int32_t startDeviceId, 35 napi_value handle = nullptr); 36 napi_value Stop(napi_env env, napi_value handle = nullptr); 37 napi_value GetState(napi_env env, const std::string &deviceDescriptor, napi_value handle = nullptr); 38 void RegisterListener(napi_env env, const std::string &type, napi_value handle); 39 void UnregisterListener(napi_env env, const std::string &type, napi_value handle = nullptr); 40 void ResetEnv(); 41 42 private: 43 std::mutex mutex_; 44 }; 45 } // namespace DeviceStatus 46 } // namespace Msdp 47 } // namespace OHOS 48 #endif // JS_COOPERATE_MANAGER_H 49