comparison OrthancServer/Plugins/Engine/OrthancPlugins.cpp @ 4819:70d2a97ca8cb openssl-3.x

integration mainline->openssl-3.x
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 25 Nov 2021 13:12:32 +0100
parents f0038043fb97 0bd98c52474b
children 2e71a08eea15
comparison
equal deleted inserted replaced
4785:61da49321754 4819:70d2a97ca8cb
65 #include "PluginsJob.h" 65 #include "PluginsJob.h"
66 66
67 #include <boost/regex.hpp> 67 #include <boost/regex.hpp>
68 #include <dcmtk/dcmdata/dcdict.h> 68 #include <dcmtk/dcmdata/dcdict.h>
69 #include <dcmtk/dcmdata/dcdicent.h> 69 #include <dcmtk/dcmdata/dcdicent.h>
70 #include <dcmtk/dcmnet/dimse.h>
70 71
71 #define ERROR_MESSAGE_64BIT "A 64bit version of the Orthanc API is necessary" 72 #define ERROR_MESSAGE_64BIT "A 64bit version of the Orthanc API is necessary"
72 73
73 74
74 namespace Orthanc 75 namespace Orthanc
1151 typedef std::list<OrthancPluginOnStoredInstanceCallback> OnStoredCallbacks; 1152 typedef std::list<OrthancPluginOnStoredInstanceCallback> OnStoredCallbacks;
1152 typedef std::list<OrthancPluginOnChangeCallback> OnChangeCallbacks; 1153 typedef std::list<OrthancPluginOnChangeCallback> OnChangeCallbacks;
1153 typedef std::list<OrthancPluginIncomingHttpRequestFilter> IncomingHttpRequestFilters; 1154 typedef std::list<OrthancPluginIncomingHttpRequestFilter> IncomingHttpRequestFilters;
1154 typedef std::list<OrthancPluginIncomingHttpRequestFilter2> IncomingHttpRequestFilters2; 1155 typedef std::list<OrthancPluginIncomingHttpRequestFilter2> IncomingHttpRequestFilters2;
1155 typedef std::list<OrthancPluginIncomingDicomInstanceFilter> IncomingDicomInstanceFilters; 1156 typedef std::list<OrthancPluginIncomingDicomInstanceFilter> IncomingDicomInstanceFilters;
1157 typedef std::list<OrthancPluginIncomingCStoreInstanceFilter> IncomingCStoreInstanceFilters;
1156 typedef std::list<OrthancPluginDecodeImageCallback> DecodeImageCallbacks; 1158 typedef std::list<OrthancPluginDecodeImageCallback> DecodeImageCallbacks;
1157 typedef std::list<OrthancPluginTranscoderCallback> TranscoderCallbacks; 1159 typedef std::list<OrthancPluginTranscoderCallback> TranscoderCallbacks;
1158 typedef std::list<OrthancPluginJobsUnserializer> JobsUnserializers; 1160 typedef std::list<OrthancPluginJobsUnserializer> JobsUnserializers;
1159 typedef std::list<OrthancPluginRefreshMetricsCallback> RefreshMetricsCallbacks; 1161 typedef std::list<OrthancPluginRefreshMetricsCallback> RefreshMetricsCallbacks;
1160 typedef std::list<StorageCommitmentScp*> StorageCommitmentScpCallbacks; 1162 typedef std::list<StorageCommitmentScp*> StorageCommitmentScpCallbacks;
1173 JobsUnserializers jobsUnserializers_; 1175 JobsUnserializers jobsUnserializers_;
1174 _OrthancPluginMoveCallback moveCallbacks_; 1176 _OrthancPluginMoveCallback moveCallbacks_;
1175 IncomingHttpRequestFilters incomingHttpRequestFilters_; 1177 IncomingHttpRequestFilters incomingHttpRequestFilters_;
1176 IncomingHttpRequestFilters2 incomingHttpRequestFilters2_; 1178 IncomingHttpRequestFilters2 incomingHttpRequestFilters2_;
1177 IncomingDicomInstanceFilters incomingDicomInstanceFilters_; 1179 IncomingDicomInstanceFilters incomingDicomInstanceFilters_;
1180 IncomingCStoreInstanceFilters incomingCStoreInstanceFilters_; // New in Orthanc 1.9.8
1178 RefreshMetricsCallbacks refreshMetricsCallbacks_; 1181 RefreshMetricsCallbacks refreshMetricsCallbacks_;
1179 StorageCommitmentScpCallbacks storageCommitmentScpCallbacks_; 1182 StorageCommitmentScpCallbacks storageCommitmentScpCallbacks_;
1180 std::unique_ptr<StorageAreaFactory> storageArea_; 1183 std::unique_ptr<StorageAreaFactory> storageArea_;
1181 std::set<std::string> authorizationTokens_; 1184 std::set<std::string> authorizationTokens_;
1182 1185
2247 } 2250 }
2248 2251
2249 return true; 2252 return true;
2250 } 2253 }
2251 2254
2252 2255
2256
2257 uint16_t OrthancPlugins::FilterIncomingCStoreInstance(const DicomInstanceToStore& instance,
2258 const Json::Value& simplified)
2259 {
2260 DicomInstanceFromCallback wrapped(instance);
2261
2262 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
2263
2264 for (PImpl::IncomingCStoreInstanceFilters::const_iterator
2265 filter = pimpl_->incomingCStoreInstanceFilters_.begin();
2266 filter != pimpl_->incomingCStoreInstanceFilters_.end(); ++filter)
2267 {
2268 int32_t filterResult = (*filter) (reinterpret_cast<const OrthancPluginDicomInstance*>(&wrapped));
2269
2270 if (filterResult >= 0 && filterResult <= 0xFFFF)
2271 {
2272 return static_cast<uint16_t>(filterResult);
2273 }
2274 else
2275 {
2276 // The callback is only allowed to answer uint16_t
2277 throw OrthancException(ErrorCode_Plugin);
2278 }
2279 }
2280
2281 return STATUS_Success;
2282 }
2283
2284
2253 void OrthancPlugins::SignalChangeInternal(OrthancPluginChangeType changeType, 2285 void OrthancPlugins::SignalChangeInternal(OrthancPluginChangeType changeType,
2254 OrthancPluginResourceType resourceType, 2286 OrthancPluginResourceType resourceType,
2255 const char* resource) 2287 const char* resource)
2256 { 2288 {
2257 boost::recursive_mutex::scoped_lock lock(pimpl_->changeCallbackMutex_); 2289 boost::recursive_mutex::scoped_lock lock(pimpl_->changeCallbackMutex_);
2462 const _OrthancPluginIncomingDicomInstanceFilter& p = 2494 const _OrthancPluginIncomingDicomInstanceFilter& p =
2463 *reinterpret_cast<const _OrthancPluginIncomingDicomInstanceFilter*>(parameters); 2495 *reinterpret_cast<const _OrthancPluginIncomingDicomInstanceFilter*>(parameters);
2464 2496
2465 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to filter incoming DICOM instances"; 2497 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to filter incoming DICOM instances";
2466 pimpl_->incomingDicomInstanceFilters_.push_back(p.callback); 2498 pimpl_->incomingDicomInstanceFilters_.push_back(p.callback);
2499 }
2500
2501
2502 void OrthancPlugins::RegisterIncomingCStoreInstanceFilter(const void* parameters)
2503 {
2504 const _OrthancPluginIncomingCStoreInstanceFilter& p =
2505 *reinterpret_cast<const _OrthancPluginIncomingCStoreInstanceFilter*>(parameters);
2506
2507 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to filter incoming C-Store DICOM instances";
2508 pimpl_->incomingCStoreInstanceFilters_.push_back(p.callback);
2467 } 2509 }
2468 2510
2469 2511
2470 void OrthancPlugins::RegisterRefreshMetricsCallback(const void* parameters) 2512 void OrthancPlugins::RegisterRefreshMetricsCallback(const void* parameters)
2471 { 2513 {
4943 4985
4944 case _OrthancPluginService_RegisterIncomingDicomInstanceFilter: 4986 case _OrthancPluginService_RegisterIncomingDicomInstanceFilter:
4945 RegisterIncomingDicomInstanceFilter(parameters); 4987 RegisterIncomingDicomInstanceFilter(parameters);
4946 return true; 4988 return true;
4947 4989
4990 case _OrthancPluginService_RegisterIncomingCStoreInstanceFilter:
4991 RegisterIncomingCStoreInstanceFilter(parameters);
4992 return true;
4993
4948 case _OrthancPluginService_RegisterRefreshMetricsCallback: 4994 case _OrthancPluginService_RegisterRefreshMetricsCallback:
4949 RegisterRefreshMetricsCallback(parameters); 4995 RegisterRefreshMetricsCallback(parameters);
4950 return true; 4996 return true;
4951 4997
4952 case _OrthancPluginService_RegisterStorageCommitmentScpCallback: 4998 case _OrthancPluginService_RegisterStorageCommitmentScpCallback: