Implement WidgetComponent 84/249184/8
authorhyunho <hhstark.kang@samsung.com>
Tue, 8 Dec 2020 10:35:24 +0000 (19:35 +0900)
committerhyunho <hhstark.kang@samsung.com>
Thu, 17 Dec 2020 03:30:16 +0000 (12:30 +0900)
Change-Id: Ic6844156a826d5e2c21a16e76d4672aa94906a63
Signed-off-by: hyunho <hhstark.kang@samsung.com>
18 files changed:
component_based/base/CMakeLists.txt
component_based/base/component.h
component_based/base/component_manager_internal.cc
component_based/base/component_manager_internal.h
component_based/base/frame_component.h
component_based/base/service_component.h
component_based/base/stub.cc
component_based/base/widget_component.cc [new file with mode: 0644]
component_based/base/widget_component.h [new file with mode: 0644]
component_based/base/widget_component_implementation.h [new file with mode: 0644]
component_based/efl_base/CMakeLists.txt
component_based/efl_base/elm_widget_window.cc [new file with mode: 0644]
component_based/efl_base/elm_widget_window.h [new file with mode: 0644]
component_based/efl_base/stub.cc
packaging/component-based.spec
unit_tests/CMakeLists.txt
unit_tests/src/base/test_component_based_component_mananger.cc
unit_tests/src/test_component_based_application.cc

index ec231f61dd0f2dcd3f7b30fe3823cada061b1b69..9b3645e1ef14412fc2e091096f6ce6992f81f48c 100644 (file)
@@ -9,8 +9,9 @@ SET(INCLUDEDIR "\${prefix}/include")
 SET(VERSION ${FULLVER})
 
 INCLUDE(FindPkgConfig)
