# HG changeset patch # User Sebastien Jodogne # Date 1435325588 -7200 # Node ID d7bd116777eb236828ba188c3e2d32456039d4d4 # Parent c6ac4deb303bc190d553996d5452045387926538 Use of OrthancPluginGetConfiguration diff -r c6ac4deb303b -r d7bd116777eb Plugin/ViewerToolbox.cpp --- a/Plugin/ViewerToolbox.cpp Wed Jun 24 16:21:47 2015 +0200 +++ b/Plugin/ViewerToolbox.cpp Fri Jun 26 15:33:08 2015 +0200 @@ -27,7 +27,6 @@ #include #include #include -#include #include namespace OrthancPlugins @@ -216,33 +215,30 @@ bool ReadConfiguration(Json::Value& configuration, OrthancPluginContext* context) { - std::string path; + std::string s; { - char* pathTmp = OrthancPluginGetConfigurationPath(context); - if (pathTmp == NULL) + char* tmp = OrthancPluginGetConfiguration(context); + if (tmp == NULL) { - OrthancPluginLogError(context, "No configuration file is provided"); + OrthancPluginLogError(context, "Error while retrieving the configuration from Orthanc"); return false; } - path = std::string(pathTmp); - - OrthancPluginFreeString(context, pathTmp); + s.assign(tmp); + OrthancPluginFreeString(context, tmp); } - std::ifstream f(path.c_str()); - Json::Reader reader; - if (!reader.parse(f, configuration) || - configuration.type() != Json::objectValue) + if (reader.parse(s, configuration)) { - std::string s = "Unable to parse the configuration file: " + std::string(path); - OrthancPluginLogError(context, s.c_str()); + return true; + } + else + { + OrthancPluginLogError(context, "Unable to parse the configuration"); return false; } - - return true; }