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 {
100 const char * TaskManifestFile::encoding = "UTF-8";
102 TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
103 DPL::TaskDecl<TaskManifestFile>(this),
106 if (false == m_context.existingWidgetInfo.isExist) {
107 AddStep(&TaskManifestFile::stepCopyIconFiles);
108 AddStep(&TaskManifestFile::stepCreateExecFile);
109 AddStep(&TaskManifestFile::stepGenerateManifest);
110 AddStep(&TaskManifestFile::stepParseManifest);
111 AddStep(&TaskManifestFile::stepFinalize);
113 AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
115 // for widget update.
116 AddStep(&TaskManifestFile::stepBackupIconFiles);
117 AddStep(&TaskManifestFile::stepCopyIconFiles);
118 AddStep(&TaskManifestFile::stepGenerateManifest);
119 AddStep(&TaskManifestFile::stepParseUpgradedManifest);
120 AddStep(&TaskManifestFile::stepUpdateFinalize);
122 AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
126 TaskManifestFile::~TaskManifestFile()
129 void TaskManifestFile::stepCreateExecFile()
131 std::string exec = m_context.locations->getExecFile();
132 std::string clientExeStr = GlobalConfig::GetWrtClientExec();
134 LogInfo("link -s " << clientExeStr << " " << exec);
135 symlink(clientExeStr.c_str(), exec.c_str());
137 m_context.job->UpdateProgress(
138 InstallerContext::INSTALL_CREATE_EXECFILE,
139 "Widget execfile creation Finished");
142 void TaskManifestFile::stepCopyIconFiles()
144 LogDebug("CopyIconFiles");
146 //This function copies icon to desktop icon path. For each locale avaliable
147 //which there is at least one icon in widget for, icon file is copied.
148 //Coping prioritize last positions when coping. If there is several icons
149 //with given locale, the one, that will be copied, will be icon
150 //which is declared by <icon> tag later than the others in config.xml of
153 std::vector<Locale> generatedLocales;
155 WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
156 m_context.widgetConfig.localizationData.icons;
158 //reversed: last <icon> has highest priority to be copied if it has given
159 // locale (TODO: why was that working that way?)
160 for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
161 icon = icons.rbegin();
162 icon != icons.rend();
165 FOREACH(locale, icon->availableLocales)
167 DPL::String src = icon->src;
168 LogDebug("Icon for locale: " << *locale << "is : " << src);
170 if (std::find(generatedLocales.begin(), generatedLocales.end(),
171 *locale) != generatedLocales.end())
173 LogDebug("Skipping - has that locale");
176 generatedLocales.push_back(*locale);
179 std::ostringstream sourceFile;
180 std::ostringstream targetFile;
182 sourceFile << m_context.locations->getSourceDir() << "/";
184 if (!locale->empty()) {
185 sourceFile << "locales/" << *locale << "/";
190 targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
191 targetFile << getIconTargetFilename(*locale);
193 if (m_context.widgetConfig.packagingType ==
194 WrtDB::PKG_TYPE_HOSTED_WEB_APP)
196 m_context.locations->setIconTargetFilenameForLocale(
200 LogDebug("Copying icon: " << sourceFile.str() <<
201 " -> " << targetFile.str());
203 icon_list.push_back(targetFile.str());
207 DPL::FileInput input(sourceFile.str());
208 DPL::FileOutput output(targetFile.str());
209 DPL::Copy(&input, &output);
212 Catch(DPL::FileInput::Exception::Base)
214 // Error while opening or closing source file
215 //ReThrowMsg(InstallerException::CopyIconFailed,
216 // sourceFile.str());
218 "Copying widget's icon failed. Widget's icon will not be" \
219 "available from Main Screen");
222 Catch(DPL::FileOutput::Exception::Base)
224 // Error while opening or closing target file
225 //ReThrowMsg(InstallerException::CopyIconFailed,
226 // targetFile.str());
228 "Copying widget's icon failed. Widget's icon will not be" \
229 "available from Main Screen");
232 Catch(DPL::CopyFailed)
234 // Error while copying
235 //ReThrowMsg(InstallerException::CopyIconFailed,
236 // targetFile.str());
238 "Copying widget's icon failed. Widget's icon will not be" \
239 "available from Main Screen");
244 m_context.job->UpdateProgress(
245 InstallerContext::INSTALL_COPY_ICONFILE,
246 "Widget iconfile copy Finished");
249 void TaskManifestFile::stepBackupIconFiles()
251 LogDebug("Backup Icon Files");
253 backup_dir << m_context.locations->getPackageInstallationDir();
254 backup_dir << "/" << "backup" << "/";
258 m_context.job->UpdateProgress(
259 InstallerContext::INSTALL_BACKUP_ICONFILE,
260 "New Widget icon file backup Finished");
263 void TaskManifestFile::stepAbortIconFiles()
265 LogDebug("Abrot Icon Files");
266 FOREACH(it, icon_list)
268 LogDebug("Remove Update Icon : " << (*it));
269 unlink((*it).c_str());
272 std::ostringstream b_icon_dir;
273 b_icon_dir << backup_dir.str() << "icons";
275 std::list<std::string> fileList;
276 getFileList(b_icon_dir.str().c_str(), fileList);
278 FOREACH(back_icon, fileList)
280 std::ostringstream res_file;
281 res_file << GlobalConfig::GetUserWidgetDesktopIconPath();
282 res_file << "/" << (*back_icon);
284 std::ostringstream backup_file;
285 backup_file << b_icon_dir.str() << "/" << (*back_icon);
289 DPL::FileInput input(backup_file.str());
290 DPL::FileOutput output(res_file.str());
291 DPL::Copy(&input, &output);
293 Catch(DPL::FileInput::Exception::Base)
295 LogError("Restoration icon File Failed." << backup_file.str()
296 << " to " << res_file.str());
299 Catch(DPL::FileOutput::Exception::Base)
301 LogError("Restoration icon File Failed." << backup_file.str()
302 << " to " << res_file.str());
304 Catch(DPL::CopyFailed)
306 LogError("Restoration icon File Failed." << backup_file.str()
307 << " to " << res_file.str());
312 void TaskManifestFile::stepUpdateFinalize()
315 LogDebug("Finished Update Desktopfile");
318 DPL::String TaskManifestFile::getIconTargetFilename(
319 const DPL::String& languageTag) const
321 DPL::OStringStream filename;
322 TizenAppId appid = m_context.widgetConfig.tzAppid;
324 filename << DPL::ToUTF8String(appid).c_str();
326 if (!languageTag.empty()) {
327 DPL::OptionalString tag = getLangTag(languageTag); // translate en ->
333 LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
335 if (locale.empty()) {
336 filename << L"." << languageTag;
338 filename << L"." << locale;
343 return filename.str();
346 void TaskManifestFile::stepFinalize()
349 LogInfo("Finished ManifestFile step");
352 void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
353 const DPL::String& key,
354 const DPL::String& languageTag)
357 LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
360 if (!locale.empty()) {
361 file << "[" << locale << "]";
366 void TaskManifestFile::updateAilInfo()
368 // Update ail for desktop
369 std::string cfgAppid =
370 DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
371 const char* appid = cfgAppid.c_str();
373 LogDebug("Update ail desktop : " << appid);
374 ail_appinfo_h ai = NULL;
377 ret = ail_package_get_appinfo(appid, &ai);
379 ail_package_destroy_appinfo(ai);
382 if (AIL_ERROR_NO_DATA == ret) {
383 if (ail_desktop_add(appid) < 0) {
384 LogWarning("Failed to add ail desktop : " << appid);
386 } else if (AIL_ERROR_OK == ret) {
387 if (ail_desktop_update(appid) < 0) {
388 LogWarning("Failed to update ail desktop : " << appid);
393 void TaskManifestFile::backupIconFiles()
395 LogInfo("Backup Icon Files");
397 std::ostringstream b_icon_dir;
398 b_icon_dir << backup_dir.str() << "icons";
400 LogDebug("Create icon backup folder : " << b_icon_dir.str());
401 WrtUtilMakeDir(b_icon_dir.str());
403 std::list<std::string> fileList;
404 getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
405 std::string appid = DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
407 FOREACH(it, fileList)
409 if (0 == (strncmp((*it).c_str(), appid.c_str(),
410 strlen(appid.c_str()))))
412 std::ostringstream icon_file, backup_icon;
413 icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
414 icon_file << "/" << (*it);
416 backup_icon << b_icon_dir.str() << "/" << (*it);
418 LogDebug("Backup icon file " << icon_file.str() << " to " <<
422 DPL::FileInput input(icon_file.str());
423 DPL::FileOutput output(backup_icon.str());
424 DPL::Copy(&input, &output);
426 Catch(DPL::FileInput::Exception::Base)
428 LogError("Backup Desktop File Failed.");
429 ReThrowMsg(Exceptions::BackupFailed, icon_file.str());
432 Catch(DPL::FileOutput::Exception::Base)
434 LogError("Backup Desktop File Failed.");
435 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
437 Catch(DPL::CopyFailed)
439 LogError("Backup Desktop File Failed.");
440 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
442 unlink((*it).c_str());
447 void TaskManifestFile::getFileList(const char* path,
448 std::list<std::string> &list)
450 DIR* dir = opendir(path);
452 LogError("icon directory doesn't exist");
453 ThrowMsg(Exceptions::InternalError, path);
456 struct dirent* d_ent;
458 if ((d_ent = readdir(dir))) {
459 if (strcmp(d_ent->d_name, ".") == 0 ||
460 strcmp(d_ent->d_name, "..") == 0)
464 std::string file_name = d_ent->d_name;
465 list.push_back(file_name);
468 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
469 LogError("Failed to close dir: " << path << " with error: "
470 << DPL::GetErrnoString());
474 void TaskManifestFile::stepGenerateManifest()
476 TizenPkgId pkgid = m_context.widgetConfig.tzPkgid;
477 manifest_name = pkgid + L".xml";
478 manifest_file += L"/tmp/" + manifest_name;
480 //libxml - init and check
481 LibxmlSingleton::Instance().init();
483 writeManifest(manifest_file);
485 m_context.job->UpdateProgress(
486 InstallerContext::INSTALL_CREATE_MANIFEST,
487 "Widget Manifest Creation Finished");
490 void TaskManifestFile::stepParseManifest()
492 int code = pkgmgr_parser_parse_manifest_for_installation(
493 DPL::ToUTF8String(manifest_file).c_str(), NULL);
496 LogError("Manifest parser error: " << code);
497 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
500 // TODO : It will be removed. AIL update is temporary code request by pkgmgr
504 m_context.job->UpdateProgress(
505 InstallerContext::INSTALL_CREATE_MANIFEST,
506 "Widget Manifest Parsing Finished");
507 LogDebug("Manifest parsed");
510 void TaskManifestFile::stepParseUpgradedManifest()
512 int code = pkgmgr_parser_parse_manifest_for_upgrade(
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::commitManifest()
532 LogDebug("Commiting manifest file : " << manifest_file);
534 std::ostringstream destFile;
535 destFile << "/opt/share/packages" << "/"; //TODO constant with path
536 destFile << DPL::ToUTF8String(manifest_name);
537 LogInfo("cp " << manifest_file << " " << destFile.str());
539 DPL::FileInput input(DPL::ToUTF8String(manifest_file));
540 DPL::FileOutput output(destFile.str());
541 DPL::Copy(&input, &output);
542 LogDebug("Manifest writen to: " << destFile.str());
545 unlink((DPL::ToUTF8String(manifest_file)).c_str());
546 manifest_file = DPL::FromUTF8String(destFile.str().c_str());
549 void TaskManifestFile::writeManifest(const DPL::String & path)
551 LogDebug("Generating manifest file : " << path);
555 setWidgetExecPath(uiApp);
556 setWidgetName(manifest, uiApp);
557 setWidgetIcons(uiApp);
558 setWidgetManifest(manifest);
559 setWidgetOtherInfo(uiApp);
560 setAppServiceInfo(uiApp);
561 setAppControlInfo(uiApp);
562 setAppCategory(uiApp);
563 setLiveBoxInfo(manifest);
565 manifest.addUiApplication(uiApp);
566 manifest.generate(path);
567 LogDebug("Manifest file serialized");
570 void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp)
572 uiApp.setExec(DPL::FromASCIIString(m_context.locations->getExecFile()));
575 void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
577 bool defaultNameSaved = false;
579 DPL::OptionalString defaultLocale =
580 m_context.widgetConfig.configInfo.defaultlocale;
581 std::pair<DPL::String,
582 WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
584 FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
586 Locale i = localizedData->first;
587 DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
591 DPL::OptionalString name = localizedData->second.name;
592 generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
594 //store default locale localized data
595 if (!!defaultLocale && defaultLocale == i) {
596 defaultLocalizedData = *localizedData;
600 if (!!defaultLocale && !defaultNameSaved) {
601 DPL::OptionalString name = defaultLocalizedData.second.name;
602 generateWidgetName(manifest,
604 DPL::OptionalString::Null,
609 TizenAppId appid = m_context.widgetConfig.tzAppid;
610 uiApp.setAppid(appid);
613 if (!!m_context.widgetConfig.guid) {
614 uiApp.setExtraid(*m_context.widgetConfig.guid);
616 if (!appid.empty()) {
617 uiApp.setExtraid(DPL::String(L"http://") + appid);
622 uiApp.setType(DPL::FromASCIIString("webapp"));
623 manifest.setType(L"wgt");
626 void TaskManifestFile::generateWidgetName(Manifest & manifest,
627 UiApplication &uiApp,
628 const DPL::OptionalString& tag,
629 DPL::OptionalString name,
630 bool & defaultNameSaved)
635 LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
637 if (!locale.empty()) {
638 uiApp.addLabel(LabelType(*name, *tag));
640 uiApp.addLabel(LabelType(*name));
641 manifest.addLabel(LabelType(*name));
644 defaultNameSaved = true;
645 uiApp.addLabel(LabelType(*name));
646 manifest.addLabel(LabelType(*name));
651 void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
653 //TODO this file will need to be updated when user locale preferences
655 bool defaultIconSaved = false;
657 DPL::OptionalString defaultLocale =
658 m_context.widgetConfig.configInfo.defaultlocale;
660 std::vector<Locale> generatedLocales;
661 WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
662 m_context.widgetConfig.localizationData.icons;
664 //reversed: last <icon> has highest priority to be writen to manifest if it
665 // has given locale (TODO: why was that working that way?)
666 for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
667 icon = icons.rbegin();
668 icon != icons.rend();
671 FOREACH(locale, icon->availableLocales)
673 if (std::find(generatedLocales.begin(), generatedLocales.end(),
674 *locale) != generatedLocales.end())
676 LogDebug("Skipping - has that locale - already in manifest");
679 generatedLocales.push_back(*locale);
682 DPL::OptionalString tag = getLangTag(*locale); // translate en ->
688 generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved);
691 if (!!defaultLocale && !defaultIconSaved) {
692 generateWidgetIcon(uiApp, DPL::OptionalString::Null,
698 void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp,
699 const DPL::OptionalString& tag,
700 const DPL::String& language,
701 bool & defaultIconSaved)
705 locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
707 defaultIconSaved = true;
710 DPL::String iconText;
711 iconText += getIconTargetFilename(language);
713 if (!locale.empty()) {
714 uiApp.addIcon(IconType(iconText, locale));
716 uiApp.addIcon(IconType(iconText));
720 void TaskManifestFile::setWidgetManifest(Manifest & manifest)
722 manifest.setPackage(m_context.widgetConfig.tzPkgid);
724 if (!!m_context.widgetConfig.version) {
725 manifest.setVersion(*m_context.widgetConfig.version);
727 DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ?
728 *m_context.widgetConfig.configInfo.authorEmail : L"");
729 DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
730 *m_context.widgetConfig.configInfo.authorHref : L"");
731 DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ?
732 *m_context.widgetConfig.configInfo.authorName : L"");
733 manifest.addAuthor(Author(email, href, L"", name));
736 void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
738 FOREACH(it, m_context.widgetConfig.configInfo.settingsList)
740 if (!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) {
741 if (!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) {
742 uiApp.setNodisplay(true);
743 uiApp.setTaskmanage(false);
745 uiApp.setNodisplay(false);
746 uiApp.setTaskmanage(true);
751 //There is no "X-TIZEN-PackageType=wgt"
752 //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" <<
753 // DPL::ToUTF8String(*widgetID).c_str()
754 //There is no Comment in pkgmgr "Comment=Widget application"
755 //that were in desktop file
758 void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
760 WrtDB::ConfigParserData::ServiceInfoList appServiceList =
761 m_context.widgetConfig.configInfo.appServiceList;
763 if (appServiceList.empty()) {
764 LogInfo("Widget doesn't contain application service");
768 // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
769 FOREACH(it, appServiceList) {
770 AppControl appControl;
771 if (!it->m_operation.empty()) {
772 appControl.addOperation(it->m_operation); //TODO: encapsulation?
774 if (!it->m_scheme.empty()) {
775 appControl.addUri(it->m_scheme);
777 if (!it->m_mime.empty()) {
778 appControl.addMime(it->m_mime);
780 uiApp.addAppControl(appControl);
784 void TaskManifestFile::setAppControlInfo(UiApplication & uiApp)
786 WrtDB::ConfigParserData::AppControlInfoList appControlList =
787 m_context.widgetConfig.configInfo.appControlList;
789 if (appControlList.empty()) {
790 LogInfo("Widget doesn't contain app control");
794 // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
795 FOREACH(it, appControlList) {
796 AppControl appControl;
797 if (!it->m_operation.empty()) {
798 appControl.addOperation(it->m_operation); //TODO: encapsulation?
800 if (!it->m_uriList.empty()) {
801 FOREACH(uri, it->m_uriList) {
802 appControl.addUri(*uri);
805 if (!it->m_mimeList.empty()) {
806 FOREACH(mime, it->m_mimeList) {
807 appControl.addMime(*mime);
810 uiApp.addAppControl(appControl);
814 void TaskManifestFile::setAppCategory(UiApplication &uiApp)
816 WrtDB::ConfigParserData::CategoryList categoryList =
817 m_context.widgetConfig.configInfo.categoryList;
819 if (categoryList.empty()) {
820 LogInfo("Widget doesn't contain application category");
823 FOREACH(it, categoryList) {
824 if (!(*it).empty()) {
825 uiApp.addAppCategory(*it);
830 void TaskManifestFile::stepAbortParseManifest()
832 LogError("[Parse Manifest] Abroting....");
834 int code = pkgmgr_parser_parse_manifest_for_uninstallation(
835 DPL::ToUTF8String(manifest_file).c_str(), NULL);
838 LogWarning("Manifest parser error: " << code);
839 ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
841 int ret = unlink(DPL::ToUTF8String(manifest_file).c_str());
843 LogWarning("No manifest file found: " << manifest_file);
847 void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
849 FOREACH(it, m_context.widgetConfig.configInfo.m_livebox) {
850 LogInfo("setLiveBoxInfo");
852 DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
853 DPL::String appid = m_context.widgetConfig.tzAppid;
856 if (ConfigInfo->m_liveboxId != L"") {
857 found = ConfigInfo->m_liveboxId.find_last_of(L".");
858 if (found != std::string::npos) {
859 if (0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) {
860 liveBox.setLiveboxId(ConfigInfo->m_liveboxId);
862 DPL::String liveboxId =
863 appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
864 liveBox.setLiveboxId(liveboxId);
867 DPL::String liveboxId =
868 appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
869 liveBox.setLiveboxId(liveboxId);
873 if (ConfigInfo->m_primary != L"") {
874 liveBox.setPrimary(ConfigInfo->m_primary);
877 if (ConfigInfo->m_autoLaunch == L"true") {
878 liveBox.setAutoLaunch(appid);
881 if (ConfigInfo->m_updatePeriod != L"") {
882 liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod);
885 if (ConfigInfo->m_label != L"") {
886 liveBox.setLabel(ConfigInfo->m_label);
889 DPL::String defaultLocale
890 = DPL::FromUTF8String(
891 m_context.locations->getPackageInstallationDir())
892 + DPL::String(L"/res/wgt/");
894 if (ConfigInfo->m_icon != L"") {
895 liveBox.setIcon(defaultLocale + ConfigInfo->m_icon);
898 if (ConfigInfo->m_boxInfo.m_boxSrc.empty() ||
899 ConfigInfo->m_boxInfo.m_boxSize.empty())
901 LogInfo("Widget doesn't contain box");
905 if (!ConfigInfo->m_boxInfo.m_boxSrc.empty()) {
906 if ((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http"))
908 ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https")))
910 box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc;
912 box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc;
916 if (ConfigInfo->m_boxInfo.m_boxMouseEvent == L"true") {
917 box.boxMouseEvent = ConfigInfo->m_boxInfo.m_boxMouseEvent;
919 box.boxMouseEvent = L"false";
922 std::list<std::pair<DPL::String, DPL::String> > BoxSizeList
923 = ConfigInfo->m_boxInfo.m_boxSize;
924 FOREACH(im, BoxSizeList) {
925 std::pair<DPL::String, DPL::String> boxSize = *im;
926 if (!boxSize.second.empty()) {
927 boxSize.second = defaultLocale + boxSize.second;
929 box.boxSize.push_back(boxSize);
932 if (!ConfigInfo->m_boxInfo.m_pdSrc.empty()
933 && !ConfigInfo->m_boxInfo.m_pdWidth.empty()
934 && !ConfigInfo->m_boxInfo.m_pdHeight.empty())
936 box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc;
937 box.pdWidth = ConfigInfo->m_boxInfo.m_pdWidth;
938 box.pdHeight = ConfigInfo->m_boxInfo.m_pdHeight;
942 manifest.addLivebox(liveBox);
945 } //namespace WidgetInstall