1 /* 2 * Copyright (c) 2021-2022 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 "multimodal_input_connect_def_parcel.h" 17 #include "mmi_log.h" 18 19 namespace OHOS { 20 namespace MMI { Marshalling(Parcel & out) const21bool ConnectReqParcel::Marshalling(Parcel& out) const 22 { 23 if (!out.WriteInt32(data.moduleId)) { 24 return false; 25 } 26 if (!out.WriteString(data.clientName)) { 27 return false; 28 } 29 return true; 30 } 31 Unmarshalling(Parcel & in)32ConnectReqParcel *ConnectReqParcel::Unmarshalling(Parcel& in) 33 { 34 auto* request = new (std::nothrow) ConnectReqParcel(); 35 if (request == nullptr) { 36 return nullptr; 37 } 38 39 if (!in.ReadInt32(request->data.moduleId)) { 40 delete request; 41 request = nullptr; 42 return nullptr; 43 } 44 45 request->data.clientName = in.ReadString(); 46 return request; 47 } 48 Marshalling(Parcel & out) const49bool ConnectRespParcel::Marshalling(Parcel &out) const 50 { 51 if (!out.WriteInt32(data.returnCode)) { 52 return false; 53 } 54 if (!out.WriteInt32(data.allocedSocketId)) { 55 return false; 56 } 57 return true; 58 } 59 Unmarshalling(Parcel & in)60ConnectRespParcel *ConnectRespParcel::Unmarshalling(Parcel &in) 61 { 62 auto *response = new (std::nothrow) ConnectRespParcel(); 63 if (response == nullptr) { 64 return nullptr; 65 } 66 67 if (!in.ReadInt32(response->data.returnCode)) { 68 delete response; 69 response = nullptr; 70 return nullptr; 71 } 72 73 if (!in.ReadInt32(response->data.allocedSocketId)) { 74 delete response; 75 response = nullptr; 76 return nullptr; 77 } 78 return response; 79 } 80 } // namespace MMI 81 } // namespace OHOS 82