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 INTERACTION_MANAGER_IMPL_H 17 #define INTERACTION_MANAGER_IMPL_H 18 19 #include <mutex> 20 21 #include "client.h" 22 #include "coordination_manager_impl.h" 23 #include "drag_data.h" 24 #include "drag_manager_impl.h" 25 #include "interaction_manager.h" 26 #include "singleton.h" 27 28 namespace OHOS { 29 namespace Msdp { 30 namespace DeviceStatus { 31 class InteractionManagerImpl { 32 DECLARE_SINGLETON(InteractionManagerImpl); 33 using CooperateMsgInfoCallback = std::function<void(const std::string&, const CoordinationMsgInfo&)>; 34 public: 35 DISALLOW_MOVE(InteractionManagerImpl); 36 bool InitClient(); 37 int32_t RegisterCoordinationListener( 38 std::shared_ptr<ICoordinationListener> listener, bool isCompatible = false); 39 int32_t UnregisterCoordinationListener( 40 std::shared_ptr<ICoordinationListener> listener, bool isCompatible = false); 41 int32_t PrepareCoordination(CooperateMsgInfoCallback callback, bool isCompatible = false); 42 int32_t UnprepareCoordination(CooperateMsgInfoCallback callback, bool isCompatible = false); 43 int32_t ActivateCoordination(const std::string &remoteNetworkId, int32_t startDeviceId, 44 CooperateMsgInfoCallback callback, bool isCompatible = false); 45 int32_t DeactivateCoordination(bool isUnchained, CooperateMsgInfoCallback callback, bool isCompatible = false); 46 int32_t GetCoordinationState(const std::string &networkId, std::function<void(bool)> callback, 47 bool isCompatible = false); 48 int32_t GetCoordinationState(const std::string &udId, bool &state); 49 int32_t UpdateDragStyle(DragCursorStyle style); 50 int32_t StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener); 51 int32_t StopDrag(const DragDropResult &dropResult); 52 int32_t GetDragTargetPid(); 53 int32_t GetUdKey(std::string &udKey); 54 int32_t AddDraglistener(DragListenerPtr listener); 55 int32_t RemoveDraglistener(DragListenerPtr listener); 56 int32_t AddSubscriptListener(SubscriptListenerPtr listener); 57 int32_t RemoveSubscriptListener(SubscriptListenerPtr listener); 58 int32_t SetDragWindowVisible(bool visible, bool isForce = false); 59 int32_t GetShadowOffset(ShadowOffset &shadowOffset); 60 int32_t UpdateShadowPic(const ShadowInfo &shadowInfo); 61 int32_t GetDragData(DragData &dragData); 62 int32_t GetDragState(DragState &dragState); 63 int32_t AddHotAreaListener(std::shared_ptr<IHotAreaListener> listener); 64 int32_t RemoveHotAreaListener(std::shared_ptr<IHotAreaListener> listener = nullptr); 65 int32_t UpdatePreviewStyle(const PreviewStyle &previewStyle); 66 int32_t UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle, const PreviewAnimation &animation); 67 int32_t GetDragSummary(std::map<std::string, int64_t> &summarys); 68 int32_t EnterTextEditorArea(bool enable); 69 int32_t GetDragAction(DragAction &dragAction); 70 int32_t GetExtraInfo(std::string &extraInfo); 71 int32_t AddPrivilege(); 72 int32_t EraseMouseIcon(); 73 74 private: 75 void InitMsgHandler(); 76 private: 77 std::mutex mutex_; 78 IClientPtr client_ { nullptr }; 79 DragManagerImpl dragManagerImpl_; 80 CoordinationManagerImpl coordinationManagerImpl_; 81 }; 82 } // namespace DeviceStatus 83 } // namespace Msdp 84 } // namespace OHOS 85 86 #define INTER_MGR_IMPL OHOS::Singleton<InteractionManagerImpl>::GetInstance() 87 88 #endif // INTERACTION_MANAGER_IMPL_H 89