• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 } // namespace DeviceStatus
92 } // namespace Msdp
93 } // namespace OHOS
94