application->ui_gadget = 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 {
}
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");
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)));
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()) {
return true;
}
+bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) {
+ std::shared_ptr<const wgt::parse::AppWidgetInfo> appwidget_info =
+ std::static_pointer_cast<const wgt::parse::AppWidgetInfo>(
+ parser_->GetManifestData(
+ 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->multiple = 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("false");
+ 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::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());
// 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))
#include <cstdio>
#include <string>
-#include "wgt/wgt_backend_data.h"
-
namespace bf = boost::filesystem;
namespace bs = boost::system;
bf::create_symlink(bf::path(WRT_LAUNCHER), exec_path, error);
} else if (strcmp(app->component_type, "watchapp") == 0) {
bf::create_symlink(bf::path(WRT_LAUNCHER), exec_path, error);
+ } else if (strcmp(app->component_type, "widgetapp") == 0) {
+ bf::create_symlink(kWidgetClientBinaryPath, exec_path, error);
} else {
bf::create_symlink(kWrtServiceBinaryPath, exec_path, error);
}
return true;
}
-bool StepCreateSymbolicLink::CreateSymlinksForAppWidgets() {
- WgtBackendData* backend_data =
- static_cast<WgtBackendData*>(context_->backend_data.get());
- for (auto& appwidget : backend_data->appwidgets.get().app_widgets()) {
- bf::path exec_path = context_->pkg_path.get() / "bin" / appwidget.id;
- bs::error_code error;
- bf::create_symlink(kWidgetClientBinaryPath, exec_path, error);
- if (error) {
- LOG(ERROR) << "Failed to create symlink for app widget: "
- << appwidget.id;
- return false;
- }
- }
- return true;
-}
-
common_installer::Step::Status StepCreateSymbolicLink::process() {
assert(context_->manifest_data.get());
if (!CreateSymlinksForApps())
return Status::APP_DIR_ERROR;
- if (!CreateSymlinksForAppWidgets())
- return Status::APP_DIR_ERROR;
-
LOG(DEBUG) << "Symlinks created successfully";
return Status::OK;
}
BAD_CAST app->taskmanage);
}
-void WriteWidgetApplicationAttributes(
- xmlTextWriterPtr writer, application_x *app) {
+bool WriteWidgetApplicationAttributesAndElements(
+ xmlTextWriterPtr writer, application_x *app,
+ const wgt::parse::AppWidgetInfo& widget_info,
+ const bf::path& shared_path) {
if (app->nodisplay)
xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay",
BAD_CAST app->nodisplay);
if (app->multiple)
xmlTextWriterWriteAttribute(writer, BAD_CAST "multiple",
BAD_CAST app->multiple);
+
+ // Generate attributes and elements not covered in manifest.xsd
+ auto& appwidgets = widget_info.app_widgets();
+ const auto& appwidget = std::find_if(appwidgets.begin(), appwidgets.end(),
+ [app](const wgt::parse::AppWidget& widget) {
+ return widget.id == app->appid;
+ });
+ if (appwidget == appwidgets.end()) {
+ LOG(ERROR) << "Failed to generate appwidget extra elements";
+ return false;
+ }
+
+ xmlTextWriterWriteAttribute(writer, BAD_CAST "main",
+ BAD_CAST (appwidget->primary ? "true" : "false")); // NOLINT
+ xmlTextWriterWriteAttribute(writer, BAD_CAST "update-period", BAD_CAST "0");
+
+ for (auto& size : appwidget->content_size) {
+ xmlTextWriterStartElement(writer, BAD_CAST "support-size");
+
+ std::string type = wgt::parse::AppWidgetSizeTypeToString(size.type);
+ if (!size.preview.empty()) {
+ std::string icon_name = shared_path.string() + "/" + appwidget->id + "." + type + "." + "preview" +
+ bf::path(size.preview).extension().string();
+ xmlTextWriterWriteAttribute(writer, BAD_CAST "preview",
+ BAD_CAST icon_name.c_str()); // NOLINT
+ }
+
+ xmlTextWriterWriteAttribute(writer, BAD_CAST "frame",
+ BAD_CAST "true");
+ xmlTextWriterWriteString(writer,
+ BAD_CAST type.c_str());
+ xmlTextWriterEndElement(writer);
+ }
+ return true;
}
void WriteWatchApplicationAttributes(
- xmlTextWriterPtr writer, application_x *app) {
+ xmlTextWriterPtr writer, application_x* app) {
if (app->ambient_support)
xmlTextWriterWriteAttribute(writer, BAD_CAST "ambient-support",
BAD_CAST app->ambient_support);
WriteServiceApplicationAttributes(writer, app);
break;
case AppCompType::WIDGETAPP:
- WriteWidgetApplicationAttributes(writer, app);
+ if (!WriteWidgetApplicationAttributesAndElements(writer, app,
+ static_cast<WgtBackendData*>(
+ context_->backend_data.get())->appwidgets.get(),
+ context_->pkg_path.get() / "shared" / "res"))
+ return Status::MANIFEST_ERROR;
break;
case AppCompType::WATCHAPP:
WriteWatchApplicationAttributes(writer, app);
GenerateIme(writer);
GenerateProfiles(writer);
GenerateShortcuts(writer);
- GenerateWidget(writer);
xmlTextWriterEndElement(writer);
return Status::OK;
xmlFreeTextWriter(writer);
return Status::ERROR;
}
- GenerateApplicationCommonXml(app, writer, type);
+ Status status = GenerateApplicationCommonXml(app, writer, type);
+ if (status != Status::OK) {
+ xmlFreeTextWriter(writer);
+ return status;
+ }
xmlTextWriterEndElement(writer);
}
return Status::OK;
}
}
-void StepGenerateXml::GenerateWidget(xmlTextWriterPtr writer) {
- WgtBackendData* backend_data =
- static_cast<WgtBackendData*>(context_->backend_data.get());
- bf::path widget_content_path = context_->pkg_path.get() / kResWgt;
- for (auto& appwidget : backend_data->appwidgets.get().app_widgets()) {
- xmlTextWriterStartElement(writer, BAD_CAST "widget");
- xmlTextWriterWriteAttribute(writer, BAD_CAST "appid",
- BAD_CAST appwidget.id.c_str());
- xmlTextWriterWriteAttribute(writer, BAD_CAST "primary",
- BAD_CAST (appwidget.primary ? "true" : "false")); // NOLINT
- xmlTextWriterWriteAttribute(writer, BAD_CAST "abi",
- BAD_CAST "html");
- xmlTextWriterWriteAttribute(writer, BAD_CAST "network",
- BAD_CAST "true");
- xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay",
- BAD_CAST "false");
-
- if (!appwidget.label.default_value.empty()) {
- xmlTextWriterStartElement(writer, BAD_CAST "label");
- xmlTextWriterWriteString(writer,
- BAD_CAST appwidget.label.default_value.c_str());
- xmlTextWriterEndElement(writer);
- }
- for (auto& pair : appwidget.label.lang_value_map) {
- xmlTextWriterStartElement(writer, BAD_CAST "label");
- xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
- BAD_CAST pair.first.c_str());
- xmlTextWriterWriteString(writer, BAD_CAST pair.second.c_str());
- xmlTextWriterEndElement(writer);
- }
-
- if (!appwidget.icon_src.empty()) {
- xmlTextWriterStartElement(writer, BAD_CAST "icon");
- xmlTextWriterWriteString(writer, BAD_CAST appwidget.icon_src.c_str());
- xmlTextWriterEndElement(writer);
- }
-
- xmlTextWriterStartElement(writer, BAD_CAST "box");
- xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST "buffer");
- xmlTextWriterWriteAttribute(writer, BAD_CAST "mouse_event",
- BAD_CAST (appwidget.content_mouse_event ? "true" : "false")); // NOLINT
- xmlTextWriterWriteAttribute(writer, BAD_CAST "touch_effect",
- BAD_CAST (appwidget.content_touch_effect ? "true" : "false")); // NOLINT
- xmlTextWriterStartElement(writer, BAD_CAST "script");
- bf::path src = widget_content_path / appwidget.content_src;
- xmlTextWriterWriteAttribute(writer, BAD_CAST "src",
- BAD_CAST src.c_str());
- xmlTextWriterEndElement(writer);
- for (auto& size : appwidget.content_size) {
- xmlTextWriterStartElement(writer, BAD_CAST "size");
-
- std::string type = wgt::parse::AppWidgetSizeTypeToString(size.type);
- if (!size.preview.empty()) {
- std::string icon_name = appwidget.id + "." + type + "." + "preview" +
- bf::path(size.preview).extension().string();
- bf::path preview_icon =
- context_->pkg_path.get() / kSharedRes / icon_name;
- xmlTextWriterWriteAttribute(writer, BAD_CAST "preview",
- BAD_CAST preview_icon.c_str()); // NOLINT
- }
-
- xmlTextWriterWriteAttribute(writer, BAD_CAST "need_frame",
- BAD_CAST "true");
- xmlTextWriterWriteString(writer,
- BAD_CAST type.c_str());
- xmlTextWriterEndElement(writer);
- }
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterEndElement(writer);
- }
-}
-
} // namespace pkgmgr
} // namespace wgt