Mercurial > hg > orthanc-dicomweb
changeset 132:972a2cca130d dev
default encoding
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 24 Jun 2016 11:56:09 +0200 |
parents | 17c916a8bc65 |
children | a6c099292e55 |
files | Plugin/Configuration.cpp Plugin/Configuration.h Plugin/Dicom.cpp Plugin/Plugin.cpp |
diffstat | 4 files changed, 27 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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_; + } } }
--- 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 <orthanc/OrthancCPlugin.h> #include <json/value.h> @@ -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(); } }
--- 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(); } }
--- 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");