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