From 742a30e2ea4b0e4b13c0664b9f61975285bd0d81 Mon Sep 17 00:00:00 2001 From: Agnelo Vaz Date: Thu, 4 Aug 2016 14:05:49 +0100 Subject: [PATCH] Adding GetResourcePath API to framework.h Different platforms can now implement their own method to get the Application resource path Tizen Platform path used if Tizen version 3 or greater else dali defined locations Change-Id: I463d395b3dc7ad9e77e5846907789392bb8056b1 --- adaptors/common/application-impl.cpp | 6 ++++++ adaptors/common/application-impl.h | 5 +++++ adaptors/common/framework.h | 10 ++++++++- adaptors/libuv/framework-libuv.cpp | 6 ++++++ .../public-api/adaptor-framework/application.cpp | 5 +++++ .../public-api/adaptor-framework/application.h | 9 ++++++++ adaptors/tizen/framework-tizen.cpp | 14 +++++++++++++ adaptors/ubuntu/framework-ubuntu.cpp | 14 +++++++++++++ build/tizen/adaptor-uv/Makefile.am | 1 + build/tizen/adaptor-uv/configure.ac | 11 +++++++++- build/tizen/adaptor/Makefile.am | 1 + build/tizen/adaptor/configure.ac | 8 ++++++++ packaging/dali-adaptor.spec | 24 +++++++++++++--------- 13 files changed, 102 insertions(+), 12 deletions(-) diff --git a/adaptors/common/application-impl.cpp b/adaptors/common/application-impl.cpp index e43871f..3cfb156 100644 --- a/adaptors/common/application-impl.cpp +++ b/adaptors/common/application-impl.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -345,6 +346,11 @@ void Application::ReplaceWindow(PositionSize windowPosition, const std::string& mWindow = newWindow; } +std::string Application::GetResourcePath() +{ + return Internal::Adaptor::Framework::GetResourcePath(); +} + } // namespace Adaptor } // namespace Internal diff --git a/adaptors/common/application-impl.h b/adaptors/common/application-impl.h index 68de173..506496f 100644 --- a/adaptors/common/application-impl.h +++ b/adaptors/common/application-impl.h @@ -106,6 +106,11 @@ public: */ void ReplaceWindow(PositionSize windowPosition, const std::string& name); + /** + * @copydoc Dali::Application::GetResourcePath(); + */ + static std::string GetResourcePath(); + public: // Stereoscopy /** diff --git a/adaptors/common/framework.h b/adaptors/common/framework.h index 4dacf5f..6037d57 100644 --- a/adaptors/common/framework.h +++ b/adaptors/common/framework.h @@ -38,9 +38,12 @@ namespace Adaptor { /** - * The Framework class is used to register callbacks with the TIZEN platform so that + * The Framework class is ideally placed to provide key API required by Applications. + * + * The class is also used to register callbacks with the TIZEN platform so that * we know when any of the application lifecycle events occur. This includes events * like when our application is to be initialised, terminated, paused, resumed etc. + * */ class Framework { @@ -179,6 +182,11 @@ public: */ std::string GetBundleId() const; + /** + * Gets the path at which application resources are stored. + */ + static std::string GetResourcePath(); + private: // Undefined diff --git a/adaptors/libuv/framework-libuv.cpp b/adaptors/libuv/framework-libuv.cpp index cc7dc77..3a8f3ae 100644 --- a/adaptors/libuv/framework-libuv.cpp +++ b/adaptors/libuv/framework-libuv.cpp @@ -158,6 +158,12 @@ std::string Framework::GetBundleId() const return ""; } +std::string Framework::GetResourcePath() +{ + // TIZEN_PLATFORM_CONFIG_SUPPORTED not defined for libuv so path not available. + return ""; +} + void Framework::SetBundleId(const std::string& id) { } diff --git a/adaptors/public-api/adaptor-framework/application.cpp b/adaptors/public-api/adaptor-framework/application.cpp index 0a5e4f3..62908dd 100644 --- a/adaptors/public-api/adaptor-framework/application.cpp +++ b/adaptors/public-api/adaptor-framework/application.cpp @@ -110,6 +110,11 @@ void Application::ReplaceWindow(PositionSize windowPosition, const std::string& Internal::Adaptor::GetImplementation(*this).ReplaceWindow(windowPosition, name); } +std::string Application::GetResourcePath() +{ + return Internal::Adaptor::Application::GetResourcePath(); +} + void Application::SetViewMode( ViewMode viewMode ) { Internal::Adaptor::GetImplementation(*this).SetViewMode( viewMode ); diff --git a/adaptors/public-api/adaptor-framework/application.h b/adaptors/public-api/adaptor-framework/application.h index f62e8a6..5242ded 100644 --- a/adaptors/public-api/adaptor-framework/application.h +++ b/adaptors/public-api/adaptor-framework/application.h @@ -260,6 +260,15 @@ public: */ void ReplaceWindow(PositionSize windowPosition, const std::string& name); + /** + * @brief Get path application resources are stored at + * + * @SINCE_1_2.2 + * @return the full path of the resources + */ + static std::string GetResourcePath(); + + public: // Stereoscopy /** diff --git a/adaptors/tizen/framework-tizen.cpp b/adaptors/tizen/framework-tizen.cpp index 47ef3c4..d140a99 100644 --- a/adaptors/tizen/framework-tizen.cpp +++ b/adaptors/tizen/framework-tizen.cpp @@ -30,6 +30,10 @@ #include #endif +#if defined( TIZEN_PLATFORM_CONFIG_SUPPORTED ) && TIZEN_PLATFORM_CONFIG_SUPPORTED +#include +#endif // TIZEN_PLATFORM_CONFIG_SUPPORTED + #include // INTERNAL INCLUDES @@ -391,6 +395,16 @@ std::string Framework::GetBundleId() const return mBundleId; } +std::string Framework::GetResourcePath() +{ + std::string resourcePath = ""; +#if defined( TIZEN_PLATFORM_CONFIG_SUPPORTED ) && TIZEN_PLATFORM_CONFIG_SUPPORTED + resourcePath = app_get_resource_path(); +#endif //TIZEN_PLATFORM_CONFIG_SUPPORTED + + return resourcePath; +} + void Framework::SetBundleId(const std::string& id) { mBundleId = id; diff --git a/adaptors/ubuntu/framework-ubuntu.cpp b/adaptors/ubuntu/framework-ubuntu.cpp index fe706ea..22203cc 100644 --- a/adaptors/ubuntu/framework-ubuntu.cpp +++ b/adaptors/ubuntu/framework-ubuntu.cpp @@ -194,6 +194,20 @@ std::string Framework::GetBundleId() const return mBundleId; } +std::string Framework::GetResourcePath() +{ + // "DALI_APPLICATION_PACKAGE" is used by Ubuntu specifically to get the already configured Application package path. + const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_PACKAGE"; + char* value = getenv( ubuntuEnvironmentVariable ); + std::string resourcePath; + if ( value != NULL ) + { + resourcePath = value; + } + + return resourcePath; +} + void Framework::SetBundleId(const std::string& id) { mBundleId = id; diff --git a/build/tizen/adaptor-uv/Makefile.am b/build/tizen/adaptor-uv/Makefile.am index 15b99df..4e8e1d7 100644 --- a/build/tizen/adaptor-uv/Makefile.am +++ b/build/tizen/adaptor-uv/Makefile.am @@ -356,6 +356,7 @@ libdali_adaptor_uv_la_CXXFLAGS = \ -DFONT_DOWNLOADED_PATH="\"${fontDownloadedPath}\"" \ -DFONT_APPLICATION_PATH="\"${fontApplicationPath}\"" \ -DFONT_CONFIGURATION_FILE="\"${fontConfigurationFile}\"" \ + -DTIZEN_PLATFORM_CONFIG_SUPPORTED=${tizenPlatformConfigSupported} \ -DNON_POWER_OF_TWO_TEXTURES \ -DDALI_COMPILATION -DDALI_ADAPTOR_COMPILATION \ -Werror -Wall -lgcc \ diff --git a/build/tizen/adaptor-uv/configure.ac b/build/tizen/adaptor-uv/configure.ac index 3e54632..e61fccf 100644 --- a/build/tizen/adaptor-uv/configure.ac +++ b/build/tizen/adaptor-uv/configure.ac @@ -332,11 +332,18 @@ if test x$FONT_CONFIGURATION_FILE != x; then fontConfigurationFile=$FONT_CONFIGURATION_FILE fi +if test x$TIZEN_PLATFORM_CONFIG_SUPPORTED != x; then + tizenPlatformConfigSupported=$TIZEN_PLATFORM_CONFIG_SUPPORTED +else + tizenPlatformConfigSupported=0 +fi + AC_SUBST(dataReadWriteDir) AC_SUBST(dataReadOnlyDir) AC_SUBST(DALI_ADAPTOR_CFLAGS) AC_SUBST(DALI_PROFILE_CFLAGS) AC_SUBST(fontConfigurationFile) +AC_SUBST(tizenPlatformConfigSupported) # Specify the include directory for development headers #devincludepath=${includedir}/dali/internal @@ -374,7 +381,9 @@ Configuration Font config file: $fontConfigurationFile Building with EFL Libraries: $enable_efl Using Tizen APP FW libraries: $enable_appfw - OpenGL ES version: $enable_gles" + OpenGL ES version: $enable_gles + Tizen Platform Config supported: $tizenPlatformConfigSupported +" # optional output of node.js source path if we're building with libuv if test "x$build_for_libuv" != "xno"; then echo " LibUV header path $with_libuv" diff --git a/build/tizen/adaptor/Makefile.am b/build/tizen/adaptor/Makefile.am index 1ddadf0..8670157 100644 --- a/build/tizen/adaptor/Makefile.am +++ b/build/tizen/adaptor/Makefile.am @@ -375,6 +375,7 @@ libdali_adaptor_la_CXXFLAGS = \ -DFONT_DOWNLOADED_PATH="\"${fontDownloadedPath}\"" \ -DFONT_APPLICATION_PATH="\"${fontApplicationPath}\"" \ -DFONT_CONFIGURATION_FILE="\"${fontConfigurationFile}\"" \ + -DTIZEN_PLATFORM_CONFIG_SUPPORTED=${tizenPlatformConfigSupported} \ -DNON_POWER_OF_TWO_TEXTURES \ -DDALI_COMPILATION -DDALI_ADAPTOR_COMPILATION \ -Werror -Wall -lgcc \ diff --git a/build/tizen/adaptor/configure.ac b/build/tizen/adaptor/configure.ac index e9f3994..de27247 100644 --- a/build/tizen/adaptor/configure.ac +++ b/build/tizen/adaptor/configure.ac @@ -314,6 +314,12 @@ else dataReadOnlyDir=${prefix}/share/dali/ fi +if test x$TIZEN_PLATFORM_CONFIG_SUPPORTED != x; then + tizenPlatformConfigSupported=$TIZEN_PLATFORM_CONFIG_SUPPORTED +else + tizenPlatformConfigSupported=0 +fi + if test x$FONT_CONFIGURATION_FILE != x; then fontConfigurationFile=$FONT_CONFIGURATION_FILE fi @@ -323,6 +329,7 @@ AC_SUBST(dataReadOnlyDir) AC_SUBST(DALI_ADAPTOR_CFLAGS) AC_SUBST(DALI_PROFILE_CFLAGS) AC_SUBST(fontConfigurationFile) +AC_SUBST(tizenPlatformConfigSupported) # Specify the include directory for development headers #devincludepath=${includedir}/dali/internal @@ -362,6 +369,7 @@ Configuration Building with EFL Libraries: $enable_efl Using Tizen APP FW libraries: $enable_appfw OpenGL ES version: $enable_gles + Tizen Platform Config supported $tizenPlatformConfigSupported " # optional output of node.js source path if we're building with libuv if test "x$build_for_libuv" != "xno"; then diff --git a/packaging/dali-adaptor.spec b/packaging/dali-adaptor.spec index 379c7a6..052c4a6 100644 --- a/packaging/dali-adaptor.spec +++ b/packaging/dali-adaptor.spec @@ -27,7 +27,8 @@ Requires: giflib #need libtzplatform-config for directory if tizen version is 3.x -%if "%{tizen_version_major}" == "3" +%if "%{tizen_version_major}" >= "3" +%define tizen_platform_config_supported 1 BuildRequires: pkgconfig(libtzplatform-config) %endif @@ -228,22 +229,22 @@ VideoPlayer plugin to play a video file for Dali %prep %setup -q -#Use TZ_PATH when tizen version is 3.x +#Use TZ_PATH when tizen version is 3.x or greater -%if "%{tizen_version_major}" == "2" -%define dali_data_rw_dir /usr/share/dali/ -%define dali_data_ro_dir /usr/share/dali/ -%define font_preloaded_path /usr/share/fonts/ -%define font_downloaded_path /opt/share/fonts/ -%define font_application_path /usr/share/app_fonts/ -%define font_configuration_file /opt/etc/fonts/conf.avail/99-slp.conf -%else +%if "%{tizen_version_major}" >= "3" %define dali_data_rw_dir %TZ_SYS_RO_SHARE/dali/ %define dali_data_ro_dir %TZ_SYS_RO_SHARE/dali/ %define font_preloaded_path %TZ_SYS_RO_SHARE/fonts/ %define font_downloaded_path %TZ_SYS_SHARE/fonts/ %define font_application_path %TZ_SYS_RO_SHARE/app_fonts/ %define font_configuration_file %TZ_SYS_ETC/fonts/conf.avail/99-slp.conf +%else +%define dali_data_rw_dir /usr/share/dali/ +%define dali_data_ro_dir /usr/share/dali/ +%define font_preloaded_path /usr/share/fonts/ +%define font_downloaded_path /opt/share/fonts/ +%define font_application_path /usr/share/app_fonts/ +%define font_configuration_file /opt/etc/fonts/conf.avail/99-slp.conf %endif %define user_shader_cache_dir %{dali_data_ro_dir}/core/shaderbin/ @@ -283,6 +284,9 @@ FONT_PRELOADED_PATH="%{font_preloaded_path}" ; export FONT_PRELOADED_PATH FONT_DOWNLOADED_PATH="%{font_downloaded_path}" ; export FONT_DOWNLOADED_PATH FONT_APPLICATION_PATH="%{font_application_path}" ; export FONT_APPLICATION_PATH FONT_CONFIGURATION_FILE="%{font_configuration_file}" ; export FONT_CONFIGURATION_FILE +%if 0%{?tizen_platform_config_supported} +TIZEN_PLATFORM_CONFIG_SUPPORTED="%{tizen_platform_config_supported}" ; export TIZEN_PLATFORM_CONFIG_SUPPORTED +%endif # Default to GLES 2.0 if not specified. %{!?target_gles_version: %define target_gles_version 20} -- 2.7.4