1 /* 2 * Copyright (c) 2023-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 COOPERATE_SERVER_H 17 #define COOPERATE_SERVER_H 18 19 #include "nocopyable.h" 20 21 #include "i_context.h" 22 #include "i_plugin.h" 23 24 namespace OHOS { 25 namespace Msdp { 26 namespace DeviceStatus { 27 class CooperateServer final { 28 public: 29 CooperateServer(IContext *context); 30 ~CooperateServer() = default; 31 DISALLOW_COPY_AND_MOVE(CooperateServer); 32 33 int32_t EnableCooperate(CallingContext &context, int32_t userData); 34 int32_t DisableCooperate(CallingContext &context, int32_t userData); 35 int32_t StartCooperate(CallingContext &context, const std::string& remoteNetworkId, int32_t userData, 36 int32_t startDeviceId, bool checkPermission); 37 int32_t StartCooperateWithOptions(CallingContext &context, const std::string& remoteNetworkId, 38 int32_t userData, int32_t startDeviceId, CooperateOptions options); 39 int32_t StopCooperate(CallingContext &context, int32_t userData, bool isUnchained, bool checkPermission); 40 int32_t RegisterCooperateListener(CallingContext &context); 41 int32_t UnregisterCooperateListener(CallingContext &context); 42 int32_t RegisterHotAreaListener(CallingContext &context, int32_t userData, bool checkPermission); 43 int32_t UnregisterHotAreaListener(CallingContext &context); 44 int32_t RegisterMouseEventListener(CallingContext &context, const std::string& networkId); 45 int32_t UnregisterMouseEventListener(CallingContext &context, const std::string& networkId); 46 int32_t GetCooperateStateSync(CallingContext &context, const std::string& udid, bool& state); 47 int32_t GetCooperateStateAsync(CallingContext &context, const std::string& networkId, int32_t userData, 48 bool isCheckPermission); 49 int32_t SetDamplingCoefficient(CallingContext &context, uint32_t direction, double coefficient); 50 private: 51 bool CheckCooperatePermission(CallingContext &context); 52 bool IsSystemServiceCalling(CallingContext &context); 53 bool IsSystemCalling(CallingContext &context); 54 int32_t CheckPermission(CallingContext &context); 55 private: 56 IContext *context_ { nullptr }; 57 int32_t unloadTimerId_ { -1 }; 58 }; 59 } // namespace DeviceStatus 60 } // namespace Msdp 61 } // namespace OHOS 62 #endif // COOPERATE_SERVER_H