Implement new API, DevelApplication::GetDataPath() 03/198303/2
authorJiyun Yang <ji.yang@samsung.com>
Wed, 23 Jan 2019 11:51:49 +0000 (20:51 +0900)
committerJiyun Yang <ji.yang@samsung.com>
Wed, 23 Jan 2019 12:05:03 +0000 (21:05 +0900)
"Data path" is the path to the application's data directory
which is used to store private data of the application.

Change-Id: Iec455cb5d64c06d88627baa175c105f8436fa37d
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
dali/devel-api/adaptor-framework/application-devel.cpp
dali/devel-api/adaptor-framework/application-devel.h
dali/internal/adaptor/common/application-impl.cpp
dali/internal/adaptor/common/application-impl.h
dali/internal/adaptor/common/framework.h
dali/internal/adaptor/tizen-wayland/framework-tizen.cpp
dali/internal/adaptor/ubuntu/framework-ubuntu.cpp

index 8444e89..c7bfa39 100644 (file)
@@ -58,6 +58,11 @@ bool DestroyWindow( Application application, const std::string& childWindowName
   return Internal::Adaptor::Adaptor::GetImplementation( adaptor ).RemoveWindow( childWindowName );
 }
 
+std::string GetDataPath()
+{
+  return Internal::Adaptor::Application::GetDataPath();
+}
+
 } // namespace DevelApplication
 
 } // namespace Dali
index 080d1db..bb0c140 100644 (file)
@@ -84,6 +84,13 @@ DALI_ADAPTOR_API bool DestroyWindow( Application application, Dali::Window* chil
  */
 DALI_ADAPTOR_API bool DestroyWindow( Application application, const std::string& childWindowName );
 
+/**
+* @brief Gets the absolute path to the application's data directory which is used to store private data of the application.
+* @return The absolute path to the application's data directory
+*/
+DALI_ADAPTOR_API std::string GetDataPath();
+
+
 } // namespace DevelApplication
 
 } // namespace Dali
index 1e67df8..7856020 100644 (file)
@@ -452,6 +452,11 @@ std::string Application::GetResourcePath()
   return Internal::Adaptor::Framework::GetResourcePath();
 }
 
+std::string Application::GetDataPath()
+{
+  return Internal::Adaptor::Framework::GetDataPath();
+}
+
 void Application::SetStyleSheet( const std::string& stylesheet )
 {
   mStylesheet = stylesheet;
index 8c8f726..8d56f23 100644 (file)
@@ -148,6 +148,11 @@ public:
   static std::string GetResourcePath();
 
   /**
+   * @copydoc Dali::DevelApplication::GetDataPath()
+   */
+  static std::string GetDataPath();
+
+  /**
    * Retrieves the pre-initialized application.
    *
    * @return A pointer to the pre-initialized application
index 7c5011a..96dfb7d 100644 (file)
@@ -191,6 +191,11 @@ public:
   static std::string GetResourcePath();
 
   /**
+   *  Gets the path at which application data are stored.
+   */
+  static std::string GetDataPath();
+
+  /**
    * Sets system language.
    */
   void SetLanguage( const std::string& language );
index 925db04..f944bd7 100644 (file)
@@ -815,6 +815,18 @@ std::string Framework::GetResourcePath()
   return resourcePath;
 }
 
+std::string Framework::GetDataPath()
+{
+  std::string result;
+  char* dataPath = app_get_data_path();
+  if( dataPath )
+  {
+    result = dataPath;
+    free(dataPath);
+  }
+  return result;
+}
+
 void Framework::SetBundleId(const std::string& id)
 {
   mBundleId = id;
index 404d1c2..1cc0ce6 100644 (file)
@@ -222,6 +222,19 @@ std::string Framework::GetResourcePath()
   return resourcePath;
 }
 
+std::string Framework::GetDataPath()
+{
+  const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_DATA_DIR";
+  char* value = getenv( ubuntuEnvironmentVariable );
+  std::string dataPath;
+  if ( value != NULL )
+  {
+    dataPath = value;
+  }
+
+  return dataPath;
+}
+
 void Framework::SetBundleId(const std::string& id)
 {
   mBundleId = id;