#include <boost/filesystem/path.hpp>
#include <common/app_installer.h>
+#include <common/paths.h>
#include <common/installer_context.h>
#include <common/step/step.h>
#include <common/utils/glist_range.h>
const std::string kManifestVersion = "1.0.0";
const char kTizenPackageXmlNamespace[] = "http://tizen.org/ns/packages";
+const char kImeCategoryName[] = "http://tizen.org/category/ime";
+
+const char kResWgt[] = "res/wgt";
GList* GenerateMetadataListX(const wgt::parse::MetaDataInfo& meta_info) {
GList* list = nullptr;
application->screenreader = strdup("use-system-setting");
application->submode = strdup("false");
application->support_disable = strdup("false");
- application->taskmanage = strdup("true");
application->ui_gadget = strdup("false");
+ application->multiple = strdup("false");
}
+template<typename T>
+void AppendLabel(T* root, const std::string& label,
+ const std::string& locale) {
+ label_x* label_item = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
+ label_item->name = strdup(label.c_str());
+ label_item->text = strdup(label.c_str());
+ label_item->lang = !locale.empty() ?
+ strdup(locale.c_str()) : strdup(DEFAULT_LOCALE);
+ root->label = g_list_append(root->label, label_item);
+}
} // namespace
namespace wgt {
namespace sc = std::chrono;
StepParse::StepParse(common_installer::InstallerContext* context,
+ ConfigLocation config_location,
bool check_start_file)
: Step(context),
+ config_location_(config_location),
check_start_file_(check_start_file) {
}
}
bool StepParse::FillIconPaths(manifest_x* manifest) {
- std::shared_ptr<const wgt::parse::TizenApplicationInfo> app_info =
- std::static_pointer_cast<const wgt::parse::TizenApplicationInfo>(
- parser_->GetManifestData(app_keys::kTizenApplicationKey));
+ auto app_info =
+ GetManifestDataForKey<const wgt::parse::TizenApplicationInfo>(
+ app_keys::kTizenApplicationKey);
if (!app_info) {
LOG(ERROR) << "Application info manifest data has not been found.";
return false;
}
- std::shared_ptr<const wgt::parse::ApplicationIconsInfo> icons_info =
- std::static_pointer_cast<const wgt::parse::ApplicationIconsInfo>(
- parser_->GetManifestData(app_keys::kIconsKey));
+ 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)));
}
bool StepParse::FillWidgetInfo(manifest_x* manifest) {
- std::shared_ptr<const wgt::parse::WidgetInfo> wgt_info =
- std::static_pointer_cast<const wgt::parse::WidgetInfo>(
- parser_->GetManifestData(app_keys::kWidgetKey));
+ auto wgt_info =
+ GetManifestDataForKey<const wgt::parse::WidgetInfo>(
+ app_keys::kWidgetKey);
+
if (!wgt_info.get()) {
LOG(ERROR) << "Widget info manifest data has not been found.";
return false;
}
for (auto& item : wgt_info->name_set()) {
- label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
- label->name = strdup(item.second.c_str());
- label->text = strdup(item.second.c_str());
- label->lang = !item.first.empty() ?
- strdup(item.first.c_str()) : strdup(DEFAULT_LOCALE);
- manifest->label = g_list_append(manifest->label, label);
+ AppendLabel(manifest, item.second, item.first);
}
manifest->type = strdup("wgt");
manifest->appsetting = strdup("false");
manifest->nodisplay_setting = strdup("false");
manifest->preload = strdup("false");
+ manifest->installed_storage = strdup("installed_internal");
// For wgt package use the long name
+ application_x* app =
+ reinterpret_cast<application_x*>(manifest->application->data);
for (auto& item : wgt_info->name_set()) {
- application_x* app =
- reinterpret_cast<application_x*>(manifest->application->data);
- label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
- label->name = strdup(item.second.c_str());
- label->text = strdup(item.second.c_str());
- label->lang = !item.first.empty() ?
- strdup(item.first.c_str()) : strdup(DEFAULT_LOCALE);
- app->label = g_list_append(app->label, label);
+ AppendLabel(app, item.second, item.first);
}
author_x* author = reinterpret_cast<author_x*>(calloc(1, sizeof(author_x)));
author->lang = strdup(DEFAULT_LOCALE);
manifest->author = g_list_append(manifest->author, author);
- std::shared_ptr<const wgt::parse::SettingInfo> settings_info =
- std::static_pointer_cast<const wgt::parse::SettingInfo>(
- parser_->GetManifestData(
- wgt::application_widget_keys::kTizenSettingKey));
+ auto settings_info =
+ GetManifestDataForKey<const wgt::parse::SettingInfo>(
+ wgt::application_widget_keys::kTizenSettingKey);
if (settings_info) {
switch (settings_info->install_location()) {
case wgt::parse::SettingInfo::InstallLocation::AUTO: {
}
bool StepParse::FillMainApplicationInfo(manifest_x* manifest) {
- std::shared_ptr<const wgt::parse::TizenApplicationInfo> app_info =
- std::static_pointer_cast<const wgt::parse::TizenApplicationInfo>(
- parser_->GetManifestData(app_keys::kTizenApplicationKey));
+ auto app_info =
+ GetManifestDataForKey<const wgt::parse::TizenApplicationInfo>(
+ app_keys::kTizenApplicationKey);
if (!app_info) {
LOG(ERROR) << "Application info manifest data has not been found.";
return false;
}
bool has_watch_catergory = false;
- std::shared_ptr<const wgt::parse::CategoryInfoList> category_info =
- std::static_pointer_cast<const wgt::parse::CategoryInfoList>(
- parser_->GetManifestData(app_keys::kTizenCategoryKey));
+ bool has_ime = false;
+ auto category_info =
+ GetManifestDataForKey<const wgt::parse::CategoryInfoList>(
+ app_keys::kTizenCategoryKey);
+
if (category_info) {
has_watch_catergory = std::find_if(category_info->categories.begin(),
category_info->categories.end(),
return category == kCategoryWearableClock ||
category == kCategoryWatchClock;
}) != category_info->categories.end();
+ has_ime = std::find(category_info->categories.begin(),
+ category_info->categories.end(),
+ kImeCategoryName)
+ != category_info->categories.end();
}
// application data
application->component_type =
has_watch_catergory ? strdup("watchapp") : strdup("uiapp");
application->mainapp = strdup("true");
- application->nodisplay = strdup("false");
- application->multiple = strdup("false");
application->appid = strdup(app_info->id().c_str());
+ application->nodisplay = has_ime ? strdup("true") : strdup("false");
+ application->taskmanage = has_ime ? strdup("false") : strdup("true");
SetApplicationXDefaults(application);
if (has_watch_catergory)
application->ambient_support =
app_icon->lang = strdup(icon->lang);
application->icon = g_list_append(application->icon, app_icon);
}
- manifest->application = g_list_append(manifest->application, application);
+ // guarantees that the main app will be at the begining of the list
+ manifest->application = g_list_insert(manifest->application, application, 0);
manifest->package = strdup(app_info->package().c_str());
manifest->mainapp_id = strdup(app_info->id().c_str());
}
bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) {
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::static_pointer_cast<const wgt::parse::ServiceList>(
- parser_->GetManifestData(app_keys::kTizenServiceKey));
+ auto service_list =
+ GetManifestDataForKey<const wgt::parse::ServiceList>(
+ app_keys::kTizenServiceKey);
if (!service_list)
return true;
for (auto& service_info : service_list->services) {
(calloc(1, sizeof(application_x)));
application->component_type = strdup("svcapp");
application->mainapp = strdup("false");
- application->nodisplay = strdup("false");
- application->multiple = strdup("false");
application->appid = strdup(service_info.id().c_str());
application->exec =
strdup((context_->root_application_path.get() / manifest->package
service_info.on_boot() ? strdup("true") : strdup("false");
application->autorestart =
service_info.auto_restart() ? strdup("true") : strdup("false");
+ application->nodisplay = strdup("false");
+ application->taskmanage = strdup("true");
SetApplicationXDefaults(application);
application->ambient_support = strdup("false");
application->package = strdup(manifest->package);
for (auto& pair : service_info.names()) {
- label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
- label->lang = !pair.first.empty() ?
- strdup(pair.first.c_str()) : strdup(DEFAULT_LOCALE);
- label->name = strdup(pair.second.c_str());
- label->text = strdup(pair.second.c_str());
- application->label = g_list_append(application->label, label);
+ AppendLabel(application, pair.second, pair.first);
}
if (!service_info.icon().empty()) {
+ bf::path icon_path = context_->root_application_path.get()
+ / manifest->package / "res" / "wgt" / service_info.icon();
icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
- icon->text = strdup(service_info.icon().c_str());
+ icon->text = strdup(icon_path.c_str());
icon->lang = strdup(DEFAULT_LOCALE);
application->icon = g_list_append(application->icon, icon);
}
return true;
}
+bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) {
+ auto appwidget_info =
+ GetManifestDataForKey<const wgt::parse::AppWidgetInfo>(
+ wgt::application_widget_keys::kTizenAppWidgetFullKey);
+ if (!appwidget_info)
+ return true;
+ for (auto& app_widget : appwidget_info->app_widgets()) {
+ application_x* application = reinterpret_cast<application_x*>
+ (calloc(1, sizeof(application_x)));
+ application->component_type = strdup("widgetapp");
+ application->mainapp = strdup("false");
+ application->appid = strdup(app_widget.id.c_str());
+ application->exec =
+ strdup((context_->root_application_path.get() / manifest->package
+ / "bin" / application->appid).c_str());
+ application->type = strdup("webapp");
+ application->nodisplay = strdup("true");
+ application->taskmanage = strdup("false");
+ SetApplicationXDefaults(application);
+ application->ambient_support = strdup("false");
+ application->package = strdup(manifest->package);
+
+ if (!app_widget.label.default_value.empty()) {
+ AppendLabel(application, app_widget.label.default_value, std::string());
+ }
+
+ for (auto& pair : app_widget.label.lang_value_map) {
+ AppendLabel(application, pair.second, pair.first);
+ }
+
+ if (!app_widget.icon_src.empty()) {
+ icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
+ icon->text = strdup(app_widget.icon_src.c_str());
+ icon->lang = strdup(DEFAULT_LOCALE);
+ application->icon = g_list_append(application->icon, icon);
+ }
+
+ manifest->application = g_list_append(manifest->application, application);
+ }
+ return true;
+}
+
+
bool StepParse::FillBackgroundCategoryInfo(manifest_x* manifest) {
auto manifest_data = parser_->GetManifestData(
app_keys::kTizenBackgroundCategoryKey);
}
bool StepParse::FillAppControl(manifest_x* manifest) {
- std::shared_ptr<const wgt::parse::AppControlInfoList> app_info_list =
- std::static_pointer_cast<const wgt::parse::AppControlInfoList>(
- parser_->GetManifestData(app_keys::kTizenApplicationAppControlsKey));
+ auto app_info_list =
+ GetManifestDataForKey<const wgt::parse::AppControlInfoList>(
+ app_keys::kTizenApplicationAppControlsKey);
application_x* app =
reinterpret_cast<application_x*>(manifest->application->data);
}
bool StepParse::FillPrivileges(manifest_x* manifest) {
- std::shared_ptr<const wgt::parse::PermissionsInfo> perm_info =
- std::static_pointer_cast<const wgt::parse::PermissionsInfo>(
- parser_->GetManifestData(app_keys::kTizenPermissionsKey));
+ auto perm_info =
+ GetManifestDataForKey<const wgt::parse::PermissionsInfo>(
+ app_keys::kTizenPermissionsKey);
std::set<std::string> privileges;
if (perm_info)
privileges = ExtractPrivileges(perm_info);
}
bool StepParse::FillCategories(manifest_x* manifest) {
- std::shared_ptr<const wgt::parse::CategoryInfoList> category_info =
- std::static_pointer_cast<const wgt::parse::CategoryInfoList>(
- parser_->GetManifestData(app_keys::kTizenCategoryKey));
+ auto category_info =
+ GetManifestDataForKey<const wgt::parse::CategoryInfoList>(
+ app_keys::kTizenCategoryKey);
if (!category_info)
return true;
}
bool StepParse::FillMetadata(manifest_x* manifest) {
- std::shared_ptr<const wgt::parse::MetaDataInfo> meta_info =
- std::static_pointer_cast<const wgt::parse::MetaDataInfo>(
- parser_->GetManifestData(app_keys::kTizenMetaDataKey));
+ auto meta_info =
+ GetManifestDataForKey<const wgt::parse::MetaDataInfo>(
+ app_keys::kTizenMetaDataKey);
if (!meta_info)
return true;
return true;
}
+bool StepParse::FillAppWidget() {
+ // This is needed to store preview icons which are not saved into manifest_x
+ WgtBackendData* backend_data =
+ static_cast<WgtBackendData*>(context_->backend_data.get());
+
+ auto appwidget_info =
+ GetManifestDataForKey<const wgt::parse::AppWidgetInfo>(
+ wgt::application_widget_keys::kTizenAppWidgetFullKey);
+ if (appwidget_info)
+ backend_data->appwidgets.set(*appwidget_info);
+ return true;
+}
+
bool StepParse::FillAccounts(manifest_x* manifest) {
- std::shared_ptr<const wgt::parse::AccountInfo> account_info =
- std::static_pointer_cast<const wgt::parse::AccountInfo>(
- parser_->GetManifestData(app_keys::kAccountKey));
+ auto account_info =
+ GetManifestDataForKey<const wgt::parse::AccountInfo>(
+ app_keys::kAccountKey);
if (!account_info)
return true;
common_installer::AccountInfo info;
}
bool StepParse::FillImeInfo() {
- const auto ime_info = std::static_pointer_cast<const wgt::parse::ImeInfo>(
- parser_->GetManifestData(app_keys::kTizenImeKey));
+ auto ime_info =
+ GetManifestDataForKey<const wgt::parse::ImeInfo>(
+ app_keys::kTizenImeKey);
if (!ime_info)
return true;
}
bool StepParse::FillExtraManifestInfo(manifest_x* manifest) {
- return FillAccounts(manifest) && FillImeInfo();
+ return FillAccounts(manifest) && FillImeInfo() && FillAppWidget();
}
bool StepParse::FillManifestX(manifest_x* manifest) {
// TODO(t.iwanek): fix adding ui application element
// for now adding application service is added here because rest of code
// assumes that there is one application at manifest->application
- // so this must execute last
+ // so this must execute last. Don't move it above any item
if (!FillServiceApplicationInfo(manifest))
return false;
+ if (!FillWidgetApplicationInfo(manifest))
+ return false;
if (!FillBackgroundCategoryInfo(manifest))
return false;
if (!FillExtraManifestInfo(manifest))
}
bool StepParse::LocateConfigFile() {
- return StepParse::Check(context_->unpacked_dir_path.get());
+ switch (config_location_) {
+ case ConfigLocation::PACKAGE:
+ return StepParse::Check(context_->unpacked_dir_path.get());
+ case ConfigLocation::INSTALLED:
+ return StepParse::Check(context_->pkg_path.get() / kResWgt);
+ case ConfigLocation::RECOVERY:
+ if (StepParse::Check(common_installer::GetBackupPathForPackagePath(
+ context_->root_application_path.get()
+ / context_->pkgid.get()) / kResWgt))
+ return true;
+ if (StepParse::Check(
+ context_->root_application_path.get()
+ / context_->pkgid.get() / kResWgt))
+ return true;
+ return false;
+ case ConfigLocation::RESOURCE_WGT:
+ return StepParse::Check(context_->unpacked_dir_path.get() / kResWgt);
+ default:
+ LOG(ERROR) << "Unknown config location";
+ return false;
+ }
}
common_installer::Step::Status StepParse::process() {
}
// Copy data from ManifestData to InstallerContext
- std::shared_ptr<const wgt::parse::TizenApplicationInfo> info =
- std::static_pointer_cast<const wgt::parse::TizenApplicationInfo>(
- parser_->GetManifestData(
- wgt::application_widget_keys::kTizenApplicationKey));
- std::shared_ptr<const wgt::parse::WidgetInfo> wgt_info =
- std::static_pointer_cast<const wgt::parse::WidgetInfo>(
- parser_->GetManifestData(
- wgt::application_widget_keys::kTizenWidgetKey));
+ auto info =
+ GetManifestDataForKey<const wgt::parse::TizenApplicationInfo>(
+ wgt::application_widget_keys::kTizenApplicationKey);
+ auto wgt_info =
+ GetManifestDataForKey<const wgt::parse::WidgetInfo>(
+ wgt::application_widget_keys::kTizenWidgetKey);
std::string name;
const auto& name_set = wgt_info->name_set();
context_->recovery_info.get().recovery_file->WriteAndCommitFileContent();
}
- std::shared_ptr<const wgt::parse::PermissionsInfo> perm_info =
- std::static_pointer_cast<const wgt::parse::PermissionsInfo>(
- parser_->GetManifestData(
- wgt::application_widget_keys::kTizenPermissionsKey));
+ auto perm_info =
+ GetManifestDataForKey<const wgt::parse::PermissionsInfo>(
+ wgt::application_widget_keys::kTizenPermissionsKey);
parser::PermissionSet permissions;
if (perm_info)
permissions = perm_info->GetAPIPermissions();
WgtBackendData* backend_data =
static_cast<WgtBackendData*>(context_->backend_data.get());
- std::shared_ptr<const wgt::parse::SettingInfo> settings_info =
- std::static_pointer_cast<const wgt::parse::SettingInfo>(
- parser_->GetManifestData(
- wgt::application_widget_keys::kTizenSettingKey));
+ auto settings_info =
+ GetManifestDataForKey<const wgt::parse::SettingInfo>(
+ wgt::application_widget_keys::kTizenSettingKey);
if (settings_info)
backend_data->settings.set(*settings_info);