• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "form_js_info.h"
17 #include "string_ex.h"
18 
19 namespace OHOS {
20 namespace AppExecFwk {
ReadFromParcel(Parcel & parcel)21 bool FormJsInfo::ReadFromParcel(Parcel &parcel)
22 {
23     formId = parcel.ReadInt64();
24     formName = Str16ToStr8(parcel.ReadString16());
25     bundleName = Str16ToStr8(parcel.ReadString16());
26     abilityName = Str16ToStr8(parcel.ReadString16());
27 
28     formTempFlg = parcel.ReadBool();
29     jsFormCodePath = Str16ToStr8(parcel.ReadString16());
30     formData = Str16ToStr8(parcel.ReadString16());
31 
32     auto bindingData = parcel.ReadParcelable<FormProviderData>();
33     if (nullptr == bindingData){
34         return false;
35     }
36     formProviderData = *bindingData;
37     return true;
38 }
39 
Unmarshalling(Parcel & parcel)40 FormJsInfo *FormJsInfo::Unmarshalling(Parcel &parcel)
41 {
42     FormJsInfo *formJsInfo = new (std::nothrow) FormJsInfo();
43     if (formJsInfo && !formJsInfo->ReadFromParcel(parcel)) {
44         delete formJsInfo;
45         formJsInfo = nullptr;
46     }
47     return formJsInfo;
48 }
49 
Marshalling(Parcel & parcel) const50 bool FormJsInfo::Marshalling(Parcel &parcel) const
51 {
52     // write formId
53     if (!parcel.WriteInt64(formId)) {
54         return false;
55     }
56     // write formName
57     if (!parcel.WriteString16(Str8ToStr16(formName))) {
58         return false;
59     }
60     // write bundleName
61     if (!parcel.WriteString16(Str8ToStr16(bundleName))) {
62         return false;
63     }
64     // write abilityName
65     if (!parcel.WriteString16(Str8ToStr16(abilityName))) {
66         return false;
67     }
68 
69     // write tempFlag
70     if (!parcel.WriteBool(formTempFlg)) {
71         return false;
72     }
73 
74     // write jsFormCodePath
75     if (!parcel.WriteString16(Str8ToStr16(jsFormCodePath))) {
76         return false;
77     }
78 
79     // write formData
80     if (!parcel.WriteString16(Str8ToStr16(formData))) {
81         return false;
82     }
83 
84     // write formProviderData
85     if (!parcel.WriteParcelable(&formProviderData)) {
86         return false;
87     }
88 
89     return true;
90 }
91 }  // namespace AppExecFwk
92 }  // namespace OHOS