changeset 5544:dce22a789a2b

Multitenant DICOM plugin: added support for locales
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 22 Mar 2024 18:56:46 +0100
parents cd698247b029
children f8b9eaa5effa
files NEWS OrthancFramework/Resources/CMake/BoostConfiguration.cmake OrthancServer/Plugins/Samples/MultitenantDicom/CMakeLists.txt OrthancServer/Plugins/Samples/MultitenantDicom/OrthancFrameworkDependencies.cpp OrthancServer/Plugins/Samples/MultitenantDicom/Plugin.cpp
diffstat 5 files changed, 48 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Mar 22 16:02:37 2024 +0100
+++ b/NEWS	Fri Mar 22 18:56:46 2024 +0100
@@ -11,13 +11,16 @@
   could slow down the response time.  Note that this seems to happen mainly 
   when the query originates from some GE devices (AWS).
 
-
 REST API
 --------
 
 * API version upgraded to 24
 * Added "MaximumPatientCount" in /system
 
+Plugins
+-------
+
+* Multitenant DICOM plugin: added support for locales
 
 
 Version 1.12.3 (2024-01-31)
--- a/OrthancFramework/Resources/CMake/BoostConfiguration.cmake	Fri Mar 22 16:02:37 2024 +0100
+++ b/OrthancFramework/Resources/CMake/BoostConfiguration.cmake	Fri Mar 22 18:56:46 2024 +0100
@@ -319,6 +319,7 @@
       ${BOOST_SOURCES_DIR}/libs/locale/src/boost/locale/icu/conversion.cpp
       ${BOOST_SOURCES_DIR}/libs/locale/src/boost/locale/icu/date_time.cpp
       ${BOOST_SOURCES_DIR}/libs/locale/src/boost/locale/icu/formatter.cpp
+      ${BOOST_SOURCES_DIR}/libs/locale/src/boost/locale/icu/formatters_cache.cpp
       ${BOOST_SOURCES_DIR}/libs/locale/src/boost/locale/icu/icu_backend.cpp
       ${BOOST_SOURCES_DIR}/libs/locale/src/boost/locale/icu/numeric.cpp
       ${BOOST_SOURCES_DIR}/libs/locale/src/boost/locale/icu/time_zone.cpp
--- a/OrthancServer/Plugins/Samples/MultitenantDicom/CMakeLists.txt	Fri Mar 22 16:02:37 2024 +0100
+++ b/OrthancServer/Plugins/Samples/MultitenantDicom/CMakeLists.txt	Fri Mar 22 18:56:46 2024 +0100
@@ -30,6 +30,7 @@
 include(${CMAKE_SOURCE_DIR}/../../../../OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake)
 
 set(ENABLE_LOCALE ON CACHE INTERNAL "")
+set(ENABLE_ZLIB ON CACHE INTERNAL "")  # This is necessary for static builds with ICU
 set(ENABLE_DCMTK ON CACHE INTERNAL "")
 set(ENABLE_DCMTK_NETWORKING ON CACHE INTERNAL "")
 set(ENABLE_DCMTK_TRANSCODING OFF CACHE INTERNAL "")
--- a/OrthancServer/Plugins/Samples/MultitenantDicom/OrthancFrameworkDependencies.cpp	Fri Mar 22 16:02:37 2024 +0100
+++ b/OrthancServer/Plugins/Samples/MultitenantDicom/OrthancFrameworkDependencies.cpp	Fri Mar 22 18:56:46 2024 +0100
@@ -86,8 +86,20 @@
 #include "../../../../OrthancFramework/Sources/MultiThreading/RunnableWorkersPool.cpp"
 #include "../../../../OrthancFramework/Sources/MultiThreading/SharedMessageQueue.cpp"
 #include "../../../../OrthancFramework/Sources/OrthancException.cpp"
+#include "../../../../OrthancFramework/Sources/OrthancFramework.cpp"
 #include "../../../../OrthancFramework/Sources/RestApi/RestApiOutput.cpp"
 #include "../../../../OrthancFramework/Sources/SerializationToolbox.cpp"
 #include "../../../../OrthancFramework/Sources/SystemToolbox.cpp"
+#include "../../../../OrthancFramework/Sources/TemporaryFile.cpp"
 #include "../../../../OrthancFramework/Sources/Toolbox.cpp"
-#include "../../../../OrthancFramework/Sources/TemporaryFile.cpp"
+
+namespace Orthanc
+{
+  void HttpClient::GlobalInitialize()
+  {
+  }
+
+  void HttpClient::GlobalFinalize()
+  {
+  }
+}
--- a/OrthancServer/Plugins/Samples/MultitenantDicom/Plugin.cpp	Fri Mar 22 16:02:37 2024 +0100
+++ b/OrthancServer/Plugins/Samples/MultitenantDicom/Plugin.cpp	Fri Mar 22 18:56:46 2024 +0100
@@ -27,6 +27,7 @@
 #include "../../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
 #include "../../../../OrthancFramework/Sources/Logging.h"
 #include "../../../../OrthancFramework/Sources/OrthancException.h"
+#include "../../../../OrthancFramework/Sources/OrthancFramework.h"
 
 #include "../Common/OrthancPluginCppWrapper.h"
 
@@ -90,6 +91,31 @@
 }
 
 
+static void MyInitialization(const OrthancPlugins::OrthancConfiguration& config)
+{
+  static const char* const LOCALE = "Locale";
+  static const char* const DEFAULT_ENCODING = "DefaultEncoding";
+
+  /**
+   * This function is a simplified version of function
+   * "Orthanc::OrthancInitialize()" that is executed when starting the
+   * Orthanc server.
+   **/
+
+  Orthanc::InitializeFramework(config.GetStringValue(LOCALE, ""), false /* loadPrivateDictionary */);
+
+  std::string encoding;
+  if (config.LookupStringValue(encoding, DEFAULT_ENCODING))
+  {
+    Orthanc::SetDefaultDicomEncoding(Orthanc::StringToEncoding(encoding.c_str()));
+  }
+  else
+  {
+    Orthanc::SetDefaultDicomEncoding(Orthanc::ORTHANC_DEFAULT_DICOM_ENCODING);
+  }
+}
+
+
 extern "C"
 {
   ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
@@ -121,13 +147,6 @@
       return -1;
     }
 
-    // For static builds, this is not required - but does not harm - because the dictionary seems to be shared between the Orthanc Core and the plugin.
-    // For dynamic builds, this is however required.  See https://discourse.orthanc-server.org/t/dimse-failure-using-multitenant-plugin/3665
-    Orthanc::FromDcmtkBridge::InitializeDictionary(false /* loadPrivateDictionary */);
-
-    /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */
-    dcmDisableGethostbyaddr.set(OFTrue);
-
     OrthancPluginSetDescription2(context, ORTHANC_PLUGIN_NAME, "Multitenant plugin for Orthanc.");
 
     OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback);
@@ -135,6 +154,7 @@
     try
     {
       OrthancPlugins::OrthancConfiguration globalConfig;
+      MyInitialization(globalConfig);
 
       OrthancPlugins::OrthancConfiguration pluginConfig;
       globalConfig.GetSection(pluginConfig, KEY_MULTITENANT_DICOM);
@@ -183,6 +203,8 @@
         }
       }
     }
+
+    Orthanc::FinalizeFramework();
   }