1c29fa5a6Sopenharmony_ci/*
2c29fa5a6Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3c29fa5a6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4c29fa5a6Sopenharmony_ci * you may not use this file except in compliance with the License.
5c29fa5a6Sopenharmony_ci * You may obtain a copy of the License at
6c29fa5a6Sopenharmony_ci *
7c29fa5a6Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8c29fa5a6Sopenharmony_ci *
9c29fa5a6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10c29fa5a6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11c29fa5a6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12c29fa5a6Sopenharmony_ci * See the License for the specific language governing permissions and
13c29fa5a6Sopenharmony_ci * limitations under the License.
14c29fa5a6Sopenharmony_ci */
15c29fa5a6Sopenharmony_ci
16c29fa5a6Sopenharmony_ci#ifndef INTENTION_MANAGER_H
17c29fa5a6Sopenharmony_ci#define INTENTION_MANAGER_H
18c29fa5a6Sopenharmony_ci
19c29fa5a6Sopenharmony_ci#include <mutex>
20c29fa5a6Sopenharmony_ci
21c29fa5a6Sopenharmony_ci#include "singleton.h"
22c29fa5a6Sopenharmony_ci
23c29fa5a6Sopenharmony_ci#include "cooperate_client.h"
24c29fa5a6Sopenharmony_ci#include "drag_client.h"
25c29fa5a6Sopenharmony_ci#include "drag_data.h"
26c29fa5a6Sopenharmony_ci#include "drag_manager_impl.h"
27c29fa5a6Sopenharmony_ci#include "i_event_listener.h"
28c29fa5a6Sopenharmony_ci#include "socket_client.h"
29c29fa5a6Sopenharmony_ci#include "stationary_client.h"
30c29fa5a6Sopenharmony_ci#include "tunnel_client.h"
31c29fa5a6Sopenharmony_ci
32c29fa5a6Sopenharmony_cinamespace OHOS {
33c29fa5a6Sopenharmony_cinamespace Msdp {
34c29fa5a6Sopenharmony_cinamespace DeviceStatus {
35c29fa5a6Sopenharmony_ciclass IntentionManager {
36c29fa5a6Sopenharmony_ci    DECLARE_SINGLETON(IntentionManager);
37c29fa5a6Sopenharmony_ci    using CooperateMsgInfoCallback = std::function<void(const std::string&, const CoordinationMsgInfo&)>;
38c29fa5a6Sopenharmony_ci
39c29fa5a6Sopenharmony_cipublic:
40c29fa5a6Sopenharmony_ci    DISALLOW_MOVE(IntentionManager);
41c29fa5a6Sopenharmony_ci    int32_t SubscribeCallback(Type type, ActivityEvent event, ReportLatencyNs latency,
42c29fa5a6Sopenharmony_ci        sptr<IRemoteDevStaCallback> callback);
43c29fa5a6Sopenharmony_ci    int32_t UnsubscribeCallback(Type type, ActivityEvent event, sptr<IRemoteDevStaCallback> callback);
44c29fa5a6Sopenharmony_ci    Data GetDeviceStatusData(const Type type);
45c29fa5a6Sopenharmony_ci    int32_t RegisterCoordinationListener(
46c29fa5a6Sopenharmony_ci        std::shared_ptr<ICoordinationListener> listener, bool isCompatible = false);
47c29fa5a6Sopenharmony_ci    int32_t UnregisterCoordinationListener(
48c29fa5a6Sopenharmony_ci        std::shared_ptr<ICoordinationListener> listener, bool isCompatible = false);
49c29fa5a6Sopenharmony_ci    int32_t PrepareCoordination(CooperateMsgInfoCallback callback, bool isCompatible = false);
50c29fa5a6Sopenharmony_ci    int32_t UnprepareCoordination(CooperateMsgInfoCallback callback, bool isCompatible = false);
51c29fa5a6Sopenharmony_ci    int32_t ActivateCoordination(const std::string &remoteNetworkId, int32_t startDeviceId,
52c29fa5a6Sopenharmony_ci        CooperateMsgInfoCallback callback, bool isCompatible = false);
53c29fa5a6Sopenharmony_ci    int32_t DeactivateCoordination(bool isUnchained, CooperateMsgInfoCallback callback, bool isCompatible = false);
54c29fa5a6Sopenharmony_ci    int32_t GetCoordinationState(const std::string &networkId, std::function<void(bool)> callback,
55c29fa5a6Sopenharmony_ci        bool isCompatible = false);
56c29fa5a6Sopenharmony_ci    int32_t GetCoordinationState(const std::string &udId, bool &state);
57c29fa5a6Sopenharmony_ci    int32_t RegisterEventListener(const std::string &networkId, std::shared_ptr<IEventListener> listener);
58c29fa5a6Sopenharmony_ci    int32_t UnregisterEventListener(const std::string &networkId, std::shared_ptr<IEventListener> listener = nullptr);
59c29fa5a6Sopenharmony_ci    int32_t UpdateDragStyle(DragCursorStyle style);
60c29fa5a6Sopenharmony_ci    int32_t StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener);
61c29fa5a6Sopenharmony_ci    int32_t StopDrag(const DragDropResult &dropResult);
62c29fa5a6Sopenharmony_ci    int32_t GetDragTargetPid();
63c29fa5a6Sopenharmony_ci    int32_t GetUdKey(std::string &udKey);
64c29fa5a6Sopenharmony_ci    int32_t AddDraglistener(DragListenerPtr listener);
65c29fa5a6Sopenharmony_ci    int32_t RemoveDraglistener(DragListenerPtr listener);
66c29fa5a6Sopenharmony_ci    int32_t AddSubscriptListener(SubscriptListenerPtr listener);
67c29fa5a6Sopenharmony_ci    int32_t RemoveSubscriptListener(SubscriptListenerPtr listener);
68c29fa5a6Sopenharmony_ci    int32_t SetDragWindowVisible(bool visible, bool isForce = false);
69c29fa5a6Sopenharmony_ci    int32_t GetShadowOffset(ShadowOffset &shadowOffset);
70c29fa5a6Sopenharmony_ci    int32_t UpdateShadowPic(const ShadowInfo &shadowInfo);
71c29fa5a6Sopenharmony_ci    int32_t GetDragData(DragData &dragData);
72c29fa5a6Sopenharmony_ci    int32_t GetDragState(DragState &dragState);
73c29fa5a6Sopenharmony_ci    int32_t AddHotAreaListener(std::shared_ptr<IHotAreaListener> listener);
74c29fa5a6Sopenharmony_ci    int32_t RemoveHotAreaListener(std::shared_ptr<IHotAreaListener> listener = nullptr);
75c29fa5a6Sopenharmony_ci    int32_t UpdatePreviewStyle(const PreviewStyle &previewStyle);
76c29fa5a6Sopenharmony_ci    int32_t UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle, const PreviewAnimation &animation);
77c29fa5a6Sopenharmony_ci    int32_t RotateDragWindowSync(const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr);
78c29fa5a6Sopenharmony_ci    int32_t GetDragSummary(std::map<std::string, int64_t> &summarys);
79c29fa5a6Sopenharmony_ci    int32_t EnterTextEditorArea(bool enable);
80c29fa5a6Sopenharmony_ci    int32_t GetDragAction(DragAction &dragAction);
81c29fa5a6Sopenharmony_ci    int32_t GetExtraInfo(std::string &extraInfo);
82c29fa5a6Sopenharmony_ci    int32_t AddPrivilege();
83c29fa5a6Sopenharmony_ci    int32_t EraseMouseIcon();
84c29fa5a6Sopenharmony_ci    int32_t SetDragWindowScreenId(uint64_t displayId, uint64_t screenId);
85c29fa5a6Sopenharmony_ci    int32_t AddSelectedPixelMap(std::shared_ptr<OHOS::Media::PixelMap> pixelMap, std::function<void(bool)> callback);
86c29fa5a6Sopenharmony_ci
87c29fa5a6Sopenharmony_ciprivate:
88c29fa5a6Sopenharmony_ci    void InitClient();
89c29fa5a6Sopenharmony_ci    void InitMsgHandler();
90c29fa5a6Sopenharmony_ci
91c29fa5a6Sopenharmony_ci    std::mutex mutex_;
92c29fa5a6Sopenharmony_ci    std::shared_ptr<TunnelClient> tunnel_ { nullptr };
93c29fa5a6Sopenharmony_ci    std::unique_ptr<SocketClient> client_ { nullptr };
94c29fa5a6Sopenharmony_ci    CooperateClient cooperate_;
95c29fa5a6Sopenharmony_ci    DragClient drag_;
96c29fa5a6Sopenharmony_ci    StationaryClient stationary_;
97c29fa5a6Sopenharmony_ci    bool isScreenRotation_ { false };
98c29fa5a6Sopenharmony_ci    std::vector<std::string> foldRotatePolicys_ {};
99c29fa5a6Sopenharmony_ci};
100c29fa5a6Sopenharmony_ci
101c29fa5a6Sopenharmony_ci#define INTER_MGR_IMPL OHOS::Singleton<IntentionManager>::GetInstance()
102c29fa5a6Sopenharmony_ci} // namespace DeviceStatus
103c29fa5a6Sopenharmony_ci} // namespace Msdp
104c29fa5a6Sopenharmony_ci} // namespace OHOS
105c29fa5a6Sopenharmony_ci#endif // INTENTION_MANAGER_H
106