From e11660bf9e6ad7fa8183ae7eecd435763a1bf027 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Mon, 19 Aug 2013 11:58:29 +0200 Subject: [PATCH] Icon extension for package manager and manifest fix [Issue#] LINUXWRT-804 / WGL-428 [Bug] Hardcoded .png extension [Cause] N/A [Solution] Use extension of used icon [SCMRequest] This requries wrt-commons change: https://review.tizendev.org/gerrit/86777 [Verification] Install widget from https://bugs.tizendev.org/jira/browse/WGL-428. Manifest file in /opt/share/packages/J7tHY89x22.xml should contain icon with .svg extension (J7tHY89x22.Y2y1.svg). Change-Id: Ifef3f38e1566b92817f62aa01c1ac73bc073d71b --- src/jobs/widget_install/task_manifest_file.cpp | 56 +++++++++++--------------- src/jobs/widget_install/task_manifest_file.h | 5 ++- src/jobs/widget_install/task_widget_config.cpp | 2 +- 3 files changed, 27 insertions(+), 36 deletions(-) diff --git a/src/jobs/widget_install/task_manifest_file.cpp b/src/jobs/widget_install/task_manifest_file.cpp index 37d856e..8308125 100644 --- a/src/jobs/widget_install/task_manifest_file.cpp +++ b/src/jobs/widget_install/task_manifest_file.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #define DEFAULT_ICON_NAME "icon.png" #define DEFAULT_PREVIEW_NAME "preview.png" @@ -219,53 +220,37 @@ void TaskManifestFile::stepCopyIconFiles() if (std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end()) { - if (icon->src == L"icon.jpg") { - generatedLocales.push_back(*locale); - } else if (icon->src == L"icon.gif") { - generatedLocales.push_back(*locale); - } else if (icon->src == L"icon.png") { - generatedLocales.push_back(*locale); - } else if (icon->src == L"icon.ico") { - generatedLocales.push_back(*locale); - } else if (icon->src == L"icon.svg") { - generatedLocales.push_back(*locale); - } LogDebug("Skipping - has that locale"); continue; } else { generatedLocales.push_back(*locale); } - std::ostringstream sourceFile; - std::ostringstream targetFile; - - sourceFile << m_context.locations->getSourceDir() << "/"; - + DPL::Utils::Path sourceFile(m_context.locations->getSourceDir()); if (!locale->empty()) { - sourceFile << "locales/" << *locale << "/"; + sourceFile /= "locales"; + sourceFile /= *locale; } + sourceFile /= src; - sourceFile << src; - - targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/"; - targetFile << getIconTargetFilename(*locale); + DPL::Utils::Path targetFile(GlobalConfig::GetUserWidgetDesktopIconPath()); + targetFile /= getIconTargetFilename(*locale, sourceFile.Extension()); if (m_context.widgetConfig.packagingType == WrtDB::PKG_TYPE_HOSTED_WEB_APP) { m_context.locations->setIconTargetFilenameForLocale( - targetFile.str()); + targetFile.Fullpath()); } - LogDebug("Copying icon: " << sourceFile.str() << - " -> " << targetFile.str()); + LogDebug("Copying icon: " << sourceFile << " -> " << targetFile); - icon_list.push_back(targetFile.str()); + icon_list.push_back(targetFile.Fullpath()); Try { - DPL::FileInput input(sourceFile.str()); - DPL::FileOutput output(targetFile.str()); + DPL::FileInput input(sourceFile.Fullpath()); + DPL::FileOutput output(targetFile.Fullpath()); DPL::Copy(&input, &output); } @@ -442,7 +427,7 @@ void TaskManifestFile::stepAbortIconFiles() } DPL::String TaskManifestFile::getIconTargetFilename( - const DPL::String& languageTag) const + const DPL::String& languageTag, const std::string & ext) const { DPL::OStringStream filename; TizenAppId appid = m_context.widgetConfig.tzAppid; @@ -465,7 +450,10 @@ DPL::String TaskManifestFile::getIconTargetFilename( } } - filename << L".png"; + if(!ext.empty()) + { + filename << L"." + DPL::FromUTF8String(ext); + } return filename.str(); } @@ -826,12 +814,13 @@ void TaskManifestFile::setWidgetIcons(UiApplication & uiApp) tag = *locale; } - generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved); + generateWidgetIcon(uiApp, tag, *locale, DPL::Utils::Path(icon->src).Extension(), defaultIconSaved); } } if (!!defaultLocale && !defaultIconSaved) { generateWidgetIcon(uiApp, DPL::OptionalString::Null, DPL::String(), + std::string(), defaultIconSaved); } } @@ -839,6 +828,7 @@ void TaskManifestFile::setWidgetIcons(UiApplication & uiApp) void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, const DPL::String& language, + const std::string & extension, bool & defaultIconSaved) { DPL::String locale; @@ -849,7 +839,7 @@ void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, } DPL::String iconText; - iconText += getIconTargetFilename(language); + iconText += getIconTargetFilename(language, extension); if (!locale.empty()) { uiApp.addIcon(IconType(iconText, locale)); @@ -858,8 +848,8 @@ void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, } std::ostringstream iconPath; iconPath << GlobalConfig::GetUserWidgetDesktopIconPath() << "/"; - iconPath << getIconTargetFilename(locale); - m_context.job->SendProgressIconPath(iconPath.str()); + iconPath << getIconTargetFilename(locale, extension); + m_context.job->SendProgressIconPath(iconPath.str()); } void TaskManifestFile::setWidgetDescription(Manifest & manifest) diff --git a/src/jobs/widget_install/task_manifest_file.h b/src/jobs/widget_install/task_manifest_file.h index a318fc8..98c3d23 100644 --- a/src/jobs/widget_install/task_manifest_file.h +++ b/src/jobs/widget_install/task_manifest_file.h @@ -118,7 +118,7 @@ class TaskManifestFile : DPL::OptionalString description); void generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, - const DPL::String& language, + const DPL::String& language, const std::string &extension, bool & defaultIconSaved); void DynamicBoxFileCopy(const std::string& sourceFile, const std::string& targetFile); @@ -126,7 +126,8 @@ class TaskManifestFile : //for widget update void backupIconFiles(); void getFileList(const char* path, std::list &list); - DPL::String getIconTargetFilename(const DPL::String& languageTag) const; + DPL::String getIconTargetFilename(const DPL::String& languageTag, + const std::string & ext) const; static void saveLocalizedKey(std::ofstream &file, const DPL::String& key, diff --git a/src/jobs/widget_install/task_widget_config.cpp b/src/jobs/widget_install/task_widget_config.cpp index 221fd1c..c837279 100644 --- a/src/jobs/widget_install/task_widget_config.cpp +++ b/src/jobs/widget_install/task_widget_config.cpp @@ -293,7 +293,7 @@ void TaskWidgetConfig::ProcessBackgroundPageFile() void TaskWidgetConfig::ProcessLocalizedIcons() { using namespace WrtDB; - FOREACH(i, m_installContext.widgetConfig.configInfo.iconsList) + FOREACH(i, m_installContext.widgetConfig.configInfo.iconsList) { ProcessIcon(*i); } -- 2.7.4