# HG changeset patch # User Sebastien Jodogne # Date 1466762169 -7200 # Node ID 972a2cca130d83e5fda91bf2d04bd1aac6b8edcf # Parent 17c916a8bc6534186f8a1a52e77781fae640d00d default encoding diff -r 17c916a8bc65 -r 972a2cca130d Plugin/Configuration.cpp --- a/Plugin/Configuration.cpp Fri Jun 24 11:45:21 2016 +0200 +++ b/Plugin/Configuration.cpp Fri Jun 24 11:56:09 2016 +0200 @@ -353,6 +353,8 @@ namespace Configuration { + // Assume Latin-1 encoding by default (as in the Orthanc core) + static Orthanc::Encoding defaultEncoding_ = Orthanc::Encoding_Latin1; static OrthancConfiguration configuration_; @@ -361,6 +363,13 @@ OrthancPlugins::OrthancConfiguration global(context); global.GetSection(configuration_, "DicomWeb"); + std::string s; + if (global.LookupStringValue(s, "DefaultEncoding")) + { + defaultEncoding_ = Orthanc::StringToEncoding(s.c_str()); + printf(">> [%s] [%d]\n", s.c_str(), defaultEncoding_); + } + OrthancPlugins::OrthancConfiguration servers; configuration_.GetSection(servers, "Servers"); OrthancPlugins::DicomWebServers::GetInstance().Load(servers.GetJson()); @@ -482,5 +491,11 @@ { OrthancPluginLogInfo(GetContext(), message.c_str()); } + + + Orthanc::Encoding GetDefaultEncoding() + { + return defaultEncoding_; + } } } diff -r 17c916a8bc65 -r 972a2cca130d Plugin/Configuration.h --- a/Plugin/Configuration.h Fri Jun 24 11:45:21 2016 +0200 +++ b/Plugin/Configuration.h Fri Jun 24 11:56:09 2016 +0200 @@ -20,6 +20,8 @@ #pragma once +#include "../Orthanc/Core/Enumerations.h" + #include #include @@ -33,7 +35,6 @@ namespace OrthancPlugins { - // TODO MOVE THIS to DicomWebServers struct MultipartItem { const char* data_; @@ -107,5 +108,7 @@ void LogWarning(const std::string& message); void LogInfo(const std::string& message); + + Orthanc::Encoding GetDefaultEncoding(); } } diff -r 17c916a8bc65 -r 972a2cca130d Plugin/Dicom.cpp --- a/Plugin/Dicom.cpp Fri Jun 24 11:45:21 2016 +0200 +++ b/Plugin/Dicom.cpp Fri Jun 24 11:56:09 2016 +0200 @@ -370,8 +370,7 @@ const gdcm::ByteValue* data = element.GetByteValue(); if (!data) { - // Assume Latin-1 encoding (TODO add a parameter as in Orthanc) - return Orthanc::Encoding_Latin1; + return Configuration::GetDefaultEncoding(); } std::string tmp(data->GetPointer(), data->GetLength()); @@ -384,8 +383,7 @@ } else { - // Assume Latin-1 encoding (TODO add a parameter as in Orthanc) - return Orthanc::Encoding_Latin1; + return Configuration::GetDefaultEncoding(); } } diff -r 17c916a8bc65 -r 972a2cca130d Plugin/Plugin.cpp --- a/Plugin/Plugin.cpp Fri Jun 24 11:45:21 2016 +0200 +++ b/Plugin/Plugin.cpp Fri Jun 24 11:56:09 2016 +0200 @@ -520,6 +520,12 @@ std::string(e.GetErrorDescription(context))); return -1; } + catch (Orthanc::OrthancException& e) + { + OrthancPlugins::Configuration::LogError("Exception while initializing the DICOMweb plugin: " + + std::string(e.What())); + return -1; + } catch (...) { OrthancPlugins::Configuration::LogError("Exception while initializing the DICOMweb plugin");