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_manifest_file.cpp
18 * @author Pawel Sikorski (p.sikorski@samgsung.com)
26 #include <dpl/assert.h>
32 #include <widget_install/task_manifest_file.h>
33 #include <widget_install/job_widget_install.h>
34 #include <widget_install/widget_install_errors.h>
35 #include <widget_install/widget_install_context.h>
36 #include <dpl/wrt-dao-ro/global_config.h>
37 #include <dpl/log/log.h>
38 #include <dpl/file_input.h>
39 #include <dpl/errno_string.h>
40 #include <dpl/file_output.h>
42 #include <dpl/exception.h>
43 #include <dpl/foreach.h>
44 #include <dpl/sstream.h>
45 #include <dpl/string.h>
46 #include <dpl/optional.h>
47 #include <dpl/utils/wrt_utility.h>
49 #include <libxml_utils.h>
50 #include <pkgmgr/pkgmgr_parser.h>
51 #include <dpl/localization/LanguageTagsProvider.h>
53 #define DEFAULT_ICON_NAME "icon.png"
55 using namespace WrtDB;
58 typedef std::map<DPL::String, DPL::String> LanguageTagMap;
60 const char* const ST_TRUE = "true";
61 const char* const ST_NODISPLAY = "nodisplay";
63 LanguageTagMap getLanguageTagMap()
67 #define ADD(tag, l_tag) map.insert(std::make_pair(L###tag, L###l_tag));
68 #include "languages.def"
74 DPL::OptionalString getLangTag(const DPL::String& tag)
76 static LanguageTagMap TagsMap =
79 DPL::String langTag = tag;
81 LogDebug("Trying to map language tag: " << langTag);
82 size_t pos = langTag.find_first_of(L'_');
83 if (pos != DPL::String::npos) {
86 DPL::OptionalString ret;
88 LanguageTagMap::iterator it = TagsMap.find(langTag);
89 if (it != TagsMap.end()) {
92 LogDebug("Mapping IANA Language tag to language tag: " <<
93 langTag << " -> " << ret);
100 namespace WidgetInstall {
101 const char * TaskManifestFile::encoding = "UTF-8";
103 TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
104 DPL::TaskDecl<TaskManifestFile>(this),
108 if (false == m_context.existingWidgetInfo.isExist) {
109 AddStep(&TaskManifestFile::stepCopyIconFiles);
110 AddStep(&TaskManifestFile::stepCreateExecFile);
111 AddStep(&TaskManifestFile::stepGenerateManifest);
112 AddStep(&TaskManifestFile::stepParseManifest);
113 AddStep(&TaskManifestFile::stepFinalize);
115 AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
117 // for widget update.
118 AddStep(&TaskManifestFile::stepBackupIconFiles);
119 AddStep(&TaskManifestFile::stepCopyIconFiles);
120 AddStep(&TaskManifestFile::stepGenerateManifest);
121 AddStep(&TaskManifestFile::stepParseUpgradedManifest);
122 AddStep(&TaskManifestFile::stepUpdateFinalize);
124 AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
128 TaskManifestFile::~TaskManifestFile()
131 void TaskManifestFile::stepCreateExecFile()
133 std::string exec = m_context.locations->getExecFile();
134 std::string clientExeStr = GlobalConfig::GetWrtClientExec();
136 LogInfo("link -s " << clientExeStr << " " << exec);
139 if (symlink(clientExeStr.c_str(), exec.c_str()) != 0)
143 LogPedantic("Failed to make a symbolic name for a file "
144 << "[" << DPL::GetErrnoString(error) << "]");
145 ThrowMsg(Exceptions::InstallationFailed,
146 "Symbolic link creating is not done.");
148 m_context.job->UpdateProgress(
149 InstallerContext::INSTALL_CREATE_EXECFILE,
150 "Widget execfile creation Finished");
153 void TaskManifestFile::stepCopyIconFiles()
155 LogDebug("CopyIconFiles");
157 //This function copies icon to desktop icon path. For each locale avaliable
158 //which there is at least one icon in widget for, icon file is copied.
159 //Coping prioritize last positions when coping. If there is several icons
160 //with given locale, the one, that will be copied, will be icon
161 //which is declared by <icon> tag later than the others in config.xml of
164 std::vector<Locale> generatedLocales;
166 WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
167 m_context.widgetConfig.localizationData.icons;
169 //reversed: last <icon> has highest priority to be copied if it has given
170 // locale (TODO: why was that working that way?)
171 for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
172 icon = icons.rbegin();
173 icon != icons.rend();
176 FOREACH(locale, icon->availableLocales)
178 DPL::String src = icon->src;
179 LogDebug("Icon for locale: " << *locale << "is : " << src);
181 if (std::find(generatedLocales.begin(), generatedLocales.end(),
182 *locale) != generatedLocales.end())
184 LogDebug("Skipping - has that locale");
187 generatedLocales.push_back(*locale);
190 std::ostringstream sourceFile;
191 std::ostringstream targetFile;
193 sourceFile << m_context.locations->getSourceDir() << "/";
195 if (!locale->empty()) {
196 sourceFile << "locales/" << *locale << "/";
201 targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
202 targetFile << getIconTargetFilename(*locale);
204 if (m_context.widgetConfig.packagingType ==
205 WrtDB::PKG_TYPE_HOSTED_WEB_APP)
207 m_context.locations->setIconTargetFilenameForLocale(
211 LogDebug("Copying icon: " << sourceFile.str() <<
212 " -> " << targetFile.str());
214 icon_list.push_back(targetFile.str());
218 DPL::FileInput input(sourceFile.str());
219 DPL::FileOutput output(targetFile.str());
220 DPL::Copy(&input, &output);
223 Catch(DPL::FileInput::Exception::Base)
225 // Error while opening or closing source file
226 //ReThrowMsg(InstallerException::CopyIconFailed,
227 // sourceFile.str());
229 "Copying widget's icon failed. Widget's icon will not be" \
230 "available from Main Screen");
233 Catch(DPL::FileOutput::Exception::Base)
235 // Error while opening or closing target file
236 //ReThrowMsg(InstallerException::CopyIconFailed,
237 // targetFile.str());
239 "Copying widget's icon failed. Widget's icon will not be" \
240 "available from Main Screen");
243 Catch(DPL::CopyFailed)
245 // Error while copying
246 //ReThrowMsg(InstallerException::CopyIconFailed,
247 // targetFile.str());
249 "Copying widget's icon failed. Widget's icon will not be" \
250 "available from Main Screen");
255 m_context.job->UpdateProgress(
256 InstallerContext::INSTALL_COPY_ICONFILE,
257 "Widget iconfile copy Finished");
260 void TaskManifestFile::stepBackupIconFiles()
262 LogDebug("Backup Icon Files");
264 backup_dir << m_context.locations->getPackageInstallationDir();
265 backup_dir << "/" << "backup" << "/";
269 m_context.job->UpdateProgress(
270 InstallerContext::INSTALL_BACKUP_ICONFILE,
271 "New Widget icon file backup Finished");
274 void TaskManifestFile::stepAbortIconFiles()
276 LogDebug("Abrot Icon Files");
277 FOREACH(it, icon_list)
279 LogDebug("Remove Update Icon : " << (*it));
280 unlink((*it).c_str());
283 std::ostringstream b_icon_dir;
284 b_icon_dir << backup_dir.str() << "icons";
286 std::list<std::string> fileList;
287 getFileList(b_icon_dir.str().c_str(), fileList);
289 FOREACH(back_icon, fileList)
291 std::ostringstream res_file;
292 res_file << GlobalConfig::GetUserWidgetDesktopIconPath();
293 res_file << "/" << (*back_icon);
295 std::ostringstream backup_file;
296 backup_file << b_icon_dir.str() << "/" << (*back_icon);
300 DPL::FileInput input(backup_file.str());
301 DPL::FileOutput output(res_file.str());
302 DPL::Copy(&input, &output);
304 Catch(DPL::FileInput::Exception::Base)
306 LogError("Restoration icon File Failed." << backup_file.str()
307 << " to " << res_file.str());
310 Catch(DPL::FileOutput::Exception::Base)
312 LogError("Restoration icon File Failed." << backup_file.str()
313 << " to " << res_file.str());
315 Catch(DPL::CopyFailed)
317 LogError("Restoration icon File Failed." << backup_file.str()
318 << " to " << res_file.str());
323 void TaskManifestFile::stepUpdateFinalize()
326 LogDebug("Finished Update Desktopfile");
329 DPL::String TaskManifestFile::getIconTargetFilename(
330 const DPL::String& languageTag) const
332 DPL::OStringStream filename;
333 TizenAppId appid = m_context.widgetConfig.tzAppid;
335 filename << DPL::ToUTF8String(appid).c_str();
337 if (!languageTag.empty()) {
338 DPL::OptionalString tag = getLangTag(languageTag); // translate en ->
344 LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
346 if (locale.empty()) {
347 filename << L"." << languageTag;
349 filename << L"." << locale;
354 return filename.str();
357 void TaskManifestFile::stepFinalize()
360 LogInfo("Finished ManifestFile step");
363 void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
364 const DPL::String& key,
365 const DPL::String& languageTag)
368 LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
371 if (!locale.empty()) {
372 file << "[" << locale << "]";
377 void TaskManifestFile::updateAilInfo()
379 // Update ail for desktop
380 std::string cfgAppid =
381 DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
382 const char* appid = cfgAppid.c_str();
384 LogDebug("Update ail desktop : " << appid);
385 ail_appinfo_h ai = NULL;
388 ret = ail_get_appinfo(appid, &ai);
390 ail_destroy_appinfo(ai);
393 if (AIL_ERROR_NO_DATA == ret) {
394 if (ail_desktop_add(appid) < 0) {
395 LogWarning("Failed to add ail desktop : " << appid);
397 } else if (AIL_ERROR_OK == ret) {
398 if (ail_desktop_update(appid) < 0) {
399 LogWarning("Failed to update ail desktop : " << appid);
404 void TaskManifestFile::backupIconFiles()
406 LogInfo("Backup Icon Files");
408 std::ostringstream b_icon_dir;
409 b_icon_dir << backup_dir.str() << "icons";
411 LogDebug("Create icon backup folder : " << b_icon_dir.str());
412 WrtUtilMakeDir(b_icon_dir.str());
414 std::list<std::string> fileList;
415 getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
416 std::string appid = DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
418 FOREACH(it, fileList)
420 if (0 == (strncmp((*it).c_str(), appid.c_str(),
421 strlen(appid.c_str()))))
423 std::ostringstream icon_file, backup_icon;
424 icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
425 icon_file << "/" << (*it);
427 backup_icon << b_icon_dir.str() << "/" << (*it);
429 LogDebug("Backup icon file " << icon_file.str() << " to " <<
433 DPL::FileInput input(icon_file.str());
434 DPL::FileOutput output(backup_icon.str());
435 DPL::Copy(&input, &output);
437 Catch(DPL::FileInput::Exception::Base)
439 LogError("Backup Desktop File Failed.");
440 ReThrowMsg(Exceptions::BackupFailed, icon_file.str());
443 Catch(DPL::FileOutput::Exception::Base)
445 LogError("Backup Desktop File Failed.");
446 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
448 Catch(DPL::CopyFailed)
450 LogError("Backup Desktop File Failed.");
451 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
453 unlink((*it).c_str());
458 void TaskManifestFile::getFileList(const char* path,
459 std::list<std::string> &list)
461 DIR* dir = opendir(path);
463 LogError("icon directory doesn't exist");
464 ThrowMsg(Exceptions::InternalError, path);
468 struct dirent *result;
471 for (return_code = readdir_r(dir, &entry, &result);
472 result != NULL && return_code == 0;
473 return_code = readdir_r(dir, &entry, &result))
475 if (strcmp(entry.d_name, ".") == 0 ||
476 strcmp(entry.d_name, "..") == 0)
480 std::string file_name = entry.d_name;
481 list.push_back(file_name);
484 if (return_code != 0 || errno != 0) {
485 LogError("readdir_r() failed with " << DPL::GetErrnoString());
488 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
489 LogError("Failed to close dir: " << path << " with error: "
490 << DPL::GetErrnoString());
494 void TaskManifestFile::stepGenerateManifest()
496 TizenPkgId pkgid = m_context.widgetConfig.tzPkgid;
497 manifest_name = pkgid + L".xml";
498 manifest_file += L"/tmp/" + manifest_name;
500 //libxml - init and check
501 LibxmlSingleton::Instance().init();
503 writeManifest(manifest_file);
505 m_context.job->UpdateProgress(
506 InstallerContext::INSTALL_CREATE_MANIFEST,
507 "Widget Manifest Creation Finished");
510 void TaskManifestFile::stepParseManifest()
512 int code = pkgmgr_parser_parse_manifest_for_installation(
513 DPL::ToUTF8String(manifest_file).c_str(), NULL);
516 LogError("Manifest parser error: " << code);
517 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
520 // TODO : It will be removed. AIL update is temporary code request by pkgmgr
524 m_context.job->UpdateProgress(
525 InstallerContext::INSTALL_CREATE_MANIFEST,
526 "Widget Manifest Parsing Finished");
527 LogDebug("Manifest parsed");
530 void TaskManifestFile::stepParseUpgradedManifest()
532 int code = pkgmgr_parser_parse_manifest_for_upgrade(
533 DPL::ToUTF8String(manifest_file).c_str(), NULL);
536 LogError("Manifest parser error: " << code);
537 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
540 // TODO : It will be removed. AIL update is temporary code request by pkgmgr
544 m_context.job->UpdateProgress(
545 InstallerContext::INSTALL_CREATE_MANIFEST,
546 "Widget Manifest Parsing Finished");
547 LogDebug("Manifest parsed");
550 void TaskManifestFile::commitManifest()
552 LogDebug("Commiting manifest file : " << manifest_file);
554 std::ostringstream destFile;
555 destFile << "/opt/share/packages" << "/"; //TODO constant with path
556 destFile << DPL::ToUTF8String(manifest_name);
557 LogInfo("cp " << manifest_file << " " << destFile.str());
559 DPL::FileInput input(DPL::ToUTF8String(manifest_file));
560 DPL::FileOutput output(destFile.str());
561 DPL::Copy(&input, &output);
562 LogDebug("Manifest writen to: " << destFile.str());
565 unlink((DPL::ToUTF8String(manifest_file)).c_str());
566 manifest_file = DPL::FromUTF8String(destFile.str().c_str());
569 void TaskManifestFile::writeManifest(const DPL::String & path)
571 LogDebug("Generating manifest file : " << path);
575 setWidgetExecPath(uiApp);
576 setWidgetName(manifest, uiApp);
577 setWidgetIcons(uiApp);
578 setWidgetManifest(manifest);
579 setWidgetOtherInfo(uiApp);
580 setAppServiceInfo(uiApp);
581 setAppControlInfo(uiApp);
582 setAppCategory(uiApp);
583 setLiveBoxInfo(manifest);
584 setAccount(manifest);
585 setPrivilege(manifest);
587 manifest.addUiApplication(uiApp);
588 manifest.generate(path);
589 LogDebug("Manifest file serialized");
592 void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp)
594 uiApp.setExec(DPL::FromASCIIString(m_context.locations->getExecFile()));
597 void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
599 bool defaultNameSaved = false;
601 DPL::OptionalString defaultLocale =
602 m_context.widgetConfig.configInfo.defaultlocale;
603 std::pair<DPL::String,
604 WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
606 FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
608 Locale i = localizedData->first;
609 DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
613 DPL::OptionalString name = localizedData->second.name;
614 generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
616 //store default locale localized data
617 if (!!defaultLocale && defaultLocale == i) {
618 defaultLocalizedData = *localizedData;
622 if (!!defaultLocale && !defaultNameSaved) {
623 DPL::OptionalString name = defaultLocalizedData.second.name;
624 generateWidgetName(manifest,
626 DPL::OptionalString::Null,
631 TizenAppId appid = m_context.widgetConfig.tzAppid;
632 uiApp.setAppid(appid);
635 if (!!m_context.widgetConfig.guid) {
636 uiApp.setExtraid(*m_context.widgetConfig.guid);
638 if (!appid.empty()) {
639 uiApp.setExtraid(DPL::String(L"http://") + appid);
644 uiApp.setType(DPL::FromASCIIString("webapp"));
645 manifest.setType(L"wgt");
648 void TaskManifestFile::generateWidgetName(Manifest & manifest,
649 UiApplication &uiApp,
650 const DPL::OptionalString& tag,
651 DPL::OptionalString name,
652 bool & defaultNameSaved)
657 LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
659 if (!locale.empty()) {
660 uiApp.addLabel(LabelType(*name, *tag));
662 uiApp.addLabel(LabelType(*name));
663 manifest.addLabel(LabelType(*name));
666 defaultNameSaved = true;
667 uiApp.addLabel(LabelType(*name));
668 manifest.addLabel(LabelType(*name));
673 void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
675 //TODO this file will need to be updated when user locale preferences
677 bool defaultIconSaved = false;
679 DPL::OptionalString defaultLocale =
680 m_context.widgetConfig.configInfo.defaultlocale;
682 std::vector<Locale> generatedLocales;
683 WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
684 m_context.widgetConfig.localizationData.icons;
686 //reversed: last <icon> has highest priority to be writen to manifest if it
687 // has given locale (TODO: why was that working that way?)
688 for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
689 icon = icons.rbegin();
690 icon != icons.rend();
693 FOREACH(locale, icon->availableLocales)
695 if (std::find(generatedLocales.begin(), generatedLocales.end(),
696 *locale) != generatedLocales.end())
698 LogDebug("Skipping - has that locale - already in manifest");
701 generatedLocales.push_back(*locale);
704 DPL::OptionalString tag = getLangTag(*locale); // translate en ->
710 generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved);
713 if (!!defaultLocale && !defaultIconSaved) {
714 generateWidgetIcon(uiApp, DPL::OptionalString::Null,
720 void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp,
721 const DPL::OptionalString& tag,
722 const DPL::String& language,
723 bool & defaultIconSaved)
727 locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
729 defaultIconSaved = true;
732 DPL::String iconText;
733 iconText += getIconTargetFilename(language);
735 if (!locale.empty()) {
736 uiApp.addIcon(IconType(iconText, locale));
738 uiApp.addIcon(IconType(iconText));
740 std::ostringstream iconPath;
741 iconPath << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
742 iconPath << getIconTargetFilename(locale);
743 m_context.job->SendProgressIconPath(iconPath.str());
746 void TaskManifestFile::setWidgetManifest(Manifest & manifest)
748 manifest.setPackage(m_context.widgetConfig.tzPkgid);
750 if (!!m_context.widgetConfig.version) {
751 manifest.setVersion(*m_context.widgetConfig.version);
753 DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ?
754 *m_context.widgetConfig.configInfo.authorEmail : L"");
755 DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
756 *m_context.widgetConfig.configInfo.authorHref : L"");
757 DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ?
758 *m_context.widgetConfig.configInfo.authorName : L"");
759 manifest.addAuthor(Author(email, href, L"", name));
762 void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
764 FOREACH(it, m_context.widgetConfig.configInfo.settingsList)
766 if (!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) {
767 if (!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) {
768 uiApp.setNodisplay(true);
769 uiApp.setTaskmanage(false);
771 uiApp.setNodisplay(false);
772 uiApp.setTaskmanage(true);
777 //There is no "X-TIZEN-PackageType=wgt"
778 //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" <<
779 // DPL::ToUTF8String(*widgetID).c_str()
780 //There is no Comment in pkgmgr "Comment=Widget application"
781 //that were in desktop file
784 void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
786 WrtDB::ConfigParserData::ServiceInfoList appServiceList =
787 m_context.widgetConfig.configInfo.appServiceList;
789 if (appServiceList.empty()) {
790 LogInfo("Widget doesn't contain application service");
794 // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
795 FOREACH(it, appServiceList) {
796 AppControl appControl;
797 if (!it->m_operation.empty()) {
798 appControl.addOperation(it->m_operation); //TODO: encapsulation?
800 if (!it->m_scheme.empty()) {
801 appControl.addUri(it->m_scheme);
803 if (!it->m_mime.empty()) {
804 appControl.addMime(it->m_mime);
806 uiApp.addAppControl(appControl);
810 void TaskManifestFile::setAppControlInfo(UiApplication & uiApp)
812 WrtDB::ConfigParserData::AppControlInfoList appControlList =
813 m_context.widgetConfig.configInfo.appControlList;
815 if (appControlList.empty()) {
816 LogInfo("Widget doesn't contain app control");
820 // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
821 FOREACH(it, appControlList) {
822 AppControl appControl;
823 if (!it->m_operation.empty()) {
824 appControl.addOperation(it->m_operation); //TODO: encapsulation?
826 if (!it->m_uriList.empty()) {
827 FOREACH(uri, it->m_uriList) {
828 appControl.addUri(*uri);
831 if (!it->m_mimeList.empty()) {
832 FOREACH(mime, it->m_mimeList) {
833 appControl.addMime(*mime);
836 uiApp.addAppControl(appControl);
840 void TaskManifestFile::setAppCategory(UiApplication &uiApp)
842 WrtDB::ConfigParserData::CategoryList categoryList =
843 m_context.widgetConfig.configInfo.categoryList;
845 if (categoryList.empty()) {
846 LogInfo("Widget doesn't contain application category");
849 FOREACH(it, categoryList) {
850 if (!(*it).empty()) {
851 uiApp.addAppCategory(*it);
856 void TaskManifestFile::stepAbortParseManifest()
858 LogError("[Parse Manifest] Abroting....");
860 int code = pkgmgr_parser_parse_manifest_for_uninstallation(
861 DPL::ToUTF8String(manifest_file).c_str(), NULL);
864 LogWarning("Manifest parser error: " << code);
865 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
867 int ret = unlink(DPL::ToUTF8String(manifest_file).c_str());
869 LogWarning("No manifest file found: " << manifest_file);
873 void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
875 FOREACH(it, m_context.widgetConfig.configInfo.m_livebox) {
876 LogInfo("setLiveBoxInfo");
878 DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
879 DPL::String appid = m_context.widgetConfig.tzAppid;
881 if (ConfigInfo->m_liveboxId != L"") {
882 size_t found = ConfigInfo->m_liveboxId.find_last_of(L".");
883 if (found != std::string::npos) {
884 if (0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) {
885 liveBox.setLiveboxId(ConfigInfo->m_liveboxId);
887 DPL::String liveboxId =
888 appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
889 liveBox.setLiveboxId(liveboxId);
892 DPL::String liveboxId =
893 appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
894 liveBox.setLiveboxId(liveboxId);
898 if (ConfigInfo->m_primary != L"") {
899 liveBox.setPrimary(ConfigInfo->m_primary);
902 if (ConfigInfo->m_updatePeriod != L"") {
903 liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod);
906 if (ConfigInfo->m_label != L"") {
907 liveBox.setLabel(ConfigInfo->m_label);
910 DPL::String defaultLocale
911 = DPL::FromUTF8String(
912 m_context.locations->getPackageInstallationDir())
913 + DPL::String(L"/res/wgt/");
915 if (ConfigInfo->m_icon != L"") {
916 liveBox.setIcon(defaultLocale + ConfigInfo->m_icon);
919 if (ConfigInfo->m_boxInfo.m_boxSrc.empty() ||
920 ConfigInfo->m_boxInfo.m_boxSize.empty())
922 LogInfo("Widget doesn't contain box");
926 if (!ConfigInfo->m_boxInfo.m_boxSrc.empty()) {
927 if ((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http"))
929 ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https")))
931 box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc;
933 box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc;
937 if (ConfigInfo->m_boxInfo.m_boxMouseEvent == L"true") {
938 box.boxMouseEvent = ConfigInfo->m_boxInfo.m_boxMouseEvent;
940 box.boxMouseEvent = L"false";
943 if (ConfigInfo->m_boxInfo.m_boxTouchEffect == L"true") {
944 box.boxTouchEffect = ConfigInfo->m_boxInfo.m_boxTouchEffect;
946 box.boxTouchEffect= L"false";
949 std::list<std::pair<DPL::String, DPL::String> > BoxSizeList
950 = ConfigInfo->m_boxInfo.m_boxSize;
951 FOREACH(im, BoxSizeList) {
952 std::pair<DPL::String, DPL::String> boxSize = *im;
953 if (!boxSize.second.empty()) {
954 boxSize.second = defaultLocale + boxSize.second;
956 box.boxSize.push_back(boxSize);
959 if (!ConfigInfo->m_boxInfo.m_pdSrc.empty()
960 && !ConfigInfo->m_boxInfo.m_pdWidth.empty()
961 && !ConfigInfo->m_boxInfo.m_pdHeight.empty())
963 if ((0 == ConfigInfo->m_boxInfo.m_pdSrc.compare(0, 4, L"http"))
964 || (0 == ConfigInfo->m_boxInfo.m_pdSrc.compare(0, 5, L"https")))
966 box.pdSrc = ConfigInfo->m_boxInfo.m_pdSrc;
968 box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc;
970 box.pdWidth = ConfigInfo->m_boxInfo.m_pdWidth;
971 box.pdHeight = ConfigInfo->m_boxInfo.m_pdHeight;
975 manifest.addLivebox(liveBox);
979 void TaskManifestFile::setAccount(Manifest& manifest)
981 WrtDB::ConfigParserData::AccountProvider account =
982 m_context.widgetConfig.configInfo.accountProvider;
984 AccountProviderType provider;
986 if (account.m_iconSet.empty()) {
987 LogInfo("Widget doesn't contain Account");
990 if (account.m_multiAccountSupport) {
991 provider.multiAccount = L"ture";
993 provider.multiAccount = L"false";
995 provider.appid = m_context.widgetConfig.tzAppid;
997 FOREACH(it, account.m_iconSet) {
998 std::pair<DPL::String, DPL::String> icon;
1000 if (it->first == ConfigParserData::IconSectionType::DefaultIcon) {
1001 icon.first = L"account";
1002 } else if (it->first == ConfigParserData::IconSectionType::SmallIcon) {
1003 icon.first = L"account-small";
1005 icon.second = it->second;
1007 provider.icon.push_back(icon);
1010 FOREACH(it, account.m_displayNameSet) {
1011 provider.name.push_back(LabelType(it->second, it->first));
1014 FOREACH(it, account.m_capabilityList) {
1015 provider.capability.push_back(*it);
1018 Account accountInfo;
1019 accountInfo.addAccountProvider(provider);
1020 manifest.addAccount(accountInfo);
1023 void TaskManifestFile::setPrivilege(Manifest& manifest)
1025 WrtDB::ConfigParserData::PrivilegeList privileges =
1026 m_context.widgetConfig.configInfo.privilegeList;
1028 PrivilegeType privilege;
1030 FOREACH(it, privileges)
1032 privilege.addPrivilegeName(it->name);
1035 manifest.addPrivileges(privilege);
1038 } //namespace WidgetInstall