# HG changeset patch # User Sebastien Jodogne # Date 1405595042 -7200 # Node ID d06186cdc502f6ebb8d2fd6ae621c1f8e24afb8b # Parent 5a5a4890ffca867761f2099f1974fbd4969f997f check plugin version in samples diff -r 5a5a4890ffca -r d06186cdc502 Plugins/OrthancCPlugin/OrthancCPlugin.h --- a/Plugins/OrthancCPlugin/OrthancCPlugin.h Thu Jul 17 12:46:00 2014 +0200 +++ b/Plugins/OrthancCPlugin/OrthancCPlugin.h Thu Jul 17 13:04:02 2014 +0200 @@ -372,7 +372,6 @@ /* Assume compatibility with the mainline */ if (!strcmp(context->orthancVersion, "mainline")) { - printf("mainline\n"); return 1; } @@ -414,7 +413,7 @@ /* Check the revision number of the version */ - if (revision >= ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER) + if (revision >= ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER) { return 1; } diff -r 5a5a4890ffca -r d06186cdc502 Plugins/Samples/Basic/Plugin.c --- a/Plugins/Samples/Basic/Plugin.c Thu Jul 17 12:46:00 2014 +0200 +++ b/Plugins/Samples/Basic/Plugin.c Thu Jul 17 13:04:02 2014 +0200 @@ -134,21 +134,21 @@ char info[1024]; char *id, *eos; - char error[256]; + context = c; + OrthancPluginLogWarning(context, "Sample plugin is initializing"); + + /* Check the version of the Orthanc core */ if (OrthancPluginCheckVersion(c) == 0) { - sprintf(error, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", + sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", c->orthancVersion, ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); - OrthancPluginLogError(context, error); + OrthancPluginLogError(context, info); return -1; } - context = c; - OrthancPluginLogWarning(context, "Sample plugin is initializing"); - sprintf(info, "The version of Orthanc is '%s'", context->orthancVersion); OrthancPluginLogInfo(context, info); diff -r 5a5a4890ffca -r d06186cdc502 Plugins/Samples/GdcmDecoding/OrthancContext.cpp --- a/Plugins/Samples/GdcmDecoding/OrthancContext.cpp Thu Jul 17 12:46:00 2014 +0200 +++ b/Plugins/Samples/GdcmDecoding/OrthancContext.cpp Thu Jul 17 13:04:02 2014 +0200 @@ -46,15 +46,6 @@ } -OrthancContext::~OrthancContext() -{ - if (context_ != NULL) - { - throw std::runtime_error("The Orthanc plugin was not properly finalized"); - } -} - - void OrthancContext::ExtractGetArguments(Arguments& arguments, const OrthancPluginHttpRequest& request) { diff -r 5a5a4890ffca -r d06186cdc502 Plugins/Samples/GdcmDecoding/OrthancContext.h --- a/Plugins/Samples/GdcmDecoding/OrthancContext.h Thu Jul 17 12:46:00 2014 +0200 +++ b/Plugins/Samples/GdcmDecoding/OrthancContext.h Thu Jul 17 13:04:02 2014 +0200 @@ -52,8 +52,6 @@ static OrthancContext& GetInstance(); - ~OrthancContext(); - void Initialize(OrthancPluginContext* context) { context_ = context; diff -r 5a5a4890ffca -r d06186cdc502 Plugins/Samples/GdcmDecoding/Plugin.cpp --- a/Plugins/Samples/GdcmDecoding/Plugin.cpp Thu Jul 17 12:46:00 2014 +0200 +++ b/Plugins/Samples/GdcmDecoding/Plugin.cpp Thu Jul 17 13:04:02 2014 +0200 @@ -29,6 +29,7 @@ #include #include #include +#include #include "OrthancContext.h" #include "../../../Core/ImageFormats/ImageProcessing.h" @@ -235,6 +236,19 @@ { OrthancContext::GetInstance().Initialize(context); OrthancContext::GetInstance().LogWarning("Initializing GDCM decoding"); + + // Check the version of the Orthanc core + if (OrthancPluginCheckVersion(context) == 0) + { + OrthancContext::GetInstance().LogError( + "Your version of Orthanc (" + std::string(context->orthancVersion) + + ") must be above " + boost::lexical_cast(ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER) + + "." + boost::lexical_cast(ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER) + + "." + boost::lexical_cast(ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER) + + " to run this plugin"); + return -1; + } + OrthancContext::GetInstance().Register("/instances/([^/]+)/(preview|image-uint8|image-uint16|image-int16)", DecodeImage); return 0; }