Add field for backend specific data in installer context 16/41416/2
authorTomasz Iwanek <t.iwanek@samsung.com>
Thu, 11 Jun 2015 08:11:12 +0000 (10:11 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Mon, 15 Jun 2015 14:27:50 +0000 (16:27 +0200)
There will be additional field in context just to store
backend specific data - "backend_data".

Each backend should set this to own instance of BackendData
implementation.

Settings field will be used in next commits.

Change-Id: Idf500cbac8d96c2dd10eb87113529f297fa3bcff

src/common/context_installer.cc
src/common/context_installer.h
src/common/utils/property.h [new file with mode: 0644]
src/wgt/CMakeLists.txt
src/wgt/step/step_parse.cc
src/wgt/wgt_backend.cc
src/wgt/wgt_backend_data.cc [new file with mode: 0644]
src/wgt/wgt_backend_data.h [new file with mode: 0644]

index 37714dd..6e9d434 100644 (file)
@@ -14,13 +14,16 @@ namespace fs = boost::filesystem;
 ContextInstaller::ContextInstaller()
     : manifest_data(static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)))),
       old_manifest_data(nullptr),
-      uid(getuid()) {}
+      uid(getuid()),
+      backend_data(nullptr) {}
 
 ContextInstaller::~ContextInstaller() {
   if (manifest_data.get())
     pkgmgr_parser_free_manifest_xml(manifest_data.get());
   if (old_manifest_data.get())
     pkgmgr_parser_free_manifest_xml(old_manifest_data.get());
+  if (backend_data.get())
+    delete backend_data.get();
 }
 
 }  // namespace common_installer
index 6ffca51..b11b483 100644 (file)
 #include <memory>
 #include <string>
 
