• 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 Obtains the transparencyEnabled.
310      * @return Returns transparencyEnabled.
311      */
312     bool IsTransparencyEnabled() const;
313     /**
314      * @brief Set value of transparencyEnabled.
315      * @param isTransparencyEnabled transparencyEnabled flag.
316      */
317     void SetTransparencyEnabled(bool isTransparencyEnabled);
318     /**
319      * @brief Obtains the privacyLevel.
320      * @return Returns privacyLevel.
321      */
322     int32_t GetPrivacyLevel() const;
323     /**
324      * @brief Set value of privacyLevel.
325      * @param level privacyLevel.
326      */
327     void SetPrivacyLevel(int32_t level);
328     /**
329      * @brief Get uiSyntax.
330      * @return uiSyntax.
331      */
332     FormType GetUiSyntax() const;
333     /**
334      * @brief Set value of uiSyntax.
335      * @param uiSyntax.
336      */
337     void SetUiSyntax(const FormType &uiSyntax);
338     /**
339      * @brief Set value of isSystemApp.
340      * @param isSystemApp systemAppFlag.
341      */
342     void SetSystemAppFlag(bool isSystemApp);
343     /**
344      * @brief Get systemAppFlag.
345      * @return systemAppFlag.
346      */
347     bool GetSystemAppFlag() const;
348 
349     void SetDataProxyFlag(bool dataProxyEnabled);
350     bool GetDataProxyFlag() const;
351 
352     /**
353      * @brief save the uid of formProvider.
354      * @param uid the uid of formProvider.
355      */
356     void SetProviderUid(int32_t uid);
357     /**
358      * @brief Get the uid of formProvider.
359      * @return uid.
360      */
361     int32_t GetProviderUid() const;
362 
363     /**
364      * @brief Save the description of formInfo.
365      * @param description The description of formInfo.
366      */
367     void SetDescription(const std::string &description);
368     /**
369      * @brief Get the description of formInfo.
370      * @return description.
371      */
372     std::string GetDescription() const;
373 
374 private:
375     /**
376      * @brief Equal or not.
377      * @param left left string.
378      * @param right right string.
379      * @return Equal or not
380      */
381     bool IsEqual(const std::string &left, const std::string &right);
382 
383 private:
384     int64_t formId_ = -1;
385     std::string packageName_ = "";
386     std::string providerBundleName_ = "";
387     std::string hostBundleName_ = "";
388     std::string moduleName_ = "";
389     std::string abilityName_ = "";
390     std::string formName_ = "";
391     int32_t specificationId_ = 0;
392     bool updateFlag_ = false;
393     int32_t updateDuration_ = 0;
394     std::string scheduledUpdateTime_ = "";
395     std::vector<std::string> hapSourceDirs_;
396     bool temporaryFlag_ = false;
397     bool formVisibleNotify_ = false;
398     std::string formSrc_ = "";
399     FormWindow formWindow_;
400     uint32_t versionCode_ = 0;
401     std::string versionName_ = "";
402     uint32_t compatibleVersion_ = 0;
403     FormType type_ = FormType::JS;
404     FormType uiSyntax_ = FormType::JS;
405     std::string icon_ = "";
406     bool isDynamic_ = true;
407     bool transparencyEnabled_ = false;
408     int32_t privacyLevel_ = 0;
409     std::string jsComponentName_ = "";
410     std::string abilityModuleName_ = "";
411     std::unordered_map<std::string, std::string> moduleInfoMap_;
412     std::string deviceId_ = "";
413     bool dataProxyEnabled_ = false;
414     bool isSystemApp_ = false;
415     int32_t uid_ = -1;
416     std::string description_ = "";
417 };
418 } // namespace AppExecFwk
419 } // namespace OHOS
420 
421 #endif // OHOS_FORM_FWK_FORM_ITEM_INFO_H
422