return TRUE;
}
-char* getIconInfo(const std::string widgetPath,
- const std::string icon_name, int &icon_size)
+char* getIconInfo(const std::string &widgetPath,
+ const std::string &icon_name, int &icon_size)
{
Try {
std::unique_ptr<DPL::ZipInput> zipFile(
}
Catch(DPL::ZipInput::Exception::OpenFailed)
{
- LogError("Failed to open widget package");
+ LogDebug("Failed to open widget package");
return NULL;
}
Catch(DPL::ZipInput::Exception::OpenFileFailed)
{
- LogError("Failed to open icon file");
+ LogDebug("Not found icon file " << icon_name);
return NULL;
}
}
+char* getIconForLocale(const std::string& bp, const std::string& tag,
+ const std::string& icon, int & size)
+{
+ std::string iconPath;
+ if (!tag.empty()) {
+ iconPath += std::string("locales/") + tag;
+ }
+ if (!iconPath.empty()) {
+ iconPath += "/";
+ }
+
+ iconPath += icon;
+ return getIconInfo(bp, iconPath, size);
+}
+
+char* getIcon(const std::string & basepath, const WrtDB::ConfigParserData & config, int & size)
+{
+ const std::list<std::string> defaultIcons{ "icon.svg", "icon.ico", "icon.png", "icon.gif", "icon.jpg" };
+ LanguageTags tagsList =
+ LanguageTagsProviderSingleton::Instance().getLanguageTags();
+
+ char * result = NULL;
+
+ //for each locale tag - searching for icon presence and returning raw data
+ //first found is best as locale tags are ordered
+ FOREACH(tag, tagsList)
+ {
+ FOREACH(icon, config.iconsList)
+ {
+ std::string src = DPL::ToUTF8String(icon->src);
+ result = getIconForLocale(basepath, DPL::ToUTF8String(*tag), src, size);
+ if(result) {
+ return result;
+ }
+ }
+ FOREACH(i, defaultIcons)
+ {
+ result = getIconForLocale(basepath, DPL::ToUTF8String(*tag), *i, size);
+ if(result) {
+ return result;
+ }
+ }
+ }
+ return NULL;
+}
+
int getWidgetDetailInfoFromPackage(const char* pkgPath,
package_manager_pkg_detail_info_t* pkg_detail_info)
{
g_list_append(pkg_detail_info->privilege_list, privilege);
}
- std::string icon_name;
- FOREACH(i, configInfo.iconsList) {
- LogDebug("icon name: " << i->src);
- icon_name = DPL::ToUTF8String(i->src);
- break;
- }
+ char* icon_buf = getIcon(widget_path, configInfo, pkg_detail_info->icon_size);
- pkg_detail_info->icon_buf = getIconInfo(widget_path, icon_name,
- pkg_detail_info->icon_size);
- LogDebug("icon size : " << pkg_detail_info->icon_size);
+ if (icon_buf) {
+ LogDebug("icon size : " << pkg_detail_info->icon_size);
+ pkg_detail_info->icon_buf = icon_buf;
+ } else {
+ LogDebug("No icon");
+ pkg_detail_info->icon_size = 0;
+ pkg_detail_info->icon_buf = NULL;
+ }
return TRUE;
}