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(
23 int32_t userData, const std::string &remoteNetworkId, int32_t startDeviceId, bool checkPermission)
24 : remoteNetworkId(remoteNetworkId), userData(userData), startDeviceId(startDeviceId),
25 checkPermission(checkPermission)
26 {
27 }
28
Marshalling(MessageParcel & parcel) const29 bool StartCooperateParam::Marshalling(MessageParcel &parcel) const
30 {
31 return (parcel.WriteString(remoteNetworkId) && parcel.WriteInt32(startDeviceId) && parcel.WriteInt32(userData) &&
32 parcel.WriteBool(checkPermission));
33 }
34
Unmarshalling(MessageParcel & parcel)35 bool StartCooperateParam::Unmarshalling(MessageParcel &parcel)
36 {
37 return (parcel.ReadString(remoteNetworkId) && parcel.ReadInt32(startDeviceId) && parcel.ReadInt32(userData) &&
38 parcel.ReadBool(checkPermission));
39 }
40
StopCooperateParam(int32_t userData,bool isUnchained,bool checkPermission)41 StopCooperateParam::StopCooperateParam(int32_t userData, bool isUnchained, bool checkPermission)
42 : userData(userData), isUnchained(isUnchained), checkPermission(checkPermission)
43 {
44 }
45
Marshalling(MessageParcel & parcel) const46 bool StopCooperateParam::Marshalling(MessageParcel &parcel) const
47 {
48 return (parcel.WriteBool(isUnchained) && parcel.WriteBool(checkPermission) && parcel.WriteInt32(userData));
49 }
50
Unmarshalling(MessageParcel & parcel)51 bool StopCooperateParam::Unmarshalling(MessageParcel &parcel)
52 {
53 return (parcel.ReadBool(isUnchained) && parcel.ReadBool(checkPermission) && parcel.ReadInt32(userData));
54 }
55
GetCooperateStateParam(int32_t userData,const std::string & networkId,bool checkPermission)56 GetCooperateStateParam::GetCooperateStateParam(int32_t userData, const std::string &networkId, bool checkPermission)
57 : networkId(networkId), userData(userData), checkPermission(checkPermission)
58 {
59 }
60
Marshalling(MessageParcel & parcel) const61 bool GetCooperateStateParam::Marshalling(MessageParcel &parcel) const
62 {
63 return (parcel.WriteInt32(userData) && parcel.WriteString(networkId) && parcel.WriteBool(checkPermission));
64 }
65
Unmarshalling(MessageParcel & parcel)66 bool GetCooperateStateParam::Unmarshalling(MessageParcel &parcel)
67 {
68 return (parcel.ReadInt32(userData) && parcel.ReadString(networkId) && parcel.ReadBool(checkPermission));
69 }
70
RegisterEventListenerParam(const std::string & networkId)71 RegisterEventListenerParam::RegisterEventListenerParam(const std::string &networkId) : networkId(networkId) { }
72
Marshalling(MessageParcel & parcel) const73 bool RegisterEventListenerParam::Marshalling(MessageParcel &parcel) const
74 {
75 return parcel.WriteString(networkId);
76 }
77
Unmarshalling(MessageParcel & parcel)78 bool RegisterEventListenerParam::Unmarshalling(MessageParcel &parcel)
79 {
80 return parcel.ReadString(networkId);
81 }
82
GetCooperateStateSyncParam(const std::string & udId)83 GetCooperateStateSyncParam::GetCooperateStateSyncParam(const std::string &udId) : udId(udId) { }
84
Marshalling(MessageParcel & parcel) const85 bool GetCooperateStateSyncParam::Marshalling(MessageParcel &parcel) const
86 {
87 return parcel.WriteString(udId);
88 }
89
Unmarshalling(MessageParcel & parcel)90 bool GetCooperateStateSyncParam::Unmarshalling(MessageParcel &parcel)
91 {
92 return parcel.ReadString(udId);
93 }
94
RegisterHotAreaListenerParam(int32_t userData,bool checkPermission)95 RegisterHotAreaListenerParam::RegisterHotAreaListenerParam(int32_t userData, bool checkPermission)
96 : userData(userData), checkPermission(checkPermission)
97 {
98 }
99
Marshalling(MessageParcel & parcel) const100 bool RegisterHotAreaListenerParam::Marshalling(MessageParcel &parcel) const
101 {
102 return parcel.WriteInt32(userData) && parcel.WriteBool(checkPermission);
103 }
104
Unmarshalling(MessageParcel & parcel)105 bool RegisterHotAreaListenerParam::Unmarshalling(MessageParcel &parcel)
106 {
107 return parcel.ReadInt32(userData) && parcel.ReadBool(checkPermission);
108 }
109
110 } // namespace DeviceStatus
111 } // namespace Msdp
112 } // namespace OHOS
113