From 5fc86dbd4d03954d32485b644f359100b7480203 Mon Sep 17 00:00:00 2001 From: "huiyu.eun" Date: Mon, 25 Nov 2019 17:58:43 +0900 Subject: [PATCH] [Tizen] Add Component Application Structure Change-Id: I48a877fe10eccaccddb4e28f262637f809f9394f Signed-off-by: huiyu.eun --- build/tizen/deps-check.cmake | 3 + .../adaptor-framework/component-application.h | 94 ++++++++++++++++++++++ dali/devel-api/file.list | 1 + dali/internal/adaptor/common/framework.h | 20 ++++- dali/internal/adaptor/file.list | 2 + .../tizen-wayland/component-application-impl.cpp | 63 +++++++++++++++ .../tizen-wayland/component-application-impl.h | 92 +++++++++++++++++++++ .../tizen-wayland/component-application.cpp | 83 +++++++++++++++++++ .../adaptor/tizen-wayland/framework-tizen.cpp | 80 +++++++++++++++++- packaging/dali-adaptor.spec | 10 ++- 10 files changed, 444 insertions(+), 4 deletions(-) create mode 100644 dali/devel-api/adaptor-framework/component-application.h create mode 100644 dali/internal/adaptor/tizen-wayland/component-application-impl.cpp create mode 100644 dali/internal/adaptor/tizen-wayland/component-application-impl.h create mode 100644 dali/internal/adaptor/tizen-wayland/component-application.cpp diff --git a/build/tizen/deps-check.cmake b/build/tizen/deps-check.cmake index fbea7f1..89413f7 100644 --- a/build/tizen/deps-check.cmake +++ b/build/tizen/deps-check.cmake @@ -93,6 +93,7 @@ CHECK_MODULE_AND_SET( CAPI_SYSTEM_INFO capi-system-info [] ) CHECK_MODULE_AND_SET( CAPI_SYSTEM_SENSOR capi-system-sensor capi_system_sensor_support ) CHECK_MODULE_AND_SET( CAPI_SYSTEM_SYSTEM_SETTINGS capi-system-system-settings [] ) CHECK_MODULE_AND_SET( CAPI_APPFW_APPLICATION capi-appfw-application [] ) +CHECK_MODULE_AND_SET( COMPONENT_BASED_CORE_BASE component-based-core-base [] ) CHECK_MODULE_AND_SET( ELEMENTARY elementary [] ) CHECK_MODULE_AND_SET( BUNDLE bundle [] ) @@ -348,6 +349,7 @@ IF( enable_appfw ) ${CAPI_APPFW_WIDGET_BASE_CFLAGS} ${ECORE_IMF_CFLAGS} ${FRIBIDI_CFLAGS} + ${COMPONENT_BASED_CORE_BASE_CFLAGS} ) SET( DALI_LDFLAGS ${DALI_LDFLAGS} @@ -362,6 +364,7 @@ IF( enable_appfw ) ${CAPI_APPFW_WIDGET_BASE_LDFLAGS} ${ECORE_IMF_LDFLAGS} ${FRIBIDI_LDFLAGS} + ${COMPONENT_BASED_CORE_BASE_LDFLAGS} ) ELSE() SET( DALI_CFLAGS ${DALI_CFLAGS} diff --git a/dali/devel-api/adaptor-framework/component-application.h b/dali/devel-api/adaptor-framework/component-application.h new file mode 100644 index 0000000..f353f0b --- /dev/null +++ b/dali/devel-api/adaptor-framework/component-application.h @@ -0,0 +1,94 @@ +#ifndef DALI_COMPONENT_APPLICATION_H +#define DALI_COMPONENT_APPLICATION_H + +/* + * Copyright (c) 2019 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. + * + */ + +#ifdef COMPONENT_APPLICATION_SUPPORT + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Internal DALI_INTERNAL +{ + +namespace Adaptor +{ +class ComponentApplication; +} + +} + +class DALI_ADAPTOR_API ComponentApplication : public Application +{ + +public: + static ComponentApplication New( ); + static ComponentApplication New( int* argc, char **argv[] ); + static ComponentApplication New( int* argc, char **argv[], const std::string& stylesheet ); + + /** + * @brief The default constructor. + */ + ComponentApplication(); + + /** + * @brief Copy Constructor. + * + * @param[in] componentApplication Handle to an object + */ + ComponentApplication( const ComponentApplication& componentApplication ); + + /** + * @brief Assignment operator. + * + * @param[in] componentApplication Handle to an object + * @return A reference to this + */ + ComponentApplication& operator=( const ComponentApplication& componentApplication ); + + /** + * @brief Destructor + */ + ~ComponentApplication(); + + public: + typedef Signal< component_class_h (void* user_data) > CreateSignalType; + + CreateSignalType& CreateSignal(); + +public: + /// @cond internal + /** + * @brief Internal constructor. + */ + explicit DALI_INTERNAL ComponentApplication(Internal::Adaptor::ComponentApplication* componentApplication); + /// @endcond +}; + +/** + * @} + */ +} // namespace Dali + +#endif + +#endif // DALI_COMPONENT_APPLICATION_H + diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index 062abc2..a59d2bd 100644 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -89,6 +89,7 @@ SET( devel_api_adaptor_framework_header_files ${adaptor_devel_api_dir}/adaptor-framework/key-devel.h ${adaptor_devel_api_dir}/adaptor-framework/thread-settings.h ${adaptor_devel_api_dir}/adaptor-framework/window-devel.h + ${adaptor_devel_api_dir}/adaptor-framework/component-application.h ) diff --git a/dali/internal/adaptor/common/framework.h b/dali/internal/adaptor/common/framework.h index d95388c..531e37d 100644 --- a/dali/internal/adaptor/common/framework.h +++ b/dali/internal/adaptor/common/framework.h @@ -24,6 +24,9 @@ #ifdef APPCORE_WATCH_AVAILABLE #include #endif +#ifdef COMPONENT_APPLICATION_SUPPORT +#include +#endif // INTERNAL INCLUDES #include @@ -54,7 +57,8 @@ public: { NORMAL, ///< normal appFramework WATCH, ///< watch appFramework - WIDGET ///< widget appFramework + WIDGET, ///< widget appFramework + COMPONENT ///< component appFramework }; /** @@ -141,6 +145,13 @@ public: * Invoked when the platform surface is destroyed. */ virtual void OnSurfaceDestroyed( Any newSurface ) {} + +#ifdef COMPONENT_APPLICATION_SUPPORT + /** + * Invoked when the component application is created. + */ + virtual void* OnCreate(void *) { return NULL; } +#endif }; public: @@ -293,6 +304,13 @@ private: */ void InitThreads(); +#ifdef COMPONENT_APPLICATION_SUPPORT + /** + * Called when the component application is created. + */ + component_class_h CreateComponent(void * data); +#endif + private: Observer& mObserver; bool mInitialised; diff --git a/dali/internal/adaptor/file.list b/dali/internal/adaptor/file.list index 866f6d4..5ca9af6 100644 --- a/dali/internal/adaptor/file.list +++ b/dali/internal/adaptor/file.list @@ -14,6 +14,8 @@ SET( adaptor_adaptor_common_src_files SET( adaptor_adaptor_tizen_wayland_src_files ${adaptor_adaptor_dir}/tizen-wayland/adaptor-impl-tizen.cpp ${adaptor_adaptor_dir}/tizen-wayland/framework-tizen.cpp + ${adaptor_adaptor_dir}/tizen-wayland/component-application.cpp + ${adaptor_adaptor_dir}/tizen-wayland/component-application-impl.cpp ) # module: adaptor, backend: tizen-wearable diff --git a/dali/internal/adaptor/tizen-wayland/component-application-impl.cpp b/dali/internal/adaptor/tizen-wayland/component-application-impl.cpp new file mode 100644 index 0000000..786a350 --- /dev/null +++ b/dali/internal/adaptor/tizen-wayland/component-application-impl.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019 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. + * + */ +#ifdef COMPONENT_APPLICATION_SUPPORT + +// CLASS HEADER +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ +ComponentApplicationPtr ComponentApplication::New( + int* argc, + char **argv[], + const std::string& stylesheet, + Dali::Application::WINDOW_MODE windowMode) +{ + ComponentApplicationPtr application ( new ComponentApplication (argc, argv, stylesheet, windowMode ) ); + return application; +} + +ComponentApplication::ComponentApplication( int* argc, char** argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode ) +: Application(argc, argv, stylesheet, windowMode, PositionSize(), Framework::COMPONENT) +{ +} + +ComponentApplication::~ComponentApplication() +{ +} + +component_class_h ComponentApplication::OnCreate(void* user_data) +{ + return mCreateSignal.Emit( user_data ); +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali +#endif diff --git a/dali/internal/adaptor/tizen-wayland/component-application-impl.h b/dali/internal/adaptor/tizen-wayland/component-application-impl.h new file mode 100644 index 0000000..6ede5a7 --- /dev/null +++ b/dali/internal/adaptor/tizen-wayland/component-application-impl.h @@ -0,0 +1,92 @@ +#ifndef DALI_INTERNAL_COMPONENT_APPLICATION_H +#define DALI_INTERNAL_COMPONENT_APPLICATION_H + +/* + * Copyright (c) 2019 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. + * + */ +#ifdef COMPONENT_APPLICATION_SUPPORT + +// INTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ +class Adaptor; + +namespace Internal +{ + +namespace Adaptor +{ + +class ComponentApplication; +typedef IntrusivePtr ComponentApplicationPtr; + +class ComponentApplication : public Application +{ +public: + typedef Dali::ComponentApplication::CreateSignalType CreateSignal; + + static ComponentApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode ); + + ComponentApplication( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode ); + + /** + * Destructor + */ + virtual ~ComponentApplication(); + virtual component_class_h OnCreate(void*user_data); + +private: + + // @brief Undefined copy constructor. + ComponentApplication( const ComponentApplication& ); + + // @brief Undefined assignment operator. + ComponentApplication& operator=( const ComponentApplication& ); + +public: + CreateSignal mCreateSignal; +}; + +inline ComponentApplication& GetImplementation(Dali::ComponentApplication& application) +{ + DALI_ASSERT_ALWAYS(application && "application handle is empty"); + + BaseObject& handle = application.GetBaseObject(); + + return static_cast(handle); +} + +inline const ComponentApplication& GetImplementation(const Dali::ComponentApplication& application) +{ + DALI_ASSERT_ALWAYS(application && "Time handle is empty"); + + const BaseObject& handle = application.GetBaseObject(); + + return static_cast(handle); +} + + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali +#endif +#endif // DALI_INTERNAL_COMPONENT_APPLICATION_H diff --git a/dali/internal/adaptor/tizen-wayland/component-application.cpp b/dali/internal/adaptor/tizen-wayland/component-application.cpp new file mode 100644 index 0000000..e9669b9 --- /dev/null +++ b/dali/internal/adaptor/tizen-wayland/component-application.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2019 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. + * + */ + +#ifdef COMPONENT_APPLICATION_SUPPORT + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +ComponentApplication ComponentApplication::New() +{ + return New( NULL, NULL ); +} + +ComponentApplication ComponentApplication::New( int* argc, char **argv[] ) +{ + Internal::Adaptor::ComponentApplicationPtr internal = Internal::Adaptor::ComponentApplication::New( argc, argv, "", OPAQUE ); + return ComponentApplication(internal.Get()); +} + +ComponentApplication ComponentApplication::New( int* argc, char **argv[], const std::string& stylesheet ) +{ + Internal::Adaptor::ComponentApplicationPtr internal = Internal::Adaptor::ComponentApplication::New( argc, argv, stylesheet, OPAQUE ); + return ComponentApplication(internal.Get()); +} + +ComponentApplication::~ComponentApplication() +{ +} + +ComponentApplication::ComponentApplication() +{ +} + +ComponentApplication::ComponentApplication(const ComponentApplication& implementation) +: Application(implementation) +{ +} + +ComponentApplication& ComponentApplication::operator=(const ComponentApplication& application) +{ + if( *this != application ) + { + BaseHandle::operator=( application ); + } + return *this; +} + +ComponentApplication::CreateSignalType& ComponentApplication::CreateSignal() +{ + return Internal::Adaptor::GetImplementation(*this).mCreateSignal; +} + +ComponentApplication::ComponentApplication(Internal::Adaptor::ComponentApplication* implementation) +: Application(implementation) +{ +} + +} // namespace Dali + +#endif diff --git a/dali/internal/adaptor/tizen-wayland/framework-tizen.cpp b/dali/internal/adaptor/tizen-wayland/framework-tizen.cpp index c440eeb..f2db238 100644 --- a/dali/internal/adaptor/tizen-wayland/framework-tizen.cpp +++ b/dali/internal/adaptor/tizen-wayland/framework-tizen.cpp @@ -41,6 +41,10 @@ #include #endif // TIZEN_PLATFORM_CONFIG_SUPPORTED +#ifdef COMPONENT_APPLICATION_SUPPORT +#include +#endif + #include // INTERNAL INCLUDES @@ -231,10 +235,16 @@ struct Framework::Impl { ret = AppWidgetMain(); } - else + else if(mApplicationType == WATCH) { ret = AppWatchMain(); } +#ifdef COMPONENT_APPLICATION_SUPPORT + else + { + ret = AppComponentMain(); + } +#endif return ret; } @@ -248,10 +258,16 @@ struct Framework::Impl { AppWidgetExit(); } - else + else if(mApplicationType == WATCH) { AppWatchExit(); } +#ifdef COMPONENT_APPLICATION_SUPPORT + else + { + AppComponentExit(); + } +#endif } void SetLanguage( const std::string& language ) @@ -697,6 +713,57 @@ struct Framework::Impl #endif } +#ifdef COMPONENT_APPLICATION_SUPPORT + int AppComponentMain() + { + int ret; + + /*Crate component_based_app_base_lifecycle_callback*/ + component_based_app_base_lifecycle_callback_s callback; + callback.init = AppInit; + callback.run = AppRun; + callback.exit = AppExit; + callback.create = AppComponentCreate; + callback.terminate = AppComponentTerminate; + callback.fini = AppComponentFinish; + + ret = component_based_app_base_main(*mFramework->mArgc, *mFramework->mArgv, &callback, mFramework); + + if (ret != TIZEN_ERROR_NONE) + return ret; + + return TIZEN_ERROR_NONE; + } + + static void* AppComponentCreate( void *data ) + { + return static_cast( static_cast(data)->CreateComponent(data) ); + } + + static void AppComponentTerminate( void *data ) + { + Observer *observer = &static_cast(data)->mObserver; + observer->OnTerminate(); + } + + static void AppComponentFinish( void *data ) + { + ecore_shutdown(); + + if(getenv("AUL_LOADER_INIT")) + { + unsetenv("AUL_LOADER_INIT"); + ecore_shutdown(); + } + } + + void AppComponentExit() + { + component_based_app_base_exit(); + } + +#endif + private: // Undefined Impl( const Impl& impl ); @@ -884,6 +951,15 @@ std::string Framework::GetRegion() const return mImpl->GetRegion(); } +#ifdef COMPONENT_APPLICATION_SUPPORT +component_class_h Framework::CreateComponent( void * data ) +{ + mInitialised = true; + mObserver.OnInit(); + return mObserver.OnCreate(data); +} +#endif + } // namespace Adaptor } // namespace Internal diff --git a/packaging/dali-adaptor.spec b/packaging/dali-adaptor.spec index 74bc157..17a4da0 100644 --- a/packaging/dali-adaptor.spec +++ b/packaging/dali-adaptor.spec @@ -86,7 +86,6 @@ BuildRequires: pkgconfig(wayland-egl-tizen) %else BuildRequires: pkgconfig(ecore-wayland) %endif - # dali-adaptor needs tbm_surface in tizen 3.0 wayland BuildRequires: pkgconfig(libtbm) @@ -111,6 +110,10 @@ BuildRequires: pkgconfig(capi-ui-autofill) BuildRequires: pkgconfig(mm-sound) BuildRequires: pkgconfig(feedback) +%if 0%{?tizen_version_major} >= 5 && 0%{?tizen_version_minor} >= 5 || 0%{?tizen_version_major} >= 6 +BuildRequires: pkgconfig(component-based-core-base) +%endif + # for multiprofile Requires: %{name}-compat = %{version}-%{release} Recommends: %{name}-profile_common = %{version}-%{release} @@ -284,6 +287,11 @@ cmake_flags+=" -DCMAKE_BUILD_TYPE=Debug" cmake_flags+=" -DENABLE_TRACE=ON" %endif +%if 0%{?tizen_version_major} >= 5 && 0%{?tizen_version_minor} >= 5 || 0%{?tizen_version_major} >= 6 +CFLAGS+=" -DCOMPONENT_APPLICATION_SUPPORT" +CXXFLAGS+=" -DCOMPONENT_APPLICATION_SUPPORT" +%endif + libtoolize --force cd %{_builddir}/%{name}-%{version}/build/tizen -- 2.7.4