comparison Applications/DicomToTiff.cpp @ 125:7a3f4d580625

SSL is enabled by default for HTTPS transfers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 Feb 2018 17:34:35 +0100
parents a51dee6a1515
children 788dd04b87f5
comparison
equal deleted inserted replaced
124:24bd36849c56 125:7a3f4d580625
29 #include "../Resources/Orthanc/Core/OrthancException.h" 29 #include "../Resources/Orthanc/Core/OrthancException.h"
30 #include "../Resources/Orthanc/Plugins/Samples/Common/OrthancHttpConnection.h" 30 #include "../Resources/Orthanc/Plugins/Samples/Common/OrthancHttpConnection.h"
31 31
32 #include "ApplicationToolbox.h" 32 #include "ApplicationToolbox.h"
33 33
34 #include <boost/program_options.hpp>
35
36 34
37 static bool ParseParameters(int& exitStatus, 35 static bool ParseParameters(int& exitStatus,
38 boost::program_options::variables_map& options, 36 boost::program_options::variables_map& options,
39 int argc, 37 int argc,
40 char* argv[]) 38 char* argv[])
49 47
50 boost::program_options::options_description source("Options for the source DICOM image"); 48 boost::program_options::options_description source("Options for the source DICOM image");
51 source.add_options() 49 source.add_options()
52 ("orthanc", boost::program_options::value<std::string>()->default_value("http://localhost:8042/"), 50 ("orthanc", boost::program_options::value<std::string>()->default_value("http://localhost:8042/"),
53 "URL to the REST API of the target Orthanc server") 51 "URL to the REST API of the target Orthanc server")
54 ("username", boost::program_options::value<std::string>(), "Username for the target Orthanc server")
55 ("password", boost::program_options::value<std::string>(), "Password for the target Orthanc server")
56 ; 52 ;
53 OrthancWSI::ApplicationToolbox::AddRestApiOptions(source);
57 54
58 boost::program_options::options_description target("Options for the target TIFF image"); 55 boost::program_options::options_description target("Options for the target TIFF image");
59 target.add_options() 56 target.add_options()
60 ("color", boost::program_options::value<std::string>(), "Color of the background for missing tiles (e.g. \"255,0,0\")") 57 ("color", boost::program_options::value<std::string>(), "Color of the background for missing tiles (e.g. \"255,0,0\")")
61 ("reencode", boost::program_options::value<bool>(), 58 ("reencode", boost::program_options::value<bool>(),
284 { 281 {
285 if (ParseParameters(exitStatus, options, argc, argv)) 282 if (ParseParameters(exitStatus, options, argc, argv))
286 { 283 {
287 Orthanc::WebServiceParameters params; 284 Orthanc::WebServiceParameters params;
288 285
289 if (options.count("orthanc")) 286 OrthancWSI::ApplicationToolbox::SetupRestApi(params, options);
290 {
291 params.SetUrl(options["orthanc"].as<std::string>());
292 }
293
294 if (options.count("username"))
295 {
296 params.SetUsername(options["username"].as<std::string>());
297 }
298
299 if (options.count("password"))
300 {
301 params.SetPassword(options["password"].as<std::string>());
302 }
303 287
304 OrthancPlugins::OrthancHttpConnection orthanc(params); 288 OrthancPlugins::OrthancHttpConnection orthanc(params);
305 OrthancWSI::DicomPyramid source(orthanc, options["input"].as<std::string>(), 289 OrthancWSI::DicomPyramid source(orthanc, options["input"].as<std::string>(),
306 false /* don't use cached metadata */); 290 false /* don't use cached metadata */);
307 291