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),
107 if (false == m_context.existingWidgetInfo.isExist) {
108 AddStep(&TaskManifestFile::stepCopyIconFiles);
109 AddStep(&TaskManifestFile::stepCreateExecFile);
110 AddStep(&TaskManifestFile::stepGenerateManifest);
111 AddStep(&TaskManifestFile::stepParseManifest);
112 AddStep(&TaskManifestFile::stepFinalize);
114 AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
116 // for widget update.
117 AddStep(&TaskManifestFile::stepBackupIconFiles);
118 AddStep(&TaskManifestFile::stepCopyIconFiles);
119 AddStep(&TaskManifestFile::stepGenerateManifest);
120 AddStep(&TaskManifestFile::stepParseUpgradedManifest);
121 AddStep(&TaskManifestFile::stepUpdateFinalize);
123 AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
127 TaskManifestFile::~TaskManifestFile()
130 void TaskManifestFile::stepCreateExecFile()
132 std::string exec = m_context.locations->getExecFile();
133 std::string clientExeStr = GlobalConfig::GetWrtClientExec();
135 LogInfo("link -s " << clientExeStr << " " << exec);
138 if (symlink(clientExeStr.c_str(), exec.c_str()) != 0)
142 LogPedantic("Failed to make a symbolic name for a file "
143 << "[" << DPL::GetErrnoString(error) << "]");
144 ThrowMsg(Exceptions::InstallationFailed,
145 "Symbolic link creating is not done.");
147 m_context.job->UpdateProgress(
148 InstallerContext::INSTALL_CREATE_EXECFILE,
149 "Widget execfile creation Finished");
152 void TaskManifestFile::stepCopyIconFiles()
154 LogDebug("CopyIconFiles");
156 //This function copies icon to desktop icon path. For each locale avaliable
157 //which there is at least one icon in widget for, icon file is copied.
158 //Coping prioritize last positions when coping. If there is several icons
159 //with given locale, the one, that will be copied, will be icon
160 //which is declared by <icon> tag later than the others in config.xml of
163 std::vector<Locale> generatedLocales;
165 WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
166 m_context.widgetConfig.localizationData.icons;
168 //reversed: last <icon> has highest priority to be copied if it has given
169 // locale (TODO: why was that working that way?)
170 for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
171 icon = icons.rbegin();
172 icon != icons.rend();
175 FOREACH(locale, icon->availableLocales)
177 DPL::String src = icon->src;
178 LogDebug("Icon for locale: " << *locale << "is : " << src);
180 if (std::find(generatedLocales.begin(), generatedLocales.end(),
181 *locale) != generatedLocales.end())
183 LogDebug("Skipping - has that locale");
186 generatedLocales.push_back(*locale);
189 std::ostringstream sourceFile;
190 std::ostringstream targetFile;
192 sourceFile << m_context.locations->getSourceDir() << "/";
194 if (!locale->empty()) {
195 sourceFile << "locales/" << *locale << "/";
200 targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
201 targetFile << getIconTargetFilename(*locale);
203 if (m_context.widgetConfig.packagingType ==
204 WrtDB::PKG_TYPE_HOSTED_WEB_APP)
206 m_context.locations->setIconTargetFilenameForLocale(
210 LogDebug("Copying icon: " << sourceFile.str() <<
211 " -> " << targetFile.str());
213 icon_list.push_back(targetFile.str());
217 DPL::FileInput input(sourceFile.str());
218 DPL::FileOutput output(targetFile.str());
219 DPL::Copy(&input, &output);
222 Catch(DPL::FileInput::Exception::Base)
224 // Error while opening or closing source file
225 //ReThrowMsg(InstallerException::CopyIconFailed,
226 // sourceFile.str());
228 "Copying widget's icon failed. Widget's icon will not be" \
229 "available from Main Screen");
232 Catch(DPL::FileOutput::Exception::Base)
234 // Error while opening or closing target file
235 //ReThrowMsg(InstallerException::CopyIconFailed,
236 // targetFile.str());
238 "Copying widget's icon failed. Widget's icon will not be" \
239 "available from Main Screen");
242 Catch(DPL::CopyFailed)
244 // Error while copying
245 //ReThrowMsg(InstallerException::CopyIconFailed,
246 // targetFile.str());
248 "Copying widget's icon failed. Widget's icon will not be" \
249 "available from Main Screen");
254 m_context.job->UpdateProgress(
255 InstallerContext::INSTALL_COPY_ICONFILE,
256 "Widget iconfile copy Finished");
259 void TaskManifestFile::stepBackupIconFiles()
261 LogDebug("Backup Icon Files");
263 backup_dir << m_context.locations->getPackageInstallationDir();
264 backup_dir << "/" << "backup" << "/";
268 m_context.job->UpdateProgress(
269 InstallerContext::INSTALL_BACKUP_ICONFILE,
270 "New Widget icon file backup Finished");
273 void TaskManifestFile::stepAbortIconFiles()
275 LogDebug("Abrot Icon Files");
276 FOREACH(it, icon_list)
278 LogDebug("Remove Update Icon : " << (*it));
279 unlink((*it).c_str());
282 std::ostringstream b_icon_dir;
283 b_icon_dir << backup_dir.str() << "icons";
285 std::list<std::string> fileList;
286 getFileList(b_icon_dir.str().c_str(), fileList);
288 FOREACH(back_icon, fileList)
290 std::ostringstream res_file;
291 res_file << GlobalConfig::GetUserWidgetDesktopIconPath();
292 res_file << "/" << (*back_icon);
294 std::ostringstream backup_file;
295 backup_file << b_icon_dir.str() << "/" << (*back_icon);
299 DPL::FileInput input(backup_file.str());
300 DPL::FileOutput output(res_file.str());
301 DPL::Copy(&input, &output);
303 Catch(DPL::FileInput::Exception::Base)
305 LogError("Restoration icon File Failed." << backup_file.str()
306 << " to " << res_file.str());
309 Catch(DPL::FileOutput::Exception::Base)
311 LogError("Restoration icon File Failed." << backup_file.str()
312 << " to " << res_file.str());
314 Catch(DPL::CopyFailed)
316 LogError("Restoration icon File Failed." << backup_file.str()
317 << " to " << res_file.str());
322 void TaskManifestFile::stepUpdateFinalize()
325 LogDebug("Finished Update Desktopfile");
328 DPL::String TaskManifestFile::getIconTargetFilename(
329 const DPL::String& languageTag) const
331 DPL::OStringStream filename;
332 TizenAppId appid = m_context.widgetConfig.tzAppid;
334 filename << DPL::ToUTF8String(appid).c_str();
336 if (!languageTag.empty()) {
337 DPL::OptionalString tag = getLangTag(languageTag); // translate en ->
343 LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
345 if (locale.empty()) {
346 filename << L"." << languageTag;
348 filename << L"." << locale;
353 return filename.str();
356 void TaskManifestFile::stepFinalize()
359 LogInfo("Finished ManifestFile step");
362 void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
363 const DPL::String& key,
364 const DPL::String& languageTag)
367 LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
370 if (!locale.empty()) {
371 file << "[" << locale << "]";
376 void TaskManifestFile::updateAilInfo()
378 // Update ail for desktop
379 std::string cfgAppid =
380 DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
381 const char* appid = cfgAppid.c_str();
383 LogDebug("Update ail desktop : " << appid);
384 ail_appinfo_h ai = NULL;
387 ret = ail_get_appinfo(appid, &ai);
389 ail_destroy_appinfo(ai);
392 if (AIL_ERROR_NO_DATA == ret) {
393 if (ail_desktop_add(appid) < 0) {
394 LogWarning("Failed to add ail desktop : " << appid);
396 } else if (AIL_ERROR_OK == ret) {
397 if (ail_desktop_update(appid) < 0) {
398 LogWarning("Failed to update ail desktop : " << appid);
403 void TaskManifestFile::backupIconFiles()
405 LogInfo("Backup Icon Files");
407 std::ostringstream b_icon_dir;
408 b_icon_dir << backup_dir.str() << "icons";
410 LogDebug("Create icon backup folder : " << b_icon_dir.str());
411 WrtUtilMakeDir(b_icon_dir.str());
413 std::list<std::string> fileList;
414 getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
415 std::string appid = DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
417 FOREACH(it, fileList)
419 if (0 == (strncmp((*it).c_str(), appid.c_str(),
420 strlen(appid.c_str()))))
422 std::ostringstream icon_file, backup_icon;
423 icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
424 icon_file << "/" << (*it);
426 backup_icon << b_icon_dir.str() << "/" << (*it);
428 LogDebug("Backup icon file " << icon_file.str() << " to " <<
432 DPL::FileInput input(icon_file.str());
433 DPL::FileOutput output(backup_icon.str());
434 DPL::Copy(&input, &output);
436 Catch(DPL::FileInput::Exception::Base)
438 LogError("Backup Desktop File Failed.");
439 ReThrowMsg(Exceptions::BackupFailed, icon_file.str());
442 Catch(DPL::FileOutput::Exception::Base)
444 LogError("Backup Desktop File Failed.");
445 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
447 Catch(DPL::CopyFailed)
449 LogError("Backup Desktop File Failed.");
450 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
452 unlink((*it).c_str());
457 void TaskManifestFile::getFileList(const char* path,
458 std::list<std::string> &list)
460 DIR* dir = opendir(path);
462 LogError("icon directory doesn't exist");
463 ThrowMsg(Exceptions::InternalError, path);
466 struct dirent* d_ent;
468 if ((d_ent = readdir(dir))) {
469 if (strcmp(d_ent->d_name, ".") == 0 ||
470 strcmp(d_ent->d_name, "..") == 0)
474 std::string file_name = d_ent->d_name;
475 list.push_back(file_name);
478 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
479 LogError("Failed to close dir: " << path << " with error: "
480 << DPL::GetErrnoString());
484 void TaskManifestFile::stepGenerateManifest()
486 TizenPkgId pkgid = m_context.widgetConfig.tzPkgid;
487 manifest_name = pkgid + L".xml";
488 manifest_file += L"/tmp/" + manifest_name;
490 //libxml - init and check
491 LibxmlSingleton::Instance().init();
493 writeManifest(manifest_file);
495 m_context.job->UpdateProgress(
496 InstallerContext::INSTALL_CREATE_MANIFEST,
497 "Widget Manifest Creation Finished");
500 void TaskManifestFile::stepParseManifest()
502 int code = pkgmgr_parser_parse_manifest_for_installation(
503 DPL::ToUTF8String(manifest_file).c_str(), NULL);
506 LogError("Manifest parser error: " << code);
507 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
510 // TODO : It will be removed. AIL update is temporary code request by pkgmgr
514 m_context.job->UpdateProgress(
515 InstallerContext::INSTALL_CREATE_MANIFEST,
516 "Widget Manifest Parsing Finished");
517 LogDebug("Manifest parsed");
520 void TaskManifestFile::stepParseUpgradedManifest()
522 int code = pkgmgr_parser_parse_manifest_for_upgrade(
523 DPL::ToUTF8String(manifest_file).c_str(), NULL);
526 LogError("Manifest parser error: " << code);
527 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
530 // TODO : It will be removed. AIL update is temporary code request by pkgmgr
534 m_context.job->UpdateProgress(
535 InstallerContext::INSTALL_CREATE_MANIFEST,
536 "Widget Manifest Parsing Finished");
537 LogDebug("Manifest parsed");
540 void TaskManifestFile::commitManifest()
542 LogDebug("Commiting manifest file : " << manifest_file);
544 std::ostringstream destFile;
545 destFile << "/opt/share/packages" << "/"; //TODO constant with path
546 destFile << DPL::ToUTF8String(manifest_name);
547 LogInfo("cp " << manifest_file << " " << destFile.str());
549 DPL::FileInput input(DPL::ToUTF8String(manifest_file));
550 DPL::FileOutput output(destFile.str());
551 DPL::Copy(&input, &output);
552 LogDebug("Manifest writen to: " << destFile.str());
555 unlink((DPL::ToUTF8String(manifest_file)).c_str());
556 manifest_file = DPL::FromUTF8String(destFile.str().c_str());
559 void TaskManifestFile::writeManifest(const DPL::String & path)
561 LogDebug("Generating manifest file : " << path);
565 setWidgetExecPath(uiApp);
566 setWidgetName(manifest, uiApp);
567 setWidgetIcons(uiApp);
568 setWidgetManifest(manifest);
569 setWidgetOtherInfo(uiApp);
570 setAppServiceInfo(uiApp);
571 setAppControlInfo(uiApp);
572 setAppCategory(uiApp);
573 setLiveBoxInfo(manifest);
575 manifest.addUiApplication(uiApp);
576 manifest.generate(path);
577 LogDebug("Manifest file serialized");
580 void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp)
582 uiApp.setExec(DPL::FromASCIIString(m_context.locations->getExecFile()));
585 void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
587 bool defaultNameSaved = false;
589 DPL::OptionalString defaultLocale =
590 m_context.widgetConfig.configInfo.defaultlocale;
591 std::pair<DPL::String,
592 WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
594 FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
596 Locale i = localizedData->first;
597 DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
601 DPL::OptionalString name = localizedData->second.name;
602 generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
604 //store default locale localized data
605 if (!!defaultLocale && defaultLocale == i) {
606 defaultLocalizedData = *localizedData;
610 if (!!defaultLocale && !defaultNameSaved) {
611 DPL::OptionalString name = defaultLocalizedData.second.name;
612 generateWidgetName(manifest,
614 DPL::OptionalString::Null,
619 TizenAppId appid = m_context.widgetConfig.tzAppid;
620 uiApp.setAppid(appid);
623 if (!!m_context.widgetConfig.guid) {
624 uiApp.setExtraid(*m_context.widgetConfig.guid);
626 if (!appid.empty()) {
627 uiApp.setExtraid(DPL::String(L"http://") + appid);
632 uiApp.setType(DPL::FromASCIIString("webapp"));
633 manifest.setType(L"wgt");
636 void TaskManifestFile::generateWidgetName(Manifest & manifest,
637 UiApplication &uiApp,
638 const DPL::OptionalString& tag,
639 DPL::OptionalString name,
640 bool & defaultNameSaved)
645 LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
647 if (!locale.empty()) {
648 uiApp.addLabel(LabelType(*name, *tag));
650 uiApp.addLabel(LabelType(*name));
651 manifest.addLabel(LabelType(*name));
654 defaultNameSaved = true;
655 uiApp.addLabel(LabelType(*name));
656 manifest.addLabel(LabelType(*name));
661 void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
663 //TODO this file will need to be updated when user locale preferences
665 bool defaultIconSaved = false;
667 DPL::OptionalString defaultLocale =
668 m_context.widgetConfig.configInfo.defaultlocale;
670 std::vector<Locale> generatedLocales;
671 WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
672 m_context.widgetConfig.localizationData.icons;
674 //reversed: last <icon> has highest priority to be writen to manifest if it
675 // has given locale (TODO: why was that working that way?)
676 for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
677 icon = icons.rbegin();
678 icon != icons.rend();
681 FOREACH(locale, icon->availableLocales)
683 if (std::find(generatedLocales.begin(), generatedLocales.end(),
684 *locale) != generatedLocales.end())
686 LogDebug("Skipping - has that locale - already in manifest");
689 generatedLocales.push_back(*locale);
692 DPL::OptionalString tag = getLangTag(*locale); // translate en ->
698 generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved);
701 if (!!defaultLocale && !defaultIconSaved) {
702 generateWidgetIcon(uiApp, DPL::OptionalString::Null,
708 void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp,
709 const DPL::OptionalString& tag,
710 const DPL::String& language,
711 bool & defaultIconSaved)
715 locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
717 defaultIconSaved = true;
720 DPL::String iconText;
721 iconText += getIconTargetFilename(language);
723 if (!locale.empty()) {
724 uiApp.addIcon(IconType(iconText, locale));
726 uiApp.addIcon(IconType(iconText));
728 std::ostringstream iconPath;
729 iconPath << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
730 iconPath << getIconTargetFilename(locale);
731 m_context.job->SendProgressIconPath(iconPath.str());
734 void TaskManifestFile::setWidgetManifest(Manifest & manifest)
736 manifest.setPackage(m_context.widgetConfig.tzPkgid);
738 if (!!m_context.widgetConfig.version) {
739 manifest.setVersion(*m_context.widgetConfig.version);
741 DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ?
742 *m_context.widgetConfig.configInfo.authorEmail : L"");
743 DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
744 *m_context.widgetConfig.configInfo.authorHref : L"");
745 DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ?
746 *m_context.widgetConfig.configInfo.authorName : L"");
747 manifest.addAuthor(Author(email, href, L"", name));
750 void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
752 FOREACH(it, m_context.widgetConfig.configInfo.settingsList)
754 if (!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) {
755 if (!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) {
756 uiApp.setNodisplay(true);
757 uiApp.setTaskmanage(false);
759 uiApp.setNodisplay(false);
760 uiApp.setTaskmanage(true);
765 //There is no "X-TIZEN-PackageType=wgt"
766 //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" <<
767 // DPL::ToUTF8String(*widgetID).c_str()
768 //There is no Comment in pkgmgr "Comment=Widget application"
769 //that were in desktop file
772 void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
774 WrtDB::ConfigParserData::ServiceInfoList appServiceList =
775 m_context.widgetConfig.configInfo.appServiceList;
777 if (appServiceList.empty()) {
778 LogInfo("Widget doesn't contain application service");
782 // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
783 FOREACH(it, appServiceList) {
784 AppControl appControl;
785 if (!it->m_operation.empty()) {
786 appControl.addOperation(it->m_operation); //TODO: encapsulation?
788 if (!it->m_scheme.empty()) {
789 appControl.addUri(it->m_scheme);
791 if (!it->m_mime.empty()) {
792 appControl.addMime(it->m_mime);
794 uiApp.addAppControl(appControl);
798 void TaskManifestFile::setAppControlInfo(UiApplication & uiApp)
800 WrtDB::ConfigParserData::AppControlInfoList appControlList =
801 m_context.widgetConfig.configInfo.appControlList;
803 if (appControlList.empty()) {
804 LogInfo("Widget doesn't contain app control");
808 // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
809 FOREACH(it, appControlList) {
810 AppControl appControl;
811 if (!it->m_operation.empty()) {
812 appControl.addOperation(it->m_operation); //TODO: encapsulation?
814 if (!it->m_uriList.empty()) {
815 FOREACH(uri, it->m_uriList) {
816 appControl.addUri(*uri);
819 if (!it->m_mimeList.empty()) {
820 FOREACH(mime, it->m_mimeList) {
821 appControl.addMime(*mime);
824 uiApp.addAppControl(appControl);
828 void TaskManifestFile::setAppCategory(UiApplication &uiApp)
830 WrtDB::ConfigParserData::CategoryList categoryList =
831 m_context.widgetConfig.configInfo.categoryList;
833 if (categoryList.empty()) {
834 LogInfo("Widget doesn't contain application category");
837 FOREACH(it, categoryList) {
838 if (!(*it).empty()) {
839 uiApp.addAppCategory(*it);
844 void TaskManifestFile::stepAbortParseManifest()
846 LogError("[Parse Manifest] Abroting....");
848 int code = pkgmgr_parser_parse_manifest_for_uninstallation(
849 DPL::ToUTF8String(manifest_file).c_str(), NULL);
852 LogWarning("Manifest parser error: " << code);
853 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
855 int ret = unlink(DPL::ToUTF8String(manifest_file).c_str());
857 LogWarning("No manifest file found: " << manifest_file);
861 void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
863 FOREACH(it, m_context.widgetConfig.configInfo.m_livebox) {
864 LogInfo("setLiveBoxInfo");
866 DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
867 DPL::String appid = m_context.widgetConfig.tzAppid;
870 if (ConfigInfo->m_liveboxId != L"") {
871 found = ConfigInfo->m_liveboxId.find_last_of(L".");
872 if (found != std::string::npos) {
873 if (0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) {
874 liveBox.setLiveboxId(ConfigInfo->m_liveboxId);
876 DPL::String liveboxId =
877 appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
878 liveBox.setLiveboxId(liveboxId);
881 DPL::String liveboxId =
882 appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
883 liveBox.setLiveboxId(liveboxId);
887 if (ConfigInfo->m_primary != L"") {
888 liveBox.setPrimary(ConfigInfo->m_primary);
891 if (ConfigInfo->m_autoLaunch == L"true") {
892 liveBox.setAutoLaunch(appid);
895 if (ConfigInfo->m_updatePeriod != L"") {
896 liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod);
899 if (ConfigInfo->m_label != L"") {
900 liveBox.setLabel(ConfigInfo->m_label);
903 DPL::String defaultLocale
904 = DPL::FromUTF8String(
905 m_context.locations->getPackageInstallationDir())
906 + DPL::String(L"/res/wgt/");
908 if (ConfigInfo->m_icon != L"") {
909 liveBox.setIcon(defaultLocale + ConfigInfo->m_icon);
912 if (ConfigInfo->m_boxInfo.m_boxSrc.empty() ||
913 ConfigInfo->m_boxInfo.m_boxSize.empty())
915 LogInfo("Widget doesn't contain box");
919 if (!ConfigInfo->m_boxInfo.m_boxSrc.empty()) {
920 if ((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http"))
922 ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https")))
924 box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc;
926 box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc;
930 if (ConfigInfo->m_boxInfo.m_boxMouseEvent == L"true") {
931 box.boxMouseEvent = ConfigInfo->m_boxInfo.m_boxMouseEvent;
933 box.boxMouseEvent = L"false";
936 std::list<std::pair<DPL::String, DPL::String> > BoxSizeList
937 = ConfigInfo->m_boxInfo.m_boxSize;
938 FOREACH(im, BoxSizeList) {
939 std::pair<DPL::String, DPL::String> boxSize = *im;
940 if (!boxSize.second.empty()) {
941 boxSize.second = defaultLocale + boxSize.second;
943 box.boxSize.push_back(boxSize);
946 if (!ConfigInfo->m_boxInfo.m_pdSrc.empty()
947 && !ConfigInfo->m_boxInfo.m_pdWidth.empty()
948 && !ConfigInfo->m_boxInfo.m_pdHeight.empty())
950 box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc;
951 box.pdWidth = ConfigInfo->m_boxInfo.m_pdWidth;
952 box.pdHeight = ConfigInfo->m_boxInfo.m_pdHeight;
956 manifest.addLivebox(liveBox);
959 } //namespace WidgetInstall