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 #include "drag_server.h"
17
18 #include "drag_params.h"
19 #include "devicestatus_define.h"
20
21 namespace OHOS {
22 namespace Msdp {
23 namespace DeviceStatus {
24 namespace {
25 constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "DragServer" };
26 } // namespace
27
DragServer(IContext * context)28 DragServer::DragServer(IContext *context)
29 : context_(context)
30 {}
31
Enable(CallingContext & context,MessageParcel & data,MessageParcel & reply)32 int32_t DragServer::Enable(CallingContext &context, MessageParcel &data, MessageParcel &reply)
33 {
34 CALL_DEBUG_ENTER;
35 return RET_ERR;
36 }
37
Disable(CallingContext & context,MessageParcel & data,MessageParcel & reply)38 int32_t DragServer::Disable(CallingContext &context, MessageParcel &data, MessageParcel &reply)
39 {
40 CALL_DEBUG_ENTER;
41 return RET_ERR;
42 }
43
Start(CallingContext & context,MessageParcel & data,MessageParcel & reply)44 int32_t DragServer::Start(CallingContext &context, MessageParcel &data, MessageParcel &reply)
45 {
46 CALL_DEBUG_ENTER;
47 DragData dragData {};
48 StartDragParam param { dragData };
49
50 if (!param.Unmarshalling(data)) {
51 FI_HILOGE("Failed to unmarshalling param");
52 return RET_ERR;
53 }
54 CHKPR(context_, RET_ERR);
55 FI_HILOGD("Start drag");
56 return RET_OK;
57 }
58
Stop(CallingContext & context,MessageParcel & data,MessageParcel & reply)59 int32_t DragServer::Stop(CallingContext &context, MessageParcel &data, MessageParcel &reply)
60 {
61 CALL_DEBUG_ENTER;
62 StopDragParam param {};
63
64 if (!param.Unmarshalling(data)) {
65 FI_HILOGE("Failed to unmarshalling param");
66 return RET_ERR;
67 }
68 CHKPR(context_, RET_ERR);
69 FI_HILOGD("Stop drag");
70 return RET_OK;
71 }
72
AddWatch(CallingContext & context,uint32_t id,MessageParcel & data,MessageParcel & reply)73 int32_t DragServer::AddWatch(CallingContext &context, uint32_t id, MessageParcel &data, MessageParcel &reply)
74 {
75 CALL_DEBUG_ENTER;
76 switch (id) {
77 case DragRequestID::ADD_DRAG_LISTENER: {
78 FI_HILOGD("Add drag listener");
79 return RET_OK;
80 }
81 case DragRequestID::ADD_SUBSCRIPT_LISTENER: {
82 FI_HILOGD("Add subscript listener");
83 return RET_OK;
84 }
85 default: {
86 FI_HILOGE("Unexpected request ID (%{public}u)", id);
87 return RET_ERR;
88 }
89 }
90 }
91
RemoveWatch(CallingContext & context,uint32_t id,MessageParcel & data,MessageParcel & reply)92 int32_t DragServer::RemoveWatch(CallingContext &context, uint32_t id, MessageParcel &data, MessageParcel &reply)
93 {
94 CALL_DEBUG_ENTER;
95 switch (id) {
96 case DragRequestID::ADD_DRAG_LISTENER: {
97 FI_HILOGD("Remove drag listener");
98 return RET_OK;
99 }
100 case DragRequestID::ADD_SUBSCRIPT_LISTENER: {
101 FI_HILOGD("Remove subscript listener");
102 return RET_OK;
103 }
104 default: {
105 FI_HILOGE("Unexpected request ID (%{public}u)", id);
106 return RET_ERR;
107 }
108 }
109 }
110
SetParam(CallingContext & context,uint32_t id,MessageParcel & data,MessageParcel & reply)111 int32_t DragServer::SetParam(CallingContext &context, uint32_t id, MessageParcel &data, MessageParcel &reply)
112 {
113 CALL_DEBUG_ENTER;
114 switch (id) {
115 case DragRequestID::UPDATE_SHADOW_PIC: {
116 UpdateShadowPicParam param {};
117
118 if (!param.Unmarshalling(data)) {
119 FI_HILOGE("UpdateShadowPicParam::Unmarshalling fail");
120 return RET_ERR;
121 }
122 FI_HILOGD("Updata shadow pic");
123 return RET_OK;
124 }
125 default: {
126 FI_HILOGE("Unexpected request ID (%{public}u)", id);
127 return RET_ERR;
128 }
129 }
130 }
131
GetParam(CallingContext & context,uint32_t id,MessageParcel & data,MessageParcel & reply)132 int32_t DragServer::GetParam(CallingContext &context, uint32_t id, MessageParcel &data, MessageParcel &reply)
133 {
134 CALL_DEBUG_ENTER;
135 switch (id) {
136 case DragRequestID::GET_DRAG_DATA: {
137 DragData dragData {};
138 FI_HILOGD("Get drag data");
139 GetDragDataReply dragDataReply { dragData };
140
141 if (!dragDataReply.Marshalling(reply)) {
142 FI_HILOGE("GetDragDataReply::Marshalling fail");
143 return RET_ERR;
144 }
145 return RET_OK;
146 }
147 default: {
148 FI_HILOGE("Unexpected request ID (%{public}u)", id);
149 return RET_ERR;
150 }
151 }
152 }
153
Control(CallingContext & context,uint32_t id,MessageParcel & data,MessageParcel & reply)154 int32_t DragServer::Control(CallingContext &context, uint32_t id, MessageParcel &data, MessageParcel &reply)
155 {
156 CALL_DEBUG_ENTER;
157 return RET_ERR;
158 }
159 } // namespace DeviceStatus
160 } // namespace Msdp
161 } // namespace OHOS