2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file task_widget_config.cpp
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief Implementation file for installer task widget config
28 #include <dpl/errno_string.h>
29 #include <dpl/foreach.h>
30 #include <dpl/localization/w3c_file_localization.h>
31 #include <dpl/singleton_impl.h>
32 #include <dpl/utils/mime_type_utils.h>
33 #include <dpl/utils/wrt_global_settings.h>
34 #include <dpl/utils/wrt_utility.h>
35 #include <dpl/wrt-dao-ro/global_config.h>
36 #include <dpl/wrt-dao-rw/feature_dao.h>
38 #include <libiriwrapper.h>
39 #include <parser_runner.h>
40 #include <root_parser.h>
42 #include <widget_install/job_widget_install.h>
43 #include <widget_install/task_widget_config.h>
44 #include <widget_install/widget_install_context.h>
45 #include <widget_install/widget_install_errors.h>
46 #include <widget_parser.h>
47 #include <wrt_error.h>
50 namespace { // anonymous
51 const DPL::String BR = DPL::FromUTF8String("<br>");
52 const std::string WIDGET_NOT_COMPATIBLE = "This widget is "
53 "not compatible with WRT.<br><br>";
54 const std::string QUESTION = "Do you want to install it anyway?";
56 const char *const DEFAULT_LANGUAGE = "default";
58 const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
60 const std::string WINDGET_INSTALL_NETWORK_ACCESS = "network access";
65 namespace WidgetInstall {
66 void InstallerTaskWidgetPopupData::PopupData::addWidgetInfo(
67 const DPL::String &info)
72 TaskWidgetConfig::TaskWidgetConfig(InstallerContext& installContext) :
73 DPL::TaskDecl<TaskWidgetConfig>(this),
74 WidgetInstallPopup(installContext),
75 m_installContext(installContext)
78 AddStep(&TaskWidgetConfig::StepProcessConfigurationFile);
79 AddStep(&TaskWidgetConfig::ReadLocaleFolders);
80 AddStep(&TaskWidgetConfig::ProcessLocalizedStartFiles);
81 AddStep(&TaskWidgetConfig::ProcessBackgroundPageFile);
82 AddStep(&TaskWidgetConfig::ProcessLocalizedIcons);
83 AddStep(&TaskWidgetConfig::StepVerifyFeatures);
84 AddStep(&TaskWidgetConfig::StepCheckMinVersionInfo);
86 if (!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet) {
87 AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures);
88 AddStep(&TaskWidgetConfig::StepShowWidgetInfo);
89 AddStep(&TaskWidgetConfig::StepCancelWidgetInstallation);
90 AddStep(&TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion);
91 AddStep(&TaskWidgetConfig::StepDeletePopupWin);
95 void TaskWidgetConfig::StepProcessConfigurationFile()
99 std::string path = m_installContext.locations->getConfigurationDir();
100 LogInfo("path: " << path);
102 processFile(path, m_installContext.widgetConfig);
104 Catch(Exception::ConfigParseFailed)
106 LogError("Parsing failed.");
107 ReThrow(Exceptions::WidgetConfigFileInvalid);
111 // To get widget type for distribute WAC, TIZEN WebApp
112 setApplicationType();
114 Catch(Exception::ConfigParseFailed)
116 LogError("Config.xml has more than one namespace");
117 ReThrow(Exceptions::WidgetConfigFileInvalid);
120 m_installContext.job->UpdateProgress(
121 InstallerContext::INSTALL_WIDGET_CONFIG1,
122 "Parse elements of configuration file and save them");
125 void TaskWidgetConfig::ReadLocaleFolders()
127 LogDebug("Reading locale");
128 //Adding default locale
129 m_localeFolders.insert(L"");
131 std::string localePath = m_installContext.locations->getConfigurationDir() + "/locales";
132 DIR* localeDir = opendir(localePath.c_str());
134 LogDebug("No /locales directory in the widget package.");
138 struct dirent* dirent;
139 struct stat statStruct;
142 if ((dirent = readdir(localeDir))) {
143 DPL::String dirName = DPL::FromUTF8String(dirent->d_name);
144 std::string absoluteDirName = localePath + "/";
145 absoluteDirName += dirent->d_name;
147 if (stat(absoluteDirName.c_str(), &statStruct) != 0) {
148 LogError("stat() failed with " << DPL::GetErrnoString());
152 if (S_ISDIR(statStruct.st_mode)) {
153 //Yes, we ignore current, parent & hidden directories
154 if (dirName[0] != L'.') {
155 LogDebug("Adding locale directory \"" << dirName << "\"");
156 m_localeFolders.insert(dirName);
164 LogError("readdir() failed with " << DPL::GetErrnoString());
167 if (-1 == TEMP_FAILURE_RETRY(closedir(localeDir))) {
168 LogError("Failed to close dir: " << localePath << " with error: "
169 << DPL::GetErrnoString());
173 void TaskWidgetConfig::ProcessLocalizedStartFiles()
175 typedef DPL::String S;
177 m_installContext.widgetConfig.configInfo.startFile,
178 m_installContext.widgetConfig.configInfo.
179 startFileContentType,
180 m_installContext.widgetConfig.configInfo.startFileEncoding,
182 ProcessStartFile(S(L"index.htm"), S(L"text/html"));
183 ProcessStartFile(S(L"index.html"), S(L"text/html"));
184 ProcessStartFile(S(L"index.svg"), S(L"image/svg+xml"));
185 ProcessStartFile(S(L"index.xhtml"), S(L"application/xhtml+xml"));
186 ProcessStartFile(S(L"index.xht"), S(L"application/xhtml+xml"));
187 // TODO: (l.wrzosek) we need better check if in current locales widget is valid.
188 FOREACH(it, m_installContext.widgetConfig.localizationData.startFiles) {
189 if (it->propertiesForLocales.size() > 0) {
193 ThrowMsg(Exceptions::WidgetConfigFileInvalid,
194 L"The Widget has no valid start file");
197 void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
198 const DPL::OptionalString& type,
199 const DPL::OptionalString& encoding,
200 bool typeForcedInConfig)
202 using namespace WrtDB;
205 WidgetRegisterInfo::LocalizedStartFile startFileData;
206 startFileData.path = *path;
208 FOREACH(i, m_localeFolders) {
209 DPL::String pathPrefix = *i;
210 if (!pathPrefix.empty()) {
211 pathPrefix = L"locales/" + pathPrefix + L"/";
214 DPL::String relativePath = pathPrefix + *path;
215 DPL::String absolutePath = DPL::FromUTF8String(
216 m_installContext.locations->getConfigurationDir()) + L"/" + relativePath;
218 // get property data from packaged app
219 if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) {
220 WidgetRegisterInfo::StartFileProperties startFileProperties;
222 startFileProperties.type = *type;
224 startFileProperties.type =
225 MimeTypeUtils::identifyFileMimeType(absolutePath);
228 //proceed only if MIME type is supported
229 if (MimeTypeUtils::isMimeTypeSupportedForStartFile(
230 startFileProperties.type))
233 startFileProperties.encoding = *encoding;
235 MimeTypeUtils::MimeAttributes attributes =
236 MimeTypeUtils::getMimeAttributes(
237 startFileProperties.type);
238 if (attributes.count(L"charset") > 0) {
239 startFileProperties.encoding =
240 attributes[L"charset"];
242 startFileProperties.encoding = L"UTF-8";
246 startFileData.propertiesForLocales[*i] =
250 //(there seems to be no similar requirement in .6,
251 //so let's throw only when mime type is
252 // provided explcitly in config.xml)
253 if (typeForcedInConfig) {
254 ThrowMsg(Exceptions::WidgetConfigFileInvalid,
255 "Unsupported MIME type for start file.");
259 // set property data for hosted start url
260 // Hosted start url only support TIZEN WebApp
261 if (m_installContext.widgetConfig.webAppType ==
262 APP_TYPE_TIZENWEBAPP)
264 const char *startPath =
265 DPL::ToUTF8String(startFileData.path).c_str();
266 if (strstr(startPath, "http") == startPath) {
267 WidgetRegisterInfo::StartFileProperties
270 startFileProperties.type = *type;
273 startFileProperties.encoding = *encoding;
275 startFileData.propertiesForLocales[*i] =
282 m_installContext.widgetConfig.localizationData.startFiles.push_back(
287 void TaskWidgetConfig::ProcessBackgroundPageFile()
289 if (!!m_installContext.widgetConfig.configInfo.backgroundPage) {
290 // check whether file exists
291 DPL::String backgroundPagePath = DPL::FromUTF8String(
292 m_installContext.locations->getConfigurationDir()) + L"/" +
293 *m_installContext.widgetConfig.configInfo.backgroundPage;
294 //if no then cancel installation
295 if (!WrtUtilFileExists(DPL::ToUTF8String(backgroundPagePath))) {
296 ThrowMsg(Exceptions::WidgetConfigFileInvalid,
297 L"Given background page file not found in archive");
302 void TaskWidgetConfig::ProcessLocalizedIcons()
304 using namespace WrtDB;
305 ProcessIcon(ConfigParserData::Icon(L"icon.svg"));
306 ProcessIcon(ConfigParserData::Icon(L"icon.ico"));
307 ProcessIcon(ConfigParserData::Icon(L"icon.png"));
308 ProcessIcon(ConfigParserData::Icon(L"icon.gif"));
309 ProcessIcon(ConfigParserData::Icon(L"icon.jpg"));
311 FOREACH(i, m_installContext.widgetConfig.configInfo.iconsList)
317 void TaskWidgetConfig::ProcessIcon(const WrtDB::ConfigParserData::Icon& icon)
320 bool isAnyIconValid = false;
321 //In case a default filename is passed as custom filename in config.xml, we
322 //need to keep a set of already processed filenames to avoid icon duplication
325 using namespace WrtDB;
327 if (m_processedIconSet.count(icon.src) > 0) {
330 m_processedIconSet.insert(icon.src);
332 LocaleSet localesAvailableForIcon;
334 FOREACH(i, m_localeFolders)
336 DPL::String pathPrefix = *i;
337 if (!pathPrefix.empty()) {
338 pathPrefix = L"locales/" + pathPrefix + L"/";
341 DPL::String relativePath = pathPrefix + icon.src;
342 DPL::String absolutePath = DPL::FromUTF8String(
343 m_installContext.locations->getConfigurationDir()) + L"/" + relativePath;
345 if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) {
346 DPL::String type = MimeTypeUtils::identifyFileMimeType(absolutePath);
348 if (MimeTypeUtils::isMimeTypeSupportedForIcon(type)) {
349 isAnyIconValid = true;
350 localesAvailableForIcon.insert(*i);
351 LogInfo("Icon absolutePath :" << absolutePath <<
352 ", assigned locale :" << *i << ", type: " << type);
359 WidgetRegisterInfo::LocalizedIcon localizedIcon(icon,
360 localesAvailableForIcon);
361 m_installContext.widgetConfig.localizationData.icons.push_back(
366 void TaskWidgetConfig::StepCancelWidgetInstallationAfterVerifyFeatures()
368 LogDebug("StepCancelWidgetInstallationAfterVerifyFeatures");
369 if (InfoPopupButton::WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
370 m_installCancel = WRT_POPUP_BUTTON;
372 ThrowMsg(Exceptions::WidgetConfigFileInvalid, "Widget not allowed");
376 void TaskWidgetConfig::StepCancelWidgetInstallation()
378 if (InfoPopupButton::WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
379 m_installCancel = WRT_POPUP_BUTTON;
381 ThrowMsg(Exceptions::NotAllowed, "Widget not allowed");
385 void TaskWidgetConfig::StepCancelWidgetInstallationAfterMinVersion()
387 if (InfoPopupButton::WRT_POPUP_BUTTON_CANCEL == m_installCancel) {
388 m_installCancel = WRT_POPUP_BUTTON;
390 ThrowMsg(Exceptions::NotAllowed, "WRT version incompatible.");
394 void TaskWidgetConfig::createInstallPopup(PopupType type, const std::string &label)
396 m_installContext.job->Pause();
400 bool ret = createPopup();
403 loadPopup( type, label);
408 void TaskWidgetConfig::StepDeletePopupWin()
413 void TaskWidgetConfig::StepShowWidgetInfo()
415 if (!m_popupData.widgetInfo.empty()) {
416 std::string label = DPL::ToUTF8String(m_popupData.widgetInfo);
417 createInstallPopup(PopupType::WIDGET_FEATURE_INFO, label);
418 m_installContext.job->UpdateProgress(
419 InstallerContext::INSTALL_WIDGET_CONFIG2,
420 "Show Widget Info Finished");
424 void TaskWidgetConfig::StepCheckMinVersionInfo()
426 if (!isMinVersionCompatible(
427 m_installContext.widgetConfig.webAppType.appType,
428 m_installContext.widgetConfig.minVersion)) {
429 if(!GlobalSettings::TestModeEnabled() && !m_installContext.m_quiet)
431 LogDebug("Platform version to low - launching");
432 std::string label = WIDGET_NOT_COMPATIBLE + QUESTION;
433 createInstallPopup(PopupType::WIDGET_MIN_VERSION, label);
437 LogError("Platform version lower than required -> cancelling installation");
438 ThrowMsg(Exceptions::NotAllowed,
439 "Platform version does not meet requirements");
443 m_installContext.job->UpdateProgress(
444 InstallerContext::INSTALL_WIDGET_CONFIG2,
445 "Check MinVersion Finished");
448 void TaskWidgetConfig::StepVerifyFeatures()
450 using namespace WrtDB;
451 ConfigParserData &data = m_installContext.widgetConfig.configInfo;
452 ConfigParserData::FeaturesList list = data.featuresList;
453 ConfigParserData::FeaturesList newList;
455 //in case of tests, this variable is unused
456 std::string featureInfo;
459 // check feature vender for permission
460 // WAC, TIZEN WebApp cannot use other feature
462 if (!isFeatureAllowed(m_installContext.widgetConfig.webAppType.appType,
465 LogInfo("This application type not allowed to use this feature");
467 Exceptions::WidgetConfigFileInvalid,
469 m_installContext.widgetConfig.webAppType.getApptypeToString() <<
470 "] cannot be allowed to use [" <<
471 DPL::ToUTF8String(it->name) + "] feature");
473 if (!WrtDB::FeatureDAOReadOnly::isFeatureInstalled(
474 DPL::ToUTF8String(it->name))) {
475 LogWarning("Feature not found. Checking if required :[" <<
476 DPL::ToUTF8String(it->name) << "]");
480 * WL-3210 The WRT MUST inform the user if a widget cannot be
481 * installed because one or more required features are not
484 std::ostringstream os;
485 os << "Widget cannot be installed, required feature is missing:["
486 << DPL::ToUTF8String(it->name) << "]";
487 if (!GlobalSettings::TestModeEnabled() && !isTizenWebApp()) {
488 std::string label = os.str();
489 createInstallPopup(PopupType::WIDGET_WRONG_FEATURE_INFO, label);
491 ThrowMsg(Exceptions::WidgetConfigFileInvalid, os.str());
495 featureInfo += DPL::ToUTF8String(it->name);
496 featureInfo += DPL::ToUTF8String(BR);
499 if(!data.accessInfoSet.empty()) {
500 featureInfo += WINDGET_INSTALL_NETWORK_ACCESS;
501 featureInfo += DPL::ToUTF8String(BR);
503 data.featuresList = newList;
504 if (!featureInfo.empty()) {
505 m_popupData.addWidgetInfo(DPL::FromUTF8String(featureInfo));
508 m_installContext.job->UpdateProgress(
509 InstallerContext::INSTALL_WIDGET_CONFIG2,
510 "Widget Config step2 Finished");
513 void TaskWidgetConfig::setApplicationType()
515 using namespace WrtDB;
516 WidgetRegisterInfo* widgetInfo = &(m_installContext.widgetConfig);
517 ConfigParserData* configInfo = &(widgetInfo->configInfo);
519 FOREACH(iterator, configInfo->nameSpaces) {
520 LogInfo("namespace = [" << *iterator << "]");
521 AppType currentAppType = APP_TYPE_UNKNOWN;
523 if (*iterator == ConfigurationNamespace::W3CWidgetNamespaceName) {
527 ConfigurationNamespace::WacWidgetNamespaceNameForLinkElement ||
529 ConfigurationNamespace::WacWidgetNamespaceName)
531 currentAppType = APP_TYPE_WAC20;
532 } else if (*iterator == ConfigurationNamespace::TizenWebAppNamespaceName) {
533 currentAppType = APP_TYPE_TIZENWEBAPP;
536 if (widgetInfo->webAppType == APP_TYPE_UNKNOWN) {
537 widgetInfo->webAppType = currentAppType;
538 } else if (widgetInfo->webAppType == currentAppType) {
541 ThrowMsg(Exceptions::WidgetConfigFileInvalid,
542 "Config.xml has more than one namespace");
546 // If there is no define, type set to WAC 2.0
547 if (widgetInfo->webAppType == APP_TYPE_UNKNOWN) {
548 widgetInfo->webAppType = APP_TYPE_WAC20;
551 LogInfo("type = [" << widgetInfo->webAppType.getApptypeToString() << "]");
554 bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
555 DPL::String featureName)
557 using namespace WrtDB;
558 LogInfo("AppType = [" <<
559 WidgetType(appType).getApptypeToString() << "]");
560 LogInfo("FetureName = [" << featureName << "]");
562 AppType featureType = APP_TYPE_UNKNOWN;
563 const char* feature = DPL::ToUTF8String(featureName).c_str();
564 // check prefix of feature name
565 if (strstr(feature, PluginsPrefix::TIZENPluginsPrefix) == feature) {
566 // Tizen WebApp feature
567 featureType = APP_TYPE_TIZENWEBAPP;
568 } else if (strstr(feature, PluginsPrefix::WACPluginsPrefix) == feature) {
570 featureType = APP_TYPE_WAC20;
571 } else if (strstr(feature, PluginsPrefix::W3CPluginsPrefix) == feature) {
572 // W3C standard feature
573 // Both WAC and TIZEN WebApp are possible to use W3C plugins
577 // unknown feature will be checked next step
581 if (appType == featureType) {
587 bool TaskWidgetConfig::parseVersionString(const std::string &version,
588 long &majorVersion, long &minorVersion, long µVersion) const
590 std::istringstream inputString(version);
591 inputString >> majorVersion;
592 if (inputString.bad() || inputString.fail()) {
593 LogWarning("Invalid minVersion format.");
596 inputString.get(); // skip period
597 inputString >> minorVersion;
598 if (inputString.bad() || inputString.fail()) {
599 LogWarning("Invalid minVersion format");
602 inputString.get(); // skip period
603 if (inputString.bad() || inputString.fail()) {
604 inputString >> microVersion;
610 bool TaskWidgetConfig::isMinVersionCompatible(WrtDB::AppType appType,
611 const DPL::OptionalString &widgetVersion) const
613 if (widgetVersion.IsNull() || (*widgetVersion).empty())
615 LogWarning("minVersion attribute is empty. WRT assumes platform "
616 "supports this widget.");
620 //Parse widget version
621 long majorWidget = 0, minorWidget = 0, microWidget = 0;
622 if (!parseVersionString(DPL::ToUTF8String(*widgetVersion), majorWidget,
623 minorWidget, microWidget)) {
624 LogWarning("Invalid format of widget version string.");
628 //Parse supported version
629 long majorSupported = 0, minorSupported = 0, microSupported = 0;
631 if (appType == WrtDB::AppType::APP_TYPE_TIZENWEBAPP) {
632 version = WrtDB::GlobalConfig::GetTizenVersion();
633 } else if (appType == WrtDB::AppType::APP_TYPE_WAC20) {
634 version = WrtDB::GlobalConfig::GetWACVersion();
636 LogWarning("Invaild AppType");
640 if (!parseVersionString(version,
641 majorSupported, minorSupported, microSupported)) {
642 LogWarning("Invalid format of platform version string.");
646 if (majorWidget > majorSupported ||
647 (majorWidget == majorSupported && minorWidget > minorSupported) ||
648 (majorWidget == majorSupported && minorWidget == minorSupported
649 && microWidget > microSupported))
651 LogInfo("Platform doesn't support this widget.");
657 bool TaskWidgetConfig::isTizenWebApp() const
660 if (m_installContext.widgetConfig.webAppType.appType
661 == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
667 bool TaskWidgetConfig::parseConfigurationFileBrowser(WrtDB::ConfigParserData& configInfo,
668 const std::string& _currentPath, int* pErrCode)
673 parser.Parse(_currentPath, ElementParserPtr(new
677 DPL::FromUTF32String(
680 Catch(ElementParser::Exception::Base)
682 LogError("Invalid widget configuration file!");
683 *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
689 bool TaskWidgetConfig::parseConfigurationFileWidget(WrtDB::ConfigParserData& configInfo,
690 const std::string& _currentPath, int* pErrCode)
694 //TODO: rewrite this madness
695 std::string cfgAbsPath;
697 struct dirent* ptr = NULL;
699 dir = opendir(_currentPath.c_str());
701 *pErrCode = WRT_ERR_UNKNOWN;
704 bool has_config_xml = false;
706 while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on its name
707 if (ptr->d_type == DT_REG) {
708 if (!strcmp(ptr->d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
709 std::string dName(ptr->d_name);
710 WrtUtilJoinPaths(cfgAbsPath, _currentPath, dName);
712 //Parse widget configuration file
713 LogDebug("Found config: " << cfgAbsPath);
717 parser.Parse(cfgAbsPath, ElementParserPtr(new
726 Catch(ElementParser::Exception::Base)
728 LogError("Invalid widget configuration file!");
729 // _rethrown_exception.Dump();
730 *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
731 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
732 LogError("Failed to close dir: " << _currentPath << " with error: "
733 << DPL::GetErrnoString());
738 has_config_xml = true;
743 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
744 LogError("Failed to close dir: " << _currentPath << " with error: "
745 << DPL::GetErrnoString());
748 //We must have config.xml so leaveing if we doesn't
749 if (!has_config_xml) {
750 LogError("Invalid archive");
751 *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
757 bool TaskWidgetConfig::locateAndParseConfigurationFile(
758 const std::string& _currentPath,
759 WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
760 const std::string& baseFolder,
763 using namespace WrtDB;
769 ConfigParserData& configInfo = pWidgetConfigInfo.configInfo;
771 // check if this installation from browser, or not.
772 size_t pos = _currentPath.rfind("/");
773 std::ostringstream infoPath;
774 infoPath << _currentPath.substr(pos+1);
776 if (infoPath.str() != WRT_WIDGET_CONFIG_FILE_NAME) {
777 if (_currentPath.empty() || baseFolder.empty()) {
778 *pErrCode = WRT_ERR_INVALID_ARG;
781 // in case of general installation using wgt archive
782 if(!parseConfigurationFileWidget(configInfo, _currentPath, pErrCode))
787 // in case of browser installation
788 if(!parseConfigurationFileBrowser(configInfo, _currentPath, pErrCode))
794 if(!fillWidgetConfig(pWidgetConfigInfo, configInfo))
796 *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
802 bool TaskWidgetConfig::fillWidgetConfig(WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
803 WrtDB::ConfigParserData& configInfo)
805 if (!!configInfo.widget_id) {
806 if (!pWidgetConfigInfo.guid) {
807 pWidgetConfigInfo.guid = configInfo.widget_id;
809 if (pWidgetConfigInfo.guid != configInfo.widget_id) {
810 LogError("Invalid archive");
815 if (!!configInfo.tizenId) {
816 if (pWidgetConfigInfo.pkgname_NOTNULL != *configInfo.tizenId) {
817 LogError("Invalid archive - Tizen ID not same error");
821 if (!!configInfo.version) {
822 if (!pWidgetConfigInfo.version) {
823 pWidgetConfigInfo.version = configInfo.version;
825 if (pWidgetConfigInfo.version != configInfo.version) {
826 LogError("Invalid archive");
831 if (!!configInfo.minVersionRequired) {
832 pWidgetConfigInfo.minVersion = configInfo.minVersionRequired;
833 } else if (!!configInfo.tizenMinVersionRequired) {
834 pWidgetConfigInfo.minVersion = configInfo.tizenMinVersionRequired;
839 void TaskWidgetConfig::processFile(const std::string& path,
840 WrtDB::WidgetRegisterInfo &widgetConfiguration)
844 if (!locateAndParseConfigurationFile(path, widgetConfiguration,
845 DEFAULT_LANGUAGE, &pErrCode)) {
846 LogWarning("Widget archive: Failed while parsing config file");
847 ThrowMsg(Exception::ConfigParseFailed, path);
851 } //namespace WidgetInstall