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)22 StartCooperateParam::StartCooperateParam(int32_t userData, const std::string &remoteNetworkId,
23                                          int32_t startDeviceId, bool checkPermission)
24     : remoteNetworkId(remoteNetworkId), userData(userData),
25       startDeviceId(startDeviceId), checkPermission(checkPermission)
26 {}
27 
Marshalling(MessageParcel & parcel) const28 bool StartCooperateParam::Marshalling(MessageParcel &parcel) const
29 {
30     return (
31         parcel.WriteString(remoteNetworkId) &&
32         parcel.WriteInt32(startDeviceId) &&
33         parcel.WriteInt32(userData) &&
34         parcel.WriteBool(checkPermission)
35     );
36 }
37 
Unmarshalling(MessageParcel & parcel)38 bool StartCooperateParam::Unmarshalling(MessageParcel &parcel)
39 {
40     return (
41         parcel.ReadString(remoteNetworkId) &&
42         parcel.ReadInt32(startDeviceId) &&
43         parcel.ReadInt32(userData) &&
44         parcel.ReadBool(checkPermission)
45     );
46 }
47 
StopCooperateParam(int32_t userData,bool isUnchained,bool checkPermission)48 StopCooperateParam::StopCooperateParam(int32_t userData, bool isUnchained, bool checkPermission)
49     : userData(userData), isUnchained(isUnchained), checkPermission(checkPermission)
50 {}
51 
Marshalling(MessageParcel & parcel) const52 bool StopCooperateParam::Marshalling(MessageParcel &parcel) const
53 {
54     return (
55         parcel.WriteBool(isUnchained) &&
56         parcel.WriteBool(checkPermission) &&
57         parcel.WriteInt32(userData)
58     );
59 }
60 
Unmarshalling(MessageParcel & parcel)61 bool StopCooperateParam::Unmarshalling(MessageParcel &parcel)
62 {
63     return (
64         parcel.ReadBool(isUnchained) &&
65         parcel.ReadBool(checkPermission) &&
66         parcel.ReadInt32(userData)
67     );
68 }
69 
GetCooperateStateParam(int32_t userData,const std::string & networkId,bool checkPermission)70 GetCooperateStateParam::GetCooperateStateParam(int32_t userData, const std::string &networkId, bool checkPermission)
71     : networkId(networkId), userData(userData), checkPermission(checkPermission)
72 {}
73 
Marshalling(MessageParcel & parcel) const74 bool GetCooperateStateParam::Marshalling(MessageParcel &parcel) const
75 {
76     return (
77         parcel.WriteInt32(userData) &&
78         parcel.WriteString(networkId) &&
79         parcel.WriteBool(checkPermission)
80     );
81 }
82 
Unmarshalling(MessageParcel & parcel)83 bool GetCooperateStateParam::Unmarshalling(MessageParcel &parcel)
84 {
85     return (
86         parcel.ReadInt32(userData) &&
87         parcel.ReadString(networkId) &&
88         parcel.ReadBool(checkPermission)
89     );
90 }
91 
RegisterEventListenerParam(const std::string & networkId)92 RegisterEventListenerParam::RegisterEventListenerParam(const std::string &networkId) : networkId(networkId)
93 {}
94 
Marshalling(MessageParcel & parcel) const95 bool RegisterEventListenerParam::Marshalling(MessageParcel &parcel) const
96 {
97     return parcel.WriteString(networkId);
98 }
99 
Unmarshalling(MessageParcel & parcel)100 bool RegisterEventListenerParam::Unmarshalling(MessageParcel &parcel)
101 {
102     return parcel.ReadString(networkId);
103 }
104 
GetCooperateStateSyncParam(const std::string & udId)105 GetCooperateStateSyncParam::GetCooperateStateSyncParam(const std::string &udId) : udId(udId)
106 {}
107 
Marshalling(MessageParcel & parcel) const108 bool GetCooperateStateSyncParam::Marshalling(MessageParcel &parcel) const
109 {
110     return parcel.WriteString(udId);
111 }
112 
Unmarshalling(MessageParcel & parcel)113 bool GetCooperateStateSyncParam::Unmarshalling(MessageParcel &parcel)
114 {
115     return parcel.ReadString(udId);
116 }
117 
RegisterHotAreaListenerParam(int32_t userData,bool checkPermission)118 RegisterHotAreaListenerParam::RegisterHotAreaListenerParam(int32_t userData, bool checkPermission) : userData(userData),
119     checkPermission(checkPermission)
120 {}
121 
Marshalling(MessageParcel & parcel) const122 bool RegisterHotAreaListenerParam::Marshalling(MessageParcel &parcel) const
123 {
124     return parcel.WriteInt32(userData) &&
125         parcel.WriteBool(checkPermission);
126 }
127 
Unmarshalling(MessageParcel & parcel)128 bool RegisterHotAreaListenerParam::Unmarshalling(MessageParcel &parcel)
129 {
130     return parcel.ReadInt32(userData) &&
131         parcel.ReadBool(checkPermission);
132 }
133 
134 } // namespace DeviceStatus
135 } // namespace Msdp
136 } // namespace OHOS
137