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 DRAG_MANAGER_IMPL_H 17 #define DRAG_MANAGER_IMPL_H 18 19 #include <functional> 20 #include <list> 21 #include <mutex> 22 #include <string> 23 24 #include "client.h" 25 #include "devicestatus_client.h" 26 #include "devicestatus_define.h" 27 #include "drag_data.h" 28 #include "i_drag_listener.h" 29 #include "i_start_drag_listener.h" 30 #include "i_subscript_listener.h" 31 #include "include/util.h" 32 33 namespace OHOS { 34 namespace Msdp { 35 namespace DeviceStatus { 36 class DragManagerImpl { 37 public: 38 DragManagerImpl() = default; 39 ~DragManagerImpl() = default; 40 41 int32_t StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener); 42 int32_t StopDrag(const DragDropResult &dropResult); 43 int32_t OnNotifyResult(const StreamClient &client, NetPacket &pkt); 44 int32_t OnNotifyHideIcon(const StreamClient& client, NetPacket& pkt); 45 int32_t OnStateChangedMessage(const StreamClient &client, NetPacket &pkt); 46 int32_t OnDragStyleChangedMessage(const StreamClient &client, NetPacket &pkt); 47 int32_t AddDraglistener(DragListenerPtr listener); 48 int32_t RemoveDraglistener(DragListenerPtr listener); 49 int32_t AddSubscriptListener(SubscriptListenerPtr listener); 50 int32_t RemoveSubscriptListener(SubscriptListenerPtr listener); 51 int32_t SetDragWindowVisible(bool visible, bool isForce = false); 52 int32_t UpdateDragStyle(DragCursorStyle style); 53 int32_t UpdateShadowPic(const ShadowInfo &shadowInfo); 54 int32_t GetDragTargetPid(); 55 int32_t GetUdKey(std::string &udKey); 56 int32_t GetShadowOffset(ShadowOffset &shadowOffset); 57 int32_t GetDragData(DragData &dragData); 58 int32_t UpdatePreviewStyle(const PreviewStyle &previewStyle); 59 int32_t UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle, const PreviewAnimation &animation); 60 int32_t GetDragSummary(std::map<std::string, int64_t> &summarys); 61 int32_t GetDragState(DragState &dragState); 62 int32_t EnterTextEditorArea(bool enable); 63 int32_t GetDragAction(DragAction& dragAction); 64 int32_t GetExtraInfo(std::string &extraInfo); 65 int32_t AddPrivilege(); 66 int32_t EraseMouseIcon(); 67 68 private: 69 std::mutex mtx_; 70 std::atomic_bool hasRegistered_ { false }; 71 std::atomic_bool hasSubscriptRegistered_ { false }; 72 std::list<DragListenerPtr> dragListener_; 73 std::shared_ptr<IStartDragListener> startDragListener_ { nullptr }; 74 std::list<SubscriptListenerPtr> subscriptListener_; 75 }; 76 } // namespace DeviceStatus 77 } // namespace Msdp 78 } // namespace OHOS 79 #endif // DRAG_MANAGER_IMPL_H 80