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 "cooperate_params.h"
17
18 namespace OHOS {
19 namespace Msdp {
20 namespace DeviceStatus {
21
StartCooperateParam(int32_t userData,const std::string & remoteNetworkId,int32_t startDeviceId,bool checkPermission,const CooperateOptions & options,int32_t cooperateParamType)22 StartCooperateParam::StartCooperateParam(int32_t userData, const std::string &remoteNetworkId,
23 int32_t startDeviceId, bool checkPermission, const CooperateOptions &options,
24 int32_t cooperateParamType)
25 : remoteNetworkId(remoteNetworkId), userData(userData), startDeviceId(startDeviceId),
26 checkPermission(checkPermission), options(options), cooperateParamType(cooperateParamType)
27 {}
28
Marshalling(MessageParcel & parcel) const29 bool StartCooperateParam::Marshalling(MessageParcel &parcel) const
30 {
31 return (
32 parcel.WriteString(remoteNetworkId) &&
33 parcel.WriteInt32(startDeviceId) &&
34 parcel.WriteInt32(userData) &&
35 parcel.WriteBool(checkPermission) &&
36 parcel.WriteInt32(options.displayX) &&
37 parcel.WriteInt32(options.displayY) &&
38 parcel.WriteInt32(options.displayId) &&
39 parcel.WriteInt32(cooperateParamType)
40 );
41 }
42
Unmarshalling(MessageParcel & parcel)43 bool StartCooperateParam::Unmarshalling(MessageParcel &parcel)
44 {
45 return (
46 parcel.ReadString(remoteNetworkId) &&
47 parcel.ReadInt32(startDeviceId) &&
48 parcel.ReadInt32(userData) &&
49 parcel.ReadBool(checkPermission) &&
50 parcel.ReadInt32(options.displayX) &&
51 parcel.ReadInt32(options.displayY) &&
52 parcel.ReadInt32(options.displayId) &&
53 parcel.ReadInt32(cooperateParamType)
54 );
55 }
56
StopCooperateParam(int32_t userData,bool isUnchained,bool checkPermission)57 StopCooperateParam::StopCooperateParam(int32_t userData, bool isUnchained, bool checkPermission)
58 : userData(userData), isUnchained(isUnchained), checkPermission(checkPermission)
59 {}
60
Marshalling(MessageParcel & parcel) const61 bool StopCooperateParam::Marshalling(MessageParcel &parcel) const
62 {
63 return (
64 parcel.WriteBool(isUnchained) &&
65 parcel.WriteBool(checkPermission) &&
66 parcel.WriteInt32(userData)
67 );
68 }
69
Unmarshalling(MessageParcel & parcel)70 bool StopCooperateParam::Unmarshalling(MessageParcel &parcel)
71 {
72 return (
73 parcel.ReadBool(isUnchained) &&
74 parcel.ReadBool(checkPermission) &&
75 parcel.ReadInt32(userData)
76 );
77 }
78
GetCooperateStateParam(int32_t userData,const std::string & networkId,bool checkPermission)79 GetCooperateStateParam::GetCooperateStateParam(int32_t userData, const std::string &networkId, bool checkPermission)
80 : networkId(networkId), userData(userData), checkPermission(checkPermission)
81 {}
82
Marshalling(MessageParcel & parcel) const83 bool GetCooperateStateParam::Marshalling(MessageParcel &parcel) const
84 {
85 return (
86 parcel.WriteInt32(userData) &&
87 parcel.WriteString(networkId) &&
88 parcel.WriteBool(checkPermission)
89 );
90 }
91
Unmarshalling(MessageParcel & parcel)92 bool GetCooperateStateParam::Unmarshalling(MessageParcel &parcel)
93 {
94 return (
95 parcel.ReadInt32(userData) &&
96 parcel.ReadString(networkId) &&
97 parcel.ReadBool(checkPermission)
98 );
99 }
100
RegisterEventListenerParam(const std::string & networkId)101 RegisterEventListenerParam::RegisterEventListenerParam(const std::string &networkId) : networkId(networkId)
102 {}
103
Marshalling(MessageParcel & parcel) const104 bool RegisterEventListenerParam::Marshalling(MessageParcel &parcel) const
105 {
106 return parcel.WriteString(networkId);
107 }
108
Unmarshalling(MessageParcel & parcel)109 bool RegisterEventListenerParam::Unmarshalling(MessageParcel &parcel)
110 {
111 return parcel.ReadString(networkId);
112 }
113
SetDamplingCoefficientParam(uint32_t direction,double coefficient)114 SetDamplingCoefficientParam::SetDamplingCoefficientParam(uint32_t direction, double coefficient)
115 : direction(direction), coefficient(coefficient) {}
116
Marshalling(MessageParcel & parcel) const117 bool SetDamplingCoefficientParam::Marshalling(MessageParcel &parcel) const
118 {
119 return (
120 parcel.WriteUint32(direction) &&
121 parcel.WriteDouble(coefficient)
122 );
123 }
124
Unmarshalling(MessageParcel & parcel)125 bool SetDamplingCoefficientParam::Unmarshalling(MessageParcel &parcel)
126 {
127 return (
128 parcel.ReadUint32(direction) &&
129 parcel.ReadDouble(coefficient)
130 );
131 }
132
GetCooperateStateSyncParam(const std::string & udId)133 GetCooperateStateSyncParam::GetCooperateStateSyncParam(const std::string &udId) : udId(udId)
134 {}
135
Marshalling(MessageParcel & parcel) const136 bool GetCooperateStateSyncParam::Marshalling(MessageParcel &parcel) const
137 {
138 return parcel.WriteString(udId);
139 }
140
Unmarshalling(MessageParcel & parcel)141 bool GetCooperateStateSyncParam::Unmarshalling(MessageParcel &parcel)
142 {
143 return parcel.ReadString(udId);
144 }
145
RegisterHotAreaListenerParam(int32_t userData,bool checkPermission)146 RegisterHotAreaListenerParam::RegisterHotAreaListenerParam(int32_t userData, bool checkPermission) : userData(userData),
147 checkPermission(checkPermission)
148 {}
149
Marshalling(MessageParcel & parcel) const150 bool RegisterHotAreaListenerParam::Marshalling(MessageParcel &parcel) const
151 {
152 return parcel.WriteInt32(userData) &&
153 parcel.WriteBool(checkPermission);
154 }
155
Unmarshalling(MessageParcel & parcel)156 bool RegisterHotAreaListenerParam::Unmarshalling(MessageParcel &parcel)
157 {
158 return parcel.ReadInt32(userData) &&
159 parcel.ReadBool(checkPermission);
160 }
161 } // namespace DeviceStatus
162 } // namespace Msdp
163 } // namespace OHOS
164