-SET(requires "glib-2.0 bundle dlog ecore-wl2 appcore-multiwindow capi-appfw-app-control aul capi-appfw-app-common")
-SET(pc_requires "ecore-wl2 appcore-multiwindow capi-appfw-app-control component-based-app-control aul")
+SET(requires "glib-2.0 bundle dlog ecore-wl2 appcore-multiwindow capi-appfw-app-control aul capi-appfw-app-common widget_service screen_connector_provider")
+SET(pc_requires "ecore-wl2 appcore-multiwindow capi-appfw-app-control component-based-app-control aul widget_service screen_connector_provider
+")
 
 pkg_check_modules(component-based-core-base REQUIRED ${requires})
 
index cebbfe8b0a20d00f0af901f6b5849147922326e3..2f0b24ee55c9dd3c92c8a7fb940c6067cbd89219 100644 (file)
@@ -60,7 +60,8 @@ class EXPORT_API Component {
   class Factory {
    public:
     virtual std::unique_ptr<Component> Create(std::string comp_id,
-                                              std::string inst_id) = 0;
+                                            std::string inst_id,
+                                            tizen_base::Bundle& start_data) = 0;
   };
 
   Component(std::string comp_id, std::string inst_id);
index 3f5e18b942271b9bc40a1855fe873c902537912a..5e3e3d43cc257fb6dd6c52edf9f5dbbd074a5ec6 100644 (file)
@@ -19,6 +19,7 @@
 #include <app_control_internal.h>
 #include <bundle_internal.h>
 #include <glib.h>
+#include <screen_connector_provider.h>
 
 #include <algorithm>
 #include <memory>
@@ -73,12 +74,14 @@ void ComponentManager::Start(const std::string& comp_id,
     if (new_inst == "true")
       multi_inst_list_.push_back(inst_id);
 
+    tizen_base::Bundle start_data(b, false, false);
     std::unique_ptr<Component> component = fac_map_[comp_id]->Create(comp_id,
-        inst_id);
+        inst_id, start_data);
     if (component == nullptr || component.get() == nullptr) {
       LOGE("Fail to create component");
       return;
     }
+
     inst_map_[inst_id] = std::move(component);
     appcore_multiwindow_base_instance_run(comp_id.c_str(), inst_id.c_str(),
         nullptr);
@@ -187,6 +190,29 @@ bool ComponentManager::Bind(const std::string& inst_id,
   return true;
 }
 
+bool ComponentManager::BindWidget(const std::string& inst_id,
+                            std::unique_ptr<IWindow> win) {
+  appcore_multiwindow_base_instance_h context =
+      appcore_multiwindow_base_instance_find(inst_id.c_str());
+  if (!context) {
+    LOGE("Failed to find instance(%s)", inst_id.c_str());
+    return false;
+  }
+
+  win_map_[inst_id] = std::move(win);
+  Ecore_Wl2_Window* wl_win = GetWl2Window(inst_id);
+  if (!wl_win) {
+    LOGE("Failed to get wayland window(%s)", inst_id.c_str());
+    return false;
+  }
+
+  struct wl_surface* surface = ecore_wl2_window_surface_get(wl_win);
+  screen_connector_provider_remote_enable(inst_id.c_str(), surface);
+  appcore_multiwindow_base_window_bind(context, wl_win);
+  LOGI("Bind instance(%s)", inst_id.c_str());
+  return true;
+}
+
 void ComponentManager::Unbind(const std::string& inst_id) {
   auto win_iter = win_map_.find(inst_id);
   if (win_iter == win_map_.end()) {
index 7dbb12b722b6dccb48ecbfc70cbaff2c88e9bcd6..c95aa81fec719fcd696a6ac41c03acb0cb0da2a9 100644 (file)
@@ -66,6 +66,7 @@ class ComponentManager {
   void ExitAtIdle(const std::string& inst_id);
   void ExitAll();
   bool Bind(const std::string& inst_id, std::unique_ptr<IWindow> win);
+  bool BindWidget(const std::string& inst_id, std::unique_ptr<IWindow> win);
   void Unbind(const std::string& inst_id);
   std::string GetInstanceID(int win_id);
   const IWindow* GetWindow(const std::string& inst_id);
index 89031a5ec66bc85de2dfc371187a53f3f92b46dd..2e4b9ef3cd4980b54d5ab26dfdad4ebde588560b 100644 (file)
@@ -33,7 +33,8 @@ class EXPORT_API FrameComponent : public Component {
   class Factory : public Component::Factory {
    public:
     std::unique_ptr<Component> Create(std::string comp_id,
-                                      std::string inst_id) override {
+                                      std::string inst_id,
+                                      tizen_base::Bundle& start_data) override {
       return std::unique_ptr<Component>(
           new (std::nothrow) FrameComponent(
             std::move(comp_id), std::move(inst_id)));
index 90247c8400b1c69a11867121de1034cad4bc309a..f43de7f5d85dffd871dd6c36dc31a9f2c9d1ba95 100644 (file)
@@ -32,7 +32,8 @@ class EXPORT_API ServiceComponent : public Component {
   class Factory : public Component::Factory {
    public:
     std::unique_ptr<Component> Create(std::string comp_id,
-                                      std::string inst_id) override {
+                                      std::string inst_id,
+                                      tizen_base::Bundle& start_data) override {
       return std::unique_ptr<Component>(
           new (std::nothrow) ServiceComponent(
             std::move(comp_id), std::move(inst_id)));
index d6ed031ec51d89bdf23f97526aabba657f8f27e8..760a3c4e0e93a231100a965ebd98087813760c81 100644 (file)
@@ -165,7 +165,7 @@ class StubBaseComponent : public component_based::Component {
     }
 
     std::unique_ptr<component_based::Component> Create(std::string comp_id,
-        std::string inst_id) override {
+        std::string inst_id, tizen_base::Bundle& start_data) override {
       return std::unique_ptr<component_based::Component>(
           new (std::nothrow) StubBaseComponent(std::move(comp_id),
               std::move(inst_id), cb_, user_data_));
@@ -256,7 +256,7 @@ class StubFrameComponent : public component_based::FrameComponent {
     }
 
     std::unique_ptr<component_based::Component> Create(std::string comp_id,
-        std::string inst_id) override {
+        std::string inst_id, tizen_base::Bundle& start_data) override {
       return std::unique_ptr<component_based::Component>(
           new (std::nothrow) StubFrameComponent(
             std::move(comp_id), std::move(inst_id), cb_, user_data_));
@@ -398,7 +398,7 @@ class StubServiceComponent : public component_based::ServiceComponent {
     }
 
     std::unique_ptr<component_based::Component> Create(std::string comp_id,
-        std::string inst_id) override {
+        std::string inst_id, tizen_base::Bundle& start_data) override {
       return std::unique_ptr<component_based::Component>(
           new (std::nothrow) StubServiceComponent(std::move(comp_id),
               std::move(inst_id), cb_, user_data_));
diff --git a/component_based/base/widget_component.cc b/component_based/base/widget_component.cc
new file mode 100644 (file)
index 0000000..5a2cf44
--- /dev/null
@@ -0,0 +1,353 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <app_common.h>
+#include <aul.h>
+#include <aul_comp_status.h>
+#include <widget_instance.h>
+#include <glib.h>
+#include <aul_widget.h>
+#include <screen_connector_provider.h>
+#include <app_control_internal.h>
+
+#include <memory>
+
+#include "component_based/base/component_manager_internal.h"
+#include "component_based/base/dlog_internal.h"
+#include "component_based/base/widget_component.h"
+#include "component_based/base/widget_component_implementation.h"
+
+#define STATUS_FOREGROUND "fg"
+#define STATUS_BACKGROUND "bg"
+
+namespace component_based {
+
+WidgetComponent::Impl::Impl(WidgetComponent* parent)
+  : parent_(parent) {
+}
+
+WidgetComponent::WidgetComponent(std::string comp_id, std::string inst_id,
+    tizen_base::Bundle& start_data)
+  : Component::Component(std::move(comp_id),
+                         std::move(inst_id)), impl_(new Impl(this))  {
+  char pkgid[256] = {0, };
+  if (aul_app_get_pkgid_bypid(getpid(), pkgid, sizeof(pkgid)) == 0)
+    impl_->pkgid_ = std::string(pkgid);
+
+  impl_->viewer_endpoint_ = start_data.GetString(AUL_K_WIDGET_VIEWER);
+  std::string width_str = start_data.GetString(WIDGET_K_WIDTH);
+  std::string height_str = start_data.GetString(WIDGET_K_HEIGHT);
+
+  if (!width_str.empty()) {
+    impl_->width_ = std::stoi(width_str);
+    impl_->height_ = std::stoi(height_str);
+  }
+
+  std::vector<unsigned char> period_v = start_data.GetByte("__WIDGET_PERIOD__");
+  if (period_v.size() > 0) {
+    impl_->period_ = *reinterpret_cast<const uint16_t*>(&period_v[0]);
+    impl_->period_timer_ = g_timeout_add_seconds(
+        impl_->period_, impl_->PeriodTimeoutCb, this);
+  }
+}
+
+WidgetComponent::~WidgetComponent() {
+  if (impl_->period_timer_)
+    g_source_remove(impl_->period_timer_);
+}
+
+const IWindow* WidgetComponent::GetWindow() {
+  auto& mgr = internal::ComponentManager::GetInst();
+  return mgr.GetWindow(GetInstanceID());
+}
+
+bool WidgetComponent::Impl::SendStatus(int status, tizen_base::Bundle extra) {
+  int lifecycle;
+  int ret = aul_widget_send_status_to_viewer(parent_->GetComponentID().c_str(),
+      parent_->GetInstanceID().c_str(), viewer_endpoint_.c_str(),
+      status, -1, extra.GetCount() != 0 ? extra.GetHandle() : nullptr);
+  if (ret != 0)
+    return false;
+
+  lifecycle = widget_instance_convert_event_to_lifecycle_status(status);
+  if (lifecycle > -1) {
+    ret = aul_widget_send_status_to_service(
+      parent_->GetComponentID().c_str(), parent_->GetInstanceID().c_str(),
+      pkgid_.c_str(), lifecycle);
+    if (ret != 0)
+      return false;
+  }
+  return true;
+}
+
+void WidgetComponent::Impl::SetPendingUpdate(bool pending) {
+  pending_update_ = pending;
+}
+
+bool WidgetComponent::Impl::GetPendingUpdate() {
+  return pending_update_;
+}
+
+void WidgetComponent::Impl::ClearUpdateTimer() {
+  g_source_remove(period_timer_);
+  period_timer_ = 0;
+}
+
+gboolean WidgetComponent::Impl::PeriodTimeoutCb(gpointer user_data) {
+  WidgetComponent* wc = static_cast<WidgetComponent*>(user_data);
+  if (!wc) {
+    LOGE("Can't find the instance");
+    return G_SOURCE_REMOVE;
+  }
+  if (wc->GetState() != State::Running) {
+    wc->impl_->SetPendingUpdate(true);
+    wc->impl_->ClearUpdateTimer();
+  } else {
+    tizen_base::Bundle data;
+    wc->OnUpdate(data, false);
+  }
+
+  return G_SOURCE_CONTINUE;
+}
+
+bool WidgetComponent::OnBaseCreate() {
+  screen_connector_provider_init();
+  std::unique_ptr<IWindow> win = OnCreate(impl_->width_, impl_->height_);
+  if (win == nullptr) {
+    LOGE("OnCreate() returns nullptr");
+    impl_->SendStatus(WIDGET_INSTANCE_EVENT_CREATE_ABORTED);
+    return false;
+  }
+
+  auto& mgr = internal::ComponentManager::GetInst();
+  if (!mgr.BindWidget(GetInstanceID(), std::move(win))) {
+    LOGE("Bind window fail");
+    if (!impl_->SendStatus(WIDGET_INSTANCE_EVENT_CREATE_ABORTED))
+      LOGE("Fail to send abort event");
+    return false;
+  }
+
+  LOGD("%s is created", GetInstanceID().c_str());
+  if (!impl_->SendStatus(WIDGET_INSTANCE_EVENT_CREATE)) {
+    LOGE("Fail to send create event");
+    return false;
+  }
+  return true;
+}
+
+void WidgetComponent::OnBaseDestroy() {
+}
+
+void WidgetComponent::Impl::ResizeProcess(tizen_base::Bundle data) {
+  std::string width_str = data.GetString(WIDGET_K_WIDTH);
+  std::string height_str = data.GetString(WIDGET_K_HEIGHT);
+
+  if (!width_str.empty()) {
+    width_ = std::stoi(width_str);
+    height_ = std::stoi(height_str);
+  }
+  parent_->OnResize(width_, height_);
+  SendStatus(WIDGET_INSTANCE_EVENT_SIZE_CHANGED);
+}
+
+void WidgetComponent::Impl::UpdateProcess(tizen_base::Bundle data) {
+  std::string force = data.GetString("__WIDGET_FORCE__");
+  std::string update_data = data.GetString("__WIDGET_CONTENT_INFO__");
+  if (parent_->GetState() != State::Running) {
+    pending_update_data_ = update_data;
+    pending_update_ = true;
+  } else {
+    tizen_base::Bundle data(update_data);
+    parent_->OnUpdate(data, force == "true");
+    SendStatus(WIDGET_INSTANCE_EVENT_UPDATE);
+  }
+}
+
+void WidgetComponent::Impl::DestroyProcess(tizen_base::Bundle data) {
+  parent_->OnDestroy(false);
+  aul_widget_instance_del(parent_->GetComponentID().c_str(),
+      parent_->GetInstanceID().c_str());
+  SendStatus(WIDGET_INSTANCE_EVENT_DESTROY);
+  parent_->Finish();
+}
+
+void WidgetComponent::Impl::TerminateProcess(tizen_base::Bundle data) {
+  parent_->OnDestroy(true);
+  aul_widget_instance_del(parent_->GetComponentID().c_str(),
+      parent_->GetInstanceID().c_str());
+  SendStatus(WIDGET_INSTANCE_EVENT_EXTRA_UPDATED,
+      parent_->GetContent());
+  SendStatus(WIDGET_INSTANCE_EVENT_TERMINATE);
+  parent_->Finish();
+}
+
+void WidgetComponent::Impl::PeriodProcess(tizen_base::Bundle data) {
+  ClearUpdateTimer();
+  std::vector<unsigned char> period_v = data.GetByte("__WIDGET_PERIOD__");
+  if (period_v.size() > 0) {
+    period_ = *reinterpret_cast<const uint16_t*>(&period_v[0]);
+    period_timer_ = g_timeout_add_seconds(
+        period_, PeriodTimeoutCb, this);
+  }
+}
+
+void WidgetComponent::OnBaseStart(AppControl control, bool restarted) {
+  bundle* raw_data;
+  app_control_to_bundle(control.GetHandle(), &raw_data);
+  tizen_base::Bundle data(raw_data, true, true);
+  std::string op = data.GetString("__WIDGET_OP__");
+  if (op == "resize") {
+    impl_->ResizeProcess(data);
+    return;
+  } else if (op == "update") {
+    impl_->UpdateProcess(data);
+    return;
+  } else if (op == "destroy") {
+    impl_->DestroyProcess(data);
+    return;
+  } else if (op == "terminate") {
+    impl_->TerminateProcess(data);
+    return;
+  } else if (op == "resume") {
+    OnBaseResume();
+    return;
+  } else if (op == "pause") {
+    OnBasePause();
+    return;
+  } else if (op == "period") {
+    impl_->PeriodProcess(data);
+    return;
+  }
+  std::string content_str = data.GetString("__WIDGET_CONTENT_INFO__");
+  if (!content_str.empty()) {
+    tizen_base::Bundle content(content_str);
+    OnBaseRestoreContent(content);
+  } else {
+    OnBaseRestoreContent(GetContent());
+  }
+  OnStart(restarted);
+}
+
+void WidgetComponent::OnBaseResume() {
+  if (GetState() == State::Paused ||
+      GetState() == State::Started ||
+      GetState() == State::Stopped) {
+    if (impl_->pending_update_) {
+      tizen_base::Bundle update_data;
+      if (!impl_->pending_update_data_.empty())
+        update_data = tizen_base::Bundle(impl_->pending_update_data_.c_str());
+      OnUpdate(update_data, false);
+      impl_->SendStatus(WIDGET_INSTANCE_EVENT_UPDATE);
+      impl_->period_timer_ = g_timeout_add_seconds(impl_->period_,
+          impl_->PeriodTimeoutCb, this);
+    }
+
+    OnResume();
+    SetState(State::Running);
+    aul_comp_status_update(GetInstanceID().c_str(), COMP_STATUS_RESUMED);
+    impl_->SendStatus(WIDGET_INSTANCE_EVENT_RESUME);
+    aul_widget_instance_change_status(
+        GetComponentID().c_str(), STATUS_FOREGROUND);
+  }
+}
+
+void WidgetComponent::OnBasePause() {
+  if (GetState() == State::Running) {
+    OnPause();
+    SetState(State::Paused);
+    aul_comp_status_update(GetInstanceID().c_str(), COMP_STATUS_PAUSED);
+    impl_->SendStatus(WIDGET_INSTANCE_EVENT_PAUSE);
+    aul_widget_instance_change_status(
+        GetComponentID().c_str(), STATUS_BACKGROUND);
+  }
+  OnBaseStop();
+}
+
+void WidgetComponent::OnBaseStop() {
+  OnStop();
+  tizen_base::Bundle content = GetContent();
+  OnBaseSaveContent(content);
+  SetContent(std::move(content));
+}
+
+void WidgetComponent::OnBaseRestoreContent(tizen_base::Bundle content) {
+}
+
+void WidgetComponent::OnBaseSaveContent(tizen_base::Bundle& content) {
+}
+
+// LCOV_EXCL_START
+void WidgetComponent::OnBaseAction(std::string action, AppControl app_control) {
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START
+void WidgetComponent::OnBaseDeviceOrientationChanged(
+    DeviceOrientation::Orientation orientation) {
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START
+void WidgetComponent::OnBaseLanguageChanged(std::string language) {
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START
+void WidgetComponent::OnBaseRegionFormatChanged(std::string region) {
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START
+void WidgetComponent::OnBaseLowBattery(LowBattery::Status status) {
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START
+void WidgetComponent::OnBaseLowMemory(LowMemory::Status status) {
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START
+void WidgetComponent::OnBaseSuspendedStateChanged(SuspendedState::State state) {
+}
+// LCOV_EXCL_STOP
+
+std::unique_ptr<IWindow> WidgetComponent::OnCreate(int width, int height) {
+  return nullptr;
+}
+
+void WidgetComponent::OnStart(bool restarted) {
+}
+
+void WidgetComponent::OnResume() {
+}
+
+void WidgetComponent::OnPause() {
+}
+
+void WidgetComponent::OnStop() {
+}
+
+void WidgetComponent::OnDestroy(bool permanent) {
+}
+
+void WidgetComponent::OnUpdate(tizen_base::Bundle data, bool force) {
+}
+
+void WidgetComponent::OnResize(int w, int h) {
+}
+
+}  // namespace component_based
diff --git a/component_based/base/widget_component.h b/component_based/base/widget_component.h
new file mode 100644 (file)
index 0000000..93d973f
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COMPONENT_BASED_BASE_WIDGET_COMPONENT_H_
+#define COMPONENT_BASED_BASE_WIDGET_COMPONENT_H_
+
+#include <string>
+
+#include "component_based/base/component.h"
+#include "component_based/base/window_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace component_based {
+
+class EXPORT_API WidgetComponent : public Component {
+ public:
+  class Factory : public Component::Factory {
+   public:
+    std::unique_ptr<Component> Create(std::string comp_id,
+                                      std::string inst_id,
+                                      tizen_base::Bundle& start_data) override {
+      return std::unique_ptr<Component>(
+          new (std::nothrow) WidgetComponent(
+            std::move(comp_id), std::move(inst_id), start_data));
+    }
+  };
+
+  enum class DisplayStatus {
+    Unknown,
+    On,
+    Off,
+  };
+
+  class WidgetType : public Type {
+   public:
+    enum {
+      Hash = 0x3333
+    };
+
+    int GetHash() const override {
+      return Hash;
+    }
+
+    std::string GetName() const override {
+      return "widget";
+    }
+  };
+
+  std::unique_ptr<Type> GetType() const override {
+    return std::unique_ptr<Type>(new WidgetType());
+  }
+
+  WidgetComponent(std::string comp_id, std::string inst_id,
+      tizen_base::Bundle& start_data);
+  virtual ~WidgetComponent();
+
+  DisplayStatus GetDisplayStatus();
+  const IWindow* GetWindow();
+
+  bool OnBaseCreate() override;
+  void OnBaseDestroy() override;
+  void OnBaseStart(AppControl control, bool restarted) override;
+  void OnBaseResume() override;
+  void OnBasePause() override;
+  void OnBaseStop() override;
+  void OnBaseRestoreContent(tizen_base::Bundle content) override;
+  void OnBaseSaveContent(tizen_base::Bundle& content) override;
+  void OnBaseAction(std::string action, AppControl app_control) override;
+  void OnBaseDeviceOrientationChanged(
+      DeviceOrientation::Orientation orientation) override;
+  void OnBaseLanguageChanged(std::string language) override;
+  void OnBaseRegionFormatChanged(std::string region) override;
+  void OnBaseLowBattery(LowBattery::Status status) override;
+  void OnBaseLowMemory(LowMemory::Status status) override;
+  void OnBaseSuspendedStateChanged(SuspendedState::State state) override;
+
+  virtual std::unique_ptr<IWindow> OnCreate(int w, int h);
+  virtual void OnStart(bool restarted);
+  virtual void OnResume();
+  virtual void OnPause();
+  virtual void OnStop();
+  virtual void OnDestroy(bool permanent);
+  virtual void OnUpdate(tizen_base::Bundle data, bool force);
+  virtual void OnResize(int width, int height);
+
+  int GetWidth();
+  int GetHeight();
+
+ private:
+  class Impl;
+  std::unique_ptr<Impl> impl_;
+};
+
+}  // namespace component_based
+
+#endif  // COMPONENT_BASED_BASE_WIDGET_COMPONENT_H_
diff --git a/component_based/base/widget_component_implementation.h b/component_based/base/widget_component_implementation.h
new file mode 100644 (file)
index 0000000..9bdc59f
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COMPONENT_BASED_BASE_WIDGET_COMPONENT_IMPLEMENTATION_H_
+#define COMPONENT_BASED_BASE_WIDGET_COMPONENT_IMPLEMENTATION_H_
+
+#include <app_control.h>
+#include <bundle_cpp.h>
+
+#include <string>
+#include <map>
+#include <memory>
+
+#include "component_based/base/widget_component.h"
+
+namespace component_based {
+
+class WidgetComponent::Impl {
+ public:
+  virtual ~Impl() = default;
+
+ private:
+  friend class WidgetComponent;
+  Impl(WidgetComponent* parent);
+
+ private:
+  static gboolean PeriodTimeoutCb(gpointer user_data);
+  void ResizeProcess(tizen_base::Bundle data);
+  void UpdateProcess(tizen_base::Bundle data);
+  void DestroyProcess(tizen_base::Bundle data);
+  void TerminateProcess(tizen_base::Bundle data);
+  void PeriodProcess(tizen_base::Bundle data);
+  bool SendStatus(int status, tizen_base::Bundle extra = tizen_base::Bundle());
+  void SetPendingUpdate(bool update);
+  bool GetPendingUpdate();
+  void ClearUpdateTimer();
+
+ private:
+  WidgetComponent* parent_;
+  int width_;
+  int height_;
+  std::string viewer_endpoint_;
+  std::string pkgid_;
+  int period_;
+  guint period_timer_;
+  bool pending_update_;
+  std::string pending_update_data_;
+};
+
+}  // namespace component_base
+
+#endif  // COMPONENT_BASED_BASE_WIDGET_COMPONENT_IMPLEMENTATION_H_
index e7518aaeb80db503205311997e19c6a6a7e0deed..0fb1e42d6983bc207fc27ccd21ca8251de3b9999 100644 (file)
@@ -26,6 +26,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../base/)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../base/api/)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/api/)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/)
 
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCES)
 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SOURCES})
diff --git a/component_based/efl_base/elm_widget_window.cc b/component_based/efl_base/elm_widget_window.cc
new file mode 100644 (file)
index 0000000..d6b6d69
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <Ecore_Wl2.h>
+
+#include <memory>
+
+#include "elm_widget_window.h"
+
+namespace component_based {
+
+ElmWidgetWindow::ElmWidgetWindow(std::string id)
+    : ElmWindow::ElmWindow(id) {
+  int rots[3] = {0};
+  Evas_Object* win = static_cast<Evas_Object*>(GetRaw());
+  elm_win_wm_rotation_preferred_rotation_set(win, -1);
+  elm_win_wm_rotation_available_rotations_set(win, rots, 1);
+  Ecore_Wl2_Window* wl_win = ecore_evas_wayland2_window_get(
+      ecore_evas_ecore_evas_get(evas_object_evas_get(win)));
+  ecore_wl2_window_class_set(wl_win, id.c_str());
+  elm_win_aux_hint_add(win, "wm.policy.win.user.geometry", "1");
+
+  std::string plug_id = id + ":" + std::to_string(getpid());
+  evas_object_data_set(win, "___PLUGID", strdup(plug_id.c_str()));
+  evas_object_event_callback_add(
+      win, EVAS_CALLBACK_DEL, WinDelCb, NULL);
+}
+
+ElmWidgetWindow::ElmWidgetWindow(Evas_Object* win)
+    : ElmWindow::ElmWindow(win) {
+}
+
+ElmWidgetWindow::~ElmWidgetWindow() = default;
+
+void ElmWidgetWindow::WinDelCb(void* data, Evas* e,
+    Evas_Object* obj, void* event_info) {
+  char* plug_id;
+  plug_id = static_cast<char*>(evas_object_data_del(obj, "___PLUGID"));
+  free(plug_id);
+}
+
+}  // namespace component_based
diff --git a/component_based/efl_base/elm_widget_window.h b/component_based/efl_base/elm_widget_window.h
new file mode 100644 (file)
index 0000000..887183c
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COMPONENT_BASED_EFL_BASE_ELM_WIDGET_WINDOW_H_
+#define COMPONENT_BASED_EFL_BASE_ELM_WIDGET_WINDOW_H_
+
+#include <Elementary.h>
+
+#include <string>
+
+#include "elm_window.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace component_based {
+
+class EXPORT_API ElmWidgetWindow : public ElmWindow {
+ public:
+  ElmWidgetWindow(std::string id);
+  ElmWidgetWindow(Evas_Object* win);
+  virtual ~ElmWidgetWindow();
+ private:
+  static void WinDelCb(void* data, Evas* e, Evas_Object* obj, void* event_info);
+};
+
+}  // namespace component_based
+
+#endif  // COMPONENT_BASED_EFL_BASE_ELM_WIDGET_WINDOW_H_
index 75fdafd62385f3c4817326f77f69e223e70be908..1907d1df2a29549f3827c99526a147ea6e0bf2c5 100755 (executable)
@@ -150,7 +150,7 @@ class StubFrameComponent : public component_based::FrameComponent {
     }
 
     std::unique_ptr<component_based::Component> Create(std::string comp_id,
-        std::string inst_id) override {
+        std::string inst_id, tizen_base::Bundle& start_data) override {
       return std::unique_ptr<component_based::Component>(
           new (std::nothrow) StubFrameComponent(
             std::move(comp_id), std::move(inst_id), cb_, user_data_));
@@ -291,7 +291,7 @@ class StubServiceComponent : public component_based::ServiceComponent {
     }
 
     std::unique_ptr<component_based::Component> Create(std::string comp_id,
-        std::string inst_id) override {
+        std::string inst_id, tizen_base::Bundle& start_data) override {
       return std::unique_ptr<component_based::Component>(
           new (std::nothrow) StubServiceComponent(std::move(comp_id),
               std::move(inst_id), cb_, user_data_));
index fdf47ad128b710f037dc77189c0f25b6659328e7..38ab5489ca32a7a69804958f703e30887e7d7923 100644 (file)
@@ -22,6 +22,8 @@ BuildRequires: pkgconfig(capi-appfw-app-control)
 BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(elementary)
 BuildRequires: pkgconfig(capi-appfw-app-common)
+BuildRequires: pkgconfig(widget_service)
+BuildRequires: pkgconfig(screen_connector_provider)
 
 %if 0%{?gcov:1}
 BuildRequires:  lcov
index 31de1dfff872c1917dda9708cd12a04dcb401134..41f12093053cbb16345bb4caf96337338e4cc75f 100644 (file)
@@ -12,6 +12,8 @@ pkg_check_modules(component-based_unittests REQUIRED
     capi-appfw-app-common
     aul
     elementary
+    widget_service
+    screen_connector_provider
 )
 
 FOREACH(flag ${component-based_unittests_CFLAGS})
index b899be0ab172b4183bc3e74ace44778a6779abc4..96a77ac909ada80afe144a875da98d2bd2c804b7 100644 (file)
@@ -40,7 +40,7 @@ class SimpleFrameComp : public component_based::FrameComponent {
   class Factory : public component_based::Component::Factory {
    public:
     std::unique_ptr<component_based::Component> Create(std::string comp_id,
-                                            std::string inst_id) override {
+              std::string inst_id, tizen_base::Bundle& start_data) override {
       return std::unique_ptr<component_based::Component>(
           new SimpleFrameComp(std::move(comp_id), std::move(inst_id)));
     }
index e589a59ea262a3908d81b653679bb5fded2c80e6..cdad67ab838f812595af4edcc3c201b2e6d539f6 100644 (file)
@@ -26,7 +26,7 @@ class SimpleFrameComp : public component_based::FrameComponent {
   class Factory : public component_based::Component::Factory {
    public:
     std::unique_ptr<component_based::Component> Create(std::string comp_id,
-                                            std::string inst_id) override {
+              std::string inst_id, tizen_base::Bundle& start_data) override {
       return std::unique_ptr<component_based::Component>(
           new SimpleFrameComp(std::move(comp_id), std::move(inst_id)));
     }
@@ -61,7 +61,8 @@ class ServiceComp : public component_based::ServiceComponent {
   class Factory : public component_based::Component::Factory {
    public:
     std::unique_ptr<component_based::Component> Create(
-        std::string comp_id, std::string inst_id) override {
+        std::string comp_id, std::string inst_id,
+        tizen_base::Bundle& start_data) override {
       return std::unique_ptr<component_based::Component>(
           new ServiceComp(std::move(comp_id), std::move(inst_id)));
     }