ADD_SUBDIRECTORY(app_control)
ADD_SUBDIRECTORY(base)
ADD_SUBDIRECTORY(efl_base)
+ADD_SUBDIRECTORY(widget_base)
+ADD_SUBDIRECTORY(efl_widget_base)
ADD_DEPENDENCIES(component-based-app-control component-based-uri)
ADD_DEPENDENCIES(component-based-core-base component-based-app-control)
ADD_DEPENDENCIES(component-based-application component-based-core-base)
+ADD_DEPENDENCIES(component-based-core-widget-base component-based-core-base)
+ADD_DEPENDENCIES(component-based-widget-application component-based-core-widget-base)
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 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
-")
+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")
pkg_check_modules(component-based-core-base REQUIRED ${requires})
#include "component_based/common/exception.h"
#include "component_based/base/component.h"
#include "component_based/base/component_implementation.h"
+#include "component_based/base/component_manager_internal.h"
#include "component_based/base/dlog_internal.h"
namespace component_based {
}
}
+IComponentManager& Component::GetComponentManager() {
+ return internal::ComponentManager::GetInst();
+}
+
} // namespace component_based
#include "component_based/base/low_battery.h"
#include "component_based/base/low_memory.h"
#include "component_based/base/suspended_state.h"
+#include "component_based/base/component_manager_interface.h"
#ifndef EXPORT_API
#define EXPORT_API __attribute__((visibility("default")))
bool DeregisterAction(std::string app_control_name);
void SendAsync(AppControl control, AppControl::IEventListener* ev);
AppControl Send(AppControl control);
+ IComponentManager& GetComponentManager();
protected:
State GetState();
--- /dev/null
+/*
+ * 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_COMPONENT_MANAGER_INTERFACE_H_
+#define COMPONENT_BASED_BASE_COMPONENT_MANAGER_INTERFACE_H_
+
+#include <string>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace component_based {
+
+class EXPORT_API IComponentManager {
+ public:
+ virtual bool IsResumed(const std::string& inst_id) = 0;
+};
+
+} // namespace component_based
+
+#endif // COMPONENT_BASED_BASE_COMPONENT_MANAGER_INTERFACE_H_
#include <app_control_internal.h>
#include <bundle_internal.h>
#include <glib.h>
-#include <screen_connector_provider.h>
#include <algorithm>
#include <memory>
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()) {
#include "component_based/base/component.h"
#include "component_based/base/window_interface.h"
+#include "component_based/base/window_component_manager_interface.h"
namespace component_based {
namespace internal {
-class ComponentManager {
+class ComponentManager : public IWindowComponentManager {
private:
ComponentManager() = default;
~ComponentManager() = default;
void Start(const std::string& comp_id, const std::string& inst_id, bundle* b);
void Resume(const std::string& inst_id);
void Pause(const std::string& inst_id);
- bool IsResumed(const std::string& inst_id);
+ bool IsResumed(const std::string& inst_id) override;
void Stop(const std::string& inst_id);
void Exit(const std::string& inst_id);
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);
+ bool Bind(const std::string& inst_id, std::unique_ptr<IWindow> win) override;
void Unbind(const std::string& inst_id);
std::string GetInstanceID(int win_id);
- const IWindow* GetWindow(const std::string& inst_id);
+ const IWindow* GetWindow(const std::string& inst_id) override;
void AddGroup(const std::string& inst_id, int surf_id);
void RemoveGroup(const std::string& inst_id);
bool IsEmpty();
}
const IWindow* FrameComponent::GetWindow() {
- auto& mgr = internal::ComponentManager::GetInst();
- return mgr.GetWindow(GetInstanceID());
+ IComponentManager& manager = GetComponentManager();
+ IWindowComponentManager& w_manager =
+ static_cast<IWindowComponentManager&>(manager);
+ return w_manager.GetWindow(GetInstanceID());
}
bool FrameComponent::OnBaseCreate() {
return false;
}
- auto& mgr = internal::ComponentManager::GetInst();
- if (!mgr.Bind(GetInstanceID(), std::move(win))) {
+ IComponentManager& manager = GetComponentManager();
+ IWindowComponentManager& w_manager =
+ static_cast<IWindowComponentManager&>(manager);
+ if (!w_manager.Bind(GetInstanceID(), std::move(win))) {
LOGE("Bind window fail");
return false;
}
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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_
+++ /dev/null
-/*
- * 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_
--- /dev/null
+/*
+ * 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_WINDOW_COMPONENT_MANAGER_INTERFACE_H_
+#define COMPONENT_BASED_BASE_WINDOW_COMPONENT_MANAGER_INTERFACE_H_
+
+#include <string>
+#include <memory>
+
+#include "component_based/base/window_interface.h"
+#include "component_based/base/component_manager_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace component_based {
+
+class EXPORT_API IWindowComponentManager : public IComponentManager {
+ public:
+ virtual bool Bind(const std::string& inst_id,
+ std::unique_ptr<IWindow> win) = 0;
+
+ virtual const IWindow* GetWindow(const std::string& inst_id) = 0;
+};
+
+} // namespace component_based
+
+#endif // COMPONENT_BASED_BASE_WINDOW_COMPONENT_MANAGER_INTERFACE_H_
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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_
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+PROJECT(component-based-widget-application CXX)
+
+SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
+SET(EXEC_PREFIX "\${prefix}")
+SET(PROJECT_NAME "${PROJECT_NAME}")
+SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(INCLUDEDIR "\${prefix}/include")
+SET(VERSION ${FULLVER})
+
+INCLUDE(FindPkgConfig)
+SET(requires "glib-2.0 bundle dlog ecore-wl2 elementary capi-appfw-app-control")
+SET(pc_requires "elementary component-based-core-widget-base")
+pkg_check_modules(component-based-widget-application REQUIRED ${requires})
+
+FOREACH(flag ${component-based-widget-application_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline -std=c++11")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+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})
+
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${MAJORVER})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${FULLVER})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${component-based-widget-application_LDFLAGS} component-based-core-widget-base)
+
+SET(PC_NAME component-based-widget-application)
+SET(PC_REQUIRED ${pc_requires})
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc")
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
+ DESTINATION ${INCLUDE_INSTALL_DIR}/component_based/efl_widget_base
+ FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/api
+ DESTINATION ${INCLUDE_INSTALL_DIR}/component_based/efl_widget_base
+ FILES_MATCHING PATTERN "*.h")
+
+
--- /dev/null
+/*
+ * 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 __TIZEN_COMPONENT_BASED_WIDGET_COMPONENT_H__
+#define __TIZEN_COMPONENT_BASED_WIDGET_COMPONENT_H__
+
+#include <Elementary.h>
+#include <app_control.h>
+#include <bundle.h>
+
+#include <component_common.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup COMPONENT_BASED_WIDGET_COMPONENT_MODULE
+ * @{
+ */
+
+// TODO(CAPI) CAPI should be implemented to support C# APIs.
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_COMPONENT_BASED_WIDGET_COMPONENT_H__ */
+
--- /dev/null
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+
+Name: @PC_NAME@
+Description: Support development of the Tizen Extensive App Model
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} -lcomponent-based-core-widget-base -lcomponent-based-widget-application
+Cflags: -I${includedir} -I${includedir}/appfw -I${includedir}/component_based -I${includedir}/component_based/api -I${includedir}/component_based/efl_base -I${includedir}/component_based/efl_base/api -I${includedir}/component_based/widget_base -I${includedir}/component_based/widget_base/api -I${includedir}/component_based/efl_widget_base -I${includedir}/component_based/efl_widget_base/api
--- /dev/null
+/*
+ * 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) {
+ int rots[3] = {0};
+ win_ = elm_win_add(nullptr, id.c_str(), ELM_WIN_BASIC);
+ 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)
+ : win_(win) {
+}
+
+ElmWidgetWindow::~ElmWidgetWindow() {
+ if (win_ != nullptr)
+ evas_object_del(win_);
+}
+
+int ElmWidgetWindow::GetResID() const {
+ Evas* evas = evas_object_evas_get(win_);
+ Ecore_Evas* ecore_evas = ecore_evas_ecore_evas_get(evas);
+ Ecore_Wl2_Window* wl_win = ecore_evas_wayland2_window_get(ecore_evas);
+ return ecore_wl2_window_id_get(wl_win);
+}
+
+void* ElmWidgetWindow::GetRaw() {
+ return win_;
+}
+
+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
--- /dev/null
+/*
+ * 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 "component_based/base/window_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace component_based {
+
+class EXPORT_API ElmWidgetWindow : public IWindow {
+ public:
+ ElmWidgetWindow(std::string id);
+ ElmWidgetWindow(Evas_Object* win);
+ virtual ~ElmWidgetWindow();
+
+ int GetResID() const override;
+ void* GetRaw() override;
+
+ private:
+ static void WinDelCb(void* data, Evas* e, Evas_Object* obj, void* event_info);
+ Evas_Object* win_ = nullptr;
+};
+
+} // namespace component_based
+
+#endif // COMPONENT_BASED_EFL_BASE_ELM_WIDGET_WINDOW_H_
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+PROJECT(component-based-core-widget-base CXX)
+
+SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
+SET(EXEC_PREFIX "\${prefix}")
+SET(PROJECT_NAME "${PROJECT_NAME}")
+SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(INCLUDEDIR "\${prefix}/include")
+SET(VERSION ${FULLVER})
+
+INCLUDE(FindPkgConfig)
+SET(requires "glib-2.0 bundle dlog ecore-wl2 appcore-multiwindow elementary capi-appfw-app-control widget_service screen_connector_provider")
+SET(pc_requires "elementary component-based-core-base appcore-multiwindow widget_service screen_connector_provider")
+pkg_check_modules(component-based-core-widget-base REQUIRED ${requires})
+
+FOREACH(flag ${component-based-core-widget-base_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline -std=c++11")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+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})
+
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${MAJORVER})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${FULLVER})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${component-based-core-widget-base_LDFLAGS} component-based-core-base)
+
+SET(PC_NAME component-based-core-widget-base)
+SET(PC_REQUIRED ${pc_requires})
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc")
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
+ DESTINATION ${INCLUDE_INSTALL_DIR}/component_based/widget_base
+ FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/api
+ DESTINATION ${INCLUDE_INSTALL_DIR}/component_based/widget_base
+ FILES_MATCHING PATTERN "*.h")
+
--- /dev/null
+/*
+ * 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 __TIZEN_COMPONENT_BASED_BASE_WIDGET_COMPONENT_H__
+#define __TIZEN_COMPONENT_BASED_BASE_WIDGET_COMPONENT_H__
+
+#include <app_control.h>
+#include <bundle.h>
+
+#include <component_common.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+// TODO(CAPI) CAPI should be implemented to support C# APIs.
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_COMPONENT_BASED_BASE_WIDGET_COMPONENT_H__ */
+
--- /dev/null
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+
+Name: @PC_NAME@
+Description: Support development of the Tizen Component-based App Model
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} -lcomponent-based-core-base -lcomponent-based-core-widget-base
+Cflags: -I${includedir} -I${includedir}/appfw -I${includedir}/component_based -I${includedir}/component_based/api -I${includedir}/component_based/widget_base/api -I${includedir}/component_based/widget_base
--- /dev/null
+/*
+ * 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/widget_base/widget_component.h"
+#include "component_based/widget_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() {
+ IComponentManager& manager = GetComponentManager();
+ IWindowComponentManager& w_manager =
+ static_cast<IWindowComponentManager&>(manager);
+ return w_manager.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;
+ }
+
+ IComponentManager& manager = GetComponentManager();
+ IWindowComponentManager& w_manager =
+ static_cast<IWindowComponentManager&>(manager);
+ if (!w_manager.Bind(GetInstanceID(), std::move(win))) {
+ LOGE("Bind window fail");
+ if (!impl_->SendStatus(WIDGET_INSTANCE_EVENT_CREATE_ABORTED))
+ LOGE("Fail to send abort event");
+ return false;
+ }
+
+ int win_id = GetWindow()->GetResID();
+ Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
+ Ecore_Wl2_Window* wl_win = ecore_wl2_display_window_find(display, win_id);
+ struct wl_surface* surface = ecore_wl2_window_surface_get(wl_win);
+ screen_connector_provider_remote_enable(GetInstanceID().c_str(), surface);
+
+ 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
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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/widget_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_
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
Source0: %{name}-%{version}.tar.gz
Source1001: %{name}.manifest
Source1002: %{name}-application.manifest
+Source1003: %{name}-widget.manifest
+Source1004: %{name}-widget-application.manifest
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
%description -n %{name}-application-devel
Header & package configuration files to support development of the component-based application.
+
+
+#################################################
+# component-based-widget
+#################################################
+%package -n %{name}-widget
+Summary: Library for developing the component-based widget application
+Group: Application Framework/Core
+License: Apache-2.0
+
+%description -n %{name}-widget
+Provider APIs to develop the component-based widget application
+
+%package -n %{name}-widget-devel
+Summary: Component-based widget application development library (dev)
+Group: Development/Libraries
+Requires: %{name}-widget = %{version}-%{release}
+
+%description -n %{name}-widget-devel
+Header & package configuration files to support development of the component-based widget
+
+
+#################################################
+# component-based-widget-application
+#################################################
+%package -n %{name}-widget-application
+Summary: Library for developing the component-based efl widget application
+Group: Application Framework/Core
+License: Apache-2.0
+
+%description -n %{name}-widget-application
+Provider APIs to develop the component-based efl widget application
+
+%package -n %{name}-widget-application-devel
+Summary: Component-based efl widget application development library (dev)
+Group: Development/Libraries
+Requires: %{name}-widget-application = %{version}-%{release}
+
+%description -n %{name}-widget-application-devel
+Header & package configuration files to support development of the component-based efl widget application.
+
+
#################################################
# unittests
#################################################
%setup -q
cp %{SOURCE1001} .
cp %{SOURCE1002} .
+cp %{SOURCE1003} .
+cp %{SOURCE1004} .
%build
%if 0%{?gcov:1}
%postun -n %{name}-application
/sbin/ldconfig
+
+%post -n %{name}-widget -p /sbin/ldconfig
+%postun -n %{name}-widget -p /sbin/ldconfig
+
+%post -n %{name}-widget-application -p /sbin/ldconfig
+%postun -n %{name}-widget-application -p /sbin/ldconfig
+
+
%post unittests
%if 0%{?gcov:1}
%{_bindir}/component-based_unittests
%endif
-%files
+
+%files -n %{name}
%manifest %{name}.manifest
%license LICENSE
%defattr(-,root,root,-)
%{_libdir}/libcomponent-based-app-control.so.*
%{_libdir}/libcomponent-based-uri.so.*
-%files devel
+%files -n %{name}-devel
%{_includedir}/component_based/base/*.h
%{_includedir}/component_based/base/api/*.h
%{_includedir}/component_based/app_control/*.h
%{_libdir}/pkgconfig/component-based-application.pc
%{_libdir}/libcomponent-based-application.so
+
+#################################################
+# component-based-widget
+#################################################
+%files -n %{name}-widget
+%license LICENSE
+%manifest %{name}-widget.manifest
+%attr(0644,root,root) %{_libdir}/libcomponent-based-core-widget-base.so.*
+
+%files -n %{name}-widget-devel
+%{_includedir}/component_based/widget_base/*.h
+%{_includedir}/component_based/widget_base/api/*.h
+%{_libdir}/pkgconfig/component-based-core-widget-base.pc
+%{_libdir}/libcomponent-based-core-widget-base.so
+
+
+#################################################
+# component-based-widget-application
+#################################################
+%files -n %{name}-widget-application
+%license LICENSE
+%manifest %{name}-widget-application.manifest
+%attr(0644,root,root) %{_libdir}/libcomponent-based-widget-application.so.*
+
+%files -n %{name}-widget-application-devel
+%{_includedir}/component_based/efl_widget_base/*.h
+%{_includedir}/component_based/efl_widget_base/api/*.h
+%{_libdir}/pkgconfig/component-based-widget-application.pc
+%{_libdir}/libcomponent-based-widget-application.so
+
#################################################
# unittests
#################################################