• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ITEM_INFO_H
17 #define OHOS_FORM_FWK_FORM_ITEM_INFO_H
18 
19 #include <string>
20 #include <unordered_map>
21 #include <vector>
22 
23 #include "form_record.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 class FormItemInfo {
28 public:
29     /**
30      * @brief Get formId_.
31      * @return formId_.
32      */
33     int64_t GetFormId() const;
34     /**
35      * @brief Set value of formId_.
36      * @param formId Form Id.
37      */
38     void SetFormId(int64_t formId);
39     /**
40      * @brief Get packageName_.
41      * @return packageName_.
42      */
43     std::string GetPackageName() const;
44     /**
45      * @brief Set value of packageName_.
46      * @param packageName Package name.
47      */
48     void SetPackageName(const std::string &packageName);
49     /**
50      * @brief Get providerBundleName_.
51      * @return providerBundleName_.
52      */
53     std::string GetProviderBundleName() const;
54     /**
55      * @brief Set value of providerBundleName_.
56      * @param providerBundleName Provider bundle Name.
57      */
58     void SetProviderBundleName(const std::string &providerBundleName);
59     /**
60      * @brief Get hostBundleName_.
61      * @return hostBundleName_.
62      */
63     std::string GetHostBundleName() const;
64     /**
65      * @brief Set value of hostBundleName_.
66      * @param hostBundleName_ Host bundle Name.
67      */
68     void SetHostBundleName(const std::string &hostBundleName);
69     /**
70      * @brief Get moduleName_.
71      * @return moduleName_.
72      */
73     std::string GetModuleName() const;
74     /**
75      * @brief Set value of moduleName_.
76      * @param moduleName Module Name.
77      */
78     void SetModuleName(const std::string &moduleName);
79     /**
80      * @brief Get abilityName_.
81      * @return abilityName_.
82      */
83     std::string GetAbilityName() const;
84     /**
85      * @brief Set value of abilityName_.
86      * @param abilityName Ability name.
87      */
88     void SetAbilityName(const std::string &abilityName);
89     /**
90      * @brief Get formName_.
91      * @return formName_.
92      */
93     std::string GetFormName() const;
94     /**
95      * @brief Set value of formName_.
96      * @param formName Form name.
97      */
98     void SetFormName(const std::string &formName);
99     /**
100      * @brief Get jsComponentName_.
101      * @return jsComponentName_.
102      */
103     std::string GetJsComponentName() const;
104     /**
105      * @brief Set value of jsComponentName_.
106      * @param jsComponentName Js component name.
107      */
108     void SetJsComponentName(const std::string &jsComponentName);
109     /**
110      * @brief Get abilityModuleName_.
111      * @return abilityModuleName_.
112      */
113     std::string GetAbilityModuleName() const;
114     /**
115      * @brief Set value of abilityModuleName_.
116      * @param abilityModuleName ability module name_.
117      */
118     void SetAbilityModuleName(const std::string &abilityModuleName);
119     /**
120      * @brief Get specificationId_.
121      * @return specificationId_.
122      */
123     int GetSpecificationId() const;
124     /**
125      * @brief Set value of specificationId_.
126      * @param specificationId Specification id.
127      */
128     void SetSpecificationId(const int specificationId);
129 
130     /**
131      * @brief Obtains the updateFlag.
132      * @return Returns updateFlag.
133      */
134     bool IsEnableUpdateFlag() const;
135     /**
136      * @brief Set value of updateFlag_.
137      * @param isEnableUpdateFlag Enable update flag or not.
138      */
139     void SetEnableUpdateFlag(bool isEnableUpdateFlag);
140     /**
141      * @brief Get updateDuration_.
142      * @return updateDuration_.
143      */
144     int GetUpdateDuration() const;
145     /**
146      * @brief Set value of updateDuration_.
147      * @param updateDuration Update duration.
148      */
149     void SetUpdateDuration(int updateDuration);
150     /**
151      * @brief Get scheduledUpdateTime_.
152      * @return scheduledUpdateTime_.
153      */
154     std::string GetScheduledUpdateTime() const;
155     /**
156      * @brief Set value of scheduledUpdateTime_.
157      * @param scheduledUpdateTime Scheduled update time.
158      */
159     void SetScheduledUpdateTime(const std::string &scheduledUpdateTime);
160     /**
161      * @brief Get hapSourceDirs_.
162      * @param dirs Hap source dirs.
163      * @return Returns true on success, false on failure.
164      */
165     bool GetHapSourceDirs(std::vector<std::string> &dirs) const;
166     /**
167      * @brief Add hap source dir.
168      * @param hapSourceDir Hap source dir.
169      */
170     void AddHapSourceDirs(const std::string &hapSourceDir);
171     /**
172      * @brief Set value of hapSourceDirs_.
173      * @param hapSourceDirs Hap source dirs.
174      */
175     void SetHapSourceDirs(const std::vector<std::string> &hapSourceDirs);
176     /**
177      * @brief Obtains the temporaryFlag.
178      * @return Returns temporaryFlag.
179      */
180     bool IsTemporaryForm() const;
181     /**
182      * @brief Set value of temporaryFlag_.
183      * @param temporaryFlag Temporary flag.
184      */
185     void SetTemporaryFlag(bool temporaryFlag);
186     /**
187      * @brief Obtains the hap source by ability module name.
188      * @param moduleName ability module name
189      * @return Returns hap source.
190      */
191     std::string GetHapSourceByModuleName(const std::string &moduleName) const;
192     /**
193      * @brief Add module info.
194      * @param moduleName Module name.
195      * @param moduleSourceDir Module source dir.
196      */
197     void AddModuleInfo(const std::string &moduleName, const std::string &moduleSourceDir);
198     /**
199      * @brief Check if item valid or not.
200      * @return Valid or not
201      */
202     bool IsValidItem() const;
203     /**
204      * @brief Check if item match or not.
205      * @return Match or not
206      */
207     bool IsMatch(const FormRecord &record) const;
208     /**
209      * @brief Check if form config same or not.
210      * @return Same or not
211      */
212     bool IsSameFormConfig(const FormRecord &record) const;
213     /**
214      * @brief Check if visible notify or not.
215      * @return visible notify or not
216      */
217     bool IsFormVisibleNotify() const;
218     /**
219      * @brief Set value of formVisibleNotify_.
220      * @param isFormVisibleNotify visible notify or not.
221      */
222     void SetFormVisibleNotify(bool isFormVisibleNotify);
223     /**
224      * @brief Get formSrc_.
225      * @return formSrc_.
226      */
227     std::string GetFormSrc() const;
228     /**
229      * @brief Set value of formSrc_.
230      * @param formSrc form src.
231      */
232     void SetFormSrc(const std::string &formSrc);
233     /**
234      * @brief Get formWindow_.
235      * @return formWindow_.
236      */
237     FormWindow GetFormWindow() const;
238     /**
239      * @brief Set value of formWindow_.
240      * @param formWindow form window.
241      */
242     void SetFormWindow(const FormWindow &formWindow);
243     /**
244      * @brief Get versionCode_.
245      * @return versionCode_.
246      */
247     uint32_t GetVersionCode() const;
248     /**
249      * @brief Set value of versionCode_.
250      * @param versionCode bundle version code.
251      */
252     void SetVersionCode(const uint32_t versionCode);
253     /**
254      * @brief Get versionName_.
255      * @return versionName_.
256      */
257     std::string GetVersionName() const;
258     /**
259      * @brief Set value of versionName_.
260      * @param versionName bundle version name.
261      */
262     void SetVersionName(const std::string &versionName);
263     /**
264      * @brief Get compatibleVersion_.
265      * @return compatibleVersion_.
266      */
267     uint32_t GetCompatibleVersion() const;
268     /**
269      * @brief Set value of compatibleVersion_.
270      * @param compatibleVersion API compatible version.
271      */
272     void SetCompatibleVersion(const uint32_t &compatibleVersion);
273     /**
274      * @brief Get icon_.
275      * @return icon_.
276      */
277     std::string GetIcon() const;
278     /**
279      * @brief Get deviceId_.
280      * @return deviceId_.
281      */
282     std::string GetDeviceId();
283     /**
284      * @brief Set value of  deviceId_.
285      * @param deviceId.
286      */
287     void SetDeviceId(const std::string &deviceId);
288     /**
289      * @brief Get type_.
290      * @return type_.
291      */
292     FormType GetType() const;
293     /**
294      * @brief Set value of type_.
295      * @param type.
296      */
297     void SetType(const FormType &type);
298     /**
299      * @brief Obtains the isDynamic.
300      * @return Returns isDynamic.
301      */
302     bool IsDynamic() const;
303     /**
304      * @brief Set value of isDynamic.
305      * @param isDynamic isDynamic flag.
306      */
307     void SetIsDynamic(bool isDynamic);
308     /**
309      * @brief Get uiSyntax.
310      * @return uiSyntax.
311      */
312     FormType GetUiSyntax() const;
313     /**
314      * @brief Set value of uiSyntax.
315      * @param uiSyntax.
316      */
317     void SetUiSyntax(const FormType &uiSyntax);
318     /**
319      * @brief Set value of isSystemApp.
320      * @param isSystemApp systemAppFlag.
321      */
322     void SetSystemAppFlag(bool isSystemApp);
323     /**
324      * @brief Get systemAppFlag.
325      * @return systemAppFlag.
326      */
327     bool GetSystemAppFlag() const;
328 
329     void SetDataProxyFlag(bool dataProxyEnabled);
330     bool GetDataProxyFlag() const;
331 private:
332     /**
333      * @brief Equal or not.
334      * @param left left string.
335      * @param right right string.
336      * @return Equal or not
337      */
338     bool IsEqual(const std::string &left, const std::string &right);
339 
340 private:
341     int64_t formId_ = -1;
342     std::string packageName_ = "";
343     std::string providerBundleName_ = "";
344     std::string hostBundleName_ = "";
345     std::string moduleName_ = "";
346     std::string abilityName_ = "";
347     std::string formName_ = "";
348     int32_t specificationId_ = 0;
349     bool updateFlag_ = false;
350     int32_t updateDuration_ = 0;
351     std::string scheduledUpdateTime_ = "";
352     std::vector<std::string> hapSourceDirs_;
353     bool temporaryFlag_ = false;
354     bool formVisibleNotify_ = false;
355     std::string formSrc_ = "";
356     FormWindow formWindow_;
357     uint32_t versionCode_ = 0;
358     std::string versionName_ = "";
359     uint32_t compatibleVersion_ = 0;
360     FormType type_ = FormType::JS;
361     FormType uiSyntax_ = FormType::JS;
362     std::string icon_ = "";
363     bool isDynamic_ = true;
364 
365     std::string jsComponentName_ = "";
366     std::string abilityModuleName_ = "";
367     std::unordered_map<std::string, std::string> moduleInfoMap_;
368     std::string deviceId_ = "";
369     bool dataProxyEnabled_ = false;
370     bool isSystemApp_ = false;
371 };
372 } // namespace AppExecFwk
373 } // namespace OHOS
374 
375 #endif // OHOS_FORM_FWK_FORM_ITEM_INFO_H
376