Make we use Dali::EnvironmentVariable instead of getenv/setenv directly. 48/316148/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 14 Aug 2024 04:22:14 +0000 (13:22 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 14 Aug 2024 07:42:58 +0000 (16:42 +0900)
Their might something be changed the way of environment value control
per each platform backend.
To prepare this, let we use unified way to control the env value.

Change-Id: I3674033e803c29723d7cf70ef6ee9a70257200ed
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
22 files changed:
automated-tests/src/dali-adaptor-internal/CMakeLists.txt
automated-tests/src/dali-adaptor-internal/utc-Dali-AddOns.cpp
automated-tests/src/dali-adaptor/utc-Dali-Application.cpp
automated-tests/src/dali-egl-graphics/CMakeLists.txt
automated-tests/src/dali-platform-abstraction/CMakeLists.txt
dali/internal/adaptor/common/application-impl.cpp
dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application-impl.cpp
dali/internal/application-model/component-based/appmodel-component-based-tizen.cpp
dali/internal/application-model/normal/appmodel-normal-tizen.cpp
dali/internal/application-model/widget/appmodel-widget-tizen.cpp
dali/internal/graphics/gles-impl/egl-graphics-controller-debug.cpp
dali/internal/graphics/vulkan/vulkan-device.cpp
dali/internal/imaging/common/file-download.cpp
dali/internal/system/common/environment-options.cpp
dali/internal/system/macos/system-settings-mac.cpp
dali/internal/system/tizen-wayland/system-settings-tizen.cpp
dali/internal/system/tizen-wayland/widget-application-impl-tizen.cpp
dali/internal/system/ubuntu-x11/system-settings-x.cpp
dali/internal/system/windows/system-settings-win.cpp
dali/internal/window-system/common/window-render-surface.cpp
dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp
dali/internal/window-system/x11/window-base-x.cpp

index d9b980a..0293079 100644 (file)
@@ -59,6 +59,7 @@ LIST(APPEND TC_SOURCES
     ../dali-adaptor/dali-test-suite-utils/test-render-surface.cpp
     ../dali-adaptor/dali-test-suite-utils/test-trace-call-stack.cpp
     ../dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.cpp
+    ../dali-adaptor/dali-test-suite-utils/adaptor-environment-variable.cpp
 )
 
 PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
index 605c711..a08c635 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -14,7 +14,9 @@
  * limitations under the License.
  *
  */
+#include <adaptor-environment-variable.h>
 #include <dali-test-suite-utils.h>
+
 #include <dali/dali.h>
 #include <dali/devel-api/common/addon-binder.h>
 #include <dali/integration-api/addon-manager.h>
@@ -23,8 +25,8 @@
 std::unique_ptr<Dali::Integration::AddOnManager> CreateAddOnManager()
 {
   // Set env variables
-  setenv("DALI_ADDONS_PATH", ADDON_LIBS_PATH, 1);
-  setenv("DALI_ADDONS_LIBS", "libSampleAddOn.so", 1);
+  Dali::EnvironmentVariable::SetTestEnvironmentVariable("DALI_ADDONS_PATH", ADDON_LIBS_PATH);
+  Dali::EnvironmentVariable::SetTestEnvironmentVariable("DALI_ADDONS_LIBS", "libSampleAddOn.so");
 
   return std::unique_ptr<Dali::Integration::AddOnManager>(Dali::Internal::AddOnManagerFactory::CreateAddOnManager());
 }
index 7261b37..766dde8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -20,6 +20,8 @@
 #include <dali/devel-api/adaptor-framework/application-devel.h>
 #include <stdlib.h>
 
+#include <adaptor-environment-variable.h> ///< for Dali::SetTestEnvironmentVariable
+
 using namespace Dali;
 
 void utc_dali_application_startup(void)
@@ -668,7 +670,7 @@ int UtcDaliApplicationAddIdleWithReturnValueN(void)
 
 int UtcDaliApplicationGetDataPathP(void)
 {
-  setenv("DALI_APPLICATION_DATA_DIR", "MyDataPath", 1);
+  Dali::EnvironmentVariable::SetTestEnvironmentVariable("DALI_APPLICATION_DATA_DIR", "MyDataPath");
   std::string dataPath = DevelApplication::GetDataPath();
   DALI_TEST_EQUALS(dataPath, "MyDataPath", TEST_LOCATION);
   END_TEST;
index a88b53d..dd6f582 100644 (file)
@@ -38,6 +38,8 @@ LIST(APPEND TC_SOURCES
   ../dali-adaptor/dali-test-suite-utils/test-render-surface.cpp
   ../dali-adaptor/dali-test-suite-utils/test-trace-call-stack.cpp
   ../dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.cpp
+  ../dali-adaptor/dali-test-suite-utils/adaptor-environment-variable.cpp
+
   tct-dali-egl-graphics-core.cpp
 )
 
index 3efc792..5e134f5 100644 (file)
@@ -36,6 +36,7 @@ LIST(APPEND TC_SOURCES
     ../dali-adaptor/dali-test-suite-utils/test-render-surface.cpp
     ../dali-adaptor/dali-test-suite-utils/test-trace-call-stack.cpp
     ../dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.cpp
+    ../dali-adaptor/dali-test-suite-utils/adaptor-environment-variable.cpp
     tct-dali-platform-abstraction-core.cpp
     utc-image-loading-common.cpp
 )
index 6c9cb29..b5ac769 100644 (file)
@@ -62,7 +62,13 @@ namespace Internal
 {
 namespace Adaptor
 {
+namespace
+{
+#ifdef UI_THREAD_AVAILABLE
+const char* TIZEN_UI_THREAD_ENV = "TIZEN_UI_THREAD";
+#endif
 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_APPLICATION, true);
+} // namespace
 
 ApplicationPtr Application::gPreInitializedApplication(NULL);
 
@@ -85,7 +91,7 @@ void Application::PreInitialize(int* argc, char** argv[])
     bool isUseUIThread = false;
 
 #ifdef UI_THREAD_AVAILABLE
-    char* retEnv = std::getenv("TIZEN_UI_THREAD");
+    const char* retEnv = Dali::EnvironmentVariable::GetEnvironmentVariable(TIZEN_UI_THREAD_ENV);
     if(retEnv)
     {
       std::string uiThreadEnv   = retEnv;
index 49d06f6..3dd0681 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -19,6 +19,7 @@
 #include <dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application-impl.h>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/internal/system/common/environment-variables.h>
 
@@ -32,7 +33,7 @@ namespace
 {
 unsigned int GetEnvWatchRenderRefreshRate()
 {
-  const char* envVariable = std::getenv(DALI_WATCH_REFRESH_RATE);
+  const char* envVariable = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_WATCH_REFRESH_RATE);
 
   return envVariable ? std::atoi(envVariable) : 2u; // Default 30 fps
 }
index 4adef23..0401669 100644 (file)
 #endif // DALI_ELDBUS_AVAILABLE
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/trace.h>
-#include <dali/internal/system/linux/dali-ecore.h>
 #include <dali/internal/adaptor/common/framework.h>
 #include <dali/internal/adaptor/tizen-wayland/framework-tizen.h>
+#include <dali/internal/system/linux/dali-ecore.h>
 
 namespace Dali
 {
@@ -42,19 +43,23 @@ namespace Internal
 {
 namespace Adaptor
 {
-extern "C" DALI_ADAPTOR_API AppModelComponentBased* Create() {
+extern "C" DALI_ADAPTOR_API AppModelComponentBased* Create()
+{
   return new AppModelComponentBased;
 }
 
-extern "C" DALI_ADAPTOR_API void Destroy(void* p) {
+extern "C" DALI_ADAPTOR_API void Destroy(void* p)
+{
   AppModelComponentBased* appComponent = static_cast<AppModelComponentBased*>(p);
   delete appComponent;
 }
 
-extern "C" DALI_ADAPTOR_API int AppMain(bool isUiThread, void* data, void* pData) {
+extern "C" DALI_ADAPTOR_API int AppMain(bool isUiThread, void* data, void* pData)
+{
   AppModelComponentBased* appComponent = static_cast<AppModelComponentBased*>(pData);
+
   int ret = 0;
-  if (appComponent != nullptr)
+  if(appComponent != nullptr)
   {
     ret = appComponent->AppMain(data);
   }
@@ -65,7 +70,8 @@ extern "C" DALI_ADAPTOR_API int AppMain(bool isUiThread, void* data, void* pData
   return ret;
 }
 
-extern "C" DALI_ADAPTOR_API void AppExit(AppModelComponentBased* p) {
+extern "C" DALI_ADAPTOR_API void AppExit(AppModelComponentBased* p)
+{
   p->AppExit();
 }
 
@@ -75,6 +81,9 @@ namespace
 Integration::Log::Filter* gDBusLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DBUS");
 #endif
 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_FRAMEWORK, true);
+
+const char* AUL_LOADER_INIT_ENV           = "AUL_LOADER_INIT";
+const char* AUL_LOADER_INIT_DEFAULT_VALUE = "0";
 } // anonymous namespace
 
 struct DALI_ADAPTOR_API AppModelComponentBased::Impl
@@ -94,7 +103,7 @@ struct DALI_ADAPTOR_API AppModelComponentBased::Impl
     callback.terminate = ComponentAppTerminate;
     callback.fini      = ComponentAppFinish;
 
-    ret = component_based_app_base_main(*mFramework->GetArgc(), *mFramework->GetArgv(), &callback, mFramework);;
+    ret = component_based_app_base_main(*mFramework->GetArgc(), *mFramework->GetArgv(), &callback, mFramework);
 #else
     DALI_LOG_ERROR("component application feature is not supported");
 #endif
@@ -103,17 +112,17 @@ struct DALI_ADAPTOR_API AppModelComponentBased::Impl
 
   static void AppInit(int argc, char** argv, void* data)
   {
-  #pragma GCC diagnostic push
-  #pragma GCC diagnostic ignored "-Wold-style-cast"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
     ecore_init();
     ecore_app_args_set(argc, (const char**)argv);
-  #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
 
-  #ifdef DALI_ELDBUS_AVAILABLE
+#ifdef DALI_ELDBUS_AVAILABLE
     // Initialize ElDBus.
     DALI_LOG_INFO(gDBusLogging, Debug::General, "Starting DBus Initialization\n");
     eldbus_init();
-  #endif
+#endif
   }
 
   static void AppRun(void* data)
@@ -128,8 +137,8 @@ struct DALI_ADAPTOR_API AppModelComponentBased::Impl
 
   static void* ComponentAppCreate(void* data)
   {
-    FrameworkTizen* framework = static_cast<FrameworkTizen*>(data);
-    Framework::Observer*       observer  = &framework->GetObserver();
+    FrameworkTizen*      framework = static_cast<FrameworkTizen*>(data);
+    Framework::Observer* observer  = &framework->GetObserver();
     observer->OnInit();
 
     return Dali::AnyCast<void*>(observer->OnCreate());
@@ -145,9 +154,9 @@ struct DALI_ADAPTOR_API AppModelComponentBased::Impl
   {
     ecore_shutdown();
 
-    if(getenv("AUL_LOADER_INIT"))
+    if(Dali::EnvironmentVariable::GetEnvironmentVariable(AUL_LOADER_INIT_ENV))
     {
-      setenv("AUL_LOADER_INIT", "0", 1);
+      Dali::EnvironmentVariable::SetEnvironmentVariable(AUL_LOADER_INIT_ENV, AUL_LOADER_INIT_DEFAULT_VALUE);
       ecore_shutdown();
     }
   }
@@ -168,8 +177,7 @@ struct DALI_ADAPTOR_API AppModelComponentBased::Impl
   {
   }
 
-  AppModelComponentBased*                     mAppModelComponentBased;
-
+  AppModelComponentBased* mAppModelComponentBased;
 };
 
 AppModelComponentBased::AppModelComponentBased()
@@ -182,7 +190,7 @@ AppModelComponentBased::~AppModelComponentBased()
   delete mImpl;
 }
 
-int AppModelComponentBased::AppMain(void *data)
+int AppModelComponentBased::AppMain(voiddata)
 {
   return mImpl->AppMain(data);
 }
@@ -191,6 +199,6 @@ void AppModelComponentBased::AppExit()
 {
   mImpl->AppExit();
 }
-} // Adaptor
-} // Internal
-} // Dali
\ No newline at end of file
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
\ No newline at end of file
index 8d634f7..0395e1c 100644 (file)
@@ -38,6 +38,7 @@
 #endif // DALI_ELDBUS_AVAILABLE
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/integration-api/debug.h>
 #include <dali/internal/adaptor/common/framework.h>
 #include <dali/internal/adaptor/tizen-wayland/framework-tizen.h>
@@ -87,6 +88,10 @@ namespace
 #if defined(DEBUG_ENABLED)
 Integration::Log::Filter* gDBusLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DBUS");
 #endif
+
+const char* TIZEN_GLIB_CONTEXT_ENV        = "TIZEN_GLIB_CONTEXT";
+const char* AUL_LOADER_INIT_ENV           = "AUL_LOADER_INIT";
+const char* AUL_LOADER_INIT_DEFAULT_VALUE = "0";
 } // anonymous namespace
 
 namespace AppCore
@@ -401,7 +406,7 @@ struct DALI_ADAPTOR_API AppModelNormal::Impl
       GMainContext* GetTizenGlibContext()
       {
         GMainContext* context;
-        const char*   env = getenv("TIZEN_GLIB_CONTEXT");
+        const char*   env = Dali::EnvironmentVariable::GetEnvironmentVariable(TIZEN_GLIB_CONTEXT_ENV);
         if(env)
         {
           context = (GMainContext*)strtoul(env, nullptr, 10);
@@ -560,9 +565,9 @@ struct DALI_ADAPTOR_API AppModelNormal::Impl
     {
       ecore_shutdown();
 
-      if(getenv("AUL_LOADER_INIT"))
+      if(Dali::EnvironmentVariable::GetEnvironmentVariable(AUL_LOADER_INIT_ENV))
       {
-        setenv("AUL_LOADER_INIT", "0", 1);
+        Dali::EnvironmentVariable::SetEnvironmentVariable(AUL_LOADER_INIT_ENV, AUL_LOADER_INIT_DEFAULT_VALUE);
         ecore_shutdown();
       }
 
index b30ff7a..190f779 100644 (file)
@@ -33,6 +33,7 @@
 #endif // DALI_ELDBUS_AVAILABLE
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/trace.h>
 #include <dali/internal/adaptor/common/framework.h>
@@ -84,6 +85,9 @@ namespace
 Integration::Log::Filter* gDBusLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DBUS");
 #endif
 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_FRAMEWORK, true);
+
+const char* AUL_LOADER_INIT_ENV           = "AUL_LOADER_INIT";
+const char* AUL_LOADER_INIT_DEFAULT_VALUE = "0";
 } // anonymous namespace
 
 namespace AppCoreWidget
@@ -228,9 +232,9 @@ struct DALI_ADAPTOR_API AppModelWidget::Impl
   {
     ecore_shutdown();
 
-    if(getenv("AUL_LOADER_INIT"))
+    if(Dali::EnvironmentVariable::GetEnvironmentVariable(AUL_LOADER_INIT_ENV))
     {
-      setenv("AUL_LOADER_INIT", "0", 1);
+      Dali::EnvironmentVariable::SetEnvironmentVariable(AUL_LOADER_INIT_ENV, AUL_LOADER_INIT_DEFAULT_VALUE);
       ecore_shutdown();
     }
 
index 822821a..bec34c7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/internal/graphics/gles-impl/egl-graphics-controller-debug.h>
 #include <cstdio>
 #include <queue>
@@ -21,6 +22,8 @@
 namespace Dali::Graphics
 {
 #if defined(DEBUG_ENABLED)
+const char* GRAPHICS_CMDBUF_OUTFILE_ENV = "GRAPHICS_CMDBUF_OUTFILE";
+
 std::string DumpCompareOp(Graphics::CompareOp compareOp)
 {
   switch(compareOp)
@@ -307,7 +310,7 @@ void DumpCommandBuffer(FILE* output, const GLES::CommandBuffer* commandBuffer)
 GraphicsFrameDump::GraphicsFrameDump()
 : outputStream(nullptr, nullptr)
 {
-  char* outfile = getenv("GRAPHICS_CMDBUF_OUTFILE");
+  const char* outfile = Dali::EnvironmentVariable::GetEnvironmentVariable(GRAPHICS_CMDBUF_OUTFILE_ENV);
   if(outfile)
   {
     outputStream = UniqueFilePtr(std::fopen(outfile, "w"), std::fclose);
index 2eaf3f1..c9b355b 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali/internal/graphics/vulkan/vulkan-device.h>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/integration-api/debug.h>
 #include <dali/internal/graphics/vulkan-impl/vulkan-command-buffer-impl.h>
 #include <dali/internal/graphics/vulkan-impl/vulkan-command-pool-impl.h>
@@ -631,7 +632,7 @@ void Device::CreateInstance(const std::vector<const char*>& extensions,
     .setEnabledLayerCount(U32(validationLayers.size()))
     .setPpEnabledLayerNames(validationLayers.data());
 
-  const char* log_level = std::getenv("LOG_VULKAN");
+  const char* log_level = Dali::EnvironmentVariable::GetEnvironmentVariable("LOG_VULKAN");
   int         intValue  = log_level ? std::atoi(log_level) : 0;
   if(!intValue)
   {
@@ -880,8 +881,7 @@ vk::Result Device::Submit(Queue& queue, const std::vector<SubmissionData>& submi
     std::transform(subData.commandBuffers.cbegin(),
                    subData.commandBuffers.cend(),
                    std::back_inserter(commandBufferHandles),
-                   [&](CommandBufferImpl* entry)
-                   {
+                   [&](CommandBufferImpl* entry) {
                      return entry->GetVkHandle();
                    });
 
index bd3a780..de90305 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -40,6 +40,8 @@ namespace TizenPlatform
 {
 namespace // unnamed namespace
 {
+const char* HTTP_PROXY_ENV = "http_proxy";
+
 inline void LogCurlResult(CURLcode result, char* errorBuffer, std::string url, std::string prefix)
 {
   if(result != CURLE_OK)
@@ -188,7 +190,7 @@ void ConfigureCurlOptions(CURL* curlHandle, const std::string& url)
   // If the proxy variable is set, ensure it's also used.
   // In theory, this variable should be used by the curl library; however, something
   // is overriding it.
-  char* proxy = std::getenv("http_proxy");
+  const char* proxy = Dali::EnvironmentVariable::GetEnvironmentVariable(HTTP_PROXY_ENV);
   if(proxy != nullptr)
   {
     curl_easy_setopt(curlHandle, CURLOPT_PROXY, proxy);
index 932336e..21d0520 100644 (file)
@@ -25,6 +25,7 @@
 #include <functional>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/internal/system/common/environment-variables.h>
 #include <dali/internal/trace/common/trace-factory.h>
 
@@ -45,7 +46,7 @@ const bool         DEFAULT_VSYNC_RENDER_REQUIRED_SETTING   = true;
 
 unsigned int GetEnvironmentVariable(const char* variable, unsigned int defaultValue)
 {
-  const char* variableParameter = std::getenv(variable);
+  const char* variableParameter = Dali::EnvironmentVariable::GetEnvironmentVariable(variable);
 
   // if the parameter exists convert it to an integer, else return the default value
   unsigned int intValue = variableParameter ? std::atoi(variableParameter) : defaultValue;
@@ -54,7 +55,7 @@ unsigned int GetEnvironmentVariable(const char* variable, unsigned int defaultVa
 
 bool GetEnvironmentVariable(const char* variable, int& intValue)
 {
-  const char* variableParameter = std::getenv(variable);
+  const char* variableParameter = Dali::EnvironmentVariable::GetEnvironmentVariable(variable);
 
   if(!variableParameter)
   {
@@ -67,7 +68,7 @@ bool GetEnvironmentVariable(const char* variable, int& intValue)
 
 bool GetEnvironmentVariable(const char* variable, float& floatValue)
 {
-  const char* variableParameter = std::getenv(variable);
+  const char* variableParameter = Dali::EnvironmentVariable::GetEnvironmentVariable(variable);
 
   if(!variableParameter)
   {
@@ -80,7 +81,7 @@ bool GetEnvironmentVariable(const char* variable, float& floatValue)
 
 void SetFromEnvironmentVariable(const char* variable, std::string& stringValue)
 {
-  const char* charValue = std::getenv(variable);
+  const char* charValue = Dali::EnvironmentVariable::GetEnvironmentVariable(variable);
   if(charValue)
   {
     stringValue = charValue;
index 98c59ea..7544502 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -21,6 +21,9 @@
 // EXTERNAL INCLUDES
 #include <stdlib.h>
 
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
+
 namespace Dali
 {
 namespace Internal
@@ -33,14 +36,14 @@ std::string GetResourcePath()
 {
   // "DALI_APPLICATION_PACKAGE" is used by macOS specifically to get the already configured Application package path.
   const char* macEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
-  char*       value                  = getenv(macEnvironmentVariable);
+  const char* value                  = Dali::EnvironmentVariable::GetEnvironmentVariable(macEnvironmentVariable);
   std::string resourcePath;
   if(value != NULL)
   {
     resourcePath = value;
   }
 
-  if(resourcePath.back() != '/')
+  if(resourcePath.empty() || resourcePath.back() != '/')
   {
     resourcePath += "/";
   }
@@ -51,7 +54,7 @@ std::string GetResourcePath()
 std::string GetDataPath()
 {
   const char* macEnvironmentVariable = "DALI_APPLICATION_DATA_DIR";
-  char*       value                  = getenv(macEnvironmentVariable);
+  const char* value                  = Dali::EnvironmentVariable::GetEnvironmentVariable(macEnvironmentVariable);
   std::string dataPath;
   if(value != NULL)
   {
index 1e9d53d..f40d85c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -24,6 +24,7 @@
 #if defined(TIZEN_PLATFORM_CONFIG_SUPPORTED) && TIZEN_PLATFORM_CONFIG_SUPPORTED
 #include <tzplatform_config.h>
 #endif // TIZEN_PLATFORM_CONFIG_SUPPORTED
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 
 namespace Dali
 {
@@ -47,13 +48,13 @@ std::string GetResourcePath()
 
   // "DALI_APPLICATION_PACKAGE" is used to get the already configured Application package path.
   const char* environmentVariable = "DALI_APPLICATION_PACKAGE";
-  char*       value               = getenv(environmentVariable);
+  const char* value               = Dali::EnvironmentVariable::GetEnvironmentVariable(environmentVariable);
   if(value != NULL)
   {
     resourcePath = value;
   }
 
-  if(resourcePath.back() != '/')
+  if(resourcePath.empty() || resourcePath.back() != '/')
   {
     resourcePath += "/";
   }
index d80d2e8..9ab2aca 100644 (file)
 #include <dali/internal/system/tizen-wayland/widget-application-impl-tizen.h>
 
 // INTERNAL INCLUDE
-#include <dali/internal/system/tizen-wayland/widget-controller-tizen.h>
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/devel-api/events/key-event-devel.h>
 #include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/internal/system/common/environment-variables.h>
+#include <dali/internal/system/tizen-wayland/widget-controller-tizen.h>
 
 #include <dali/public-api/adaptor-framework/widget-impl.h>
 #include <dali/public-api/adaptor-framework/widget.h>
@@ -38,8 +39,8 @@ namespace Internal
 {
 namespace
 {
-constexpr char const* const kApplicationNamePrefix     = "libdali2-adaptor-application-";
-constexpr char const* const kApplicationNamePostfix    = ".so";
+constexpr char const* const kApplicationNamePrefix  = "libdali2-adaptor-application-";
+constexpr char const* const kApplicationNamePostfix = ".so";
 
 std::string MakePluginName(const char* appModelName)
 {
@@ -89,7 +90,7 @@ bool OnKeyEventCallback(const char* id, screen_connector_event_type_e eventType,
 
 unsigned int GetEnvWidgetRenderRefreshRate()
 {
-  const char* envVariable = std::getenv(DALI_WIDGET_REFRESH_RATE);
+  const char* envVariable = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_WIDGET_REFRESH_RATE);
 
   return envVariable ? std::atoi(envVariable) : 1u; // Default 60 fps
 }
@@ -128,15 +129,15 @@ void WidgetApplicationTizen::RegisterWidgetCreatingFunction(const std::string& w
 {
   AddWidgetCreatingFunctionPair(CreateWidgetFunctionPair(widgetName, createFunction));
 
-  using RegisterFunction          = void (*)(const char*, void*);
-  RegisterFunction                registerFunctionPtr;
-  std::string pluginName = MakePluginName("widget");
+  using RegisterFunction = void (*)(const char*, void*);
+  RegisterFunction registerFunctionPtr;
+  std::string      pluginName = MakePluginName("widget");
 
   void* mHandle = dlopen(pluginName.c_str(), RTLD_LAZY);
 
   if(mHandle == nullptr)
   {
-    print_log(DLOG_INFO, "DALI", "error : %s", dlerror() );
+    print_log(DLOG_INFO, "DALI", "error : %s", dlerror());
     return;
   }
 
index bd37ba8..8158df8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -21,6 +21,9 @@
 // EXTERNAL INCLUDES
 #include <stdlib.h>
 
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
+
 namespace Dali
 {
 namespace Internal
@@ -33,14 +36,14 @@ std::string 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);
+  const char* value                     = Dali::EnvironmentVariable::GetEnvironmentVariable(ubuntuEnvironmentVariable);
   std::string resourcePath;
   if(value != NULL)
   {
     resourcePath = value;
   }
 
-  if(resourcePath.back() != '/')
+  if(resourcePath.empty() || resourcePath.back() != '/')
   {
     resourcePath += "/";
   }
@@ -51,7 +54,7 @@ std::string GetResourcePath()
 std::string GetDataPath()
 {
   const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_DATA_DIR";
-  char*       value                     = getenv(ubuntuEnvironmentVariable);
+  const char* value                     = Dali::EnvironmentVariable::GetEnvironmentVariable(ubuntuEnvironmentVariable);
   std::string dataPath;
   if(value != NULL)
   {
index 6dd6ab7..7b44ed3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -21,6 +21,9 @@
 // EXTERNAL INCLUDES
 #include <stdlib.h>
 
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
+
 namespace Dali
 {
 namespace Internal
@@ -33,14 +36,14 @@ std::string GetResourcePath()
 {
   // "DALI_APPLICATION_PACKAGE" is used by Windows specifically to get the already configured Application package path.
   const char* winEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
-  char*       value                  = getenv(winEnvironmentVariable);
+  const char* value                  = Dali::EnvironmentVariable::GetEnvironmentVariable(winEnvironmentVariable);
   std::string resourcePath;
   if(value != NULL)
   {
     resourcePath = value;
   }
 
-  if(resourcePath.back() != '/')
+  if(resourcePath.empty() || resourcePath.back() != '/')
   {
     resourcePath += "/";
   }
@@ -51,7 +54,7 @@ std::string GetResourcePath()
 std::string GetDataPath()
 {
   const char* winEnvironmentVariable = "DALI_APPLICATION_DATA_DIR";
-  char*       value                  = getenv(winEnvironmentVariable);
+  const char* value                  = Dali::EnvironmentVariable::GetEnvironmentVariable(winEnvironmentVariable);
   std::string dataPath;
   if(value != NULL)
   {
index fa05aca..c5185df 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali/integration-api/gl-abstraction.h>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/integration-api/adaptor-framework/thread-synchronization-interface.h>
 #include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
 #include <dali/internal/adaptor/common/adaptor-impl.h>
@@ -275,10 +276,10 @@ void WindowRenderSurface::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiV
 {
   if(mDpiHorizontal == 0 || mDpiVertical == 0)
   {
-    const char* environmentDpiHorizontal = std::getenv(DALI_ENV_DPI_HORIZONTAL);
+    const char* environmentDpiHorizontal = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_DPI_HORIZONTAL);
     mDpiHorizontal                       = environmentDpiHorizontal ? std::atoi(environmentDpiHorizontal) : 0;
 
-    const char* environmentDpiVertical = std::getenv(DALI_ENV_DPI_VERTICAL);
+    const char* environmentDpiVertical = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_DPI_VERTICAL);
     mDpiVertical                       = environmentDpiVertical ? std::atoi(environmentDpiVertical) : 0;
 
     if(mDpiHorizontal == 0 || mDpiVertical == 0)
index 282e85f..6275b23 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h>
 
 // INTERNAL HEADERS
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/internal/graphics/common/egl-include.h>
 #include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/window-system/common/window-render-surface.h>
@@ -42,6 +43,8 @@ const char*                  DEFAULT_DEVICE_NAME     = "";
 const Device::Class::Type    DEFAULT_DEVICE_CLASS    = Device::Class::NONE;
 const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE;
 
+const char* DESKTOP_STARTUP_ID_ENV = "DESKTOP_STARTUP_ID";
+
 const unsigned int PRIMARY_TOUCH_BUTTON_ID(1);
 
 #if defined(DEBUG_ENABLED)
@@ -294,10 +297,12 @@ void WindowBaseEcoreX::Initialize(PositionSize positionSize, Any surface, bool i
   }
 
   // set up etc properties to match with ecore-evas
-  char* id = NULL;
-  if((id = getenv("DESKTOP_STARTUP_ID")))
   {
-    ecore_x_netwm_startup_id_set(mEcoreWindow, id);
+    const char* id = Dali::EnvironmentVariable::GetEnvironmentVariable(DESKTOP_STARTUP_ID_ENV);
+    if(id != nullptr)
+    {
+      ecore_x_netwm_startup_id_set(mEcoreWindow, id);
+    }
   }
 
   ecore_x_icccm_hints_set(mEcoreWindow,
index 616b8ce..47e399d 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali/internal/window-system/x11/window-base-x.h>
 
 // INTERNAL HEADERS
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/internal/graphics/common/egl-include.h>
 #include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/window-system/common/window-render-surface.h>
@@ -44,6 +45,8 @@ const char*                  DEFAULT_DEVICE_NAME     = "";
 const Device::Class::Type    DEFAULT_DEVICE_CLASS    = Device::Class::NONE;
 const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE;
 
+const char* DESKTOP_STARTUP_ID_ENV = "DESKTOP_STARTUP_ID";
+
 const unsigned int PRIMARY_TOUCH_BUTTON_ID(1);
 
 #if defined(DEBUG_ENABLED)
@@ -294,10 +297,12 @@ void WindowBaseX::Initialize(PositionSize positionSize, Any surface, bool isTran
 
   auto& windowSystem = WindowSystem::GetImplementation();
 
-  char* id = NULL;
-  if((id = getenv("DESKTOP_STARTUP_ID")))
   {
-    windowSystem.SetStringProperty(mWindow, WindowSystemX::ATOM_NET_STARTUP_ID, std::string(id));
+    const char* id = Dali::EnvironmentVariable::GetEnvironmentVariable(DESKTOP_STARTUP_ID_ENV);
+    if(id != nullptr)
+    {
+      windowSystem.SetStringProperty(mWindow, WindowSystemX::ATOM_NET_STARTUP_ID, std::string(id));
+    }
   }
 
   windowSystem.SetWindowHints(mWindow, true);