• 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 #include "form_constants.h"
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 Get multiScheduledUpdateTime_.
157      * @return multiScheduledUpdateTime_.
158      */
159     std::string GetMultiScheduledUpdateTime() const;
160     /**
161      * @brief Set value of scheduledUpdateTime_.
162      * @param scheduledUpdateTime Scheduled update time.
163      */
164     void SetScheduledUpdateTime(const std::string &scheduledUpdateTime);
165     /**
166      * @brief Set value of multiScheduledUpdateTime_.
167      * @param multiScheduledUpdateTime Scheduled update time.
168      */
169     void SetMultiScheduledUpdateTime(const std::string &multiScheduledUpdateTime);
170     /**
171      * @brief Get hapSourceDirs_.
172      * @param dirs Hap source dirs.
173      * @return Returns true on success, false on failure.
174      */
175     bool GetHapSourceDirs(std::vector<std::string> &dirs) const;
176     /**
177      * @brief Add hap source dir.
178      * @param hapSourceDir Hap source dir.
179      */
180     void AddHapSourceDirs(const std::string &hapSourceDir);
181     /**
182      * @brief Set value of hapSourceDirs_.
183      * @param hapSourceDirs Hap source dirs.
184      */
185     void SetHapSourceDirs(const std::vector<std::string> &hapSourceDirs);
186     /**
187      * @brief Obtains the temporaryFlag.
188      * @return Returns temporaryFlag.
189      */
190     bool IsTemporaryForm() const;
191     /**
192      * @brief Set value of temporaryFlag_.
193      * @param temporaryFlag Temporary flag.
194      */
195     void SetTemporaryFlag(bool temporaryFlag);
196     /**
197      * @brief Obtains the hap source by ability module name.
198      * @param moduleName ability module name
199      * @return Returns hap source.
200      */
201     std::string GetHapSourceByModuleName(const std::string &moduleName) const;
202     /**
203      * @brief Add module info.
204      * @param moduleName Module name.
205      * @param moduleSourceDir Module source dir.
206      */
207     void AddModuleInfo(const std::string &moduleName, const std::string &moduleSourceDir);
208     /**
209      * @brief Add module package name.
210      * @param moduleName Module name.
211      * @param packageName Package name.
212      */
213     void AddModulePkgName(const std::string &moduleName, const std::string &packageName);
214     /**
215      * @brief Get module package name map.
216      * @return Module package name map
217      */
218     const std::map<std::string, std::string>& GetModulePkgNameMap() const;
219     /**
220      * @brief Check if item valid or not.
221      * @return Valid or not
222      */
223     bool IsValidItem() const;
224     /**
225      * @brief Check if item match or not.
226      * @return Match or not
227      */
228     bool IsMatch(const FormRecord &record) const;
229     /**
230      * @brief Check if form config same or not.
231      * @return Same or not
232      */
233     bool IsSameFormConfig(const FormRecord &record) const;
234     /**
235      * @brief Check if visible notify or not.
236      * @return visible notify or not
237      */
238     bool IsFormVisibleNotify() const;
239     /**
240      * @brief Set value of formVisibleNotify_.
241      * @param isFormVisibleNotify visible notify or not.
242      */
243     void SetFormVisibleNotify(bool isFormVisibleNotify);
244     /**
245      * @brief Get formSrc_.
246      * @return formSrc_.
247      */
248     std::string GetFormSrc() const;
249     /**
250      * @brief Set value of formSrc_.
251      * @param formSrc form src.
252      */
253     void SetFormSrc(const std::string &formSrc);
254     /**
255      * @brief Get formWindow_.
256      * @return formWindow_.
257      */
258     FormWindow GetFormWindow() const;
259     /**
260      * @brief Set value of formWindow_.
261      * @param formWindow form window.
262      */
263     void SetFormWindow(const FormWindow &formWindow);
264     /**
265      * @brief Get versionCode_.
266      * @return versionCode_.
267      */
268     uint32_t GetVersionCode() const;
269     /**
270      * @brief Set value of versionCode_.
271      * @param versionCode bundle version code.
272      */
273     void SetVersionCode(const uint32_t versionCode);
274     /**
275      * @brief Get versionName_.
276      * @return versionName_.
277      */
278     std::string GetVersionName() const;
279     /**
280      * @brief Set value of versionName_.
281      * @param versionName bundle version name.
282      */
283     void SetVersionName(const std::string &versionName);
284     /**
285      * @brief Get compatibleVersion_.
286      * @return compatibleVersion_.
287      */
288     uint32_t GetCompatibleVersion() const;
289     /**
290      * @brief Set value of compatibleVersion_.
291      * @param compatibleVersion API compatible version.
292      */
293     void SetCompatibleVersion(const uint32_t &compatibleVersion);
294     /**
295      * @brief Get icon_.
296      * @return icon_.
297      */
298     std::string GetIcon() const;
299     /**
300      * @brief Get deviceId_.
301      * @return deviceId_.
302      */
303     std::string GetDeviceId();
304     /**
305      * @brief Set value of  deviceId_.
306      * @param deviceId.
307      */
308     void SetDeviceId(const std::string &deviceId);
309     /**
310      * @brief Get type_.
311      * @return type_.
312      */
313     FormType GetType() const;
314     /**
315      * @brief Set value of type_.
316      * @param type.
317      */
318     void SetType(const FormType &type);
319     /**
320      * @brief Obtains the isDynamic.
321      * @return Returns isDynamic.
322      */
323     bool IsDynamic() const;
324     /**
325      * @brief Set value of isDynamic.
326      * @param isDynamic isDynamic flag.
327      */
328     void SetIsDynamic(bool isDynamic);
329     /**
330      * @brief Obtains the transparencyEnabled.
331      * @return Returns transparencyEnabled.
332      */
333     bool IsTransparencyEnabled() const;
334     /**
335      * @brief Set value of transparencyEnabled.
336      * @param isTransparencyEnabled transparencyEnabled flag.
337      */
338     void SetTransparencyEnabled(bool isTransparencyEnabled);
339     /**
340      * @brief Obtains the privacyLevel.
341      * @return Returns privacyLevel.
342      */
343     int32_t GetPrivacyLevel() const;
344     /**
345      * @brief Set value of privacyLevel.
346      * @param level privacyLevel.
347      */
348     void SetPrivacyLevel(int32_t level);
349     /**
350      * @brief Get uiSyntax.
351      * @return uiSyntax.
352      */
353     FormType GetUiSyntax() const;
354     /**
355      * @brief Set value of uiSyntax.
356      * @param uiSyntax.
357      */
358     void SetUiSyntax(const FormType &uiSyntax);
359     /**
360      * @brief Set value of isSystemApp.
361      * @param isSystemApp systemAppFlag.
362      */
363     void SetSystemAppFlag(bool isSystemApp);
364     /**
365      * @brief Get systemAppFlag.
366      * @return systemAppFlag.
367      */
368     bool GetSystemAppFlag() const;
369 
370     void SetDataProxyFlag(bool dataProxyEnabled);
371     bool GetDataProxyFlag() const;
372 
373     /**
374      * @brief save the uid of formProvider.
375      * @param uid the uid of formProvider.
376      */
377     void SetProviderUid(int32_t uid);
378     /**
379      * @brief Get the uid of formProvider.
380      * @return uid.
381      */
382     int32_t GetProviderUid() const;
383 
384     /**
385      * @brief Save the description of formInfo.
386      * @param description The description of formInfo.
387      */
388     void SetDescription(const std::string &description);
389     /**
390      * @brief Get the description of formInfo.
391      * @return description.
392      */
393     std::string GetDescription() const;
394 
395     /**
396      * @brief Get the formLocation of formInfo.
397      * @return formLocation.
398      */
399     Constants::FormLocation GetFormLocation() const;
400 
401     /**
402      * @brief set the formLocation.
403      * @param formLocation The FormLocation.
404      */
405     void SetFormLocation(Constants::FormLocation formLocation);
406 
407     /**
408      * @brief Get whether it belongs to theme form.
409      * @return is theme form or not.
410      */
411     bool GetIsThemeForm() const;
412 
413     /**
414      * @brief Set whether it belongs to theme form.
415      * @param isThemeForm is theme form or not.
416      */
417     void SetIsThemeForm(bool isThemeForm);
418 
419     /**
420      * @brief Get bundleType of formProvider.
421      * @return bundleType of from.
422      */
423     BundleType GetFormBundleType() const;
424 
425     /**
426      * @brief Set bundleType of formProvider.
427      * @param formBundleType formBundleType
428      */
429     void SetFormBundleType(BundleType formBundleType);
430 
431     /**
432      * @brief Get whether form bundle is enable.
433      * @return True for enable form bundle, false for disable form bundle.
434      */
435     bool IsEnableForm() const;
436 
437     /**
438      * @brief Set whether form bundle is enable.
439      * @param enableForm True for enable form bundle, false for disable form bundle.
440      */
441     void SetEnableForm(bool enableForm);
442 
443     /**
444      * @brief Get renderingMode of form.
445      * @return renderingMode of from.
446      */
447     Constants::RenderingMode GetRenderingMode() const;
448 
449     /**
450      * @brief Set renderingMode of form.
451      * @param renderingMode renderingMode
452      */
453     void SetRenderingMode(Constants::RenderingMode renderingMode);
454 
455     /**
456      * @brief Get whether is lock.
457      * @return True for lock, false for unlock.
458      */
459     bool IsLockForm() const;
460 
461     /**
462      * @brief Set whether is lock.
463      * @param lockForm True for lock, false for unlock.
464      */
465     void SetLockForm(bool lockForm);
466 
467     /**
468      * @brief Get whether is protect.
469      * @return True for protect, false for unprotect.
470      */
471     bool IsProtectForm() const;
472 
473     /**
474      * @brief Set whether is protect.
475      * @param protectForm True for protect, false for unprotect.
476      */
477     void SetProtectForm(bool protectForm);
478     /**
479      * @brief Get updateDuration_.
480      * @return updateDuration_.
481      */
482     std::vector<int32_t> GetConditionUpdate() const;
483     /**
484      * @brief Set value of updateDuration_.
485      * @param updateDuration Update duration.
486      */
487     void SetConditionUpdate(const std::vector<int32_t> &conditionUpdate);
488 
489 private:
490     /**
491      * @brief Equal or not.
492      * @param left left string.
493      * @param right right string.
494      * @return Equal or not
495      */
496     bool IsEqual(const std::string &left, const std::string &right);
497 
498 private:
499     int64_t formId_ = -1;
500     std::string packageName_ = "";
501     std::string providerBundleName_ = "";
502     std::string hostBundleName_ = "";
503     std::string moduleName_ = "";
504     std::string abilityName_ = "";
505     std::string formName_ = "";
506     int32_t specificationId_ = 0;
507     bool updateFlag_ = false;
508     int32_t updateDuration_ = 0;
509     std::string scheduledUpdateTime_ = "";
510     std::string multiScheduledUpdateTime_ = "";
511     std::vector<std::string> hapSourceDirs_;
512     bool temporaryFlag_ = false;
513     bool formVisibleNotify_ = false;
514     std::string formSrc_ = "";
515     FormWindow formWindow_;
516     uint32_t versionCode_ = 0;
517     std::string versionName_ = "";
518     uint32_t compatibleVersion_ = 0;
519     FormType type_ = FormType::JS;
520     FormType uiSyntax_ = FormType::JS;
521     std::string icon_ = "";
522     bool isDynamic_ = true;
523     bool transparencyEnabled_ = false;
524     int32_t privacyLevel_ = 0;
525     std::string jsComponentName_ = "";
526     std::string abilityModuleName_ = "";
527     std::unordered_map<std::string, std::string> moduleInfoMap_;
528     std::map<std::string, std::string> modulePkgNameMap_;
529     std::string deviceId_ = "";
530     bool dataProxyEnabled_ = false;
531     bool isSystemApp_ = false;
532     int32_t uid_ = -1;
533     std::string description_ = "";
534     Constants::FormLocation formLocation_;
535     bool isThemeForm_ = false;
536     BundleType bundleType_ = BundleType::APP;
537     bool enableForm_ = true;
538     Constants::RenderingMode renderingMode_ = Constants::RenderingMode::FULL_COLOR;
539     bool lockForm_ = false;
540     bool protectForm_ = false;
541     std::vector<int32_t> conditionUpdate_;
542 };
543 } // namespace AppExecFwk
544 } // namespace OHOS
545 
546 #endif // OHOS_FORM_FWK_FORM_ITEM_INFO_H
547