FIND_PACKAGE(Boost REQUIRED COMPONENTS system filesystem regex program_options)
FIND_PACKAGE(GTest REQUIRED)
+ADD_SUBDIRECTORY(data)
ADD_SUBDIRECTORY(src)
--- /dev/null
+INSTALL(FILES "default.png" DESTINATION "${SHAREDIR}/wgt-backend/")
%license LICENSE
%{_sysconfdir}/package-manager/backend/wgt
%{_bindir}/wgt-backend
+%{_datadir}/wgt-backend/default.png
%files tests
%manifest wgt-backend-tests.manifest
#include <wgt_manifest_handlers/background_category_handler.h>
#include <wgt_manifest_handlers/category_handler.h>
#include <wgt_manifest_handlers/content_handler.h>
+#include <wgt_manifest_handlers/ime_handler.h>
#include <wgt_manifest_handlers/metadata_handler.h>
#include <wgt_manifest_handlers/service_handler.h>
#include <wgt_manifest_handlers/setting_handler.h>
#include <wgt_manifest_handlers/tizen_application_handler.h>
#include <wgt_manifest_handlers/widget_handler.h>
-#include <wgt_manifest_handlers/ime_handler.h>
+#include <wgt_manifest_handlers/w3c_pc_utils.h>
#include <pkgmgr/pkgmgr_parser.h>
return false;
}
auto icons_info =
- GetManifestDataForKey<const wgt::parse::ApplicationIconsInfo>(
- app_keys::kIconsKey);
- if (icons_info.get()) {
- for (auto& application_icon : icons_info->icons()) {
- icon_x* icon = reinterpret_cast<icon_x*> (calloc(1, sizeof(icon_x)));
- bf::path icon_path = context_->root_application_path.get()
- / app_info->package() / "res" / "wgt" / application_icon.path();
- icon->text = strdup(icon_path.c_str());
+ GetManifestDataForKey<const wgt::parse::ApplicationIconsInfo>(
+ app_keys::kIconsKey);
+ if (!icons_info) {
+ icons_info.reset(new wgt::parse::ApplicationIconsInfo());
+ }
+ wgt::parse::LocalizedApplicationIconsInfo localized_list =
+ wgt::parse::GetLocalizedIconList(*icons_info,
+ context_->unpacked_dir_path.get());
+ // We need to generate icon for each locale and icons are already set into
+ // lookup order. There isn't said that all icons should be received from
+ // one <icon> tag position so we iterate utils we run out of icons creating
+ // any icon element that are possible for given locale.
+ std::set<std::string> found_locales;
+ for (auto& application_icon : localized_list) {
+ const std::string& locale = application_icon.locale();
+ if (found_locales.find(locale) != found_locales.end())
+ continue;
+ found_locales.insert(locale);
+
+ icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
+ bf::path icon_path = context_->root_application_path.get()
+ / app_info->package() / "res" / "wgt" / application_icon.path();
+ icon->text = strdup(icon_path.c_str());
+ if (!locale.empty())
+ icon->lang = strdup(locale.c_str());
+ else
icon->lang = strdup(DEFAULT_LOCALE);
- manifest->icon = g_list_append(manifest->icon, icon);
- }
+ manifest->icon = g_list_append(manifest->icon, icon);
}
return true;
}
application->autorestart = strdup("false");
application->launch_mode = strdup(app_info->launch_mode().c_str());
- if (manifest->icon) {
- icon_x* icon = reinterpret_cast<icon_x*>(manifest->icon->data);
+ for (auto& icon : GListRange<icon_x*>(manifest->icon)) {
icon_x* app_icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
app_icon->text = strdup(icon->text);
app_icon->lang = strdup(icon->lang);
namespace bs = boost::system;
namespace ci = common_installer;
+namespace {
+
+const char kDefaultIconPath[] = "/usr/share/wgt-backend/default.png";
+
+} // namespace
+
namespace wgt {
namespace filesystem {
if (strcmp(app->type, "webapp") != 0)
continue;
if (app->icon) {
- icon_x* icon = reinterpret_cast<icon_x*>(app->icon->data);
- bf::path icon_text(icon->text);
- bf::path icon_path = common_icon_location / app->appid;
- if (icon_text.has_extension())
- icon_path += icon_text.extension();
- else
- icon_path += ".png";
+ // edit icon->text and copy icons to common location
+ for (auto& icon : GListRange<icon_x*>(app->icon)) {
+ bf::path icon_text(icon->text);
+ bf::path icon_path = common_icon_location / app->appid;
+ if (strcmp(icon->lang, DEFAULT_LOCALE)) {
+ icon_path += ".";
+ icon_path += icon->lang;
+ }
+ if (icon_text.has_extension())
+ icon_path += icon_text.extension();
+ else
+ icon_path += ".png";
- bf::copy_file(icon->text, icon_path,
- bf::copy_option::overwrite_if_exists, error);
+ bf::copy_file(icon->text, icon_path,
+ bf::copy_option::overwrite_if_exists, error);
+ if (error) {
+ LOG(ERROR) << "Failed to move icon from " << icon->text << " to "
+ << icon_path;
+ return Status::ICON_ERROR;
+ }
+ if (icon->text)
+ free(const_cast<char*>(icon->text));
+ icon->text = strdup(icon_path.c_str());
+ }
+ } else {
+ // create default icon if there is no icon at all
+ bf::path icon_path = common_icon_location / app->appid;
+ icon_path += ".png";
+ bf::copy_file(kDefaultIconPath, icon_path, error);
if (error) {
- LOG(ERROR) << "Failed to move icon from " << icon->text << " to "
- << icon_path;
+ LOG(ERROR) << "Failed to create default icon for web application";
return Status::ICON_ERROR;
}
- if (icon->text)
- free(const_cast<char*>(icon->text));
+ icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
icon->text = strdup(icon_path.c_str());
+ icon->lang = strdup(DEFAULT_LOCALE);
+ app->icon = g_list_append(app->icon, icon);
}
}
return Status::OK;
}
}
- if (app->icon) {
- icon_x* iconx = reinterpret_cast<icon_x*>(app->icon->data);
- xmlTextWriterWriteFormatElement(
- writer, BAD_CAST "icon", "%s", BAD_CAST iconx->text);
- } else {
- // Default icon setting is role of the platform
- LOG(DEBUG) << "Icon was not found in application";
+ for (auto& icon : GListRange<icon_x*>(app->icon)) {
+ xmlTextWriterStartElement(writer, BAD_CAST "icon");
+ if (icon->lang && strcmp(DEFAULT_LOCALE, icon->lang) != 0) {
+ xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
+ BAD_CAST icon->lang);
+ }
+ xmlTextWriterWriteString(writer, BAD_CAST icon->text);
+ xmlTextWriterEndElement(writer);
}
for (image_x* image : GListRange<image_x*>(app->image)) {