• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 public:
34     DISALLOW_MOVE(InteractionManagerImpl);
35     bool InitClient();
36     int32_t RegisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener);
37     int32_t UnregisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener = nullptr);
38     int32_t PrepareCoordination(std::function<void(std::string, CoordinationMessage)> callback);
39     int32_t UnprepareCoordination(std::function<void(std::string, CoordinationMessage)> callback);
40     int32_t ActivateCoordination(const std::string &remoteNetworkId, int32_t startDeviceId,
41         std::function<void(std::string, CoordinationMessage)> callback);
42     int32_t DeactivateCoordination(bool isUnchained, std::function<void(std::string, CoordinationMessage)> callback);
43     int32_t GetCoordinationState(const std::string &deviceId, std::function<void(bool)> callback);
44     int32_t UpdateDragStyle(DragCursorStyle style);
45     int32_t StartDrag(const DragData &dragData, std::function<void(const DragNotifyMsg&)> callback);
46     int32_t StopDrag(DragResult result, bool hasCustomAnimation);
47     int32_t GetDragTargetPid();
48     int32_t GetUdKey(std::string &udKey);
49     int32_t AddDraglistener(DragListenerPtr listener);
50     int32_t RemoveDraglistener(DragListenerPtr listener);
51     int32_t SetDragWindowVisible(bool visible);
52     int32_t GetShadowOffset(int32_t& offsetX, int32_t& offsetY, int32_t& width, int32_t& height);
53     int32_t UpdateShadowPic(const ShadowInfo &shadowInfo);
54 private:
55     void InitMsgHandler();
56 
57 private:
58     std::mutex mutex_;
59     IClientPtr client_ { nullptr };
60     DragManagerImpl dragManagerImpl_;
61     CoordinationManagerImpl coordinationManagerImpl_;
62 };
63 } // namespace DeviceStatus
64 } // namespace Msdp
65 } // namespace OHOS
66 
67 #define INTER_MGR_IMPL OHOS::Singleton<InteractionManagerImpl>::GetInstance()
68 
69 #endif // INTERACTION_MANAGER_IMPL_H
70