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
18namespace OHOS {
19namespace Msdp {
20namespace DeviceStatus {
21
22StartCooperateParam::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
28bool 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
38bool 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
48StopCooperateParam::StopCooperateParam(int32_t userData, bool isUnchained, bool checkPermission)
49    : userData(userData), isUnchained(isUnchained), checkPermission(checkPermission)
50{}
51
52bool StopCooperateParam::Marshalling(MessageParcel &parcel) const
53{
54    return (
55        parcel.WriteBool(isUnchained) &&
56        parcel.WriteBool(checkPermission) &&
57        parcel.WriteInt32(userData)
58    );
59}
60
61bool StopCooperateParam::Unmarshalling(MessageParcel &parcel)
62{
63    return (
64        parcel.ReadBool(isUnchained) &&
65        parcel.ReadBool(checkPermission) &&
66        parcel.ReadInt32(userData)
67    );
68}
69
70GetCooperateStateParam::GetCooperateStateParam(int32_t userData, const std::string &networkId, bool checkPermission)
71    : networkId(networkId), userData(userData), checkPermission(checkPermission)
72{}
73
74bool GetCooperateStateParam::Marshalling(MessageParcel &parcel) const
75{
76    return (
77        parcel.WriteInt32(userData) &&
78        parcel.WriteString(networkId) &&
79        parcel.WriteBool(checkPermission)
80    );
81}
82
83bool GetCooperateStateParam::Unmarshalling(MessageParcel &parcel)
84{
85    return (
86        parcel.ReadInt32(userData) &&
87        parcel.ReadString(networkId) &&
88        parcel.ReadBool(checkPermission)
89    );
90}
91
92RegisterEventListenerParam::RegisterEventListenerParam(const std::string &networkId) : networkId(networkId)
93{}
94
95bool RegisterEventListenerParam::Marshalling(MessageParcel &parcel) const
96{
97    return parcel.WriteString(networkId);
98}
99
100bool RegisterEventListenerParam::Unmarshalling(MessageParcel &parcel)
101{
102    return parcel.ReadString(networkId);
103}
104
105GetCooperateStateSyncParam::GetCooperateStateSyncParam(const std::string &udId) : udId(udId)
106{}
107
108bool GetCooperateStateSyncParam::Marshalling(MessageParcel &parcel) const
109{
110    return parcel.WriteString(udId);
111}
112
113bool GetCooperateStateSyncParam::Unmarshalling(MessageParcel &parcel)
114{
115    return parcel.ReadString(udId);
116}
117
118RegisterHotAreaListenerParam::RegisterHotAreaListenerParam(int32_t userData, bool checkPermission) : userData(userData),
119    checkPermission(checkPermission)
120{}
121
122bool RegisterHotAreaListenerParam::Marshalling(MessageParcel &parcel) const
123{
124    return parcel.WriteInt32(userData) &&
125        parcel.WriteBool(checkPermission);
126}
127
128bool 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