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)
25 #include <dpl/assert.h>
31 #include <widget_install/task_manifest_file.h>
32 #include <widget_install/job_widget_install.h>
33 #include <widget_install/widget_install_errors.h>
34 #include <widget_install/widget_install_context.h>
35 #include <dpl/wrt-dao-ro/global_config.h>
36 #include <dpl/log/log.h>
37 #include <dpl/file_input.h>
38 #include <dpl/errno_string.h>
39 #include <dpl/file_output.h>
41 #include <dpl/exception.h>
42 #include <dpl/foreach.h>
43 #include <dpl/sstream.h>
44 #include <dpl/string.h>
45 #include <dpl/optional.h>
46 #include <dpl/utils/wrt_utility.h>
48 #include <libxml_utils.h>
49 #include <pkgmgr/pkgmgr_parser.h>
50 #include <dpl/localization/LanguageTagsProvider.h>
52 #define DEFAULT_ICON_NAME "icon.png"
54 using namespace WrtDB;
57 typedef std::map<DPL::String, DPL::String> LanguageTagMap;
59 const char* const ST_TRUE = "true";
60 const char* const ST_NODISPLAY = "nodisplay";
62 LanguageTagMap getLanguageTagMap()
66 #define ADD(tag, l_tag) map.insert(std::make_pair(L ## # tag, L ## # l_tag));
67 #include "languages.def"
73 DPL::OptionalString getLangTag(const DPL::String& tag)
75 static LanguageTagMap TagsMap =
78 DPL::String langTag = tag;
80 LogDebug("Trying to map language tag: " << langTag);
81 size_t pos = langTag.find_first_of(L'_');
82 if (pos != DPL::String::npos) {
85 DPL::OptionalString ret;
87 LanguageTagMap::iterator it = TagsMap.find(langTag);
88 if (it != TagsMap.end()) {
91 LogDebug("Mapping IANA Language tag to language tag: " <<
92 langTag << " -> " << ret);
99 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()
131 void TaskManifestFile::stepCreateExecFile()
133 std::string exec = m_context.locations->getExecFile();
134 std::string clientExeStr = GlobalConfig::GetWrtClientExec();
136 LogInfo("link -s " << clientExeStr << " " << exec);
137 symlink(clientExeStr.c_str(), exec.c_str());
139 m_context.job->UpdateProgress(
140 InstallerContext::INSTALL_CREATE_EXECFILE,
141 "Widget execfile creation Finished");
144 void TaskManifestFile::stepCopyIconFiles()
146 LogDebug("CopyIconFiles");
148 //This function copies icon to desktop icon path. For each locale avaliable
149 //which there is at least one icon in widget for, icon file is copied.
150 //Coping prioritize last positions when coping. If there is several icons
151 //with given locale, the one, that will be copied, will be icon
152 //which is declared by <icon> tag later than the others in config.xml of widget
154 std::vector<Locale> generatedLocales;
156 WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons;
158 //reversed: last <icon> has highest priority to be copied if it has given locale (TODO: why was that working that way?)
159 for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++)
161 FOREACH(locale, icon->availableLocales)
163 DPL::String src = icon->src;
164 LogDebug("Icon for locale: " << *locale << "is : " << src);
166 if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
168 LogDebug("Skipping - has that locale");
173 generatedLocales.push_back(*locale);
176 std::ostringstream sourceFile;
177 std::ostringstream targetFile;
179 sourceFile << m_context.locations->getSourceDir() << "/";
181 if (!locale->empty()) {
182 sourceFile << "locales/" << *locale << "/";
187 targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
188 targetFile << getIconTargetFilename(*locale);
191 if (m_context.widgetConfig.packagingType ==
192 WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
193 m_context.locations->setIconTargetFilenameForLocale(targetFile.str());
196 LogDebug("Copying icon: " << sourceFile.str() <<
197 " -> " << targetFile.str());
199 icon_list.push_back(targetFile.str());
203 DPL::FileInput input(sourceFile.str());
204 DPL::FileOutput output(targetFile.str());
205 DPL::Copy(&input, &output);
208 Catch(DPL::FileInput::Exception::Base)
210 // Error while opening or closing source file
211 //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str());
213 "Copying widget's icon failed. Widget's icon will not be"\
214 "available from Main Screen");
217 Catch(DPL::FileOutput::Exception::Base)
219 // Error while opening or closing target file
220 //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
222 "Copying widget's icon failed. Widget's icon will not be"\
223 "available from Main Screen");
226 Catch(DPL::CopyFailed)
228 // Error while copying
229 //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
231 "Copying widget's icon failed. Widget's icon will not be"\
232 "available from Main Screen");
237 m_context.job->UpdateProgress(
238 InstallerContext::INSTALL_COPY_ICONFILE,
239 "Widget iconfile copy Finished");
242 void TaskManifestFile::stepBackupIconFiles()
244 LogDebug("Backup Icon Files");
246 backup_dir << m_context.locations->getPackageInstallationDir();
247 backup_dir << "/" << "backup" << "/";
251 m_context.job->UpdateProgress(
252 InstallerContext::INSTALL_BACKUP_ICONFILE,
253 "New Widget icon file backup Finished");
256 void TaskManifestFile::stepAbortIconFiles()
258 LogDebug("Abrot Icon Files");
259 FOREACH(it, icon_list)
261 LogDebug("Remove Update Icon : " << (*it));
262 unlink((*it).c_str());
265 std::ostringstream b_icon_dir;
266 b_icon_dir << backup_dir.str() << "icons";
268 std::list<std::string> fileList;
269 getFileList(b_icon_dir.str().c_str(), fileList);
271 FOREACH(back_icon, fileList)
273 std::ostringstream res_file;
274 res_file << GlobalConfig::GetUserWidgetDesktopIconPath();
275 res_file << "/" << (*back_icon);
277 std::ostringstream backup_file;
278 backup_file << b_icon_dir.str() << "/" << (*back_icon);
282 DPL::FileInput input(backup_file.str());
283 DPL::FileOutput output(res_file.str());
284 DPL::Copy(&input, &output);
286 Catch(DPL::FileInput::Exception::Base)
288 LogError("Restoration icon File Failed." << backup_file.str()
289 << " to " << res_file.str());
292 Catch(DPL::FileOutput::Exception::Base)
294 LogError("Restoration icon File Failed." << backup_file.str()
295 << " to " << res_file.str());
297 Catch(DPL::CopyFailed)
299 LogError("Restoration icon File Failed." << backup_file.str()
300 << " to " << res_file.str());
305 void TaskManifestFile::stepUpdateFinalize()
308 LogDebug("Finished Update Desktopfile");
311 DPL::String TaskManifestFile::getIconTargetFilename(
312 const DPL::String& languageTag) const
314 DPL::OStringStream filename;
315 TizenAppId appid = m_context.widgetConfig.tzAppid;
317 filename << DPL::ToUTF8String(appid).c_str();
319 if (!languageTag.empty()) {
320 DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
321 if (tag.IsNull()) { tag = languageTag; }
323 LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
326 filename << L"." << languageTag;
328 filename << L"." << locale;
333 return filename.str();
336 void TaskManifestFile::stepFinalize()
339 LogInfo("Finished ManifestFile step");
343 void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
344 const DPL::String& key,
345 const DPL::String& languageTag)
348 LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
351 if (!locale.empty()) {
352 file << "[" << locale << "]";
357 void TaskManifestFile::updateAilInfo()
359 // Update ail for desktop
360 std::string cfgAppid =
361 DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
362 const char* appid = cfgAppid.c_str();
364 LogDebug("Update ail desktop : " << appid);
365 ail_appinfo_h ai = NULL;
368 ret = ail_package_get_appinfo(appid, &ai);
370 ail_package_destroy_appinfo(ai);
373 if (AIL_ERROR_NO_DATA == ret) {
374 if (ail_desktop_add(appid) < 0) {
375 LogWarning("Failed to add ail desktop : " << appid);
377 } else if (AIL_ERROR_OK == ret) {
378 if (ail_desktop_update(appid) < 0) {
379 LogWarning("Failed to update ail desktop : " << appid);
384 void TaskManifestFile::backupIconFiles()
386 LogInfo("Backup Icon Files");
388 std::ostringstream b_icon_dir;
389 b_icon_dir << backup_dir.str() << "icons";
391 LogDebug("Create icon backup folder : " << b_icon_dir.str());
392 WrtUtilMakeDir(b_icon_dir.str());
394 std::list<std::string> fileList;
395 getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
396 std::string appid = DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
398 FOREACH(it, fileList)
400 if (0 == (strncmp((*it).c_str(), appid.c_str(),
401 strlen(appid.c_str())))) {
402 std::ostringstream icon_file, backup_icon;
403 icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
404 icon_file << "/" << (*it);
406 backup_icon << b_icon_dir.str() << "/" << (*it);
408 LogDebug("Backup icon file " << icon_file.str() << " to " <<
412 DPL::FileInput input(icon_file.str());
413 DPL::FileOutput output(backup_icon.str());
414 DPL::Copy(&input, &output);
416 Catch(DPL::FileInput::Exception::Base)
418 LogError("Backup Desktop File Failed.");
419 ReThrowMsg(Exceptions::BackupFailed, icon_file.str());
422 Catch(DPL::FileOutput::Exception::Base)
424 LogError("Backup Desktop File Failed.");
425 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
427 Catch(DPL::CopyFailed)
429 LogError("Backup Desktop File Failed.");
430 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
432 unlink((*it).c_str());
437 void TaskManifestFile::getFileList(const char* path,
438 std::list<std::string> &list)
440 DIR* dir = opendir(path);
442 LogError("icon directory doesn't exist");
443 ThrowMsg(Exceptions::InternalError, path);
446 struct dirent* d_ent;
448 if ((d_ent = readdir(dir))) {
449 if(strcmp(d_ent->d_name, ".") == 0 ||
450 strcmp(d_ent->d_name, "..") == 0) {
453 std::string file_name = d_ent->d_name;
454 list.push_back(file_name);
457 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
458 LogError("Failed to close dir: " << path << " with error: "
459 << DPL::GetErrnoString());
463 void TaskManifestFile::stepGenerateManifest()
465 TizenPkgId pkgid = m_context.widgetConfig.tzPkgid;
466 manifest_name = pkgid + L".xml";
467 manifest_file += L"/tmp/" + manifest_name;
469 //libxml - init and check
470 LibxmlSingleton::Instance().init();
472 writeManifest(manifest_file);
474 m_context.job->UpdateProgress(
475 InstallerContext::INSTALL_CREATE_MANIFEST,
476 "Widget Manifest Creation Finished");
479 void TaskManifestFile::stepParseManifest()
481 int code = pkgmgr_parser_parse_manifest_for_installation(
482 DPL::ToUTF8String(manifest_file).c_str(), NULL);
486 LogError("Manifest parser error: " << code);
487 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
490 // TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
493 m_context.job->UpdateProgress(
494 InstallerContext::INSTALL_CREATE_MANIFEST,
495 "Widget Manifest Parsing Finished");
496 LogDebug("Manifest parsed");
499 void TaskManifestFile::stepParseUpgradedManifest()
501 int code = pkgmgr_parser_parse_manifest_for_upgrade(
502 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 team.
513 m_context.job->UpdateProgress(
514 InstallerContext::INSTALL_CREATE_MANIFEST,
515 "Widget Manifest Parsing Finished");
516 LogDebug("Manifest parsed");
519 void TaskManifestFile::commitManifest()
521 LogDebug("Commiting manifest file : " << manifest_file);
523 std::ostringstream destFile;
524 destFile << "/opt/share/packages" << "/"; //TODO constant with path
525 destFile << DPL::ToUTF8String(manifest_name);
526 LogInfo("cp " << manifest_file << " " << destFile.str());
528 DPL::FileInput input(DPL::ToUTF8String(manifest_file));
529 DPL::FileOutput output(destFile.str());
530 DPL::Copy(&input, &output);
531 LogDebug("Manifest writen to: " << destFile.str());
534 unlink((DPL::ToUTF8String(manifest_file)).c_str());
535 manifest_file = DPL::FromUTF8String(destFile.str().c_str());
538 void TaskManifestFile::writeManifest(const DPL::String & path)
540 LogDebug("Generating manifest file : " << path);
544 setWidgetExecPath(uiApp);
545 setWidgetName(manifest, uiApp);
546 setWidgetIcons(uiApp);
547 setWidgetManifest(manifest);
548 setWidgetOtherInfo(uiApp);
549 setAppServiceInfo(uiApp);
550 setAppControlInfo(uiApp);
551 setAppCategory(uiApp);
552 setLiveBoxInfo(manifest);
554 manifest.addUiApplication(uiApp);
555 manifest.generate(path);
556 LogDebug("Manifest file serialized");
559 void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp)
561 uiApp.setExec(DPL::FromASCIIString(m_context.locations->getExecFile()));
564 void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
566 bool defaultNameSaved = false;
568 DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
569 std::pair<DPL::String, WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
571 FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
573 Locale i = localizedData->first;
574 DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
579 DPL::OptionalString name = localizedData->second.name;
580 generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
582 //store default locale localized data
583 if(!!defaultLocale && defaultLocale == i)
585 defaultLocalizedData = *localizedData;
589 if (!!defaultLocale && !defaultNameSaved)
591 DPL::OptionalString name = defaultLocalizedData.second.name;
592 generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved);
595 TizenAppId appid = m_context.widgetConfig.tzAppid;
596 uiApp.setAppid(appid);
600 if(!!m_context.widgetConfig.guid) {
601 uiApp.setExtraid(*m_context.widgetConfig.guid);
604 uiApp.setExtraid(DPL::String(L"http://") + appid);
609 uiApp.setType(DPL::FromASCIIString("webapp"));
610 manifest.setType(L"wgt");
613 void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved)
619 LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
621 if (!locale.empty()) {
622 uiApp.addLabel(LabelType(*name,*tag));
626 uiApp.addLabel(LabelType(*name));
627 manifest.addLabel(LabelType(*name));
632 defaultNameSaved = true;
633 uiApp.addLabel(LabelType(*name));
634 manifest.addLabel(LabelType(*name));
639 void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
641 //TODO this file will need to be updated when user locale preferences
643 bool defaultIconSaved = false;
645 DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
647 std::vector<Locale> generatedLocales;
648 WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons;
650 //reversed: last <icon> has highest priority to be writen to manifest if it has given locale (TODO: why was that working that way?)
651 for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++)
653 FOREACH(locale, icon->availableLocales)
655 if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
657 LogDebug("Skipping - has that locale - already in manifest");
662 generatedLocales.push_back(*locale);
665 DPL::OptionalString tag = getLangTag(*locale); // translate en -> en_US etc
666 if (tag.IsNull()) { tag = *locale; }
668 generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved);
671 if (!!defaultLocale && !defaultIconSaved)
673 generateWidgetIcon(uiApp, DPL::OptionalString::Null,
679 void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag,
680 const DPL::String& language, bool & defaultIconSaved)
685 locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
689 defaultIconSaved = true;
692 DPL::String iconText;
693 iconText += getIconTargetFilename(language);
697 uiApp.addIcon(IconType(iconText, locale));
701 uiApp.addIcon(IconType(iconText));
705 void TaskManifestFile::setWidgetManifest(Manifest & manifest)
707 manifest.setPackage(m_context.widgetConfig.tzPkgid);
709 if(!!m_context.widgetConfig.version)
711 manifest.setVersion(*m_context.widgetConfig.version);
713 DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ?
714 *m_context.widgetConfig.configInfo.authorEmail : L"");
715 DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
716 *m_context.widgetConfig.configInfo.authorHref : L"");
717 DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ?
718 *m_context.widgetConfig.configInfo.authorName : L"");
719 manifest.addAuthor(Author(email,href,L"",name));
722 void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
724 FOREACH(it, m_context.widgetConfig.configInfo.settingsList)
726 if(!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) {
727 if(!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) {
728 uiApp.setNodisplay(true);
729 uiApp.setTaskmanage(false);
732 uiApp.setNodisplay(false);
733 uiApp.setTaskmanage(true);
738 //There is no "X-TIZEN-PackageType=wgt"
739 //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str()
740 //There is no Comment in pkgmgr "Comment=Widget application"
741 //that were in desktop file
744 void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
746 WrtDB::ConfigParserData::ServiceInfoList appServiceList = m_context.widgetConfig.configInfo.appServiceList;
748 if (appServiceList.empty()) {
749 LogInfo("Widget doesn't contain application service");
753 // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
754 FOREACH(it, appServiceList) {
755 AppControl appControl;
756 if (!it->m_operation.empty()) {
757 appControl.addOperation(it->m_operation); //TODO: encapsulation?
759 if (!it->m_scheme.empty()) {
760 appControl.addUri(it->m_scheme);
762 if (!it->m_mime.empty()) {
763 appControl.addMime(it->m_mime);
765 uiApp.addAppControl(appControl);
769 void TaskManifestFile::setAppControlInfo(UiApplication & uiApp)
771 WrtDB::ConfigParserData::AppControlInfoList appControlList =
772 m_context.widgetConfig.configInfo.appControlList;
774 if (appControlList.empty()) {
775 LogInfo("Widget doesn't contain app control");
779 // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
780 FOREACH(it, appControlList) {
781 AppControl appControl;
782 if (!it->m_operation.empty()) {
783 appControl.addOperation(it->m_operation); //TODO: encapsulation?
785 if (!it->m_uriList.empty()) {
786 FOREACH(uri, it->m_uriList) {
787 appControl.addUri(*uri);
790 if (!it->m_mimeList.empty()) {
791 FOREACH(mime, it->m_mimeList) {
792 appControl.addMime(*mime);
795 uiApp.addAppControl(appControl);
799 void TaskManifestFile::setAppCategory(UiApplication &uiApp)
801 WrtDB::ConfigParserData::CategoryList categoryList =
802 m_context.widgetConfig.configInfo.categoryList;
804 if (categoryList.empty()) {
805 LogInfo("Widget doesn't contain application category");
808 FOREACH(it, categoryList) {
809 if (!(*it).empty()) {
810 uiApp.addAppCategory(*it);
815 void TaskManifestFile::stepAbortParseManifest()
817 LogError("[Parse Manifest] Abroting....");
819 int code = pkgmgr_parser_parse_manifest_for_uninstallation(
820 DPL::ToUTF8String(manifest_file).c_str(), NULL);
824 LogWarning("Manifest parser error: " << code);
825 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
827 int ret = unlink(DPL::ToUTF8String(manifest_file).c_str());
830 LogWarning("No manifest file found: " << manifest_file);
834 void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
836 FOREACH(it, m_context.widgetConfig.configInfo.m_livebox) {
837 LogInfo("setLiveBoxInfo");
839 DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
840 DPL::String pkgid = m_context.widgetConfig.tzPkgid;
843 if(ConfigInfo->m_liveboxId != L"") {
844 found = ConfigInfo->m_liveboxId.find_first_of(L".");
845 if(found != std::string::npos) {
846 if(0 == ConfigInfo->m_liveboxId.compare(0, found, pkgid))
847 liveBox.setLiveboxId(ConfigInfo->m_liveboxId);
849 DPL::String liveboxId =
850 pkgid+DPL::String(L".")+ConfigInfo->m_liveboxId;
851 liveBox.setLiveboxId(liveboxId);
854 DPL::String liveboxId =
855 pkgid+DPL::String(L".")+ConfigInfo->m_liveboxId;
856 liveBox.setLiveboxId(liveboxId);
860 if(ConfigInfo->m_primary != L"")
861 liveBox.setPrimary(ConfigInfo->m_primary);
863 if(ConfigInfo->m_autoLaunch == L"true")
864 liveBox.setAutoLaunch(pkgid);
866 if(ConfigInfo->m_updatePeriod != L"")
867 liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod);
869 if(ConfigInfo->m_label != L"")
870 liveBox.setLabel(ConfigInfo->m_label);
872 DPL::String defaultLocale
873 = DPL::FromUTF8String(m_context.locations->getPackageInstallationDir())
874 + DPL::String(L"/res/wgt/");
876 if(ConfigInfo->m_icon!=L"") {
877 liveBox.setIcon(defaultLocale+ConfigInfo->m_icon);
880 if (ConfigInfo->m_boxInfo.m_boxSrc.empty() || ConfigInfo->m_boxInfo.m_boxSize.empty()) {
881 LogInfo("Widget doesn't contain box");
885 if (!ConfigInfo->m_boxInfo.m_boxSrc.empty()) {
886 if((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http"))
887 || (0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https")))
888 box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc;
890 box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc;
893 std::list<std::pair<DPL::String,DPL::String>> BoxSizeList
894 = ConfigInfo->m_boxInfo.m_boxSize;
895 FOREACH(im, BoxSizeList) {
896 std::pair<DPL::String, DPL::String> boxSize = *im;
897 if(!boxSize.second.empty())
898 boxSize.second = defaultLocale + boxSize.second;
899 box.boxSize.push_back(boxSize);
902 if (!ConfigInfo->m_boxInfo.m_pdSrc.empty()
903 && !ConfigInfo->m_boxInfo.m_pdWidth.empty()
904 && !ConfigInfo->m_boxInfo.m_pdHeight.empty()) {
905 box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc;
906 box.pdWidth = ConfigInfo->m_boxInfo.m_pdWidth;
907 box.pdHeight = ConfigInfo->m_boxInfo.m_pdHeight;
913 manifest.addLivebox(liveBox);
918 } //namespace WidgetInstall