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_DRAG_CLIENT_H
17c29fa5a6Sopenharmony_ci#define INTENTION_DRAG_CLIENT_H
18c29fa5a6Sopenharmony_ci
19c29fa5a6Sopenharmony_ci#include "nocopyable.h"
20c29fa5a6Sopenharmony_ci
21c29fa5a6Sopenharmony_ci#include <set>
22c29fa5a6Sopenharmony_ci
23c29fa5a6Sopenharmony_ci#include "i_drag_listener.h"
24c29fa5a6Sopenharmony_ci#include "i_subscript_listener.h"
25c29fa5a6Sopenharmony_ci#include "i_tunnel_client.h"
26c29fa5a6Sopenharmony_ci#include "i_start_drag_listener.h"
27c29fa5a6Sopenharmony_ci#include "socket_client.h"
28c29fa5a6Sopenharmony_ci#include "transaction/rs_transaction.h"
29c29fa5a6Sopenharmony_ci
30c29fa5a6Sopenharmony_cinamespace OHOS {
31c29fa5a6Sopenharmony_cinamespace Msdp {
32c29fa5a6Sopenharmony_cinamespace DeviceStatus {
33c29fa5a6Sopenharmony_ciclass DragClient final {
34c29fa5a6Sopenharmony_cipublic:
35c29fa5a6Sopenharmony_ci    DragClient() = default;
36c29fa5a6Sopenharmony_ci    ~DragClient() = default;
37c29fa5a6Sopenharmony_ci    DISALLOW_COPY_AND_MOVE(DragClient);
38c29fa5a6Sopenharmony_ci
39c29fa5a6Sopenharmony_ci    int32_t StartDrag(ITunnelClient &tunnel, const DragData &dragData, std::shared_ptr<IStartDragListener> listener);
40c29fa5a6Sopenharmony_ci    int32_t StopDrag(ITunnelClient &tunnel, const DragDropResult &dropResult);
41c29fa5a6Sopenharmony_ci    int32_t AddDraglistener(ITunnelClient &tunnel, DragListenerPtr listener);
42c29fa5a6Sopenharmony_ci    int32_t RemoveDraglistener(ITunnelClient &tunnel, DragListenerPtr listener);
43c29fa5a6Sopenharmony_ci    int32_t AddSubscriptListener(ITunnelClient &tunnel, SubscriptListenerPtr listener);
44c29fa5a6Sopenharmony_ci    int32_t RemoveSubscriptListener(ITunnelClient &tunnel, SubscriptListenerPtr listener);
45c29fa5a6Sopenharmony_ci    int32_t SetDragWindowVisible(ITunnelClient &tunnel, bool visible, bool isForce);
46c29fa5a6Sopenharmony_ci    int32_t UpdateDragStyle(ITunnelClient &tunnel, DragCursorStyle style);
47c29fa5a6Sopenharmony_ci    int32_t UpdateShadowPic(ITunnelClient &tunnel, const ShadowInfo &shadowInfo);
48c29fa5a6Sopenharmony_ci    int32_t GetDragTargetPid(ITunnelClient &tunnel);
49c29fa5a6Sopenharmony_ci    int32_t GetUdKey(ITunnelClient &tunnel, std::string &udKey);
50c29fa5a6Sopenharmony_ci    int32_t GetShadowOffset(ITunnelClient &tunnel, ShadowOffset &shadowOffset);
51c29fa5a6Sopenharmony_ci    int32_t GetDragData(ITunnelClient &tunnel, DragData &dragData);
52c29fa5a6Sopenharmony_ci    int32_t UpdatePreviewStyle(ITunnelClient &tunnel, const PreviewStyle &previewStyle);
53c29fa5a6Sopenharmony_ci    int32_t UpdatePreviewStyleWithAnimation(ITunnelClient &tunnel,
54c29fa5a6Sopenharmony_ci        const PreviewStyle &previewStyle, const PreviewAnimation &animation);
55c29fa5a6Sopenharmony_ci    int32_t RotateDragWindowSync(ITunnelClient &tunnel,
56c29fa5a6Sopenharmony_ci        const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr);
57c29fa5a6Sopenharmony_ci    int32_t SetDragWindowScreenId(ITunnelClient &tunnel, uint64_t displayId, uint64_t screenId);
58c29fa5a6Sopenharmony_ci    int32_t GetDragSummary(ITunnelClient &tunnel, std::map<std::string, int64_t> &summary);
59c29fa5a6Sopenharmony_ci    int32_t GetDragState(ITunnelClient &tunnel, DragState &dragState);
60c29fa5a6Sopenharmony_ci    int32_t EnterTextEditorArea(ITunnelClient &tunnel, bool enable);
61c29fa5a6Sopenharmony_ci    int32_t GetDragAction(ITunnelClient &tunnel, DragAction &dragAction);
62c29fa5a6Sopenharmony_ci    int32_t GetExtraInfo(ITunnelClient &tunnel, std::string &extraInfo);
63c29fa5a6Sopenharmony_ci    int32_t AddPrivilege(ITunnelClient &tunnel);
64c29fa5a6Sopenharmony_ci    int32_t EraseMouseIcon(ITunnelClient &tunnel);
65c29fa5a6Sopenharmony_ci    int32_t AddSelectedPixelMap(ITunnelClient &tunnel, std::shared_ptr<OHOS::Media::PixelMap> pixelMap,
66c29fa5a6Sopenharmony_ci        std::function<void(bool)> callback);
67c29fa5a6Sopenharmony_ci
68c29fa5a6Sopenharmony_ci    int32_t OnNotifyResult(const StreamClient &client, NetPacket &pkt);
69c29fa5a6Sopenharmony_ci    int32_t OnNotifyHideIcon(const StreamClient& client, NetPacket& pkt);
70c29fa5a6Sopenharmony_ci    int32_t OnStateChangedMessage(const StreamClient &client, NetPacket &pkt);
71c29fa5a6Sopenharmony_ci    int32_t OnDragStyleChangedMessage(const StreamClient &client, NetPacket &pkt);
72c29fa5a6Sopenharmony_ci    int32_t OnAddSelectedPixelMapResult(const StreamClient &client, NetPacket &pkt);
73c29fa5a6Sopenharmony_ci
74c29fa5a6Sopenharmony_ciprivate:
75c29fa5a6Sopenharmony_ci    mutable std::mutex mtx_;
76c29fa5a6Sopenharmony_ci    std::shared_ptr<IStartDragListener> startDragListener_ { nullptr };
77c29fa5a6Sopenharmony_ci    bool hasRegistered_ { false };
78c29fa5a6Sopenharmony_ci    bool hasSubscriptRegistered_ { false };
79c29fa5a6Sopenharmony_ci    std::set<DragListenerPtr> dragListeners_;
80c29fa5a6Sopenharmony_ci    std::set<SubscriptListenerPtr> subscriptListeners_;
81c29fa5a6Sopenharmony_ci    std::function<void(bool)> addSelectedPixelMapCallback_;
82c29fa5a6Sopenharmony_ci};
83c29fa5a6Sopenharmony_ci} // namespace DeviceStatus
84c29fa5a6Sopenharmony_ci} // namespace Msdp
85c29fa5a6Sopenharmony_ci} // namespace OHOS
86c29fa5a6Sopenharmony_ci#endif // INTENTION_DRAG_CLIENT_H
87