1 /* 2 * Copyright (c) 2023-2025 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 INTENTION_DRAG_CLIENT_H 17 #define INTENTION_DRAG_CLIENT_H 18 19 #include "nocopyable.h" 20 21 #include <set> 22 23 #include "transaction/rs_transaction.h" 24 25 #include "i_drag_listener.h" 26 #include "i_hotarea_listener.h" 27 #include "i_subscript_listener.h" 28 #include "i_start_drag_listener.h" 29 #include "socket_client.h" 30 31 namespace OHOS { 32 namespace Msdp { 33 namespace DeviceStatus { 34 class DragClient final { 35 public: 36 DragClient() = default; 37 ~DragClient() = default; 38 DISALLOW_COPY_AND_MOVE(DragClient); 39 int32_t StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener); 40 int32_t StopDrag(const DragDropResult &dropResult); 41 int32_t AddDraglistener(DragListenerPtr listener, bool isJsCaller = false); 42 int32_t RemoveDraglistener(DragListenerPtr listener, bool isJsCaller = false); 43 int32_t AddSubscriptListener(SubscriptListenerPtr listener); 44 int32_t RemoveSubscriptListener(SubscriptListenerPtr listener); 45 int32_t SetDragWindowVisible(bool visible, bool isForce, 46 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr); 47 int32_t UpdateDragStyle(DragCursorStyle style, int32_t eventId = -1); 48 int32_t UpdateShadowPic(const ShadowInfo &shadowInfo); 49 int32_t GetDragTargetPid(); 50 int32_t GetUdKey(std::string &udKey); 51 int32_t GetShadowOffset(ShadowOffset &shadowOffset); 52 int32_t GetDragData(DragData &dragData); 53 int32_t UpdatePreviewStyle(const PreviewStyle &previewStyle); 54 int32_t UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle, const PreviewAnimation &animation); 55 int32_t RotateDragWindowSync(const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr); 56 int32_t SetDragWindowScreenId(uint64_t displayId, uint64_t screenId); 57 int32_t GetDragSummary(std::map<std::string, int64_t> &summarys, bool isJsCaller = false); 58 int32_t SetDragSwitchState(bool enable, bool isJsCaller = false); 59 int32_t SetAppDragSwitchState(bool enable, const std::string &pkgName, bool isJsCaller = false); 60 int32_t GetDragState(DragState &dragState); 61 int32_t EnableUpperCenterMode(bool enable); 62 int32_t GetDragAction(DragAction &dragAction); 63 int32_t GetExtraInfo(std::string &extraInfo); 64 int32_t AddPrivilege(); 65 int32_t EraseMouseIcon(); 66 int32_t SetMouseDragMonitorState(bool state); 67 int32_t OnNotifyResult(const StreamClient &client, NetPacket &pkt); 68 int32_t OnNotifyHideIcon(const StreamClient &client, NetPacket &pkt); 69 int32_t OnStateChangedMessage(const StreamClient &client, NetPacket &pkt); 70 int32_t OnDragStyleChangedMessage(const StreamClient &client, NetPacket &pkt); 71 int32_t GetDragBundleInfo(DragBundleInfo &dragBundleInfo); 72 int32_t SetDraggableState(bool state); 73 int32_t GetAppDragSwitchState(bool &state); 74 void SetDraggableStateAsync(bool state, int64_t downTime); 75 int32_t EnableInternalDropAnimation(const std::string &animationInfo); 76 void OnConnected(); 77 void OnDisconnected(); 78 bool IsDragStart(); 79 int32_t GetDragSummaryInfo(DragSummaryInfo &dragSummaryInfo); 80 81 private: 82 mutable std::mutex mtx_; 83 std::shared_ptr<IStartDragListener> startDragListener_ { nullptr }; 84 bool hasRegistered_ { false }; 85 bool hasSubscriptRegistered_ { false }; 86 std::set<DragListenerPtr> dragListeners_; 87 std::set<DragListenerPtr> connectedDragListeners_; 88 std::set<SubscriptListenerPtr> subscriptListeners_; 89 }; 90 } // namespace DeviceStatus 91 } // namespace Msdp 92 } // namespace OHOS 93 #endif // INTENTION_DRAG_CLIENT_H 94