• 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 #ifndef FOUNDATION_APPEXECFWK_OHOS_FORM_PROVIDER_INFO_H
17 #define FOUNDATION_APPEXECFWK_OHOS_FORM_PROVIDER_INFO_H
18 
19 #include <string>
20 #include "form_provider_data.h"
21 #include "parcel.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 /**
26  * @struct FormProviderInfo
27  * Defines form provider info.
28  */
29 class FormProviderInfo : public Parcelable {
30 public:
31     FormProviderInfo() = default;
32     ~FormProviderInfo() = default;
33 
34     /**
35      * @brief Set the form data.
36      * @param formProviderData The form data.
37      */
SetFormData(const FormProviderData & formProviderData)38     inline void SetFormData(const FormProviderData &formProviderData)
39     {
40         jsBindingData_ = formProviderData;
41     }
42 
43     /**
44      * @brief Get the form data.
45      * @return the form data.
46      */
GetFormData()47     inline FormProviderData GetFormData() const
48     {
49         return jsBindingData_;
50     }
51     /**
52      * @brief Get the form data.
53      * @return the form data.
54      */
GetFormDataString()55     inline std::string GetFormDataString() const
56     {
57         return jsBindingData_.GetDataString();
58     }
59 
60     /**
61      * @brief Set the upgrade flg.
62      * @param upgradeFlg The upgrade flg.
63      */
SetUpgradeFlg(const bool upgradeFlg)64     inline void SetUpgradeFlg(const bool upgradeFlg)
65     {
66         upgradeFlg_ = upgradeFlg;
67     }
68     /**
69      * @brief Get the upgrade flg.
70      * @return the upgrade flg.
71      */
GetUpgradeFlg()72     inline bool GetUpgradeFlg() const
73     {
74         return upgradeFlg_;
75     }
76 
77     /**
78      * @brief Set form date by string.
79      * @param dataString string json data.
80      */
81     void SetFormDataString(std::string &dataString);
82 
83     /**
84      * @brief Updates imageDataMap in this {@code FormProviderData} object.
85      * @param imageDataMap Indicates the imageDataMap to update.
86      */
87     void SetImageDataMap(std::map<std::string, std::pair<sptr<FormAshmem>, int32_t>> imageDataMap);
88 
89     /**
90      * @brief Obtains the imageDataMap stored in this {@code FormProviderData} object.
91      * @return Returns the map that contains shared image data.
92      */
93     std::map<std::string, std::pair<sptr<FormAshmem>, int32_t>> GetImageDataMap() const;
94 
95     /**
96      * @brief Merge new data to FormProviderData.
97      * @param addJsonData data to merge to FormProviderData
98      */
99     void MergeData(nlohmann::json &addJsonData);
100 
101     bool ReadFromParcel(Parcel &parcel);
102     virtual bool Marshalling(Parcel &parcel) const override;
103     static FormProviderInfo *Unmarshalling(Parcel &parcel);
104 private:
105     FormProviderData jsBindingData_;
106     bool upgradeFlg_;
107 };
108 }  // namespace AppExecFwk
109 }  // namespace OHOS
110 #endif  // FOUNDATION_APPEXECFWK_OHOS_FORM_PROVIDER_INFO_H
111