• 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 DRAG_PARAMS_H
17 #define DRAG_PARAMS_H
18 #include <memory>
19 
20 #include "drag_data.h"
21 #include "intention_identity.h"
22 
23 namespace OHOS {
24 namespace Msdp {
25 namespace DeviceStatus {
26 enum DragRequestID : uint32_t {
27     UNKNOWN_DRAG_ACTION,
28     ADD_DRAG_LISTENER,
29     REMOVE_DRAG_LISTENER,
30     ADD_SUBSCRIPT_LISTENER,
31     REMOVE_SUBSCRIPT_LISTENER,
32     SET_DRAG_WINDOW_VISIBLE,
33     UPDATE_DRAG_STYLE,
34     UPDATE_SHADOW_PIC,
35     GET_DRAG_TARGET_PID,
36     GET_UDKEY,
37     GET_SHADOW_OFFSET,
38     GET_DRAG_DATA,
39     UPDATE_PREVIEW_STYLE,
40     UPDATE_PREVIEW_STYLE_WITH_ANIMATION,
41     GET_DRAG_SUMMARY,
42     GET_DRAG_STATE,
43     ENTER_TEXT_EDITOR_AREA,
44     GET_DRAG_ACTION,
45     GET_EXTRA_INFO,
46 };
47 
48 struct StartDragParam final : public ParamBase {
49     StartDragParam(DragData &dragData);
50     StartDragParam(const DragData &dragData);
51 
52     bool Marshalling(MessageParcel &parcel) const override;
53     bool Unmarshalling(MessageParcel &parcel) override;
54 
55     // For efficiency, we want to avoid copying 'DragData' whenever possible.
56     // Considering the 'Start drag' scenario, we use 'StartDragParam' simply
57     // as wrapper of 'DragData' and serialize 'DragData' in the right same
58     // call. We do not dereference 'DragData' or keep a reference to it for
59     // later use. In this case, we can safely keep a pointer to the input 'DragData'.
60     DragData *dragDataPtr_ { nullptr };
61     const DragData *cDragDataPtr_ { nullptr };
62 };
63 
64 struct StopDragParam final : public ParamBase {
65     StopDragParam() = default;
66     StopDragParam(const DragDropResult &dropResult);
67 
68     bool Marshalling(MessageParcel &parcel) const override;
69     bool Unmarshalling(MessageParcel &parcel) override;
70 
71     DragDropResult dropResult_ {};
72 };
73 
74 struct SetDragWindowVisibleParam final : public ParamBase {
75     SetDragWindowVisibleParam() = default;
76     SetDragWindowVisibleParam(bool visible);
77 
78     bool Marshalling(MessageParcel &parcel) const override;
79     bool Unmarshalling(MessageParcel &parcel) override;
80 
81     bool visible_ { false };
82 };
83 
84 struct UpdateDragStyleParam final : public ParamBase {
85     UpdateDragStyleParam() = default;
86     UpdateDragStyleParam(DragCursorStyle style);
87 
88     bool Marshalling(MessageParcel &parcel) const override;
89     bool Unmarshalling(MessageParcel &parcel) override;
90 
91     DragCursorStyle cursorStyle_ { DragCursorStyle::DEFAULT };
92 };
93 
94 struct UpdateShadowPicParam final : public ParamBase {
95     UpdateShadowPicParam() = default;
96     UpdateShadowPicParam(const ShadowInfo &shadowInfo);
97 
98     bool Marshalling(MessageParcel &parcel) const override;
99     bool Unmarshalling(MessageParcel &parcel) override;
100 
101     ShadowInfo shadowInfo_ {};
102 };
103 
104 struct GetDragTargetPidReply : public ParamBase {
105     GetDragTargetPidReply() = default;
106     GetDragTargetPidReply(int32_t pid);
107 
108     bool Marshalling(MessageParcel &parcel) const override;
109     bool Unmarshalling(MessageParcel &parcel) override;
110 
111     int32_t targetPid_ { -1 };
112 };
113 
114 struct GetUdKeyReply final : public ParamBase {
115     GetUdKeyReply() = default;
116     GetUdKeyReply(std::string &&udKey);
117 
118     bool Marshalling(MessageParcel &parcel) const override;
119     bool Unmarshalling(MessageParcel &parcel) override;
120 
121     std::string udKey_;
122 };
123 
124 struct GetShadowOffsetReply final : public ParamBase {
125     GetShadowOffsetReply() = default;
126     GetShadowOffsetReply(int32_t offsetX, int32_t offsetY, int32_t width, int32_t height);
127 
128     bool Marshalling(MessageParcel &parcel) const override;
129     bool Unmarshalling(MessageParcel &parcel) override;
130 
131     int32_t offsetX_ { -1 };
132     int32_t offsetY_ { -1 };
133     int32_t width_ { -1 };
134     int32_t height_ { -1 };
135 };
136 
137 using GetDragDataReply = StartDragParam;
138 
139 struct UpdatePreviewStyleParam final : public ParamBase {
140     UpdatePreviewStyleParam() = default;
141     UpdatePreviewStyleParam(const PreviewStyle &previewStyle);
142 
143     bool Marshalling(MessageParcel &parcel) const override;
144     bool Unmarshalling(MessageParcel &parcel) override;
145 
146     PreviewStyle previewStyle_;
147 };
148 
149 struct UpdatePreviewAnimationParam final : public ParamBase {
150     UpdatePreviewAnimationParam() = default;
151     UpdatePreviewAnimationParam(const PreviewStyle &previewStyle, const PreviewAnimation &animation);
152 
153     bool Marshalling(MessageParcel &parcel) const override;
154     bool Unmarshalling(MessageParcel &parcel) override;
155 
156     PreviewStyle previewStyle_ {};
157     PreviewAnimation previewAnimation_ {};
158 };
159 
160 struct GetDragSummaryReply final : public ParamBase {
161     GetDragSummaryReply() = default;
162     GetDragSummaryReply(std::map<std::string, int64_t> &&summaries);
163 
164     bool Marshalling(MessageParcel &parcel) const override;
165     bool Unmarshalling(MessageParcel &parcel) override;
166 
167     std::map<std::string, int64_t> summaries_;
168 };
169 
170 struct GetDragStateReply final : public ParamBase {
171     GetDragStateReply() = default;
172     GetDragStateReply(DragState dragState);
173 
174     bool Marshalling(MessageParcel &parcel) const override;
175     bool Unmarshalling(MessageParcel &parcel) override;
176 
177     DragState dragState_ { DragState::ERROR };
178 };
179 
180 struct EnterTextEditorAreaParam final : public ParamBase {
181     EnterTextEditorAreaParam() = default;
182     EnterTextEditorAreaParam(bool enable);
183 
184     bool Marshalling(MessageParcel &parcel) const override;
185     bool Unmarshalling(MessageParcel &parcel) override;
186 
187     bool enable_ { false };
188 };
189 
190 struct GetDragActionReply final : public ParamBase {
191     GetDragActionReply() = default;
192     GetDragActionReply(DragAction dragAction);
193 
194     bool Marshalling(MessageParcel &parcel) const override;
195     bool Unmarshalling(MessageParcel &parcel) override;
196 
197     DragAction dragAction_ { DragAction::INVALID };
198 };
199 
200 struct GetExtraInfoReply final : public ParamBase {
201     GetExtraInfoReply() = default;
202     GetExtraInfoReply(std::string &&extraInfo);
203 
204     bool Marshalling(MessageParcel &parcel) const override;
205     bool Unmarshalling(MessageParcel &parcel) override;
206 
207     std::string extraInfo_;
208 };
209 } // namespace DeviceStatus
210 } // namespace Msdp
211 } // namespace OHOS
212 #endif // DRAG_PARAMS_H
213