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);
136 symlink(clientExeStr.c_str(), exec.c_str());
138 m_context.job->UpdateProgress(
139 InstallerContext::INSTALL_CREATE_EXECFILE,
140 "Widget execfile creation Finished");
143 void TaskManifestFile::stepCopyIconFiles()
145 LogDebug("CopyIconFiles");
147 //This function copies icon to desktop icon path. For each locale avaliable
148 //which there is at least one icon in widget for, icon file is copied.
149 //Coping prioritize last positions when coping. If there is several icons
150 //with given locale, the one, that will be copied, will be icon
151 //which is declared by <icon> tag later than the others in config.xml of
154 std::vector<Locale> generatedLocales;
156 WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
157 m_context.widgetConfig.localizationData.icons;
159 //reversed: last <icon> has highest priority to be copied if it has given
160 // locale (TODO: why was that working that way?)
161 for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
162 icon = icons.rbegin();
163 icon != icons.rend();
166 FOREACH(locale, icon->availableLocales)
168 DPL::String src = icon->src;
169 LogDebug("Icon for locale: " << *locale << "is : " << src);
171 if (std::find(generatedLocales.begin(), generatedLocales.end(),
172 *locale) != generatedLocales.end())
174 LogDebug("Skipping - has that locale");
177 generatedLocales.push_back(*locale);
180 std::ostringstream sourceFile;
181 std::ostringstream targetFile;
183 sourceFile << m_context.locations->getSourceDir() << "/";
185 if (!locale->empty()) {
186 sourceFile << "locales/" << *locale << "/";
191 targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
192 targetFile << getIconTargetFilename(*locale);
194 if (m_context.widgetConfig.packagingType ==
195 WrtDB::PKG_TYPE_HOSTED_WEB_APP)
197 m_context.locations->setIconTargetFilenameForLocale(
201 LogDebug("Copying icon: " << sourceFile.str() <<
202 " -> " << targetFile.str());
204 icon_list.push_back(targetFile.str());
208 DPL::FileInput input(sourceFile.str());
209 DPL::FileOutput output(targetFile.str());
210 DPL::Copy(&input, &output);
213 Catch(DPL::FileInput::Exception::Base)
215 // Error while opening or closing source file
216 //ReThrowMsg(InstallerException::CopyIconFailed,
217 // sourceFile.str());
219 "Copying widget's icon failed. Widget's icon will not be" \
220 "available from Main Screen");
223 Catch(DPL::FileOutput::Exception::Base)
225 // Error while opening or closing target file
226 //ReThrowMsg(InstallerException::CopyIconFailed,
227 // targetFile.str());
229 "Copying widget's icon failed. Widget's icon will not be" \
230 "available from Main Screen");
233 Catch(DPL::CopyFailed)
235 // Error while copying
236 //ReThrowMsg(InstallerException::CopyIconFailed,
237 // targetFile.str());
239 "Copying widget's icon failed. Widget's icon will not be" \
240 "available from Main Screen");
245 m_context.job->UpdateProgress(
246 InstallerContext::INSTALL_COPY_ICONFILE,
247 "Widget iconfile copy Finished");
250 void TaskManifestFile::stepBackupIconFiles()
252 LogDebug("Backup Icon Files");
254 backup_dir << m_context.locations->getPackageInstallationDir();
255 backup_dir << "/" << "backup" << "/";
259 m_context.job->UpdateProgress(
260 InstallerContext::INSTALL_BACKUP_ICONFILE,
261 "New Widget icon file backup Finished");
264 void TaskManifestFile::stepAbortIconFiles()
266 LogDebug("Abrot Icon Files");
267 FOREACH(it, icon_list)
269 LogDebug("Remove Update Icon : " << (*it));
270 unlink((*it).c_str());
273 std::ostringstream b_icon_dir;
274 b_icon_dir << backup_dir.str() << "icons";
276 std::list<std::string> fileList;
277 getFileList(b_icon_dir.str().c_str(), fileList);
279 FOREACH(back_icon, fileList)
281 std::ostringstream res_file;
282 res_file << GlobalConfig::GetUserWidgetDesktopIconPath();
283 res_file << "/" << (*back_icon);
285 std::ostringstream backup_file;
286 backup_file << b_icon_dir.str() << "/" << (*back_icon);
290 DPL::FileInput input(backup_file.str());
291 DPL::FileOutput output(res_file.str());
292 DPL::Copy(&input, &output);
294 Catch(DPL::FileInput::Exception::Base)
296 LogError("Restoration icon File Failed." << backup_file.str()
297 << " to " << res_file.str());
300 Catch(DPL::FileOutput::Exception::Base)
302 LogError("Restoration icon File Failed." << backup_file.str()
303 << " to " << res_file.str());
305 Catch(DPL::CopyFailed)
307 LogError("Restoration icon File Failed." << backup_file.str()
308 << " to " << res_file.str());
313 void TaskManifestFile::stepUpdateFinalize()
316 LogDebug("Finished Update Desktopfile");
319 DPL::String TaskManifestFile::getIconTargetFilename(
320 const DPL::String& languageTag) const
322 DPL::OStringStream filename;
323 TizenAppId appid = m_context.widgetConfig.tzAppid;
325 filename << DPL::ToUTF8String(appid).c_str();
327 if (!languageTag.empty()) {
328 DPL::OptionalString tag = getLangTag(languageTag); // translate en ->
334 LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
336 if (locale.empty()) {
337 filename << L"." << languageTag;
339 filename << L"." << locale;
344 return filename.str();
347 void TaskManifestFile::stepFinalize()
350 LogInfo("Finished ManifestFile step");
353 void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
354 const DPL::String& key,
355 const DPL::String& languageTag)
358 LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
361 if (!locale.empty()) {
362 file << "[" << locale << "]";
367 void TaskManifestFile::updateAilInfo()
369 // Update ail for desktop
370 std::string cfgAppid =
371 DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
372 const char* appid = cfgAppid.c_str();
374 LogDebug("Update ail desktop : " << appid);
375 ail_appinfo_h ai = NULL;
378 ret = ail_package_get_appinfo(appid, &ai);
380 ail_package_destroy_appinfo(ai);
383 if (AIL_ERROR_NO_DATA == ret) {
384 if (ail_desktop_add(appid) < 0) {
385 LogWarning("Failed to add ail desktop : " << appid);
387 } else if (AIL_ERROR_OK == ret) {
388 if (ail_desktop_update(appid) < 0) {
389 LogWarning("Failed to update ail desktop : " << appid);
394 void TaskManifestFile::backupIconFiles()
396 LogInfo("Backup Icon Files");
398 std::ostringstream b_icon_dir;
399 b_icon_dir << backup_dir.str() << "icons";
401 LogDebug("Create icon backup folder : " << b_icon_dir.str());
402 WrtUtilMakeDir(b_icon_dir.str());
404 std::list<std::string> fileList;
405 getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
406 std::string appid = DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
408 FOREACH(it, fileList)
410 if (0 == (strncmp((*it).c_str(), appid.c_str(),
411 strlen(appid.c_str()))))
413 std::ostringstream icon_file, backup_icon;
414 icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
415 icon_file << "/" << (*it);
417 backup_icon << b_icon_dir.str() << "/" << (*it);
419 LogDebug("Backup icon file " << icon_file.str() << " to " <<
423 DPL::FileInput input(icon_file.str());
424 DPL::FileOutput output(backup_icon.str());
425 DPL::Copy(&input, &output);
427 Catch(DPL::FileInput::Exception::Base)
429 LogError("Backup Desktop File Failed.");
430 ReThrowMsg(Exceptions::BackupFailed, icon_file.str());
433 Catch(DPL::FileOutput::Exception::Base)
435 LogError("Backup Desktop File Failed.");
436 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
438 Catch(DPL::CopyFailed)
440 LogError("Backup Desktop File Failed.");
441 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
443 unlink((*it).c_str());
448 void TaskManifestFile::getFileList(const char* path,
449 std::list<std::string> &list)
451 DIR* dir = opendir(path);
453 LogError("icon directory doesn't exist");
454 ThrowMsg(Exceptions::InternalError, path);
457 struct dirent* d_ent;
459 if ((d_ent = readdir(dir))) {
460 if (strcmp(d_ent->d_name, ".") == 0 ||
461 strcmp(d_ent->d_name, "..") == 0)
465 std::string file_name = d_ent->d_name;
466 list.push_back(file_name);
469 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
470 LogError("Failed to close dir: " << path << " with error: "
471 << DPL::GetErrnoString());
475 void TaskManifestFile::stepGenerateManifest()
477 TizenPkgId pkgid = m_context.widgetConfig.tzPkgid;
478 manifest_name = pkgid + L".xml";
479 manifest_file += L"/tmp/" + manifest_name;
481 //libxml - init and check
482 LibxmlSingleton::Instance().init();
484 writeManifest(manifest_file);
486 m_context.job->UpdateProgress(
487 InstallerContext::INSTALL_CREATE_MANIFEST,
488 "Widget Manifest Creation Finished");
491 void TaskManifestFile::stepParseManifest()
493 int code = pkgmgr_parser_parse_manifest_for_installation(
494 DPL::ToUTF8String(manifest_file).c_str(), NULL);
497 LogError("Manifest parser error: " << code);
498 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
501 // TODO : It will be removed. AIL update is temporary code request by pkgmgr
505 m_context.job->UpdateProgress(
506 InstallerContext::INSTALL_CREATE_MANIFEST,
507 "Widget Manifest Parsing Finished");
508 LogDebug("Manifest parsed");
511 void TaskManifestFile::stepParseUpgradedManifest()
513 int code = pkgmgr_parser_parse_manifest_for_upgrade(
514 DPL::ToUTF8String(manifest_file).c_str(), NULL);
517 LogError("Manifest parser error: " << code);
518 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
521 // TODO : It will be removed. AIL update is temporary code request by pkgmgr
525 m_context.job->UpdateProgress(
526 InstallerContext::INSTALL_CREATE_MANIFEST,
527 "Widget Manifest Parsing Finished");
528 LogDebug("Manifest parsed");
531 void TaskManifestFile::commitManifest()
533 LogDebug("Commiting manifest file : " << manifest_file);
535 std::ostringstream destFile;
536 destFile << "/opt/share/packages" << "/"; //TODO constant with path
537 destFile << DPL::ToUTF8String(manifest_name);
538 LogInfo("cp " << manifest_file << " " << destFile.str());
540 DPL::FileInput input(DPL::ToUTF8String(manifest_file));
541 DPL::FileOutput output(destFile.str());
542 DPL::Copy(&input, &output);
543 LogDebug("Manifest writen to: " << destFile.str());
546 unlink((DPL::ToUTF8String(manifest_file)).c_str());
547 manifest_file = DPL::FromUTF8String(destFile.str().c_str());
550 void TaskManifestFile::writeManifest(const DPL::String & path)
552 LogDebug("Generating manifest file : " << path);
556 setWidgetExecPath(uiApp);
557 setWidgetName(manifest, uiApp);
558 setWidgetIcons(uiApp);
559 setWidgetManifest(manifest);
560 setWidgetOtherInfo(uiApp);
561 setAppServiceInfo(uiApp);
562 setAppControlInfo(uiApp);
563 setAppCategory(uiApp);
564 setLiveBoxInfo(manifest);
566 manifest.addUiApplication(uiApp);
567 manifest.generate(path);
568 LogDebug("Manifest file serialized");
571 void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp)
573 uiApp.setExec(DPL::FromASCIIString(m_context.locations->getExecFile()));
576 void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
578 bool defaultNameSaved = false;
580 DPL::OptionalString defaultLocale =
581 m_context.widgetConfig.configInfo.defaultlocale;
582 std::pair<DPL::String,
583 WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
585 FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
587 Locale i = localizedData->first;
588 DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
592 DPL::OptionalString name = localizedData->second.name;
593 generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
595 //store default locale localized data
596 if (!!defaultLocale && defaultLocale == i) {
597 defaultLocalizedData = *localizedData;
601 if (!!defaultLocale && !defaultNameSaved) {
602 DPL::OptionalString name = defaultLocalizedData.second.name;
603 generateWidgetName(manifest,
605 DPL::OptionalString::Null,
610 TizenAppId appid = m_context.widgetConfig.tzAppid;
611 uiApp.setAppid(appid);
614 if (!!m_context.widgetConfig.guid) {
615 uiApp.setExtraid(*m_context.widgetConfig.guid);
617 if (!appid.empty()) {
618 uiApp.setExtraid(DPL::String(L"http://") + appid);
623 uiApp.setType(DPL::FromASCIIString("webapp"));
624 manifest.setType(L"wgt");
627 void TaskManifestFile::generateWidgetName(Manifest & manifest,
628 UiApplication &uiApp,
629 const DPL::OptionalString& tag,
630 DPL::OptionalString name,
631 bool & defaultNameSaved)
636 LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
638 if (!locale.empty()) {
639 uiApp.addLabel(LabelType(*name, *tag));
641 uiApp.addLabel(LabelType(*name));
642 manifest.addLabel(LabelType(*name));
645 defaultNameSaved = true;
646 uiApp.addLabel(LabelType(*name));
647 manifest.addLabel(LabelType(*name));
652 void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
654 //TODO this file will need to be updated when user locale preferences
656 bool defaultIconSaved = false;
658 DPL::OptionalString defaultLocale =
659 m_context.widgetConfig.configInfo.defaultlocale;
661 std::vector<Locale> generatedLocales;
662 WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
663 m_context.widgetConfig.localizationData.icons;
665 //reversed: last <icon> has highest priority to be writen to manifest if it
666 // has given locale (TODO: why was that working that way?)
667 for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
668 icon = icons.rbegin();
669 icon != icons.rend();
672 FOREACH(locale, icon->availableLocales)
674 if (std::find(generatedLocales.begin(), generatedLocales.end(),
675 *locale) != generatedLocales.end())
677 LogDebug("Skipping - has that locale - already in manifest");
680 generatedLocales.push_back(*locale);
683 DPL::OptionalString tag = getLangTag(*locale); // translate en ->
689 generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved);
692 if (!!defaultLocale && !defaultIconSaved) {
693 generateWidgetIcon(uiApp, DPL::OptionalString::Null,
699 void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp,
700 const DPL::OptionalString& tag,
701 const DPL::String& language,
702 bool & defaultIconSaved)
706 locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
708 defaultIconSaved = true;
711 DPL::String iconText;
712 iconText += getIconTargetFilename(language);
714 if (!locale.empty()) {
715 uiApp.addIcon(IconType(iconText, locale));
717 uiApp.addIcon(IconType(iconText));
719 std::ostringstream iconPath;
720 iconPath << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
721 iconPath << getIconTargetFilename(locale);
722 m_context.job->SendProgressIconPath(iconPath.str());
725 void TaskManifestFile::setWidgetManifest(Manifest & manifest)
727 manifest.setPackage(m_context.widgetConfig.tzPkgid);
729 if (!!m_context.widgetConfig.version) {
730 manifest.setVersion(*m_context.widgetConfig.version);
732 DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ?
733 *m_context.widgetConfig.configInfo.authorEmail : L"");
734 DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
735 *m_context.widgetConfig.configInfo.authorHref : L"");
736 DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ?
737 *m_context.widgetConfig.configInfo.authorName : L"");
738 manifest.addAuthor(Author(email, href, L"", name));
741 void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
743 FOREACH(it, m_context.widgetConfig.configInfo.settingsList)
745 if (!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) {
746 if (!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) {
747 uiApp.setNodisplay(true);
748 uiApp.setTaskmanage(false);
750 uiApp.setNodisplay(false);
751 uiApp.setTaskmanage(true);
756 //There is no "X-TIZEN-PackageType=wgt"
757 //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" <<
758 // DPL::ToUTF8String(*widgetID).c_str()
759 //There is no Comment in pkgmgr "Comment=Widget application"
760 //that were in desktop file
763 void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
765 WrtDB::ConfigParserData::ServiceInfoList appServiceList =
766 m_context.widgetConfig.configInfo.appServiceList;
768 if (appServiceList.empty()) {
769 LogInfo("Widget doesn't contain application service");
773 // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
774 FOREACH(it, appServiceList) {
775 AppControl appControl;
776 if (!it->m_operation.empty()) {
777 appControl.addOperation(it->m_operation); //TODO: encapsulation?
779 if (!it->m_scheme.empty()) {
780 appControl.addUri(it->m_scheme);
782 if (!it->m_mime.empty()) {
783 appControl.addMime(it->m_mime);
785 uiApp.addAppControl(appControl);
789 void TaskManifestFile::setAppControlInfo(UiApplication & uiApp)
791 WrtDB::ConfigParserData::AppControlInfoList appControlList =
792 m_context.widgetConfig.configInfo.appControlList;
794 if (appControlList.empty()) {
795 LogInfo("Widget doesn't contain app control");
799 // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
800 FOREACH(it, appControlList) {
801 AppControl appControl;
802 if (!it->m_operation.empty()) {
803 appControl.addOperation(it->m_operation); //TODO: encapsulation?
805 if (!it->m_uriList.empty()) {
806 FOREACH(uri, it->m_uriList) {
807 appControl.addUri(*uri);
810 if (!it->m_mimeList.empty()) {
811 FOREACH(mime, it->m_mimeList) {
812 appControl.addMime(*mime);
815 uiApp.addAppControl(appControl);
819 void TaskManifestFile::setAppCategory(UiApplication &uiApp)
821 WrtDB::ConfigParserData::CategoryList categoryList =
822 m_context.widgetConfig.configInfo.categoryList;
824 if (categoryList.empty()) {
825 LogInfo("Widget doesn't contain application category");
828 FOREACH(it, categoryList) {
829 if (!(*it).empty()) {
830 uiApp.addAppCategory(*it);
835 void TaskManifestFile::stepAbortParseManifest()
837 LogError("[Parse Manifest] Abroting....");
839 int code = pkgmgr_parser_parse_manifest_for_uninstallation(
840 DPL::ToUTF8String(manifest_file).c_str(), NULL);
843 LogWarning("Manifest parser error: " << code);
844 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
846 int ret = unlink(DPL::ToUTF8String(manifest_file).c_str());
848 LogWarning("No manifest file found: " << manifest_file);
852 void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
854 FOREACH(it, m_context.widgetConfig.configInfo.m_livebox) {
855 LogInfo("setLiveBoxInfo");
857 DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
858 DPL::String appid = m_context.widgetConfig.tzAppid;
861 if (ConfigInfo->m_liveboxId != L"") {
862 found = ConfigInfo->m_liveboxId.find_last_of(L".");
863 if (found != std::string::npos) {
864 if (0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) {
865 liveBox.setLiveboxId(ConfigInfo->m_liveboxId);
867 DPL::String liveboxId =
868 appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
869 liveBox.setLiveboxId(liveboxId);
872 DPL::String liveboxId =
873 appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
874 liveBox.setLiveboxId(liveboxId);
878 if (ConfigInfo->m_primary != L"") {
879 liveBox.setPrimary(ConfigInfo->m_primary);
882 if (ConfigInfo->m_autoLaunch == L"true") {
883 liveBox.setAutoLaunch(appid);
886 if (ConfigInfo->m_updatePeriod != L"") {
887 liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod);
890 if (ConfigInfo->m_label != L"") {
891 liveBox.setLabel(ConfigInfo->m_label);
894 DPL::String defaultLocale
895 = DPL::FromUTF8String(
896 m_context.locations->getPackageInstallationDir())
897 + DPL::String(L"/res/wgt/");
899 if (ConfigInfo->m_icon != L"") {
900 liveBox.setIcon(defaultLocale + ConfigInfo->m_icon);
903 if (ConfigInfo->m_boxInfo.m_boxSrc.empty() ||
904 ConfigInfo->m_boxInfo.m_boxSize.empty())
906 LogInfo("Widget doesn't contain box");
910 if (!ConfigInfo->m_boxInfo.m_boxSrc.empty()) {
911 if ((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http"))
913 ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https")))
915 box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc;
917 box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc;
921 if (ConfigInfo->m_boxInfo.m_boxMouseEvent == L"true") {
922 box.boxMouseEvent = ConfigInfo->m_boxInfo.m_boxMouseEvent;
924 box.boxMouseEvent = L"false";
927 std::list<std::pair<DPL::String, DPL::String> > BoxSizeList
928 = ConfigInfo->m_boxInfo.m_boxSize;
929 FOREACH(im, BoxSizeList) {
930 std::pair<DPL::String, DPL::String> boxSize = *im;
931 if (!boxSize.second.empty()) {
932 boxSize.second = defaultLocale + boxSize.second;
934 box.boxSize.push_back(boxSize);
937 if (!ConfigInfo->m_boxInfo.m_pdSrc.empty()
938 && !ConfigInfo->m_boxInfo.m_pdWidth.empty()
939 && !ConfigInfo->m_boxInfo.m_pdHeight.empty())
941 box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc;
942 box.pdWidth = ConfigInfo->m_boxInfo.m_pdWidth;
943 box.pdHeight = ConfigInfo->m_boxInfo.m_pdHeight;
947 manifest.addLivebox(liveBox);
950 } //namespace WidgetInstall