From ef49afea8f7498bb0765db717cb8f1658bf30a88 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 14 Aug 2024 13:22:14 +0900 Subject: [PATCH] Make we use Dali::EnvironmentVariable instead of getenv/setenv directly. 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 --- .../src/dali-adaptor-internal/CMakeLists.txt | 1 + .../src/dali-adaptor-internal/utc-Dali-AddOns.cpp | 8 ++-- .../src/dali-adaptor/utc-Dali-Application.cpp | 6 ++- .../src/dali-egl-graphics/CMakeLists.txt | 2 + .../src/dali-platform-abstraction/CMakeLists.txt | 1 + dali/internal/adaptor/common/application-impl.cpp | 8 +++- .../tizen-wearable/watch-application-impl.cpp | 5 ++- .../appmodel-component-based-tizen.cpp | 52 +++++++++++++--------- .../normal/appmodel-normal-tizen.cpp | 11 +++-- .../widget/appmodel-widget-tizen.cpp | 8 +++- .../gles-impl/egl-graphics-controller-debug.cpp | 7 ++- dali/internal/graphics/vulkan/vulkan-device.cpp | 6 +-- dali/internal/imaging/common/file-download.cpp | 6 ++- .../internal/system/common/environment-options.cpp | 9 ++-- dali/internal/system/macos/system-settings-mac.cpp | 11 +++-- .../system/tizen-wayland/system-settings-tizen.cpp | 7 +-- .../widget-application-impl-tizen.cpp | 17 +++---- .../system/ubuntu-x11/system-settings-x.cpp | 11 +++-- .../system/windows/system-settings-win.cpp | 11 +++-- .../window-system/common/window-render-surface.cpp | 5 ++- .../ubuntu-x11/window-base-ecore-x.cpp | 11 +++-- dali/internal/window-system/x11/window-base-x.cpp | 11 +++-- 22 files changed, 137 insertions(+), 77 deletions(-) diff --git a/automated-tests/src/dali-adaptor-internal/CMakeLists.txt b/automated-tests/src/dali-adaptor-internal/CMakeLists.txt index d9b980a..0293079 100644 --- a/automated-tests/src/dali-adaptor-internal/CMakeLists.txt +++ b/automated-tests/src/dali-adaptor-internal/CMakeLists.txt @@ -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 diff --git a/automated-tests/src/dali-adaptor-internal/utc-Dali-AddOns.cpp b/automated-tests/src/dali-adaptor-internal/utc-Dali-AddOns.cpp index 605c711..a08c635 100644 --- a/automated-tests/src/dali-adaptor-internal/utc-Dali-AddOns.cpp +++ b/automated-tests/src/dali-adaptor-internal/utc-Dali-AddOns.cpp @@ -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 #include + #include #include #include @@ -23,8 +25,8 @@ std::unique_ptr 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::Internal::AddOnManagerFactory::CreateAddOnManager()); } diff --git a/automated-tests/src/dali-adaptor/utc-Dali-Application.cpp b/automated-tests/src/dali-adaptor/utc-Dali-Application.cpp index 7261b37..766dde8 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-Application.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-Application.cpp @@ -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 #include +#include ///< 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; diff --git a/automated-tests/src/dali-egl-graphics/CMakeLists.txt b/automated-tests/src/dali-egl-graphics/CMakeLists.txt index a88b53d..dd6f582 100644 --- a/automated-tests/src/dali-egl-graphics/CMakeLists.txt +++ b/automated-tests/src/dali-egl-graphics/CMakeLists.txt @@ -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 ) diff --git a/automated-tests/src/dali-platform-abstraction/CMakeLists.txt b/automated-tests/src/dali-platform-abstraction/CMakeLists.txt index 3efc792..5e134f5 100644 --- a/automated-tests/src/dali-platform-abstraction/CMakeLists.txt +++ b/automated-tests/src/dali-platform-abstraction/CMakeLists.txt @@ -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 ) diff --git a/dali/internal/adaptor/common/application-impl.cpp b/dali/internal/adaptor/common/application-impl.cpp index 6c9cb29..b5ac769 100644 --- a/dali/internal/adaptor/common/application-impl.cpp +++ b/dali/internal/adaptor/common/application-impl.cpp @@ -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; diff --git a/dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application-impl.cpp b/dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application-impl.cpp index 49d06f6..3dd0681 100644 --- a/dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application-impl.cpp +++ b/dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application-impl.cpp @@ -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 // INTERNAL INCLUDES +#include #include #include @@ -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 } diff --git a/dali/internal/application-model/component-based/appmodel-component-based-tizen.cpp b/dali/internal/application-model/component-based/appmodel-component-based-tizen.cpp index 4adef23..0401669 100644 --- a/dali/internal/application-model/component-based/appmodel-component-based-tizen.cpp +++ b/dali/internal/application-model/component-based/appmodel-component-based-tizen.cpp @@ -30,11 +30,12 @@ #endif // DALI_ELDBUS_AVAILABLE // INTERNAL INCLUDES +#include #include #include -#include #include #include +#include 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(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(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(data); - Framework::Observer* observer = &framework->GetObserver(); + FrameworkTizen* framework = static_cast(data); + Framework::Observer* observer = &framework->GetObserver(); observer->OnInit(); return Dali::AnyCast(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(void* data) { 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 diff --git a/dali/internal/application-model/normal/appmodel-normal-tizen.cpp b/dali/internal/application-model/normal/appmodel-normal-tizen.cpp index 8d634f7..0395e1c 100644 --- a/dali/internal/application-model/normal/appmodel-normal-tizen.cpp +++ b/dali/internal/application-model/normal/appmodel-normal-tizen.cpp @@ -38,6 +38,7 @@ #endif // DALI_ELDBUS_AVAILABLE // INTERNAL INCLUDES +#include #include #include #include @@ -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(); } diff --git a/dali/internal/application-model/widget/appmodel-widget-tizen.cpp b/dali/internal/application-model/widget/appmodel-widget-tizen.cpp index b30ff7a..190f779 100644 --- a/dali/internal/application-model/widget/appmodel-widget-tizen.cpp +++ b/dali/internal/application-model/widget/appmodel-widget-tizen.cpp @@ -33,6 +33,7 @@ #endif // DALI_ELDBUS_AVAILABLE // INTERNAL INCLUDES +#include #include #include #include @@ -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(); } diff --git a/dali/internal/graphics/gles-impl/egl-graphics-controller-debug.cpp b/dali/internal/graphics/gles-impl/egl-graphics-controller-debug.cpp index 822821a..bec34c7 100644 --- a/dali/internal/graphics/gles-impl/egl-graphics-controller-debug.cpp +++ b/dali/internal/graphics/gles-impl/egl-graphics-controller-debug.cpp @@ -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 #include #include #include @@ -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); diff --git a/dali/internal/graphics/vulkan/vulkan-device.cpp b/dali/internal/graphics/vulkan/vulkan-device.cpp index 2eaf3f1..c9b355b 100644 --- a/dali/internal/graphics/vulkan/vulkan-device.cpp +++ b/dali/internal/graphics/vulkan/vulkan-device.cpp @@ -19,6 +19,7 @@ #include // INTERNAL INCLUDES +#include #include #include #include @@ -631,7 +632,7 @@ void Device::CreateInstance(const std::vector& 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& submi std::transform(subData.commandBuffers.cbegin(), subData.commandBuffers.cend(), std::back_inserter(commandBufferHandles), - [&](CommandBufferImpl* entry) - { + [&](CommandBufferImpl* entry) { return entry->GetVkHandle(); }); diff --git a/dali/internal/imaging/common/file-download.cpp b/dali/internal/imaging/common/file-download.cpp index bd3a780..de90305 100644 --- a/dali/internal/imaging/common/file-download.cpp +++ b/dali/internal/imaging/common/file-download.cpp @@ -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); diff --git a/dali/internal/system/common/environment-options.cpp b/dali/internal/system/common/environment-options.cpp index 932336e..21d0520 100644 --- a/dali/internal/system/common/environment-options.cpp +++ b/dali/internal/system/common/environment-options.cpp @@ -25,6 +25,7 @@ #include // INTERNAL INCLUDES +#include #include #include @@ -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; diff --git a/dali/internal/system/macos/system-settings-mac.cpp b/dali/internal/system/macos/system-settings-mac.cpp index 98c59ea..7544502 100644 --- a/dali/internal/system/macos/system-settings-mac.cpp +++ b/dali/internal/system/macos/system-settings-mac.cpp @@ -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 +// INTERNAL INCLUDES +#include + 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) { diff --git a/dali/internal/system/tizen-wayland/system-settings-tizen.cpp b/dali/internal/system/tizen-wayland/system-settings-tizen.cpp index 1e9d53d..f40d85c 100644 --- a/dali/internal/system/tizen-wayland/system-settings-tizen.cpp +++ b/dali/internal/system/tizen-wayland/system-settings-tizen.cpp @@ -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 #endif // TIZEN_PLATFORM_CONFIG_SUPPORTED +#include 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 += "/"; } diff --git a/dali/internal/system/tizen-wayland/widget-application-impl-tizen.cpp b/dali/internal/system/tizen-wayland/widget-application-impl-tizen.cpp index d80d2e8..9ab2aca 100644 --- a/dali/internal/system/tizen-wayland/widget-application-impl-tizen.cpp +++ b/dali/internal/system/tizen-wayland/widget-application-impl-tizen.cpp @@ -19,10 +19,11 @@ #include // INTERNAL INCLUDE -#include +#include #include #include #include +#include #include #include @@ -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; } diff --git a/dali/internal/system/ubuntu-x11/system-settings-x.cpp b/dali/internal/system/ubuntu-x11/system-settings-x.cpp index bd37ba8..8158df8 100644 --- a/dali/internal/system/ubuntu-x11/system-settings-x.cpp +++ b/dali/internal/system/ubuntu-x11/system-settings-x.cpp @@ -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 +// INTERNAL INCLUDES +#include + 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) { diff --git a/dali/internal/system/windows/system-settings-win.cpp b/dali/internal/system/windows/system-settings-win.cpp index 6dd6ab7..7b44ed3 100644 --- a/dali/internal/system/windows/system-settings-win.cpp +++ b/dali/internal/system/windows/system-settings-win.cpp @@ -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 +// INTERNAL INCLUDES +#include + 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) { diff --git a/dali/internal/window-system/common/window-render-surface.cpp b/dali/internal/window-system/common/window-render-surface.cpp index fa05aca..c5185df 100644 --- a/dali/internal/window-system/common/window-render-surface.cpp +++ b/dali/internal/window-system/common/window-render-surface.cpp @@ -23,6 +23,7 @@ #include // INTERNAL INCLUDES +#include #include #include #include @@ -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) diff --git a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp index 282e85f..6275b23 100644 --- a/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp +++ b/dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp @@ -19,6 +19,7 @@ #include // INTERNAL HEADERS +#include #include #include #include @@ -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, diff --git a/dali/internal/window-system/x11/window-base-x.cpp b/dali/internal/window-system/x11/window-base-x.cpp index 616b8ce..47e399d 100644 --- a/dali/internal/window-system/x11/window-base-x.cpp +++ b/dali/internal/window-system/x11/window-base-x.cpp @@ -19,6 +19,7 @@ #include // INTERNAL HEADERS +#include #include #include #include @@ -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); -- 2.7.4