• 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 
19 #include <memory>
20 
21 #include "transaction/rs_transaction.h"
22 
23 #include "default_params.h"
24 #include "drag_data.h"
25 #include "intention_identity.h"
26 
27 namespace OHOS {
28 namespace Msdp {
29 namespace DeviceStatus {
30 enum DragRequestID : uint32_t {
31     UNKNOWN_DRAG_ACTION,
32     ADD_DRAG_LISTENER,
33     REMOVE_DRAG_LISTENER,
34     ADD_SUBSCRIPT_LISTENER,
35     REMOVE_SUBSCRIPT_LISTENER,
36     SET_DRAG_WINDOW_VISIBLE,
37     UPDATE_DRAG_STYLE,
38     UPDATE_SHADOW_PIC,
39     GET_DRAG_TARGET_PID,
40     GET_UDKEY,
41     GET_SHADOW_OFFSET,
42     GET_DRAG_DATA,
43     UPDATE_PREVIEW_STYLE,
44     UPDATE_PREVIEW_STYLE_WITH_ANIMATION,
45     ROTATE_DRAG_WINDOW_SYNC,
46     GET_DRAG_SUMMARY,
47     SET_DRAG_SWITCH_STATE,
48     SET_APP_DRAG_SWITCH_STATE,
49     GET_DRAG_STATE,
50     ADD_PRIVILEGE,
51     ENTER_TEXT_EDITOR_AREA,
52     SET_MOUSE_DRAG_MONITOR_STATE,
53     GET_DRAG_ACTION,
54     GET_EXTRA_INFO,
55     ERASE_MOUSE_ICON,
56     SET_DRAG_WINDOW_SCREEN_ID,
57     ADD_SELECTED_PIXELMAP,
58     SET_DRAGGABLE_STATE,
59     SET_DRAGABLE_STATE_ASYNC,
60     GET_UNIVERSAL_DRAG_APP_STATE,
61 };
62 
63 struct StartDragParam final : public ParamBase {
64     explicit StartDragParam(DragData &dragData);
65     explicit StartDragParam(const DragData &dragData);
66 
67     bool Marshalling(MessageParcel &parcel) const override;
68     bool Unmarshalling(MessageParcel &parcel) override;
69 
70     // For efficiency, we want to avoid copying 'DragData' whenever possible.
71     // Considering the 'Start drag' scenario, we use 'StartDragParam' simply
72     // as wrapper of 'DragData' and serialize 'DragData' in the right same
73     // call. We do not dereference 'DragData' or keep a reference to it for
74     // later use. In this case, we can safely keep a pointer to the input 'DragData'.
75     DragData *dragDataPtr_ { nullptr };
76     const DragData *cDragDataPtr_ { nullptr };
77 };
78 
79 struct StopDragParam final : public ParamBase {
80     StopDragParam() = default;
81     explicit StopDragParam(const DragDropResult &dropResult);
82 
83     bool Marshalling(MessageParcel &parcel) const override;
84     bool Unmarshalling(MessageParcel &parcel) override;
85 
86     DragDropResult dropResult_ {};
87 };
88 
89 struct SetDragWindowVisibleParam final : public ParamBase {
90     SetDragWindowVisibleParam() = default;
91     SetDragWindowVisibleParam(bool visible, bool isForce);
92 
93     bool Marshalling(MessageParcel &parcel) const override;
94     bool Unmarshalling(MessageParcel &parcel) override;
95 
96     bool visible_ { false };
97     bool isForce_ { false };
98 };
99 
100 struct UpdateDragStyleParam final : public ParamBase {
101     UpdateDragStyleParam() = default;
102     explicit UpdateDragStyleParam(DragCursorStyle style, int32_t eventId);
103 
104     bool Marshalling(MessageParcel &parcel) const override;
105     bool Unmarshalling(MessageParcel &parcel) override;
106 
107     DragCursorStyle cursorStyle_ { DragCursorStyle::DEFAULT };
108     int32_t eventId_ { -1 };
109 };
110 
111 struct UpdateShadowPicParam final : public ParamBase {
112     UpdateShadowPicParam() = default;
113     explicit UpdateShadowPicParam(const ShadowInfo &shadowInfo);
114 
115     bool Marshalling(MessageParcel &parcel) const override;
116     bool Unmarshalling(MessageParcel &parcel) override;
117 
118     ShadowInfo shadowInfo_ {};
119 };
120 
121 struct GetDragTargetPidReply : public ParamBase {
122     GetDragTargetPidReply() = default;
123     explicit GetDragTargetPidReply(int32_t pid);
124 
125     bool Marshalling(MessageParcel &parcel) const override;
126     bool Unmarshalling(MessageParcel &parcel) override;
127 
128     int32_t targetPid_ { -1 };
129 };
130 
131 struct GetUdKeyReply final : public ParamBase {
132     GetUdKeyReply() = default;
133     explicit GetUdKeyReply(std::string &&udKey);
134 
135     bool Marshalling(MessageParcel &parcel) const override;
136     bool Unmarshalling(MessageParcel &parcel) override;
137 
138     std::string udKey_;
139 };
140 
141 struct GetShadowOffsetReply final : public ParamBase {
142     GetShadowOffsetReply() = default;
143     explicit GetShadowOffsetReply(const ShadowOffset &shadowOffset);
144 
145     bool Marshalling(MessageParcel &parcel) const override;
146     bool Unmarshalling(MessageParcel &parcel) override;
147 
148     ShadowOffset shadowOffset_ {};
149 };
150 
151 using GetDragDataReply = StartDragParam;
152 
153 struct UpdatePreviewStyleParam final : public ParamBase {
154     UpdatePreviewStyleParam() = default;
155     explicit UpdatePreviewStyleParam(const PreviewStyle &previewStyle);
156 
157     bool Marshalling(MessageParcel &parcel) const override;
158     bool Unmarshalling(MessageParcel &parcel) override;
159 
160     PreviewStyle previewStyle_;
161 };
162 
163 struct UpdatePreviewAnimationParam final : public ParamBase {
164     UpdatePreviewAnimationParam() = default;
165     UpdatePreviewAnimationParam(const PreviewStyle &previewStyle, const PreviewAnimation &animation);
166 
167     bool Marshalling(MessageParcel &parcel) const override;
168     bool Unmarshalling(MessageParcel &parcel) override;
169 
170     PreviewStyle previewStyle_ {};
171     PreviewAnimation previewAnimation_ {};
172 };
173 
174 struct RotateDragWindowSyncParam final : public ParamBase {
175     RotateDragWindowSyncParam() = default;
176     explicit RotateDragWindowSyncParam(const std::shared_ptr<Rosen::RSTransaction>& rsTransaction);
177 
178     bool Marshalling(MessageParcel &parcel) const override;
179     bool Unmarshalling(MessageParcel &parcel) override;
180 
181     std::shared_ptr<Rosen::RSTransaction> rsTransaction_ { nullptr };
182 };
183 
184 struct SetDragWindowScreenIdParam final : public ParamBase {
185     SetDragWindowScreenIdParam() = default;
186     SetDragWindowScreenIdParam(uint64_t displayId, uint64_t screenId);
187 
188     bool Marshalling(MessageParcel &parcel) const override;
189     bool Unmarshalling(MessageParcel &parcel) override;
190 
191     uint64_t displayId_ { 0 };
192     uint64_t screenId_ { 0 };
193 };
194 
195 struct AddDraglistenerParam final : public ParamBase {
196     AddDraglistenerParam() = default;
197     AddDraglistenerParam(bool isJsCaller);
198 
199     bool Marshalling(MessageParcel &parcel) const override;
200     bool Unmarshalling(MessageParcel &parcel) override;
201 
202     bool isJsCaller_ { false };
203 };
204 
205 struct RemoveDraglistenerParam final : public ParamBase {
206     RemoveDraglistenerParam() = default;
207     RemoveDraglistenerParam(bool isJsCaller);
208 
209     bool Marshalling(MessageParcel &parcel) const override;
210     bool Unmarshalling(MessageParcel &parcel) override;
211 
212     bool isJsCaller_ { false };
213 };
214 
215 struct GetDragSummaryParam final : public ParamBase {
216     GetDragSummaryParam() = default;
217     GetDragSummaryParam(bool isJsCaller);
218 
219     bool Marshalling(MessageParcel &parcel) const override;
220     bool Unmarshalling(MessageParcel &parcel) override;
221 
222     bool isJsCaller_ { false };
223 };
224 
225 struct GetDragSummaryReply final : public ParamBase {
226     GetDragSummaryReply() = default;
227     explicit GetDragSummaryReply(std::map<std::string, int64_t> &&summary);
228 
229     bool Marshalling(MessageParcel &parcel) const override;
230     bool Unmarshalling(MessageParcel &parcel) override;
231 
232     std::map<std::string, int64_t> summary_;
233 };
234 
235 struct SetDragSwitchStateParam final : public ParamBase {
236     SetDragSwitchStateParam() = default;
237     SetDragSwitchStateParam(bool enable, bool isJsCaller);
238 
239     bool Marshalling(MessageParcel &parcel) const override;
240     bool Unmarshalling(MessageParcel &parcel) override;
241 
242     bool enable_ { false };
243     bool isJsCaller_ { false };
244 };
245 
246 struct SetAppDragSwitchStateParam final : public ParamBase {
247     SetAppDragSwitchStateParam() = default;
248     SetAppDragSwitchStateParam(bool enable, const std::string &pkgName, bool isJsCaller);
249 
250     bool Marshalling(MessageParcel &parcel) const override;
251     bool Unmarshalling(MessageParcel &parcel) override;
252 
253     bool enable_ { false };
254     std::string pkgName_;
255     bool isJsCaller_ { false };
256 };
257 
258 struct GetDragStateReply final : public ParamBase {
259     GetDragStateReply() = default;
260     explicit GetDragStateReply(DragState dragState);
261 
262     bool Marshalling(MessageParcel &parcel) const override;
263     bool Unmarshalling(MessageParcel &parcel) override;
264 
265     DragState dragState_ { DragState::ERROR };
266 };
267 
268 using EnterTextEditorAreaParam = BooleanReply;
269 using SetMouseDragMonitorStateParam = BooleanReply;
270 struct GetDragActionReply final : public ParamBase {
271     GetDragActionReply() = default;
272     explicit GetDragActionReply(DragAction dragAction);
273 
274     bool Marshalling(MessageParcel &parcel) const override;
275     bool Unmarshalling(MessageParcel &parcel) override;
276 
277     DragAction dragAction_ { DragAction::INVALID };
278 };
279 
280 struct GetExtraInfoReply final : public ParamBase {
281     GetExtraInfoReply() = default;
282     explicit GetExtraInfoReply(std::string &&extraInfo);
283 
284     bool Marshalling(MessageParcel &parcel) const override;
285     bool Unmarshalling(MessageParcel &parcel) override;
286 
287     std::string extraInfo_;
288 };
289 
290 struct AddSelectedPixelMapParam final : public ParamBase {
291     AddSelectedPixelMapParam() = default;
292     explicit AddSelectedPixelMapParam(std::shared_ptr<OHOS::Media::PixelMap> pixelMap);
293 
294     bool Marshalling(MessageParcel &parcel) const override;
295     bool Unmarshalling(MessageParcel &parcel) override;
296 
297     std::shared_ptr<OHOS::Media::PixelMap> pixelMap_ { nullptr };
298 };
299 
300 struct SetDraggableStateParam final : public ParamBase {
301     SetDraggableStateParam() = default;
302     SetDraggableStateParam(bool draggable);
303 
304     bool Marshalling(MessageParcel &parcel) const override;
305     bool Unmarshalling(MessageParcel &parcel) override;
306 
307     bool state_ { false };
308 };
309 
310 struct GetUniversalDragAppStateReply final : public ParamBase {
311     GetUniversalDragAppStateReply() = default;
312     explicit GetUniversalDragAppStateReply(bool state);
313 
314     bool Marshalling(MessageParcel &parcel) const override;
315     bool Unmarshalling(MessageParcel &parcel) override;
316 
317     bool state_ { false };
318 };
319 
320 struct SetDraggableStateAsyncParam final : public ParamBase {
321     SetDraggableStateAsyncParam() = default;
322     SetDraggableStateAsyncParam(bool state, int64_t downTime);
323 
324     bool Marshalling(MessageParcel &parcel) const override;
325     bool Unmarshalling(MessageParcel &parcel) override;
326 
327     bool state_ { false };
328     int64_t downTime_ { -1 };
329 };
330 } // namespace DeviceStatus
331 } // namespace Msdp
332 } // namespace OHOS
333 #endif // DRAG_PARAMS_H
334