Adding GetResourcePath API to framework.h 87/83387/9
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Thu, 4 Aug 2016 13:05:49 +0000 (14:05 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Thu, 18 Aug 2016 12:06:12 +0000 (05:06 -0700)
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

13 files changed:
adaptors/common/application-impl.cpp
adaptors/common/application-impl.h
adaptors/common/framework.h
adaptors/libuv/framework-libuv.cpp
adaptors/public-api/adaptor-framework/application.cpp
adaptors/public-api/adaptor-framework/application.h
adaptors/tizen/framework-tizen.cpp
adaptors/ubuntu/framework-ubuntu.cpp
build/tizen/adaptor-uv/Makefile.am
build/tizen/adaptor-uv/configure.ac
build/tizen/adaptor/Makefile.am
build/tizen/adaptor/configure.ac
packaging/dali-adaptor.spec

index e43871f..3cfb156 100644 (file)
@@ -25,6 +25,7 @@
 #include <style-monitor.h>
 #include <command-line-options.h>
 #include <common/adaptor-impl.h>
+#include <common/framework.h>
 #include <singleton-service-impl.h>
 #include <lifecycle-controller-impl.h>
 
@@ -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
index 68de173..506496f 100644 (file)
@@ -106,6 +106,11 @@ public:
    */
   void ReplaceWindow(PositionSize windowPosition, const std::string& name);
 
+  /**
+   * @copydoc Dali::Application::GetResourcePath();
+   */
+  static std::string GetResourcePath();
+
 public: // Stereoscopy
 
   /**
index 4dacf5f..6037d57 100644 (file)
@@ -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
index cc7dc77..3a8f3ae 100644 (file)
@@ -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)
 {
 }
index 0a5e4f3..62908dd 100644 (file)
@@ -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 );
index f62e8a6..5242ded 100644 (file)
@@ -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
 
   /**
index 47ef3c4..d140a99 100644 (file)
 #include <appcore-watch/watch_app.h>
 #endif
 
+#if defined( TIZEN_PLATFORM_CONFIG_SUPPORTED ) && TIZEN_PLATFORM_CONFIG_SUPPORTED
+#include <tzplatform_config.h>
+#endif // TIZEN_PLATFORM_CONFIG_SUPPORTED
+
 #include <dali/integration-api/debug.h>
 
 // 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;
index fe706ea..22203cc 100644 (file)
@@ -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;
index 15b99df..4e8e1d7 100644 (file)
@@ -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 \
index 3e54632..e61fccf 100644 (file)
@@ -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"
index 1ddadf0..8670157 100644 (file)
@@ -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 \
index e9f3994..de27247 100644 (file)
@@ -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
index 379c7a6..052c4a6 100644 (file)
@@ -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}