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_SERVICES_FORMMGR_INCLUDE_FORM_CONFIG_INFO_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_CONFIG_INFO_H 18 19 #include <stdint.h> 20 #include <string> 21 #include <vector> 22 #include <unordered_map> 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 updageFlag. 132 * @return Returns updageFlag. 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 private: 224 /** 225 * @brief Equal or not. 226 * @param left left string. 227 * @param right right string. 228 * @return Equal or not 229 */ 230 bool IsEqual(const std::string &left, const std::string &right); 231 232 private: 233 int64_t formId_ = -1; 234 std::string packageName_ = ""; 235 std::string providerBundleName_ = ""; 236 std::string hostBundleName_ = ""; 237 std::string moduleName_ = ""; 238 std::string abilityName_ = ""; 239 std::string formName_ = ""; 240 int32_t specificationId_ = 0; 241 bool updateFlag_ = false; 242 int32_t updateDuration_ = 0; 243 std::string scheduledUpdateTime_ = ""; 244 std::vector<std::string> hapSourceDirs_; 245 bool temporaryFlag_ = false; 246 bool formVisibleNotify_ = false; 247 248 std::string jsComponentName_ = ""; 249 std::string abilityModuleName_ = ""; 250 std::unordered_map<std::string, std::string> moduleInfoMap_; 251 }; 252 } // namespace AppExecFwk 253 } // namespace OHOS 254 255 #endif // FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_CONFIG_INFO_H 256