From: Tomasz Iwanek Date: Tue, 24 May 2016 09:18:41 +0000 (+0200) Subject: Generate widget element in platform manifest X-Git-Tag: accepted/tizen/common/20160602.140104~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F37%2F71237%2F6;p=platform%2Fcore%2Fappfw%2Fwgt-backend.git Generate widget element in platform manifest To verify, install widget with appwidget and: - check information generated in manifest file, - check creation of symlink for widgets in bin/ directory, - check preview icons in shared/res/ directory. Requires: - https://review.tizen.org/gerrit/71235 Change-Id: I2a38aaee729c4c1f18200d2f63764c4c87e7d730 --- diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index c2d1aa6..dd56988 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -63,6 +63,7 @@ #include "wgt/step/configuration/step_parse.h" #include "wgt/step/configuration/step_parse_recovery.h" #include "wgt/step/encryption/step_remove_encryption_data.h" +#include "wgt/step/filesystem/step_copy_preview_icons.h" #include "wgt/step/filesystem/step_create_symbolic_link.h" #include "wgt/step/filesystem/step_wgt_patch_icons.h" #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h" @@ -104,6 +105,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -146,6 +148,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -209,6 +212,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -264,6 +268,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -307,6 +312,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); diff --git a/src/wgt/CMakeLists.txt b/src/wgt/CMakeLists.txt index 1542e28..c160de9 100644 --- a/src/wgt/CMakeLists.txt +++ b/src/wgt/CMakeLists.txt @@ -5,6 +5,7 @@ SET(SRCS step/configuration/step_parse_recovery.cc step/encryption/step_encrypt_resources.cc step/encryption/step_remove_encryption_data.cc + step/filesystem/step_copy_preview_icons.cc step/filesystem/step_create_symbolic_link.cc step/filesystem/step_wgt_patch_icons.cc step/filesystem/step_wgt_patch_storage_directories.cc diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index c438598..0b9f251 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -468,6 +468,19 @@ bool StepParse::FillMetadata(manifest_x* manifest) { return true; } +bool StepParse::FillAppWidget() { + WgtBackendData* backend_data = + static_cast(context_->backend_data.get()); + + std::shared_ptr appwidget_info = + std::static_pointer_cast( + parser_->GetManifestData( + 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 account_info = std::static_pointer_cast( @@ -507,7 +520,7 @@ bool StepParse::FillImeInfo() { } bool StepParse::FillExtraManifestInfo(manifest_x* manifest) { - return FillAccounts(manifest) && FillImeInfo(); + return FillAccounts(manifest) && FillImeInfo() && FillAppWidget(); } bool StepParse::FillManifestX(manifest_x* manifest) { diff --git a/src/wgt/step/configuration/step_parse.h b/src/wgt/step/configuration/step_parse.h index 9bc1b73..4a41978 100644 --- a/src/wgt/step/configuration/step_parse.h +++ b/src/wgt/step/configuration/step_parse.h @@ -66,6 +66,7 @@ class StepParse : public common_installer::Step { bool FillExtraManifestInfo(manifest_x* manifest); bool FillAccounts(manifest_x* manifest); bool FillImeInfo(); + bool FillAppWidget(); bool FillBackgroundCategoryInfo(manifest_x* manifest); bool FillManifestX(manifest_x* manifest); diff --git a/src/wgt/step/filesystem/step_copy_preview_icons.cc b/src/wgt/step/filesystem/step_copy_preview_icons.cc new file mode 100644 index 0000000..88fc004 --- /dev/null +++ b/src/wgt/step/filesystem/step_copy_preview_icons.cc @@ -0,0 +1,52 @@ +// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache-2.0 license that can be +// found in the LICENSE file. + +#include "wgt/step/filesystem/step_copy_preview_icons.h" + +#include +#include + +#include + +#include "wgt/wgt_backend_data.h" + +namespace bf = boost::filesystem; +namespace ci = common_installer; + +namespace { + +const char kResWgt[] = "res/wgt"; +const char kSharedRes[] = "shared/res"; + +} // namespace + +namespace wgt { +namespace filesystem { + +ci::Step::Status StepCopyPreviewIcons::process() { + WgtBackendData* backend_data = + static_cast(context_->backend_data.get()); + for (auto& appwidget : backend_data->appwidgets.get().app_widgets()) { + for (auto& size : appwidget.content_size) { + if (!size.preview.empty()) { + bf::path icon_path = + context_->pkg_path.get() / kResWgt / size.preview; + std::string type = wgt::parse::AppWidgetSizeTypeToString(size.type); + 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; + if (!ci::CopyFile(icon_path, preview_icon)) { + LOG(ERROR) << "Cannot create preview icon: " << preview_icon; + return Status::ICON_ERROR; + } + } + } + } + LOG(DEBUG) << "Preview icons created"; + return Status::OK; +} + +} // namespace filesystem +} // namespace wgt diff --git a/src/wgt/step/filesystem/step_copy_preview_icons.h b/src/wgt/step/filesystem/step_copy_preview_icons.h new file mode 100644 index 0000000..ee9c525 --- /dev/null +++ b/src/wgt/step/filesystem/step_copy_preview_icons.h @@ -0,0 +1,35 @@ +// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache-2.0 license that can be +// found in the LICENSE file. + +#ifndef WGT_STEP_FILESYSTEM_STEP_COPY_PREVIEW_ICONS_H_ +#define WGT_STEP_FILESYSTEM_STEP_COPY_PREVIEW_ICONS_H_ + +#include + +#include +#include +#include + +namespace wgt { +namespace filesystem { + +/** + * \brief Step that create copy of preview icons in shared/res/ directory + */ +class StepCopyPreviewIcons : public common_installer::Step { + public: + using Step::Step; + + Status process() override; + Status clean() override { return Status::OK; } + Status undo() override { return Status::OK; } + Status precheck() override { return Status::OK; } + + SCOPE_LOG_TAG(CopyPreviewIcons) +}; + +} // namespace filesystem +} // namespace wgt + +#endif // WGT_STEP_FILESYSTEM_STEP_COPY_PREVIEW_ICONS_H_ diff --git a/src/wgt/step/filesystem/step_create_symbolic_link.cc b/src/wgt/step/filesystem/step_create_symbolic_link.cc index 397c7d8..b23fcae 100644 --- a/src/wgt/step/filesystem/step_create_symbolic_link.cc +++ b/src/wgt/step/filesystem/step_create_symbolic_link.cc @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -16,20 +17,22 @@ #include #include +#include "wgt/wgt_backend_data.h" + +namespace bf = boost::filesystem; +namespace bs = boost::system; namespace { const char kWrtServiceBinaryPath[] = "/usr/bin/wrt-service"; +const char kWidgetClientBinaryPath[] = "/usr/bin/widget-client"; } // namespace namespace wgt { namespace filesystem { -namespace bf = boost::filesystem; - -common_installer::Step::Status StepCreateSymbolicLink::process() { - assert(context_->manifest_data.get()); +bool StepCreateSymbolicLink::CreateSymlinksForApps() { boost::system::error_code error; for (application_x* app : GListRange(context_->manifest_data.get()->application)) { @@ -52,11 +55,38 @@ common_installer::Step::Status StepCreateSymbolicLink::process() { if (error) { LOG(ERROR) << "Failed to set symbolic link " << boost::system::system_error(error).what(); - return Step::Status::ERROR; + return false; } } - LOG(DEBUG) << "Symlinks created successfully"; + return true; +} +bool StepCreateSymbolicLink::CreateSymlinksForAppWidgets() { + WgtBackendData* backend_data = + static_cast(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; } diff --git a/src/wgt/step/filesystem/step_create_symbolic_link.h b/src/wgt/step/filesystem/step_create_symbolic_link.h index 0efa491..dbe650b 100644 --- a/src/wgt/step/filesystem/step_create_symbolic_link.h +++ b/src/wgt/step/filesystem/step_create_symbolic_link.h @@ -52,6 +52,10 @@ class StepCreateSymbolicLink : public common_installer::Step { */ Status precheck() override { return Status::OK; } + private: + bool CreateSymlinksForApps(); + bool CreateSymlinksForAppWidgets(); + SCOPE_LOG_TAG(SymbolicLink) }; diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index 79339f1..bfcfb23 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -23,12 +23,16 @@ #include #include "wgt/step/common/privileges.h" +#include "wgt/wgt_backend_data.h" namespace bs = boost::system; namespace bf = boost::filesystem; namespace { +const char kResWgt[] = "res/wgt"; +const char kSharedRes[] = "shared/res"; + void WriteUIApplicationAttributes( xmlTextWriterPtr writer, application_x *app) { if (app->taskmanage) @@ -499,6 +503,77 @@ common_installer::Step::Status StepGenerateXml::process() { xmlTextWriterEndElement(writer); } + WgtBackendData* backend_data = + static_cast(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); + } + xmlTextWriterEndElement(writer); xmlTextWriterEndDocument(writer); diff --git a/src/wgt/wgt_backend_data.h b/src/wgt/wgt_backend_data.h index 8fdf4a4..3d2791d 100644 --- a/src/wgt/wgt_backend_data.h +++ b/src/wgt/wgt_backend_data.h @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -25,6 +26,8 @@ class WgtBackendData : public common_installer::BackendData { * \brief Property of SettingInfo */ Property settings; + + Property appwidgets; }; } // namespace wgt diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index e61112c..ffb2d59 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -62,6 +62,7 @@ #include "wgt/step/configuration/step_parse_recovery.h" #include "wgt/step/encryption/step_encrypt_resources.h" #include "wgt/step/encryption/step_remove_encryption_data.h" +#include "wgt/step/filesystem/step_copy_preview_icons.h" #include "wgt/step/filesystem/step_create_symbolic_link.h" #include "wgt/step/filesystem/step_wgt_patch_icons.h" #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h" @@ -108,6 +109,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep( @@ -144,6 +146,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -217,6 +220,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -264,6 +268,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep( @@ -299,6 +304,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(