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 #ifndef OHOS_FORM_FWK_FORM_JS_INFO_H
17 #define OHOS_FORM_FWK_FORM_JS_INFO_H
18 
19 #include <string>
20 #include "form_ashmem.h"
21 #include "form_provider_data.h"
22 #include "form_info_base.h"
23 #include "parcel.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 /**
28  * @struct FormJsInfo
29  * Defines form js info.
30  */
31 struct FormJsInfo : public Parcelable {
32     static constexpr int IMAGE_DATA_THRESHOLD = 128;
33     int64_t formId;
34     std::string formName;
35     std::string bundleName;
36     std::string abilityName;
37     std::string moduleName;
38     std::map<std::string, std::string> modulePkgNameMap;
39     bool formTempFlag = false;
40     std::string jsFormCodePath;
41     std::string formData;
42     std::map<std::string, sptr<FormAshmem>> imageDataMap;
43     FormProviderData formProviderData;
44     std::string formSrc;
45     FormWindow formWindow;
46     uint32_t versionCode = 0;
47     std::string versionName;
48     uint32_t compatibleVersion = 0;
49     FormType type = FormType::JS;
50     FormType uiSyntax = FormType::JS;
51     bool isDynamic = true;
52     bool transparencyEnabled = false;
53 
54     bool ReadFromParcel(Parcel &parcel);
55     virtual bool Marshalling(Parcel &parcel) const override;
56     static FormJsInfo *Unmarshalling(Parcel &parcel);
57     bool WriteObjects(Parcel &parcel) const;
58     bool WriteImageData(Parcel &parcel) const;
59     void ReadImageData(Parcel &parcel);
60     bool ConvertRawImageData();
61     bool WritePkgNameMap(Parcel &parcel) const;
62     void ReadPkgNameMap(Parcel &parcel);
63 };
64 } // namespace AppExecFwk
65 } // namespace OHOS
66 #endif // OHOS_FORM_FWK_FORM_JS_INFO_H