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 class ICooperateObserver { 41 public: 42 ICooperateObserver() = default; 43 virtual ~ICooperateObserver() = default; 44 45 virtual bool IsAllowCooperate() = 0; 46 virtual void OnStartCooperate(StartCooperateData &data) = 0; 47 virtual void OnRemoteStartCooperate(RemoteStartCooperateData &data) = 0; 48 virtual void OnTransitionOut(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) = 0; 49 virtual void OnTransitionIn(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) = 0; 50 virtual void OnBack(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) = 0; 51 virtual void OnRelay(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) = 0; 52 virtual void OnReset() = 0; CloseDistributedFileConnection(const std::string & remoteNetworkId)53 virtual void CloseDistributedFileConnection(const std::string &remoteNetworkId) {} 54 }; 55 56 class ICooperate { 57 public: 58 ICooperate() = default; 59 virtual ~ICooperate() = default; 60 61 virtual void AddObserver(std::shared_ptr<ICooperateObserver> observer) = 0; 62 virtual void RemoveObserver(std::shared_ptr<ICooperateObserver> observer) = 0; 63 64 virtual int32_t RegisterListener(int32_t pid) = 0; 65 virtual int32_t UnregisterListener(int32_t pid) = 0; 66 virtual int32_t RegisterHotAreaListener(int32_t pid) = 0; 67 virtual int32_t UnregisterHotAreaListener(int32_t pid) = 0; 68 69 virtual int32_t Enable(int32_t tokenId, int32_t pid, int32_t userData) = 0; 70 virtual int32_t Disable(int32_t pid, int32_t userData) = 0; 71 virtual int32_t Start(int32_t pid, int32_t userData, 72 const std::string &remoteNetworkId, int32_t startDeviceId) = 0; 73 virtual int32_t Stop(int32_t pid, int32_t userData, bool isUnchained) = 0; 74 75 virtual int32_t GetCooperateState(int32_t pid, int32_t userData, const std::string &networkId) = 0; 76 virtual int32_t Update(uint32_t mask, uint32_t flag) = 0; 77 78 virtual int32_t RegisterEventListener(int32_t pid, const std::string &networkId) = 0; 79 virtual int32_t UnregisterEventListener(int32_t pid, const std::string &networkId) = 0; 80 virtual int32_t GetCooperateState(const std::string &udId, bool &state) = 0; 81 virtual void Dump(int32_t fd) = 0; 82 }; 83 } // namespace DeviceStatus 84 } // namespace Msdp 85 } // namespace OHOS 86 #endif // I_COOPERATE_H 87