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