-namespace common_installer {
+#include "common/utils/property.h"
 
-/** Template class for defining smart attributes.
- *
- *  Property should be used when, given attribute needs to have pure
- *  setter and getter. This template class will generate getter and setter.
- *  It uses operator() overloading.
- */
-template<typename Type>
-class Property {
- public:
-  Property() {}
-  Property(const Type &val): value_(val) { } // NOLINT
-  const Type& get() const { return value_; }
-  Type& get() { return value_; }
-  void set(const Type &val) { value_ = val; }
- private:
-  Type value_;
-};
+namespace common_installer {
 
 class ConfigData {
  public:
@@ -43,6 +27,11 @@ class ConfigData {
   Property<std::string> required_version;
 };
 
+class BackendData {
+ public:
+  virtual ~BackendData() { }
+};
+
 // TODO(p.sikorski@samsung.com) this class should be divided into:
 //  Base Context class
 //  CtxInstall class that inherits from Context
@@ -89,6 +78,9 @@ class ContextInstaller {
 
   // path for the applications root directory
   Property<boost::filesystem::path> root_application_path;
+
+  // Backend specific data
+  Property<BackendData*> backend_data;
 };
 
 }  // namespace common_installer
diff --git a/src/common/utils/property.h b/src/common/utils/property.h
new file mode 100644 (file)
index 0000000..c89fcf1
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_UTILS_PROPERTY_H_
+#define COMMON_UTILS_PROPERTY_H_
+
+/** Template class for defining smart attributes.
+ *
+ *  Property should be used when, given attribute needs to have pure
+ *  setter and getter. This template class will generate getter and setter.
+ *  It uses operator() overloading.
+ */
+template<typename Type>
+class Property {
+ public:
+  Property() {}
+  Property(const Type &val): value_(val) { } // NOLINT
+  const Type& get() const { return value_; }
+  Type& get() { return value_; }
+  void set(const Type &val) { value_ = val; }
+ private:
+  Type value_;
+};
+
+#endif  // COMMON_UTILS_PROPERTY_H_
index 02068ed..3f58625 100644 (file)
@@ -4,6 +4,7 @@ SET(SRCS
   step/step_create_symbolic_link.cc
   update_workaround.cc
   wgt_backend.cc
+  wgt_backend_data.cc
 )
 
 IF(WRT_LAUNCHER)
index 1c7105b..584818c 100644 (file)
@@ -5,12 +5,24 @@
 
 #include "wgt/step/step_parse.h"
 
-#include <string.h>
+#include <manifest_handlers/application_manifest_constants.h>
+#include <manifest_handlers/appwidget_handler.h>
+#include <manifest_handlers/category_handler.h>
+#include <manifest_handlers/ime_handler.h>
+#include <manifest_handlers/metadata_handler.h>
+#include <manifest_handlers/navigation_handler.h>
+#include <manifest_handlers/setting_handler.h>
+#include <manifest_handlers/splash_screen_handler.h>
+#include <manifest_parser/manifest_handler.h>
+#include <manifest_parser/manifest_constants.h>
 
 #include <pkgmgr/pkgmgr_parser.h>
 
+#include <string.h>
+
 #include <cstdio>
 #include <cstdlib>
+#include <memory>
 #include <set>
 #include <string>
 #include <vector>
 #include "common/context_installer.h"
 #include "common/step/step.h"
 
-#include "manifest_handlers/application_manifest_constants.h"
-#include "manifest_handlers/appwidget_handler.h"
-#include "manifest_handlers/category_handler.h"
-#include "manifest_handlers/ime_handler.h"
-#include "manifest_handlers/metadata_handler.h"
-#include "manifest_handlers/navigation_handler.h"
-#include "manifest_handlers/setting_handler.h"
-#include "manifest_handlers/splash_screen_handler.h"
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/manifest_constants.h"
+#include "wgt/wgt_backend_data.h"
 
 namespace {
 
@@ -281,6 +284,17 @@ common_installer::Step::Status StepParse::process() {
   if (perm_info)
      permissions = perm_info->GetAPIPermissions();
 
+  std::unique_ptr<WgtBackendData> backend_data(new WgtBackendData());
+
+  std::shared_ptr<const SettingInfo> settings_info =
+      std::static_pointer_cast<const SettingInfo>(
+          parser_->GetManifestData(
+              wgt::application_widget_keys::kTizenSettingKey));
+  if (settings_info)
+    backend_data->settings.set(*settings_info);
+
+  context_->backend_data.set(backend_data.release());
+
   LOG(DEBUG) << " Read data -[ ";
   LOG(DEBUG) << "App id: " << info->id();
   LOG(DEBUG) << "  package     = " <<  info->package();
index fb2d699..9514ad9 100644 (file)
@@ -27,8 +27,8 @@
 
 #include "wgt/update_workaround.h"
 
-#include "wgt/step/step_parse.h"
 #include "wgt/step/step_create_symbolic_link.h"
+#include "wgt/step/step_parse.h"
 
 namespace ci = common_installer;
 
diff --git a/src/wgt/wgt_backend_data.cc b/src/wgt/wgt_backend_data.cc
new file mode 100644 (file)
index 0000000..85930e6
--- /dev/null
@@ -0,0 +1,12 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "wgt/wgt_backend_data.h"
+
+namespace wgt {
+
+WgtBackendData::WgtBackendData() {
+}
+
+}  // namespace wgt
diff --git a/src/wgt/wgt_backend_data.h b/src/wgt/wgt_backend_data.h
new file mode 100644 (file)
index 0000000..51d5c70
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef WGT_WGT_BACKEND_DATA_H_
+#define WGT_WGT_BACKEND_DATA_H_
+
+#include <manifest_handlers/setting_handler.h>
+
+#include "common/context_installer.h"
+#include "common/utils/property.h"
+
+namespace wgt {
+
+class WgtBackendData : public common_installer::BackendData {
+ public:
+  WgtBackendData();
+
+  Property<parse::SettingInfo> settings;
+};
+
+}  // namespace wgt
+
+#endif  // WGT_WGT_BACKEND_DATA_H_