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 I_COOPERATE_H 17 #define I_COOPERATE_H 18 19 #include <memory> 20 #include <string> 21 22 namespace OHOS { 23 namespace Msdp { 24 namespace DeviceStatus { 25 struct Coordinate { 26 int32_t x; 27 int32_t y; 28 }; 29 using NormalizedCoordinate = Coordinate; 30 31 constexpr uint32_t COOPERATE_FLAG_HIDE_CURSOR { 0x1 }; 32 constexpr uint32_t COOPERATE_FLAG_FREEZE_CURSOR { 0x2 }; // 在穿越到对端时,不注入事件,对本端无效 33 34 struct StartCooperateData { 35 uint32_t flag; 36 uint32_t priv; 37 }; 38 using RemoteStartCooperateData = StartCooperateData; 39 40 struct CooperateOptions { 41 int32_t displayX; 42 int32_t displayY; 43 int32_t displayId; 44 }; 45 using NormalizedCooperateOptions = CooperateOptions; 46 47 class ICooperateObserver { 48 public: 49 ICooperateObserver() = default; 50 virtual ~ICooperateObserver() = default; 51 52 virtual bool IsAllowCooperate() = 0; 53 virtual void OnStartCooperate(StartCooperateData &data) = 0; 54 virtual void OnRemoteStartCooperate(RemoteStartCooperateData &data) = 0; 55 virtual void OnStopCooperate(const std::string &remoteNetworkId) = 0; 56 virtual void OnTransitionOut(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) = 0; 57 virtual void OnTransitionIn(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) = 0; 58 virtual void OnBack(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) = 0; 59 virtual void OnRelay(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) = 0; 60 virtual void OnReset() = 0; CloseDistributedFileConnection(const std::string & remoteNetworkId)61 virtual void CloseDistributedFileConnection(const std::string &remoteNetworkId) {} 62 }; 63 64 class ICooperate { 65 public: 66 ICooperate() = default; 67 virtual ~ICooperate() = default; 68 69 virtual void AddObserver(std::shared_ptr<ICooperateObserver> observer) = 0; 70 virtual void RemoveObserver(std::shared_ptr<ICooperateObserver> observer) = 0; 71 72 virtual int32_t RegisterListener(int32_t pid) = 0; 73 virtual int32_t UnregisterListener(int32_t pid) = 0; 74 virtual int32_t RegisterHotAreaListener(int32_t pid) = 0; 75 virtual int32_t UnregisterHotAreaListener(int32_t pid) = 0; 76 77 virtual int32_t Enable(int32_t tokenId, int32_t pid, int32_t userData) = 0; 78 virtual int32_t Disable(int32_t pid, int32_t userData) = 0; 79 virtual int32_t Start(int32_t pid, int32_t userData, 80 const std::string &remoteNetworkId, int32_t startDeviceId) = 0; 81 virtual int32_t Stop(int32_t pid, int32_t userData, bool isUnchained) = 0; 82 virtual int32_t StartWithOptions(int32_t pid, int32_t userData, const std::string &remoteNetworkId, 83 int32_t startDeviceId, const NormalizedCooperateOptions &CooperateOptions) = 0; 84 85 virtual int32_t GetCooperateState(int32_t pid, int32_t userData, const std::string &networkId) = 0; 86 virtual int32_t Update(uint32_t mask, uint32_t flag) = 0; 87 88 virtual int32_t RegisterEventListener(int32_t pid, const std::string &networkId) = 0; 89 virtual int32_t UnregisterEventListener(int32_t pid, const std::string &networkId) = 0; 90 virtual int32_t GetCooperateState(const std::string &udId, bool &state) = 0; 91 virtual int32_t SetDamplingCoefficient(uint32_t direction, double coefficient) = 0; 92 virtual void Dump(int32_t fd) = 0; 93 }; 94 } // namespace DeviceStatus 95 } // namespace Msdp 96 } // namespace OHOS 97 #endif // I_COOPERATE_H 98