annotate OrthancServer/Plugins/Engine/OrthancPlugins.cpp @ 5412:1a351a141653

ServerContextLock -> ServerContextReference to allow multiple plugins to use it at the same time
author Alain Mazy <am@osimis.io>
date Wed, 08 Nov 2023 08:55:42 +0100
parents ca9cf4d46883
children 59e3b6f8c5be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1882
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1282
diff changeset
4 * Department, University Hospital of Liege, Belgium
5185
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5138
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5138
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
23 #include "../../Sources/PrecompiledHeadersServer.h"
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
24 #include "OrthancPlugins.h"
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2135
diff changeset
26 #if ORTHANC_ENABLE_PLUGINS != 1
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
27 #error The plugin support is disabled
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
28 #endif
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
29
3118
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
30 #if !defined(DCMTK_VERSION_NUMBER)
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
31 # error The macro DCMTK_VERSION_NUMBER must be defined
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
32 #endif
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
33
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
34
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
35 #include "../../../OrthancFramework/Sources/Compression/GzipCompressor.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
36 #include "../../../OrthancFramework/Sources/Compression/ZlibCompressor.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
37 #include "../../../OrthancFramework/Sources/DicomFormat/DicomArray.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
38 #include "../../../OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
39 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
40 #include "../../../OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
41 #include "../../../OrthancFramework/Sources/DicomParsing/ToDcmtkBridge.h"
4943
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
42 #include "../../../OrthancFramework/Sources/HttpServer/HttpServer.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
43 #include "../../../OrthancFramework/Sources/HttpServer/HttpToolbox.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
44 #include "../../../OrthancFramework/Sources/Images/Image.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
45 #include "../../../OrthancFramework/Sources/Images/ImageProcessing.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
46 #include "../../../OrthancFramework/Sources/Images/JpegReader.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
47 #include "../../../OrthancFramework/Sources/Images/JpegWriter.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
48 #include "../../../OrthancFramework/Sources/Images/PngReader.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
49 #include "../../../OrthancFramework/Sources/Images/PngWriter.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
50 #include "../../../OrthancFramework/Sources/Logging.h"
4105
c02a2d9efbc2 move FromDcmtkBridge::ExecuteToDicom() to LuaFunctionCall, to remove dependency of DCMTK on Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4087
diff changeset
51 #include "../../../OrthancFramework/Sources/Lua/LuaFunctionCall.h"
4484
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
52 #include "../../../OrthancFramework/Sources/MallocMemoryBuffer.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
53 #include "../../../OrthancFramework/Sources/MetricsRegistry.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
54 #include "../../../OrthancFramework/Sources/OrthancException.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
55 #include "../../../OrthancFramework/Sources/SerializationToolbox.h"
4495
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
56 #include "../../../OrthancFramework/Sources/StringMemoryBuffer.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
57 #include "../../../OrthancFramework/Sources/Toolbox.h"
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
58 #include "../../Sources/Database/VoidDatabaseListener.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
59 #include "../../Sources/OrthancConfiguration.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
60 #include "../../Sources/OrthancFindRequestHandler.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
61 #include "../../Sources/Search/HierarchicalMatcher.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
62 #include "../../Sources/ServerContext.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
63 #include "../../Sources/ServerToolbox.h"
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
64 #include "OrthancPluginDatabase.h"
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
65 #include "OrthancPluginDatabaseV3.h"
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
66 #include "OrthancPluginDatabaseV4.h"
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
67 #include "PluginsEnumerations.h"
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
68 #include "PluginsJob.h"
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
5330
808319c1e22b fix msvc build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5328
diff changeset
70 #include <boost/math/special_functions/round.hpp>
3926
2910b0d30fe0 Allow concurrent calls to the custom image decoders provided by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3925
diff changeset
71 #include <boost/regex.hpp>
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
72 #include <dcmtk/dcmdata/dcdict.h>
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
73 #include <dcmtk/dcmdata/dcdicent.h>
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
74 #include <dcmtk/dcmnet/dimse.h>
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
4912
45d6ce72a84e fix linking of Sanitizer sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4902
diff changeset
76 #define ERROR_MESSAGE_64BIT "A 64bit version of the Orthanc SDK is necessary to use buffers > 4GB, but is currently not available"
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
77
3926
2910b0d30fe0 Allow concurrent calls to the custom image decoders provided by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3925
diff changeset
78
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 namespace Orthanc
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 {
4943
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
81 class OrthancPlugins::WebDavCollection : public IWebDavBucket
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
82 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
83 private:
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
84 PluginsErrorDictionary& errorDictionary_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
85 std::string uri_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
86 OrthancPluginWebDavIsExistingFolderCallback isExistingFolder_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
87 OrthancPluginWebDavListFolderCallback listFolder_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
88 OrthancPluginWebDavRetrieveFileCallback retrieveFile_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
89 OrthancPluginWebDavStoreFileCallback storeFile_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
90 OrthancPluginWebDavCreateFolderCallback createFolder_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
91 OrthancPluginWebDavDeleteItemCallback deleteItem_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
92 void* payload_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
93
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
94 class PathHelper : public boost::noncopyable
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
95 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
96 private:
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
97 std::vector<const char*> items_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
98
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
99 public:
4956
964bbf5cb365 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4943
diff changeset
100 explicit PathHelper(const std::vector<std::string>& path)
4943
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
101 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
102 items_.resize(path.size());
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
103 for (size_t i = 0; i < path.size(); i++)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
104 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
105 items_[i] = path[i].c_str();
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
106 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
107 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
108
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
109 uint32_t GetSize() const
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
110 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
111 return static_cast<uint32_t>(items_.size());
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
112 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
113
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
114 const char* const* GetItems() const
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
115 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
116 return (items_.empty() ? NULL : &items_[0]);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
117 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
118 };
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
119
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
120
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
121 static MimeType ParseMimeType(const char* mimeType)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
122 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
123 MimeType mime;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
124 if (LookupMimeType(mime, mimeType))
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
125 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
126 return mime;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
127 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
128 else
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
129 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
130 LOG(WARNING) << "Unknown MIME type in plugin: " << mimeType;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
131 return MimeType_Binary;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
132 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
133 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
134
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
135 static OrthancPluginErrorCode AddFile(
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
136 OrthancPluginWebDavCollection* collection,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
137 const char* displayName,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
138 uint64_t contentSize,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
139 const char* mimeType,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
140 const char* creationTime)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
141 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
142 try
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
143 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
144 std::unique_ptr<File> f(new File(displayName));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
145 f->SetCreationTime(boost::posix_time::from_iso_string(creationTime));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
146 f->SetContentLength(contentSize);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
147
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
148 if (mimeType == NULL ||
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
149 std::string(mimeType).empty())
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
150 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
151 f->SetMimeType(SystemToolbox::AutodetectMimeType(displayName));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
152 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
153 else
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
154 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
155 f->SetMimeType(ParseMimeType(mimeType));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
156 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
157
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
158 reinterpret_cast<Collection*>(collection)->AddResource(f.release());
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
159 return OrthancPluginErrorCode_Success;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
160 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
161 catch (OrthancException& e)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
162 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
163 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode());
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
164 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
165 catch (...)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
166 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
167 return OrthancPluginErrorCode_InternalError;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
168 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
169 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
170
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
171 static OrthancPluginErrorCode AddFolder(
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
172 OrthancPluginWebDavCollection* collection,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
173 const char* displayName,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
174 const char* creationTime)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
175 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
176 try
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
177 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
178 std::unique_ptr<Folder> f(new Folder(displayName));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
179 f->SetCreationTime(boost::posix_time::from_iso_string(creationTime));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
180 reinterpret_cast<Collection*>(collection)->AddResource(f.release());
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
181 return OrthancPluginErrorCode_Success;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
182 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
183 catch (OrthancException& e)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
184 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
185 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode());
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
186 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
187 catch (boost::bad_lexical_cast&)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
188 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
189 LOG(ERROR) << "Presumably ill-formed date in the plugin";
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
190 return OrthancPluginErrorCode_ParameterOutOfRange;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
191 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
192 catch (...)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
193 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
194 return OrthancPluginErrorCode_InternalError;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
195 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
196 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
197
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
198
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
199 class ContentTarget : public boost::noncopyable
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
200 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
201 private:
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
202 bool isSent_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
203 MimeType& mime_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
204 std::string& content_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
205 boost::posix_time::ptime& modificationTime_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
206
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
207 public:
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
208 ContentTarget(const std::string& displayName,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
209 MimeType& mime,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
210 std::string& content,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
211 boost::posix_time::ptime& modificationTime) :
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
212 isSent_(false),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
213 mime_(mime),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
214 content_(content),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
215 modificationTime_(modificationTime)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
216 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
217 mime = SystemToolbox::AutodetectMimeType(displayName);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
218 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
219
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
220 bool IsSent() const
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
221 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
222 return isSent_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
223 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
224
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
225 static OrthancPluginErrorCode RetrieveFile(
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
226 OrthancPluginWebDavCollection* collection,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
227 const void* data,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
228 uint64_t size,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
229 const char* mimeType,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
230 const char* creationTime)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
231 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
232 ContentTarget& target = *reinterpret_cast<ContentTarget*>(collection);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
233
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
234 if (target.isSent_)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
235 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
236 return OrthancPluginErrorCode_BadSequenceOfCalls;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
237 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
238 else
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
239 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
240 try
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
241 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
242 target.isSent_ = true;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
243
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
244 if (mimeType != NULL &&
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
245 !std::string(mimeType).empty())
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
246 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
247 target.mime_ = ParseMimeType(mimeType);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
248 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
249
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
250 target.content_.assign(reinterpret_cast<const char*>(data), size);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
251 target.modificationTime_ = boost::posix_time::from_iso_string(creationTime);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
252 return OrthancPluginErrorCode_Success;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
253 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
254 catch (Orthanc::OrthancException& e)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
255 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
256 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode());
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
257 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
258 catch (boost::bad_lexical_cast&)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
259 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
260 LOG(ERROR) << "Presumably ill-formed date in the plugin";
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
261 return OrthancPluginErrorCode_ParameterOutOfRange;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
262 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
263 catch (...)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
264 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
265 return OrthancPluginErrorCode_InternalError;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
266 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
267 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
268 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
269 };
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
270
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
271
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
272 public:
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
273 WebDavCollection(PluginsErrorDictionary& errorDictionary,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
274 const _OrthancPluginRegisterWebDavCollection& p) :
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
275 errorDictionary_(errorDictionary),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
276 uri_(p.uri),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
277 isExistingFolder_(p.isExistingFolder),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
278 listFolder_(p.listFolder),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
279 retrieveFile_(p.retrieveFile),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
280 storeFile_(p.storeFile),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
281 createFolder_(p.createFolder),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
282 deleteItem_(p.deleteItem),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
283 payload_(p.payload)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
284 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
285 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
286
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
287 const std::string& GetUri() const
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
288 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
289 return uri_;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
290 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
291
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
292 virtual bool IsExistingFolder(const std::vector<std::string>& path)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
293 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
294 PathHelper helper(path);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
295
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
296 uint8_t isExisting;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
297 OrthancPluginErrorCode code = isExistingFolder_(&isExisting, helper.GetSize(), helper.GetItems(), payload_);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
298
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
299 if (code == OrthancPluginErrorCode_Success)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
300 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
301 return (isExisting != 0);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
302 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
303 else
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
304 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
305 errorDictionary_.LogError(code, true);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
306 throw OrthancException(static_cast<ErrorCode>(code));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
307 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
308 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
309
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
310 virtual bool ListCollection(Collection& collection,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
311 const std::vector<std::string>& path)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
312 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
313 PathHelper helper(path);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
314
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
315 uint8_t isExisting;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
316 OrthancPluginErrorCode code = listFolder_(&isExisting, reinterpret_cast<OrthancPluginWebDavCollection*>(&collection),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
317 AddFile, AddFolder, helper.GetSize(), helper.GetItems(), payload_);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
318
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
319 if (code == OrthancPluginErrorCode_Success)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
320 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
321 return (isExisting != 0);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
322 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
323 else
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
324 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
325 errorDictionary_.LogError(code, true);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
326 throw OrthancException(static_cast<ErrorCode>(code));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
327 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
328 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
329
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
330 virtual bool GetFileContent(MimeType& mime,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
331 std::string& content,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
332 boost::posix_time::ptime& modificationTime,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
333 const std::vector<std::string>& path)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
334 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
335 PathHelper helper(path);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
336
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
337 ContentTarget target(path.back(), mime, content, modificationTime);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
338 OrthancPluginErrorCode code = retrieveFile_(
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
339 reinterpret_cast<OrthancPluginWebDavCollection*>(&target),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
340 ContentTarget::RetrieveFile, helper.GetSize(), helper.GetItems(), payload_);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
341
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
342 if (code == OrthancPluginErrorCode_Success)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
343 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
344 return target.IsSent();
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
345 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
346 else
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
347 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
348 errorDictionary_.LogError(code, true);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
349 throw OrthancException(static_cast<ErrorCode>(code));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
350 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
351 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
352
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
353 virtual bool StoreFile(const std::string& content,
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
354 const std::vector<std::string>& path)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
355 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
356 PathHelper helper(path);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
357
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
358 uint8_t isReadOnly;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
359 OrthancPluginErrorCode code = storeFile_(&isReadOnly, helper.GetSize(), helper.GetItems(),
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
360 content.empty() ? NULL : content.c_str(), content.size(), payload_);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
361
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
362 if (code == OrthancPluginErrorCode_Success)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
363 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
364 return (isReadOnly != 0);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
365 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
366 else
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
367 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
368 errorDictionary_.LogError(code, true);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
369 throw OrthancException(static_cast<ErrorCode>(code));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
370 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
371 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
372
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
373 virtual bool CreateFolder(const std::vector<std::string>& path)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
374 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
375 PathHelper helper(path);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
376
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
377 uint8_t isReadOnly;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
378 OrthancPluginErrorCode code = createFolder_(&isReadOnly, helper.GetSize(), helper.GetItems(), payload_);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
379
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
380 if (code == OrthancPluginErrorCode_Success)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
381 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
382 return (isReadOnly != 0);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
383 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
384 else
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
385 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
386 errorDictionary_.LogError(code, true);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
387 throw OrthancException(static_cast<ErrorCode>(code));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
388 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
389 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
390
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
391 virtual bool DeleteItem(const std::vector<std::string>& path)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
392 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
393 PathHelper helper(path);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
394
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
395 uint8_t isReadOnly;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
396 OrthancPluginErrorCode code = deleteItem_(&isReadOnly, helper.GetSize(), helper.GetItems(), payload_);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
397
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
398 if (code == OrthancPluginErrorCode_Success)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
399 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
400 return (isReadOnly != 0);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
401 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
402 else
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
403 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
404 errorDictionary_.LogError(code, true);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
405 throw OrthancException(static_cast<ErrorCode>(code));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
406 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
407 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
408
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
409 virtual void Start()
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
410 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
411 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
412
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
413 virtual void Stop()
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
414 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
415 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
416 };
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
417
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
418
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
419 static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
420 const void* data,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
421 size_t size)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
422 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
423 if (static_cast<uint32_t>(size) != size)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
424 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
425 throw OrthancException(ErrorCode_NotEnoughMemory, ERROR_MESSAGE_64BIT);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
426 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
427
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
428 target.size = size;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
429
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
430 if (size == 0)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
431 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
432 target.data = NULL;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
433 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
434 else
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
435 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
436 target.data = malloc(size);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
437 if (target.data != NULL)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
438 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
439 memcpy(target.data, data, size);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
440 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
441 else
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
442 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
443 throw OrthancException(ErrorCode_NotEnoughMemory);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
444 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
445 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
446 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
447
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
448
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
449 static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
450 const std::string& str)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
451 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
452 if (str.size() == 0)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
453 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
454 target.size = 0;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
455 target.data = NULL;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
456 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
457 else
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
458 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
459 CopyToMemoryBuffer(target, str.c_str(), str.size());
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
460 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
461 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
462
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
463
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
464 static char* CopyString(const std::string& str)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
465 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
466 if (static_cast<uint32_t>(str.size()) != str.size())
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
467 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
468 throw OrthancException(ErrorCode_NotEnoughMemory, ERROR_MESSAGE_64BIT);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
469 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
470
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
471 char *result = reinterpret_cast<char*>(malloc(str.size() + 1));
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
472 if (result == NULL)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
473 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
474 throw OrthancException(ErrorCode_NotEnoughMemory);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
475 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
476
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
477 if (str.size() == 0)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
478 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
479 result[0] = '\0';
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
480 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
481 else
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
482 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
483 memcpy(result, &str[0], str.size() + 1);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
484 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
485
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
486 return result;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
487 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
488
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
489
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
490 static void CopyDictionary(OrthancPluginMemoryBuffer& target,
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
491 const std::map<std::string, std::string>& dictionary)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
492 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
493 Json::Value json = Json::objectValue;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
494
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
495 for (HttpClient::HttpHeaders::const_iterator
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
496 it = dictionary.begin(); it != dictionary.end(); ++it)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
497 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
498 json[it->first] = it->second;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
499 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
500
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
501 std::string s = json.toStyledString();
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
502 CopyToMemoryBuffer(target, s);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
503 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
504
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
505
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
506 namespace
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
507 {
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
508 class MemoryBufferRaii : public boost::noncopyable
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
509 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
510 private:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
511 OrthancPluginMemoryBuffer buffer_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
512
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
513 public:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
514 MemoryBufferRaii()
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
515 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
516 buffer_.size = 0;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
517 buffer_.data = NULL;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
518 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
519
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
520 ~MemoryBufferRaii()
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
521 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
522 if (buffer_.size != 0)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
523 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
524 free(buffer_.data);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
525 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
526 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
527
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
528 OrthancPluginMemoryBuffer* GetObject()
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
529 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
530 return &buffer_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
531 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
532
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
533 void ToString(std::string& target) const
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
534 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
535 if ((buffer_.data == NULL && buffer_.size != 0) ||
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
536 (buffer_.data != NULL && buffer_.size == 0))
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
537 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
538 throw OrthancException(ErrorCode_Plugin);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
539 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
540 else
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
541 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
542 target.resize(buffer_.size);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
543
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
544 if (buffer_.size != 0)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
545 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
546 memcpy(&target[0], buffer_.data, buffer_.size);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
547 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
548 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
549 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
550 };
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
551
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
552
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
553 class StorageAreaBase : public IStorageArea
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
554 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
555 private:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
556 OrthancPluginStorageCreate create_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
557 OrthancPluginStorageRemove remove_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
558 PluginsErrorDictionary& errorDictionary_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
559
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
560 protected:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
561 PluginsErrorDictionary& GetErrorDictionary() const
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
562 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
563 return errorDictionary_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
564 }
4495
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
565
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
566 IMemoryBuffer* RangeFromWhole(const std::string& uuid,
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
567 FileContentType type,
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
568 uint64_t start /* inclusive */,
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
569 uint64_t end /* exclusive */)
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
570 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
571 if (start > end)
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
572 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
573 throw OrthancException(ErrorCode_BadRange);
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
574 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
575 else if (start == end)
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
576 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
577 return new StringMemoryBuffer; // Empty
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
578 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
579 else
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
580 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
581 std::unique_ptr<IMemoryBuffer> whole(Read(uuid, type));
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
582
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
583 if (start == 0 &&
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
584 end == whole->GetSize())
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
585 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
586 return whole.release();
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
587 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
588 else if (end > whole->GetSize())
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
589 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
590 throw OrthancException(ErrorCode_BadRange);
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
591 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
592 else
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
593 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
594 std::string range;
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
595 range.resize(end - start);
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
596 assert(!range.empty());
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
597
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
598 memcpy(&range[0], reinterpret_cast<const char*>(whole->GetData()) + start, range.size());
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
599
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
600 whole.reset(NULL);
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
601 return StringMemoryBuffer::CreateFromSwap(range);
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
602 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
603 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
604 }
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
605
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
606 public:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
607 StorageAreaBase(OrthancPluginStorageCreate create,
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
608 OrthancPluginStorageRemove remove,
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
609 PluginsErrorDictionary& errorDictionary) :
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
610 create_(create),
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
611 remove_(remove),
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
612 errorDictionary_(errorDictionary)
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
613 {
4483
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
614 if (create_ == NULL ||
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
615 remove_ == NULL)
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
616 {
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
617 throw OrthancException(ErrorCode_Plugin, "Storage area plugin doesn't implement all the required primitives");
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
618 }
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
619 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
620
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
621 virtual void Create(const std::string& uuid,
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
622 const void* content,
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
623 size_t size,
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
624 FileContentType type) ORTHANC_OVERRIDE
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
625 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
626 OrthancPluginErrorCode error = create_
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
627 (uuid.c_str(), content, size, Plugins::Convert(type));
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
628
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
629 if (error != OrthancPluginErrorCode_Success)
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
630 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
631 errorDictionary_.LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
632 throw OrthancException(static_cast<ErrorCode>(error));
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
633 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
634 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
635
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
636 virtual void Remove(const std::string& uuid,
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
637 FileContentType type) ORTHANC_OVERRIDE
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
638 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
639 OrthancPluginErrorCode error = remove_
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
640 (uuid.c_str(), Plugins::Convert(type));
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
641
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
642 if (error != OrthancPluginErrorCode_Success)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
643 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
644 errorDictionary_.LogError(error, true);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
645 throw OrthancException(static_cast<ErrorCode>(error));
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
646 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
647 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
648 };
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
649
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
650
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
651 class PluginStorageArea : public StorageAreaBase
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
652 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
653 private:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
654 OrthancPluginStorageRead read_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
655 OrthancPluginFree free_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
656
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
657 void Free(void* buffer) const
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
658 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
659 if (buffer != NULL)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
660 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
661 free_(buffer);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
662 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
663 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
664
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
665 public:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
666 PluginStorageArea(const _OrthancPluginRegisterStorageArea& callbacks,
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
667 PluginsErrorDictionary& errorDictionary) :
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
668 StorageAreaBase(callbacks.create, callbacks.remove, errorDictionary),
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
669 read_(callbacks.read),
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
670 free_(callbacks.free)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
671 {
4483
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
672 if (read_ == NULL)
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
673 {
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
674 throw OrthancException(ErrorCode_Plugin, "Storage area plugin doesn't implement the \"Read\" primitive");
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
675 }
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
676 }
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
677
4484
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
678 virtual IMemoryBuffer* Read(const std::string& uuid,
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
679 FileContentType type) ORTHANC_OVERRIDE
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
680 {
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
681 std::unique_ptr<MallocMemoryBuffer> result(new MallocMemoryBuffer);
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
682
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
683 void* buffer = NULL;
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
684 int64_t size = 0;
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
685
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
686 OrthancPluginErrorCode error = read_
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
687 (&buffer, &size, uuid.c_str(), Plugins::Convert(type));
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
688
4484
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
689 if (error == OrthancPluginErrorCode_Success)
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
690 {
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
691 result->Assign(buffer, size, free_);
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
692 return result.release();
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
693 }
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
694 else
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
695 {
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
696 GetErrorDictionary().LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
697 throw OrthancException(static_cast<ErrorCode>(error));
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
698 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
699 }
4495
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
700
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
701 virtual IMemoryBuffer* ReadRange(const std::string& uuid,
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
702 FileContentType type,
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
703 uint64_t start /* inclusive */,
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
704 uint64_t end /* exclusive */) ORTHANC_OVERRIDE
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
705 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
706 return RangeFromWhole(uuid, type, start, end);
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
707 }
4498
7b99e8bb8246 IStorageArea::HasReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4495
diff changeset
708
7b99e8bb8246 IStorageArea::HasReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4495
diff changeset
709 virtual bool HasReadRange() const ORTHANC_OVERRIDE
7b99e8bb8246 IStorageArea::HasReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4495
diff changeset
710 {
7b99e8bb8246 IStorageArea::HasReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4495
diff changeset
711 return false;
7b99e8bb8246 IStorageArea::HasReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4495
diff changeset
712 }
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
713 };
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
714
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
715
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
716 // New in Orthanc 1.9.0
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
717 class PluginStorageArea2 : public StorageAreaBase
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
718 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
719 private:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
720 OrthancPluginStorageReadWhole readWhole_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
721 OrthancPluginStorageReadRange readRange_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
722
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
723 public:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
724 PluginStorageArea2(const _OrthancPluginRegisterStorageArea2& callbacks,
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
725 PluginsErrorDictionary& errorDictionary) :
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
726 StorageAreaBase(callbacks.create, callbacks.remove, errorDictionary),
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
727 readWhole_(callbacks.readWhole),
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
728 readRange_(callbacks.readRange)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
729 {
4483
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
730 if (readWhole_ == NULL)
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
731 {
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
732 throw OrthancException(ErrorCode_Plugin, "Storage area plugin doesn't implement the \"ReadWhole\" primitive");
a926f8995d0b sample for OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4477
diff changeset
733 }
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
734 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
735
4484
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
736 virtual IMemoryBuffer* Read(const std::string& uuid,
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
737 FileContentType type) ORTHANC_OVERRIDE
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
738 {
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
739 std::unique_ptr<MallocMemoryBuffer> result(new MallocMemoryBuffer);
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
740
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
741 OrthancPluginMemoryBuffer64 buffer;
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
742 buffer.size = 0;
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
743 buffer.data = NULL;
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
744
4484
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
745 OrthancPluginErrorCode error = readWhole_(&buffer, uuid.c_str(), Plugins::Convert(type));
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
746
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
747 if (error == OrthancPluginErrorCode_Success)
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
748 {
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
749 result->Assign(buffer.data, buffer.size, ::free);
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
750 return result.release();
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
751 }
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
752 else
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
753 {
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
754 GetErrorDictionary().LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
755 throw OrthancException(static_cast<ErrorCode>(error));
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
756 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
757 }
4495
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
758
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
759 virtual IMemoryBuffer* ReadRange(const std::string& uuid,
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
760 FileContentType type,
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
761 uint64_t start /* inclusive */,
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
762 uint64_t end /* exclusive */) ORTHANC_OVERRIDE
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
763 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
764 if (readRange_ == NULL)
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
765 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
766 return RangeFromWhole(uuid, type, start, end);
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
767 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
768 else
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
769 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
770 if (start > end)
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
771 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
772 throw OrthancException(ErrorCode_BadRange);
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
773 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
774 else if (start == end)
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
775 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
776 return new StringMemoryBuffer;
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
777 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
778 else
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
779 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
780 std::string range;
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
781 range.resize(end - start);
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
782 assert(!range.empty());
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
783
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
784 OrthancPluginMemoryBuffer64 buffer;
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
785 buffer.data = &range[0];
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
786 buffer.size = static_cast<uint64_t>(range.size());
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
787
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
788 OrthancPluginErrorCode error =
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
789 readRange_(&buffer, uuid.c_str(), Plugins::Convert(type), start);
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
790
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
791 if (error == OrthancPluginErrorCode_Success)
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
792 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
793 return StringMemoryBuffer::CreateFromSwap(range);
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
794 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
795 else
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
796 {
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
797 GetErrorDictionary().LogError(error, true);
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
798 throw OrthancException(static_cast<ErrorCode>(error));
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
799 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
800 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
801 }
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
802 }
4498
7b99e8bb8246 IStorageArea::HasReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4495
diff changeset
803
7b99e8bb8246 IStorageArea::HasReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4495
diff changeset
804 virtual bool HasReadRange() const ORTHANC_OVERRIDE
7b99e8bb8246 IStorageArea::HasReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4495
diff changeset
805 {
7b99e8bb8246 IStorageArea::HasReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4495
diff changeset
806 return (readRange_ != NULL);
7b99e8bb8246 IStorageArea::HasReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4495
diff changeset
807 }
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
808 };
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
809
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
810
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
811 class StorageAreaFactory : public boost::noncopyable
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
812 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
813 private:
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
814 enum Version
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
815 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
816 Version1,
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
817 Version2
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
818 };
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
819
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
820 SharedLibrary& sharedLibrary_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
821 Version version_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
822 _OrthancPluginRegisterStorageArea callbacks_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
823 _OrthancPluginRegisterStorageArea2 callbacks2_;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
824 PluginsErrorDictionary& errorDictionary_;
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
825
4441
453cd3a5a0da better warning about no support of file ranges in storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4440
diff changeset
826 static void WarnNoReadRange()
453cd3a5a0da better warning about no support of file ranges in storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4440
diff changeset
827 {
453cd3a5a0da better warning about no support of file ranges in storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4440
diff changeset
828 LOG(WARNING) << "Performance warning: The storage area plugin doesn't implement reading of file ranges";
453cd3a5a0da better warning about no support of file ranges in storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4440
diff changeset
829 }
453cd3a5a0da better warning about no support of file ranges in storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4440
diff changeset
830
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
831 public:
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
832 StorageAreaFactory(SharedLibrary& sharedLibrary,
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
833 const _OrthancPluginRegisterStorageArea& callbacks,
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
834 PluginsErrorDictionary& errorDictionary) :
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
835 sharedLibrary_(sharedLibrary),
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
836 version_(Version1),
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
837 callbacks_(callbacks),
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
838 errorDictionary_(errorDictionary)
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
839 {
4441
453cd3a5a0da better warning about no support of file ranges in storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4440
diff changeset
840 WarnNoReadRange();
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
841 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
842
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
843 StorageAreaFactory(SharedLibrary& sharedLibrary,
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
844 const _OrthancPluginRegisterStorageArea2& callbacks,
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
845 PluginsErrorDictionary& errorDictionary) :
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
846 sharedLibrary_(sharedLibrary),
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
847 version_(Version2),
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
848 callbacks2_(callbacks),
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
849 errorDictionary_(errorDictionary)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
850 {
4441
453cd3a5a0da better warning about no support of file ranges in storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4440
diff changeset
851 if (callbacks.readRange == NULL)
453cd3a5a0da better warning about no support of file ranges in storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4440
diff changeset
852 {
453cd3a5a0da better warning about no support of file ranges in storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4440
diff changeset
853 WarnNoReadRange();
453cd3a5a0da better warning about no support of file ranges in storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4440
diff changeset
854 }
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
855 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
856
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
857 SharedLibrary& GetSharedLibrary()
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
858 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
859 return sharedLibrary_;
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
860 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
861
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
862 IStorageArea* Create() const
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
863 {
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
864 switch (version_)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
865 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
866 case Version1:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
867 return new PluginStorageArea(callbacks_, errorDictionary_);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
868
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
869 case Version2:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
870 return new PluginStorageArea2(callbacks2_, errorDictionary_);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
871
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
872 default:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
873 throw OrthancException(ErrorCode_InternalError);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
874 }
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
875 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
876 };
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
877
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
878
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
879 class OrthancPeers : public boost::noncopyable
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
880 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
881 private:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
882 std::vector<std::string> names_;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
883 std::vector<WebServiceParameters> parameters_;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
884
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
885 void CheckIndex(size_t i) const
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
886 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
887 assert(names_.size() == parameters_.size());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
888 if (i >= names_.size())
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
889 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
890 throw OrthancException(ErrorCode_ParameterOutOfRange);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
891 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
892 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
893
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
894 public:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
895 OrthancPeers()
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
896 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
897 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
898
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
899 std::set<std::string> peers;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
900 lock.GetConfiguration().GetListOfOrthancPeers(peers);
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
901
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
902 names_.reserve(peers.size());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
903 parameters_.reserve(peers.size());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
904
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
905 for (std::set<std::string>::const_iterator
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
906 it = peers.begin(); it != peers.end(); ++it)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
907 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
908 WebServiceParameters peer;
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
909 if (lock.GetConfiguration().LookupOrthancPeer(peer, *it))
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
910 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
911 names_.push_back(*it);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
912 parameters_.push_back(peer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
913 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
914 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
915 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
916
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
917 size_t GetPeersCount() const
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
918 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
919 return names_.size();
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
920 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
921
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
922 const std::string& GetPeerName(size_t i) const
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
923 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
924 CheckIndex(i);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
925 return names_[i];
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
926 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
927
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
928 const WebServiceParameters& GetPeerParameters(size_t i) const
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
929 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
930 CheckIndex(i);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
931 return parameters_[i];
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
932 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
933 };
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
934
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
935
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
936 class DicomWebBinaryFormatter : public DicomWebJsonVisitor::IBinaryFormatter
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
937 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
938 private:
3924
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
939 OrthancPluginDicomWebBinaryCallback oldCallback_;
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
940 OrthancPluginDicomWebBinaryCallback2 newCallback_; // New in Orthanc 1.7.0
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
941 void* newPayload_; // New in Orthanc 1.7.0
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
942 DicomWebJsonVisitor::BinaryMode currentMode_;
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
943 std::string currentBulkDataUri_;
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
944
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
945 static void Setter(OrthancPluginDicomWebNode* node,
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
946 OrthancPluginDicomWebBinaryMode mode,
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
947 const char* bulkDataUri)
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
948 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
949 DicomWebBinaryFormatter& that = *reinterpret_cast<DicomWebBinaryFormatter*>(node);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
950
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
951 switch (mode)
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
952 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
953 case OrthancPluginDicomWebBinaryMode_Ignore:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
954 that.currentMode_ = DicomWebJsonVisitor::BinaryMode_Ignore;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
955 break;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
956
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
957 case OrthancPluginDicomWebBinaryMode_InlineBinary:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
958 that.currentMode_ = DicomWebJsonVisitor::BinaryMode_InlineBinary;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
959 break;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
960
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
961 case OrthancPluginDicomWebBinaryMode_BulkDataUri:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
962 if (bulkDataUri == NULL)
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
963 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
964 throw OrthancException(ErrorCode_NullPointer);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
965 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
966
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
967 that.currentBulkDataUri_ = bulkDataUri;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
968 that.currentMode_ = DicomWebJsonVisitor::BinaryMode_BulkDataUri;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
969 break;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
970
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
971 default:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
972 throw OrthancException(ErrorCode_ParameterOutOfRange);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
973 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
974 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
975
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
976 public:
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
977 explicit DicomWebBinaryFormatter(OrthancPluginDicomWebBinaryCallback callback) :
3925
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
978 oldCallback_(callback),
3924
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
979 newCallback_(NULL),
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
980 newPayload_(NULL),
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
981 currentMode_(DicomWebJsonVisitor::BinaryMode_Ignore)
3924
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
982 {
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
983 }
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
984
3925
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
985 DicomWebBinaryFormatter(OrthancPluginDicomWebBinaryCallback2 callback,
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
986 void* payload) :
3924
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
987 oldCallback_(NULL),
3925
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
988 newCallback_(callback),
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
989 newPayload_(payload),
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
990 currentMode_(DicomWebJsonVisitor::BinaryMode_Ignore)
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
991 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
992 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
993
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
994 virtual DicomWebJsonVisitor::BinaryMode Format(std::string& bulkDataUri,
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
995 const std::vector<DicomTag>& parentTags,
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
996 const std::vector<size_t>& parentIndexes,
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
997 const DicomTag& tag,
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
998 ValueRepresentation vr) ORTHANC_OVERRIDE
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
999 {
3924
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1000 if (oldCallback_ == NULL &&
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1001 newCallback_ == NULL)
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1002 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1003 return DicomWebJsonVisitor::BinaryMode_InlineBinary;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1004 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1005 else
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1006 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1007 assert(parentTags.size() == parentIndexes.size());
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1008 std::vector<uint16_t> groups(parentTags.size());
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1009 std::vector<uint16_t> elements(parentTags.size());
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1010 std::vector<uint32_t> indexes(parentTags.size());
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1011
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1012 for (size_t i = 0; i < parentTags.size(); i++)
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1013 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1014 groups[i] = parentTags[i].GetGroup();
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1015 elements[i] = parentTags[i].GetElement();
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1016 indexes[i] = static_cast<uint32_t>(parentIndexes[i]);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1017 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1018 bool empty = parentTags.empty();
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1019
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1020 currentMode_ = DicomWebJsonVisitor::BinaryMode_Ignore;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1021
3924
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1022 if (oldCallback_ != NULL)
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1023 {
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1024 oldCallback_(reinterpret_cast<OrthancPluginDicomWebNode*>(this),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1025 DicomWebBinaryFormatter::Setter,
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1026 static_cast<uint32_t>(parentTags.size()),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1027 (empty ? NULL : &groups[0]),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1028 (empty ? NULL : &elements[0]),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1029 (empty ? NULL : &indexes[0]),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1030 tag.GetGroup(),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1031 tag.GetElement(),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1032 Plugins::Convert(vr));
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1033 }
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1034 else
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1035 {
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1036 assert(newCallback_ != NULL);
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1037 newCallback_(reinterpret_cast<OrthancPluginDicomWebNode*>(this),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1038 DicomWebBinaryFormatter::Setter,
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1039 static_cast<uint32_t>(parentTags.size()),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1040 (empty ? NULL : &groups[0]),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1041 (empty ? NULL : &elements[0]),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1042 (empty ? NULL : &indexes[0]),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1043 tag.GetGroup(),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1044 tag.GetElement(),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1045 Plugins::Convert(vr),
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1046 newPayload_);
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
1047 }
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1048
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1049 bulkDataUri = currentBulkDataUri_;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1050 return currentMode_;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1051 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1052 }
3925
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1053
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1054 void Apply(char** target,
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1055 bool isJson,
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1056 const ParsedDicomFile& dicom)
3925
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1057 {
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1058 DicomWebJsonVisitor visitor;
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1059 visitor.SetFormatter(*this);
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1060
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1061 dicom.Apply(visitor);
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1062
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1063 std::string s;
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1064
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1065 if (isJson)
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1066 {
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1067 s = visitor.GetResult().toStyledString();
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1068 }
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1069 else
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1070 {
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1071 visitor.FormatXml(s);
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1072 }
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1073
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1074 *target = CopyString(s);
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1075 }
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1076
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1077
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1078 void Apply(char** target,
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1079 bool isJson,
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1080 const void* dicom,
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1081 size_t dicomSize)
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1082 {
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1083 ParsedDicomFile parsed(dicom, dicomSize);
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1084 Apply(target, isJson, parsed);
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
1085 }
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
1086 };
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1087 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1088
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1089
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1090 class OrthancPlugins::PImpl
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1091 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1092 private:
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1093 boost::mutex contextMutex_;
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1094 boost::condition_variable contextCond_;
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1095 size_t contextRefCount_;
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1096
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1097 ServerContext* context_;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1098
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1099 public:
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1100 class PluginHttpOutput : public boost::noncopyable
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1101 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1102 private:
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1103 enum MultipartState
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1104 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1105 MultipartState_None,
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1106 MultipartState_FirstPart,
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1107 MultipartState_SecondPart,
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1108 MultipartState_NextParts
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1109 };
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1110
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1111 HttpOutput& output_;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
1112 std::unique_ptr<std::string> errorDetails_;
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1113 bool logDetails_;
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1114 MultipartState multipartState_;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1115 std::string multipartSubType_;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1116 std::string multipartContentType_;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1117 std::string multipartFirstPart_;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1118 std::map<std::string, std::string> multipartFirstHeaders_;
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1119
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1120 public:
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1121 explicit PluginHttpOutput(HttpOutput& output) :
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1122 output_(output),
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1123 logDetails_(false),
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1124 multipartState_(MultipartState_None)
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1125 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1126 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1127
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1128 HttpOutput& GetOutput()
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1129 {
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1130 if (multipartState_ == MultipartState_None)
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1131 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1132 return output_;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1133 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1134 else
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1135 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1136 // Must use "SendMultipartItem()" on multipart streams
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1137 throw OrthancException(ErrorCode_BadSequenceOfCalls);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1138 }
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1139 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1140
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1141 void SetErrorDetails(const std::string& details,
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1142 bool logDetails)
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1143 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1144 errorDetails_.reset(new std::string(details));
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1145 logDetails_ = logDetails;
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1146 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1147
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1148 bool HasErrorDetails() const
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1149 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1150 return errorDetails_.get() != NULL;
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1151 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1152
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1153 bool IsLogDetails() const
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1154 {
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1155 return logDetails_;
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1156 }
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1157
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1158 const std::string& GetErrorDetails() const
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1159 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1160 if (errorDetails_.get() == NULL)
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1161 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1162 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1163 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1164 else
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1165 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1166 return *errorDetails_;
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1167 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1168 }
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1169
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1170 void StartMultipart(const char* subType,
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1171 const char* contentType)
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1172 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1173 if (multipartState_ != MultipartState_None)
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1174 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1175 throw OrthancException(ErrorCode_BadSequenceOfCalls);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1176 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1177 else
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1178 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1179 multipartState_ = MultipartState_FirstPart;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1180 multipartSubType_ = subType;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1181 multipartContentType_ = contentType;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1182 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1183 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1184
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1185 void SendMultipartItem(const void* data,
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1186 size_t size,
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1187 const std::map<std::string, std::string>& headers)
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1188 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1189 if (size != 0 && data == NULL)
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1190 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1191 throw OrthancException(ErrorCode_NullPointer);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1192 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1193
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1194 switch (multipartState_)
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1195 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1196 case MultipartState_None:
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1197 // Must call "StartMultipart()" before
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1198 throw OrthancException(ErrorCode_BadSequenceOfCalls);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1199
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1200 case MultipartState_FirstPart:
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1201 multipartFirstPart_.assign(reinterpret_cast<const char*>(data), size);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1202 multipartFirstHeaders_ = headers;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1203 multipartState_ = MultipartState_SecondPart;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1204 break;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1205
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1206 case MultipartState_SecondPart:
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1207 // Start an actual stream for chunked transfer as soon as
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1208 // there are more than 2 elements in the multipart stream
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1209 output_.StartMultipart(multipartSubType_, multipartContentType_);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1210 output_.SendMultipartItem(multipartFirstPart_.c_str(), multipartFirstPart_.size(),
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1211 multipartFirstHeaders_);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1212 multipartFirstPart_.clear(); // Release memory
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1213
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1214 output_.SendMultipartItem(data, size, headers);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1215 multipartState_ = MultipartState_NextParts;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1216 break;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1217
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1218 case MultipartState_NextParts:
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1219 output_.SendMultipartItem(data, size, headers);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1220 break;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1221
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1222 default:
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1223 throw OrthancException(ErrorCode_ParameterOutOfRange);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1224 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1225 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1226
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1227 void Close(OrthancPluginErrorCode error,
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1228 PluginsErrorDictionary& dictionary)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1229 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1230 if (error == OrthancPluginErrorCode_Success)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1231 {
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1232 switch (multipartState_)
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1233 {
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1234 case MultipartState_None:
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1235 assert(!output_.IsWritingMultipart());
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1236 break;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1237
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1238 case MultipartState_FirstPart: // Multipart started, but no part was sent
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1239 case MultipartState_SecondPart: // Multipart started, first part is pending
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1240 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1241 assert(!output_.IsWritingMultipart());
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1242 std::vector<const void*> parts;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1243 std::vector<size_t> sizes;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1244 std::vector<const std::map<std::string, std::string>*> headers;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1245
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1246 if (multipartState_ == MultipartState_SecondPart)
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1247 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1248 parts.push_back(multipartFirstPart_.c_str());
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1249 sizes.push_back(multipartFirstPart_.size());
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1250 headers.push_back(&multipartFirstHeaders_);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1251 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1252
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1253 output_.AnswerMultipartWithoutChunkedTransfer(multipartSubType_, multipartContentType_,
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1254 parts, sizes, headers);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1255 break;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1256 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1257
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1258 case MultipartState_NextParts:
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1259 assert(output_.IsWritingMultipart());
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1260 output_.CloseMultipart();
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1261
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1262 default:
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
1263 throw OrthancException(ErrorCode_InternalError);
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1264 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1265 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1266 else
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1267 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1268 dictionary.LogError(error, false);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1269
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1270 if (HasErrorDetails())
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1271 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1272 throw OrthancException(static_cast<ErrorCode>(error),
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1273 GetErrorDetails(),
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1274 IsLogDetails());
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1275 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1276 else
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1277 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1278 throw OrthancException(static_cast<ErrorCode>(error));
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1279 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1280 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1281 }
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1282 };
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1283
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1284
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1285 class RestCallback : public boost::noncopyable
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1286 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1287 private:
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1288 boost::regex regex_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1289 OrthancPluginRestCallback callback_;
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
1290 bool mutualExclusion_;
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1291
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1292 OrthancPluginErrorCode InvokeInternal(PluginHttpOutput& output,
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
1293 const std::string& flatUri,
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
1294 const OrthancPluginHttpRequest& request)
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1295 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1296 return callback_(reinterpret_cast<OrthancPluginRestOutput*>(&output),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1297 flatUri.c_str(),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1298 &request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1299 }
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1300
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1301 public:
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1302 RestCallback(const char* regex,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1303 OrthancPluginRestCallback callback,
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
1304 bool mutualExclusion) :
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1305 regex_(regex),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1306 callback_(callback),
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
1307 mutualExclusion_(mutualExclusion)
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1308 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1309 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1310
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1311 const boost::regex& GetRegularExpression() const
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1312 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1313 return regex_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1314 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1315
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
1316 OrthancPluginErrorCode Invoke(boost::recursive_mutex& invokationMutex,
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1317 PluginHttpOutput& output,
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
1318 const std::string& flatUri,
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
1319 const OrthancPluginHttpRequest& request)
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1320 {
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
1321 if (mutualExclusion_)
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1322 {
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
1323 boost::recursive_mutex::scoped_lock lock(invokationMutex);
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1324 return InvokeInternal(output, flatUri, request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1325 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1326 else
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1327 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1328 return InvokeInternal(output, flatUri, request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1329 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1330 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1331 };
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1332
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1333
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1334 class ChunkedRestCallback : public boost::noncopyable
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1335 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1336 private:
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1337 _OrthancPluginChunkedRestCallback parameters_;
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1338 boost::regex regex_;
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1339
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1340 public:
4223
3d6f14a05db1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
1341 explicit ChunkedRestCallback(const _OrthancPluginChunkedRestCallback& parameters) :
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
1342 parameters_(parameters),
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
1343 regex_(parameters.pathRegularExpression)
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1344 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1345 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1346
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1347 const boost::regex& GetRegularExpression() const
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1348 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1349 return regex_;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1350 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1351
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1352 const _OrthancPluginChunkedRestCallback& GetParameters() const
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1353 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1354 return parameters_;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1355 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1356 };
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1357
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1358
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1359
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1360 class StorageCommitmentScp : public IStorageCommitmentFactory
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1361 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1362 private:
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1363 class Handler : public IStorageCommitmentFactory::ILookupHandler
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1364 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1365 private:
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1366 _OrthancPluginRegisterStorageCommitmentScpCallback parameters_;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1367 void* handler_;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1368
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1369 public:
4223
3d6f14a05db1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
1370 Handler(const _OrthancPluginRegisterStorageCommitmentScpCallback& parameters,
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1371 void* handler) :
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3662
diff changeset
1372 parameters_(parameters),
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3662
diff changeset
1373 handler_(handler)
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1374 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1375 if (handler == NULL)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1376 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1377 throw OrthancException(ErrorCode_NullPointer);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1378 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1379 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1380
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1381 virtual ~Handler()
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1382 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1383 assert(handler_ != NULL);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1384 parameters_.destructor(handler_);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1385 handler_ = NULL;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1386 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1387
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1388 virtual StorageCommitmentFailureReason Lookup(
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1389 const std::string& sopClassUid,
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1390 const std::string& sopInstanceUid) ORTHANC_OVERRIDE
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1391 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1392 assert(handler_ != NULL);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1393 OrthancPluginStorageCommitmentFailureReason reason =
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1394 OrthancPluginStorageCommitmentFailureReason_Success;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1395 OrthancPluginErrorCode error = parameters_.lookup(
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1396 &reason, handler_, sopClassUid.c_str(), sopInstanceUid.c_str());
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1397 if (error == OrthancPluginErrorCode_Success)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1398 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1399 return Plugins::Convert(reason);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1400 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1401 else
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1402 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1403 throw OrthancException(static_cast<ErrorCode>(error));
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1404 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1405 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1406 };
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1407
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1408 _OrthancPluginRegisterStorageCommitmentScpCallback parameters_;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1409
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1410 public:
4223
3d6f14a05db1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
1411 explicit StorageCommitmentScp(const _OrthancPluginRegisterStorageCommitmentScpCallback& parameters) :
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1412 parameters_(parameters)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1413 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1414 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1415
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1416 virtual ILookupHandler* CreateStorageCommitment(
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1417 const std::string& jobId,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1418 const std::string& transactionUid,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1419 const std::vector<std::string>& sopClassUids,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1420 const std::vector<std::string>& sopInstanceUids,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1421 const std::string& remoteAet,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1422 const std::string& calledAet) ORTHANC_OVERRIDE
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1423 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1424 const size_t n = sopClassUids.size();
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1425
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1426 if (sopInstanceUids.size() != n)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1427 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1428 throw OrthancException(ErrorCode_ParameterOutOfRange);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1429 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1430
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1431 std::vector<const char*> a, b;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1432 a.resize(n);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1433 b.resize(n);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1434
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1435 for (size_t i = 0; i < n; i++)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1436 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1437 a[i] = sopClassUids[i].c_str();
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1438 b[i] = sopInstanceUids[i].c_str();
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1439 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1440
3665
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
1441 void* handler = NULL;
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
1442 OrthancPluginErrorCode error = parameters_.factory(
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
1443 &handler, jobId.c_str(), transactionUid.c_str(),
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
1444 a.empty() ? NULL : &a[0], b.empty() ? NULL : &b[0], static_cast<uint32_t>(n),
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
1445 remoteAet.c_str(), calledAet.c_str());
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
1446
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
1447 if (error != OrthancPluginErrorCode_Success)
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1448 {
3665
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
1449 throw OrthancException(static_cast<ErrorCode>(error));
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
1450 }
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
1451 else if (handler == NULL)
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
1452 {
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
1453 // This plugin won't handle this storage commitment request
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1454 return NULL;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1455 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1456 else
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1457 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1458 return new Handler(parameters_, handler);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1459 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1460 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1461 };
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1462
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1463
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1464 // This class ensures that the Context remains valid while being used.
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1465 // But it does not prevent multiple users to use the context at the same time.
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1466 // (new behavior in 1.12.2. In previous version, only one user could use the "locked" context)
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1467 class ServerContextReference
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1468 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1469 private:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1470 ServerContext* context_;
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1471 boost::mutex& mutex_;
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1472 boost::condition_variable& cond_;
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1473 size_t& refCount_;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1474
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1475 public:
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1476 explicit ServerContextReference(PImpl& that) :
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1477 context_(that.context_),
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1478 mutex_(that.contextMutex_),
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1479 cond_(that.contextCond_),
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1480 refCount_(that.contextRefCount_)
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1481 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1482 if (context_ == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1483 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1484 throw OrthancException(ErrorCode_DatabaseNotInitialized);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1485 }
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1486
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1487 boost::mutex::scoped_lock lock(mutex_);
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1488 refCount_++;
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1489 }
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1490
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1491 ~ServerContextReference()
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1492 {
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1493 boost::mutex::scoped_lock lock(mutex_);
5412
1a351a141653 ServerContextLock -> ServerContextReference to allow multiple plugins to use it at the same time
Alain Mazy <am@osimis.io>
parents: 5411
diff changeset
1494 refCount_--;
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1495 cond_.notify_one();
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1496 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1497
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1498 ServerContext& GetContext()
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1499 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1500 assert(context_ != NULL);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1501 return *context_;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1502 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1503 };
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1504
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1505
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1506 void SetServerContext(ServerContext* context)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1507 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1508 // update only the context while nobody is using it
2836
7133ad478eea fix Debian warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
1509 boost::mutex::scoped_lock lock(contextMutex_);
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1510
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1511 while (contextRefCount_ > 0)
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1512 {
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1513 contextCond_.wait(lock);
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1514 }
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1515 context_ = context;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1516 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1517
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1518
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1519 typedef std::pair<std::string, _OrthancPluginProperty> Property;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1520 typedef std::list<RestCallback*> RestCallbacks;
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1521 typedef std::list<ChunkedRestCallback*> ChunkedRestCallbacks;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1522 typedef std::list<OrthancPluginOnStoredInstanceCallback> OnStoredCallbacks;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1523 typedef std::list<OrthancPluginOnChangeCallback> OnChangeCallbacks;
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
1524 typedef std::list<OrthancPluginIncomingHttpRequestFilter> IncomingHttpRequestFilters;
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
1525 typedef std::list<OrthancPluginIncomingHttpRequestFilter2> IncomingHttpRequestFilters2;
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1526 typedef std::list<OrthancPluginIncomingDicomInstanceFilter> IncomingDicomInstanceFilters;
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
1527 typedef std::list<OrthancPluginIncomingCStoreInstanceFilter> IncomingCStoreInstanceFilters;
2012
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
1528 typedef std::list<OrthancPluginDecodeImageCallback> DecodeImageCallbacks;
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
1529 typedef std::list<OrthancPluginTranscoderCallback> TranscoderCallbacks;
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1530 typedef std::list<OrthancPluginJobsUnserializer> JobsUnserializers;
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
1531 typedef std::list<OrthancPluginRefreshMetricsCallback> RefreshMetricsCallbacks;
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1532 typedef std::list<StorageCommitmentScp*> StorageCommitmentScpCallbacks;
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1533 typedef std::map<Property, std::string> Properties;
4943
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
1534 typedef std::list<WebDavCollection*> WebDavCollections;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1535
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1536 PluginsManager manager_;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1537
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1538 RestCallbacks restCallbacks_;
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1539 ChunkedRestCallbacks chunkedRestCallbacks_;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1540 OnStoredCallbacks onStoredCallbacks_;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1541 OnChangeCallbacks onChangeCallbacks_;
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1542 OrthancPluginFindCallback findCallback_;
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1543 OrthancPluginWorklistCallback worklistCallback_;
2012
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
1544 DecodeImageCallbacks decodeImageCallbacks_;
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
1545 TranscoderCallbacks transcoderCallbacks_;
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1546 JobsUnserializers jobsUnserializers_;
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1547 _OrthancPluginMoveCallback moveCallbacks_;
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
1548 IncomingHttpRequestFilters incomingHttpRequestFilters_;
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
1549 IncomingHttpRequestFilters2 incomingHttpRequestFilters2_;
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1550 IncomingDicomInstanceFilters incomingDicomInstanceFilters_;
4902
df86d2505df8 Orthanc 1.9.8 is now known as Orthanc 1.10.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
1551 IncomingCStoreInstanceFilters incomingCStoreInstanceFilters_; // New in Orthanc 1.10.0
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
1552 OrthancPluginReceivedInstanceCallback receivedInstanceCallback_; // New in Orthanc 1.10.0
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
1553 RefreshMetricsCallbacks refreshMetricsCallbacks_;
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1554 StorageCommitmentScpCallbacks storageCommitmentScpCallbacks_;
4943
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
1555 WebDavCollections webDavCollections_; // New in Orthanc 1.10.1
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
1556 std::unique_ptr<StorageAreaFactory> storageArea_;
4343
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
1557 std::set<std::string> authorizationTokens_;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1558
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
1559 boost::recursive_mutex restCallbackInvokationMutex_;
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
1560 boost::shared_mutex restCallbackRegistrationMutex_; // New in Orthanc 1.9.0
1466
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
1561 boost::recursive_mutex storedCallbackMutex_;
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
1562 boost::recursive_mutex changeCallbackMutex_;
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1563 boost::mutex findCallbackMutex_;
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1564 boost::mutex worklistCallbackMutex_;
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
1565 boost::shared_mutex decoderTranscoderMutex_; // Changed from "boost::mutex" in Orthanc 1.7.0
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1566 boost::mutex jobsUnserializersMutex_;
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
1567 boost::mutex refreshMetricsMutex_;
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1568 boost::mutex storageCommitmentScpMutex_;
1553
7c4b487b3b4a ensure mutual exclusion in InvokeService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1569 boost::recursive_mutex invokeServiceMutex_;
4374
79ef2b6d8e76 there will be a 1.8.2 release before 1.9.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4364
diff changeset
1570 boost::shared_mutex incomingHttpRequestFilterMutex_; // New in Orthanc 1.8.2
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1571
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1572 Properties properties_;
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1573 int argc_;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1574 char** argv_;
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
1575 std::unique_ptr<OrthancPluginDatabase> database_;
4603
c125bfd31023 rename 1.10.0 as 1.9.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4595
diff changeset
1576 std::unique_ptr<OrthancPluginDatabaseV3> databaseV3_; // New in Orthanc 1.9.2
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
1577 std::unique_ptr<OrthancPluginDatabaseV4> databaseV4_; // New in Orthanc 1.12.0
1644
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
1578 PluginsErrorDictionary dictionary_;
4604
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4603
diff changeset
1579 std::string databaseServerIdentifier_; // New in Orthanc 1.9.2
4613
2684544ff03c maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1580 unsigned int maxDatabaseRetries_; // New in Orthanc 1.9.2
4604
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4603
diff changeset
1581
4618
6c4081ae3bb8 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4613
diff changeset
1582 explicit PImpl(const std::string& databaseServerIdentifier) :
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1583 contextRefCount_(0),
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1584 context_(NULL),
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1585 findCallback_(NULL),
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1586 worklistCallback_(NULL),
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
1587 receivedInstanceCallback_(NULL),
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1588 argc_(1),
4604
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4603
diff changeset
1589 argv_(NULL),
4613
2684544ff03c maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1590 databaseServerIdentifier_(databaseServerIdentifier),
2684544ff03c maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1591 maxDatabaseRetries_(0)
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1592 {
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1593 memset(&moveCallbacks_, 0, sizeof(moveCallbacks_));
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1594 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1595 };
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1596
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1597
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1598
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1599 class OrthancPlugins::WorklistHandler : public IWorklistRequestHandler
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1600 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1601 private:
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1602 OrthancPlugins& that_;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
1603 std::unique_ptr<HierarchicalMatcher> matcher_;
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
1604 std::unique_ptr<ParsedDicomFile> filtered_;
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1605 ParsedDicomFile* currentQuery_;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1606
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1607 void Reset()
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1608 {
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1609 matcher_.reset();
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1610 filtered_.reset();
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1611 currentQuery_ = NULL;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1612 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1613
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1614 public:
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1615 explicit WorklistHandler(OrthancPlugins& that) : that_(that)
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1616 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1617 Reset();
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1618 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1619
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1620 virtual void Handle(DicomFindAnswers& answers,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1621 ParsedDicomFile& query,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1622 const std::string& remoteIp,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1623 const std::string& remoteAet,
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1624 const std::string& calledAet,
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1625 ModalityManufacturer manufacturer) ORTHANC_OVERRIDE
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1626 {
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1627 {
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1628 static const char* LUA_CALLBACK = "IncomingWorklistRequestFilter";
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1629
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1630 PImpl::ServerContextReference lock(*that_.pimpl_);
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1631 LuaScripting::Lock lua(lock.GetContext().GetLuaScripting());
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1632
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1633 if (!lua.GetLua().IsExistingFunction(LUA_CALLBACK))
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1634 {
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1635 currentQuery_ = &query;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1636 }
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1637 else
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1638 {
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1639 Json::Value source, origin;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1640 query.DatasetToJson(source, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1641
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1642 OrthancFindRequestHandler::FormatOrigin
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1643 (origin, remoteIp, remoteAet, calledAet, manufacturer);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1644
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1645 LuaFunctionCall call(lua.GetLua(), LUA_CALLBACK);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1646 call.PushJson(source);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1647 call.PushJson(origin);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1648
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1649 Json::Value target;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1650 call.ExecuteToJson(target, true);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1651
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1652 filtered_.reset(ParsedDicomFile::CreateFromJson(target, DicomFromJsonFlags_None,
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1653 "" /* no private creator */));
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1654 currentQuery_ = filtered_.get();
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1655 }
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1656 }
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1657
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1658 matcher_.reset(new HierarchicalMatcher(*currentQuery_));
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
1659
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1660 {
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1661 boost::mutex::scoped_lock lock(that_.pimpl_->worklistCallbackMutex_);
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1662
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1663 if (that_.pimpl_->worklistCallback_)
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1664 {
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1665 OrthancPluginErrorCode error = that_.pimpl_->worklistCallback_
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1666 (reinterpret_cast<OrthancPluginWorklistAnswers*>(&answers),
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1667 reinterpret_cast<const OrthancPluginWorklistQuery*>(this),
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1668 remoteAet.c_str(),
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1669 calledAet.c_str());
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1670
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1671 if (error != OrthancPluginErrorCode_Success)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1672 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1673 Reset();
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1674 that_.GetErrorDictionary().LogError(error, true);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1675 throw OrthancException(static_cast<ErrorCode>(error));
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1676 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1677 }
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1678
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1679 Reset();
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1680 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1681 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1682
1812
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
1683 void GetDicomQuery(OrthancPluginMemoryBuffer& target) const
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1684 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1685 if (currentQuery_ == NULL)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1686 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1687 throw OrthancException(ErrorCode_Plugin);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1688 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1689
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1690 std::string dicom;
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1691 currentQuery_->SaveToMemoryBuffer(dicom);
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1692 CopyToMemoryBuffer(target, dicom.c_str(), dicom.size());
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1693 }
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1694
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1695 bool IsMatch(const void* dicom,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1696 size_t size) const
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1697 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1698 if (matcher_.get() == NULL)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1699 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1700 throw OrthancException(ErrorCode_Plugin);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1701 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1702
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1703 ParsedDicomFile f(dicom, size);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1704 return matcher_->Match(f);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1705 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1706
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1707 void AddAnswer(OrthancPluginWorklistAnswers* answers,
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1708 const void* dicom,
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1709 size_t size) const
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1710 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1711 if (matcher_.get() == NULL)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1712 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1713 throw OrthancException(ErrorCode_Plugin);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1714 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1715
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1716 ParsedDicomFile f(dicom, size);
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
1717 std::unique_ptr<ParsedDicomFile> summary(matcher_->Extract(f));
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1718 reinterpret_cast<DicomFindAnswers*>(answers)->Add(*summary);
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1719 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1720 };
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1721
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1722
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1723 class OrthancPlugins::FindHandler : public IFindRequestHandler
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1724 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1725 private:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1726 OrthancPlugins& that_;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
1727 std::unique_ptr<DicomArray> currentQuery_;
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1728
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1729 void Reset()
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1730 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1731 currentQuery_.reset(NULL);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1732 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1733
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1734 public:
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1735 explicit FindHandler(OrthancPlugins& that) : that_(that)
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1736 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1737 Reset();
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1738 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1739
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1740 virtual void Handle(DicomFindAnswers& answers,
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1741 const DicomMap& input,
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1742 const std::list<DicomTag>& sequencesToReturn,
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1743 const std::string& remoteIp,
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1744 const std::string& remoteAet,
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1745 const std::string& calledAet,
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1746 ModalityManufacturer manufacturer) ORTHANC_OVERRIDE
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1747 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1748 DicomMap tmp;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1749 tmp.Assign(input);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1750
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1751 for (std::list<DicomTag>::const_iterator it = sequencesToReturn.begin();
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1752 it != sequencesToReturn.end(); ++it)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1753 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1754 if (!input.HasTag(*it))
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1755 {
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
1756 tmp.SetValue(*it, "", false);
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1757 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1758 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1759
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1760 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1761 boost::mutex::scoped_lock lock(that_.pimpl_->findCallbackMutex_);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1762 currentQuery_.reset(new DicomArray(tmp));
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1763
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1764 if (that_.pimpl_->findCallback_)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1765 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1766 OrthancPluginErrorCode error = that_.pimpl_->findCallback_
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1767 (reinterpret_cast<OrthancPluginFindAnswers*>(&answers),
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1768 reinterpret_cast<const OrthancPluginFindQuery*>(this),
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1769 remoteAet.c_str(),
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1770 calledAet.c_str());
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1771
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1772 if (error != OrthancPluginErrorCode_Success)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1773 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1774 Reset();
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1775 that_.GetErrorDictionary().LogError(error, true);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1776 throw OrthancException(static_cast<ErrorCode>(error));
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1777 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1778 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1779
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1780 Reset();
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1781 }
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1782 }
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1783
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1784 void Invoke(_OrthancPluginService service,
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1785 const _OrthancPluginFindOperation& operation) const
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1786 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1787 if (currentQuery_.get() == NULL)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1788 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1789 throw OrthancException(ErrorCode_Plugin);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1790 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1791
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1792 switch (service)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1793 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1794 case _OrthancPluginService_GetFindQuerySize:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1795 *operation.resultUint32 = currentQuery_->GetSize();
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1796 break;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1797
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1798 case _OrthancPluginService_GetFindQueryTag:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1799 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1800 const DicomTag& tag = currentQuery_->GetElement(operation.index).GetTag();
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1801 *operation.resultGroup = tag.GetGroup();
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1802 *operation.resultElement = tag.GetElement();
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1803 break;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1804 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1805
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1806 case _OrthancPluginService_GetFindQueryTagName:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1807 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
1808 const DicomElement& element = currentQuery_->GetElement(operation.index);
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
1809 *operation.resultString = CopyString(FromDcmtkBridge::GetTagName(element));
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1810 break;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1811 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1812
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1813 case _OrthancPluginService_GetFindQueryValue:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1814 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1815 *operation.resultString = CopyString(currentQuery_->GetElement(operation.index).GetValue().GetContent());
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1816 break;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1817 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1818
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1819 default:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1820 throw OrthancException(ErrorCode_InternalError);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1821 }
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1822 }
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1823 };
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1824
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1825
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1826
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1827 class OrthancPlugins::MoveHandler : public IMoveRequestHandler
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1828 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1829 private:
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1830 class Driver : public IMoveRequestIterator
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1831 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1832 private:
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1833 void* driver_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1834 unsigned int count_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1835 unsigned int pos_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1836 OrthancPluginApplyMove apply_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1837 OrthancPluginFreeMove free_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1838
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1839 public:
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1840 Driver(void* driver,
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1841 unsigned int count,
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1842 OrthancPluginApplyMove apply,
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1843 OrthancPluginFreeMove free) :
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1844 driver_(driver),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1845 count_(count),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1846 pos_(0),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1847 apply_(apply),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1848 free_(free)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1849 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1850 if (driver_ == NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1851 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1852 throw OrthancException(ErrorCode_Plugin);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1853 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1854 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1855
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1856 virtual ~Driver()
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1857 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1858 if (driver_ != NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1859 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1860 free_(driver_);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1861 driver_ = NULL;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1862 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1863 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1864
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1865 virtual unsigned int GetSubOperationCount() const ORTHANC_OVERRIDE
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1866 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1867 return count_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1868 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1869
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1870 virtual Status DoNext() ORTHANC_OVERRIDE
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1871 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1872 if (pos_ >= count_)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1873 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1874 throw OrthancException(ErrorCode_BadSequenceOfCalls);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1875 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1876 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1877 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1878 OrthancPluginErrorCode error = apply_(driver_);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1879 if (error != OrthancPluginErrorCode_Success)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1880 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1881 LOG(ERROR) << "Error while doing C-Move from plugin: "
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1882 << EnumerationToString(static_cast<ErrorCode>(error));
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1883 return Status_Failure;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1884 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1885 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1886 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1887 pos_++;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1888 return Status_Success;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1889 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1890 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1891 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1892 };
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1893
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1894
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1895 _OrthancPluginMoveCallback params_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1896
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1897
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1898 static std::string ReadTag(const DicomMap& input,
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1899 const DicomTag& tag)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1900 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1901 const DicomValue* value = input.TestAndGetValue(tag);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1902 if (value != NULL &&
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1903 !value->IsBinary() &&
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1904 !value->IsNull())
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1905 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1906 return value->GetContent();
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1907 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1908 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1909 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1910 return std::string();
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1911 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1912 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1913
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1914
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1915
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1916 public:
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1917 explicit MoveHandler(OrthancPlugins& that)
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1918 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1919 boost::recursive_mutex::scoped_lock lock(that.pimpl_->invokeServiceMutex_);
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1920 params_ = that.pimpl_->moveCallbacks_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1921
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1922 if (params_.callback == NULL ||
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1923 params_.getMoveSize == NULL ||
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1924 params_.applyMove == NULL ||
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1925 params_.freeMove == NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1926 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1927 throw OrthancException(ErrorCode_Plugin);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1928 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1929 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1930
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1931 virtual IMoveRequestIterator* Handle(const std::string& targetAet,
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1932 const DicomMap& input,
2222
21713ce8717b Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2215
diff changeset
1933 const std::string& originatorIp,
21713ce8717b Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2215
diff changeset
1934 const std::string& originatorAet,
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1935 const std::string& calledAet,
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1936 uint16_t originatorId) ORTHANC_OVERRIDE
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1937 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1938 std::string levelString = ReadTag(input, DICOM_TAG_QUERY_RETRIEVE_LEVEL);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1939 std::string patientId = ReadTag(input, DICOM_TAG_PATIENT_ID);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1940 std::string accessionNumber = ReadTag(input, DICOM_TAG_ACCESSION_NUMBER);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1941 std::string studyInstanceUid = ReadTag(input, DICOM_TAG_STUDY_INSTANCE_UID);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1942 std::string seriesInstanceUid = ReadTag(input, DICOM_TAG_SERIES_INSTANCE_UID);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1943 std::string sopInstanceUid = ReadTag(input, DICOM_TAG_SOP_INSTANCE_UID);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1944
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1945 OrthancPluginResourceType level = OrthancPluginResourceType_None;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1946
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1947 if (!levelString.empty())
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1948 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1949 level = Plugins::Convert(StringToResourceType(levelString.c_str()));
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1950 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1951
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1952 void* driver = params_.callback(level,
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1953 patientId.empty() ? NULL : patientId.c_str(),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1954 accessionNumber.empty() ? NULL : accessionNumber.c_str(),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1955 studyInstanceUid.empty() ? NULL : studyInstanceUid.c_str(),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1956 seriesInstanceUid.empty() ? NULL : seriesInstanceUid.c_str(),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1957 sopInstanceUid.empty() ? NULL : sopInstanceUid.c_str(),
2222
21713ce8717b Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2215
diff changeset
1958 originatorAet.c_str(),
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1959 calledAet.c_str(),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1960 targetAet.c_str(),
2222
21713ce8717b Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2215
diff changeset
1961 originatorId);
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1962
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1963 if (driver == NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1964 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1965 throw OrthancException(ErrorCode_Plugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1966 "Plugin cannot create a driver for an incoming C-MOVE request");
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1967 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1968
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1969 unsigned int size = params_.getMoveSize(driver);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1970
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1971 return new Driver(driver, size, params_.applyMove, params_.freeMove);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1972 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1973 };
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1974
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1975
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1976
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1977 class OrthancPlugins::HttpClientChunkedRequest : public HttpClient::IRequestBody
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1978 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1979 private:
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
1980 const _OrthancPluginChunkedHttpClient& params_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
1981 PluginsErrorDictionary& errorDictionary_;
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1982
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1983 public:
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1984 HttpClientChunkedRequest(const _OrthancPluginChunkedHttpClient& params,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1985 PluginsErrorDictionary& errorDictionary) :
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1986 params_(params),
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1987 errorDictionary_(errorDictionary)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1988 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1989 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1990
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
1991 virtual bool ReadNextChunk(std::string& chunk) ORTHANC_OVERRIDE
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1992 {
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1993 if (params_.requestIsDone(params_.request))
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1994 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1995 return false;
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1996 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1997 else
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1998 {
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1999 size_t size = params_.requestChunkSize(params_.request);
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2000
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2001 chunk.resize(size);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2002
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2003 if (size != 0)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2004 {
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2005 const void* data = params_.requestChunkData(params_.request);
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2006 memcpy(&chunk[0], data, size);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2007 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2008
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2009 OrthancPluginErrorCode error = params_.requestNext(params_.request);
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2010
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2011 if (error != OrthancPluginErrorCode_Success)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2012 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2013 errorDictionary_.LogError(error, true);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2014 throw OrthancException(static_cast<ErrorCode>(error));
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2015 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2016 else
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2017 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2018 return true;
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2019 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2020 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2021 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2022 };
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2023
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2024
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2025 class OrthancPlugins::HttpClientChunkedAnswer : public HttpClient::IAnswer
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2026 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2027 private:
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
2028 const _OrthancPluginChunkedHttpClient& params_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
2029 PluginsErrorDictionary& errorDictionary_;
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2030
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2031 public:
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2032 HttpClientChunkedAnswer(const _OrthancPluginChunkedHttpClient& params,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2033 PluginsErrorDictionary& errorDictionary) :
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2034 params_(params),
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2035 errorDictionary_(errorDictionary)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2036 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2037 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2038
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2039 virtual void AddHeader(const std::string& key,
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
2040 const std::string& value) ORTHANC_OVERRIDE
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2041 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2042 OrthancPluginErrorCode error = params_.answerAddHeader(params_.answer, key.c_str(), value.c_str());
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2043
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2044 if (error != OrthancPluginErrorCode_Success)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2045 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2046 errorDictionary_.LogError(error, true);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2047 throw OrthancException(static_cast<ErrorCode>(error));
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2048 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2049 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2050
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2051 virtual void AddChunk(const void* data,
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
2052 size_t size) ORTHANC_OVERRIDE
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2053 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2054 OrthancPluginErrorCode error = params_.answerAddChunk(params_.answer, data, size);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2055
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2056 if (error != OrthancPluginErrorCode_Success)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2057 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2058 errorDictionary_.LogError(error, true);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2059 throw OrthancException(static_cast<ErrorCode>(error));
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2060 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2061 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2062 };
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2063
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2064
4604
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4603
diff changeset
2065 OrthancPlugins::OrthancPlugins(const std::string& databaseServerIdentifier)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2066 {
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2067 /* Sanity check of the compiler */
5389
0e5e675b9750 replaced "int" by "int32_t" in the SDK to prevent any ABI issue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5337
diff changeset
2068 if (sizeof(int32_t) != sizeof(int) || // Ensure binary compatibility with Orthanc SDK <= 1.12.1
0e5e675b9750 replaced "int" by "int32_t" in the SDK to prevent any ABI issue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5337
diff changeset
2069 sizeof(int32_t) != sizeof(OrthancPluginErrorCode) ||
1579
b93c398f934d check the size of the enumerations in the plugin engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2070 sizeof(int32_t) != sizeof(OrthancPluginHttpMethod) ||
b93c398f934d check the size of the enumerations in the plugin engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2071 sizeof(int32_t) != sizeof(_OrthancPluginService) ||
b93c398f934d check the size of the enumerations in the plugin engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2072 sizeof(int32_t) != sizeof(_OrthancPluginProperty) ||
b93c398f934d check the size of the enumerations in the plugin engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2073 sizeof(int32_t) != sizeof(OrthancPluginPixelFormat) ||
b93c398f934d check the size of the enumerations in the plugin engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2074 sizeof(int32_t) != sizeof(OrthancPluginContentType) ||
b93c398f934d check the size of the enumerations in the plugin engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2075 sizeof(int32_t) != sizeof(OrthancPluginResourceType) ||
b93c398f934d check the size of the enumerations in the plugin engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2076 sizeof(int32_t) != sizeof(OrthancPluginChangeType) ||
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2077 sizeof(int32_t) != sizeof(OrthancPluginImageFormat) ||
1579
b93c398f934d check the size of the enumerations in the plugin engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
2078 sizeof(int32_t) != sizeof(OrthancPluginCompressionType) ||
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
2079 sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) ||
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2080 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) ||
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2081 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) ||
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2082 sizeof(int32_t) != sizeof(OrthancPluginCreateDicomFlags) ||
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2083 sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType) ||
1760
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1744
diff changeset
2084 sizeof(int32_t) != sizeof(OrthancPluginIdentifierConstraint) ||
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
2085 sizeof(int32_t) != sizeof(OrthancPluginInstanceOrigin) ||
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2086 sizeof(int32_t) != sizeof(OrthancPluginJobStepStatus) ||
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3205
diff changeset
2087 sizeof(int32_t) != sizeof(OrthancPluginConstraintType) ||
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3205
diff changeset
2088 sizeof(int32_t) != sizeof(OrthancPluginMetricsType) ||
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3205
diff changeset
2089 sizeof(int32_t) != sizeof(OrthancPluginDicomWebBinaryMode) ||
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2090 sizeof(int32_t) != sizeof(OrthancPluginStorageCommitmentFailureReason) ||
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
2091 sizeof(int32_t) != sizeof(OrthancPluginReceivedInstanceAction) ||
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2092 sizeof(int32_t) != sizeof(OrthancPluginLoadDicomInstanceMode) ||
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2093 static_cast<int>(OrthancPluginDicomToJsonFlags_IncludeBinary) != static_cast<int>(DicomToJsonFlags_IncludeBinary) ||
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2094 static_cast<int>(OrthancPluginDicomToJsonFlags_IncludePrivateTags) != static_cast<int>(DicomToJsonFlags_IncludePrivateTags) ||
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2095 static_cast<int>(OrthancPluginDicomToJsonFlags_IncludeUnknownTags) != static_cast<int>(DicomToJsonFlags_IncludeUnknownTags) ||
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2096 static_cast<int>(OrthancPluginDicomToJsonFlags_IncludePixelData) != static_cast<int>(DicomToJsonFlags_IncludePixelData) ||
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2097 static_cast<int>(OrthancPluginDicomToJsonFlags_ConvertBinaryToNull) != static_cast<int>(DicomToJsonFlags_ConvertBinaryToNull) ||
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2098 static_cast<int>(OrthancPluginDicomToJsonFlags_ConvertBinaryToAscii) != static_cast<int>(DicomToJsonFlags_ConvertBinaryToAscii) ||
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
2099 static_cast<int>(OrthancPluginDicomToJsonFlags_StopAfterPixelData) != static_cast<int>(DicomToJsonFlags_StopAfterPixelData) ||
4516
671ee7c1fd46 added DicomToJsonFlags_SkipGroupLengths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
2100 static_cast<int>(OrthancPluginDicomToJsonFlags_SkipGroupLengths) != static_cast<int>(DicomToJsonFlags_SkipGroupLengths) ||
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2101 static_cast<int>(OrthancPluginCreateDicomFlags_DecodeDataUriScheme) != static_cast<int>(DicomFromJsonFlags_DecodeDataUriScheme) ||
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2102 static_cast<int>(OrthancPluginCreateDicomFlags_GenerateIdentifiers) != static_cast<int>(DicomFromJsonFlags_GenerateIdentifiers))
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2103
1578
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
2104 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
2105 throw OrthancException(ErrorCode_Plugin);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
2106 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
2107
4604
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4603
diff changeset
2108 pimpl_.reset(new PImpl(databaseServerIdentifier));
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2109 pimpl_->manager_.RegisterServiceProvider(*this);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2110 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2111
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2112
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2113 void OrthancPlugins::SetServerContext(ServerContext& context)
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2114 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2115 pimpl_->SetServerContext(&context);
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2116 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2117
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2118
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2119 void OrthancPlugins::ResetServerContext()
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2120 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2121 pimpl_->SetServerContext(NULL);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2122 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2123
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2124
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
2125 OrthancPlugins::~OrthancPlugins()
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2126 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2127 for (PImpl::RestCallbacks::iterator it = pimpl_->restCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2128 it != pimpl_->restCallbacks_.end(); ++it)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2129 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
2130 delete *it;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2131 }
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2132
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2133 for (PImpl::ChunkedRestCallbacks::iterator it = pimpl_->chunkedRestCallbacks_.begin();
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2134 it != pimpl_->chunkedRestCallbacks_.end(); ++it)
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2135 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2136 delete *it;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2137 }
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2138
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2139 for (PImpl::StorageCommitmentScpCallbacks::iterator
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2140 it = pimpl_->storageCommitmentScpCallbacks_.begin();
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2141 it != pimpl_->storageCommitmentScpCallbacks_.end(); ++it)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2142 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2143 delete *it;
4943
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
2144 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
2145
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
2146 for (PImpl::WebDavCollections::iterator it = pimpl_->webDavCollections_.begin();
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
2147 it != pimpl_->webDavCollections_.end(); ++it)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
2148 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
2149 delete *it;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
2150 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2151 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2152
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2153
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2154 static void ArgumentsToPlugin(std::vector<const char*>& keys,
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2155 std::vector<const char*>& values,
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
2156 const HttpToolbox::Arguments& arguments)
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2157 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2158 keys.resize(arguments.size());
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2159 values.resize(arguments.size());
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2160
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2161 size_t pos = 0;
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
2162 for (HttpToolbox::Arguments::const_iterator
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2163 it = arguments.begin(); it != arguments.end(); ++it)
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2164 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2165 keys[pos] = it->first.c_str();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2166 values[pos] = it->second.c_str();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2167 pos++;
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2168 }
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2169 }
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2170
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2171
1363
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2172 static void ArgumentsToPlugin(std::vector<const char*>& keys,
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2173 std::vector<const char*>& values,
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
2174 const HttpToolbox::GetArguments& arguments)
1363
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2175 {
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2176 keys.resize(arguments.size());
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2177 values.resize(arguments.size());
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2178
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2179 for (size_t i = 0; i < arguments.size(); i++)
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2180 {
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2181 keys[i] = arguments[i].first.c_str();
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2182 values[i] = arguments[i].second.c_str();
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2183 }
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2184 }
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2185
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
2186
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2187 namespace
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2188 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2189 class RestCallbackMatcher : public boost::noncopyable
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2190 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2191 private:
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2192 std::string flatUri_;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2193 std::vector<std::string> groups_;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2194 std::vector<const char*> cgroups_;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2195
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2196 public:
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
2197 explicit RestCallbackMatcher(const UriComponents& uri) :
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
2198 flatUri_(Toolbox::FlattenUri(uri))
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2199 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2200 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2201
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2202 bool IsMatch(const boost::regex& re)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2203 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2204 // Check whether the regular expression associated to this
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2205 // callback matches the URI
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2206 boost::cmatch what;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2207
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2208 if (boost::regex_match(flatUri_.c_str(), what, re))
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2209 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2210 // Extract the value of the free parameters of the regular expression
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2211 if (what.size() > 1)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2212 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2213 groups_.resize(what.size() - 1);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2214 cgroups_.resize(what.size() - 1);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2215 for (size_t i = 1; i < what.size(); i++)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2216 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2217 groups_[i - 1] = what[i];
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2218 cgroups_[i - 1] = groups_[i - 1].c_str();
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2219 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2220 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2221
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2222 return true;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2223 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2224 else
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2225 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2226 // Not a match
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2227 return false;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2228 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2229 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2230
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2231 uint32_t GetGroupsCount() const
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2232 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2233 return cgroups_.size();
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2234 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2235
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2236 const char* const* GetGroups() const
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2237 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2238 return cgroups_.empty() ? NULL : &cgroups_[0];
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2239 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2240
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2241 const std::string& GetFlatUri() const
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2242 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2243 return flatUri_;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2244 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2245 };
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2246
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2247
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2248 // WARNING - The lifetime of this internal object must be smaller
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2249 // than "matcher", "headers" and "getArguments" objects
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2250 class HttpRequestConverter
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2251 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2252 private:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2253 std::vector<const char*> getKeys_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2254 std::vector<const char*> getValues_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2255 std::vector<const char*> headersKeys_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2256 std::vector<const char*> headersValues_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2257 OrthancPluginHttpRequest converted_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2258
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2259 public:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2260 HttpRequestConverter(const RestCallbackMatcher& matcher,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2261 HttpMethod method,
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
2262 const HttpToolbox::Arguments& headers)
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2263 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2264 memset(&converted_, 0, sizeof(OrthancPluginHttpRequest));
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2265
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2266 ArgumentsToPlugin(headersKeys_, headersValues_, headers);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2267 assert(headersKeys_.size() == headersValues_.size());
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2268
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2269 switch (method)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2270 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2271 case HttpMethod_Get:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2272 converted_.method = OrthancPluginHttpMethod_Get;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2273 break;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2274
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2275 case HttpMethod_Post:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2276 converted_.method = OrthancPluginHttpMethod_Post;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2277 break;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2278
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2279 case HttpMethod_Delete:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2280 converted_.method = OrthancPluginHttpMethod_Delete;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2281 break;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2282
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2283 case HttpMethod_Put:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2284 converted_.method = OrthancPluginHttpMethod_Put;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2285 break;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2286
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2287 default:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2288 throw OrthancException(ErrorCode_InternalError);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2289 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2290
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2291 converted_.groups = matcher.GetGroups();
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2292 converted_.groupsCount = matcher.GetGroupsCount();
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2293 converted_.getCount = 0;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2294 converted_.getKeys = NULL;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2295 converted_.getValues = NULL;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2296 converted_.body = NULL;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2297 converted_.bodySize = 0;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2298 converted_.headersCount = headers.size();
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2299
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2300 if (headers.size() > 0)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2301 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2302 converted_.headersKeys = &headersKeys_[0];
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2303 converted_.headersValues = &headersValues_[0];
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2304 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2305 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2306
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
2307 void SetGetArguments(const HttpToolbox::GetArguments& getArguments)
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2308 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2309 ArgumentsToPlugin(getKeys_, getValues_, getArguments);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2310 assert(getKeys_.size() == getValues_.size());
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2311
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2312 converted_.getCount = getArguments.size();
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2313
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2314 if (getArguments.size() > 0)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2315 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2316 converted_.getKeys = &getKeys_[0];
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2317 converted_.getValues = &getValues_[0];
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2318 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2319 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2320
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2321 OrthancPluginHttpRequest& GetRequest()
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2322 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2323 return converted_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2324 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2325 };
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2326 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2327
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2328
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2329 static std::string GetAllowedMethods(_OrthancPluginChunkedRestCallback parameters)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2330 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2331 std::string s;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2332
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2333 if (parameters.getHandler != NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2334 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2335 s += "GET";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2336 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2337
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2338 if (parameters.postHandler != NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2339 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2340 if (!s.empty())
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2341 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2342 s+= ",";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2343 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2344
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2345 s += "POST";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2346 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2347
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2348 if (parameters.deleteHandler != NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2349 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2350 if (!s.empty())
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2351 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2352 s+= ",";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2353 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2354
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2355 s += "DELETE";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2356 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2357
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2358 if (parameters.putHandler != NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2359 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2360 if (!s.empty())
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2361 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2362 s+= ",";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2363 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2364
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2365 s += "PUT";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2366 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2367
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2368 return s;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2369 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2370
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2371
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2372 bool OrthancPlugins::HandleChunkedGetDelete(HttpOutput& output,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2373 HttpMethod method,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2374 const UriComponents& uri,
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
2375 const HttpToolbox::Arguments& headers,
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
2376 const HttpToolbox::GetArguments& getArguments)
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2377 {
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2378 RestCallbackMatcher matcher(uri);
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2379
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2380 PImpl::ChunkedRestCallback* callback = NULL;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2381
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2382 // Loop over the callbacks registered by the plugins
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2383 boost::shared_lock<boost::shared_mutex> lock(pimpl_->restCallbackRegistrationMutex_);
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2384 for (PImpl::ChunkedRestCallbacks::const_iterator it = pimpl_->chunkedRestCallbacks_.begin();
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2385 it != pimpl_->chunkedRestCallbacks_.end(); ++it)
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2386 {
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2387 if (matcher.IsMatch((*it)->GetRegularExpression()))
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2388 {
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2389 callback = *it;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2390 break;
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2391 }
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2392 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2393
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2394 if (callback == NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2395 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2396 return false;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2397 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2398 else
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2399 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2400 CLOG(INFO, PLUGINS) << "Delegating HTTP request to plugin for URI: " << matcher.GetFlatUri();
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2401
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2402 OrthancPluginRestCallback handler;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2403
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2404 switch (method)
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2405 {
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2406 case HttpMethod_Get:
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2407 handler = callback->GetParameters().getHandler;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2408 break;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2409
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2410 case HttpMethod_Delete:
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2411 handler = callback->GetParameters().deleteHandler;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2412 break;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2413
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2414 default:
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2415 handler = NULL;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2416 break;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2417 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2418
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2419 if (handler == NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2420 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2421 output.SendMethodNotAllowed(GetAllowedMethods(callback->GetParameters()));
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2422 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2423 else
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2424 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2425 HttpRequestConverter converter(matcher, method, headers);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2426 converter.SetGetArguments(getArguments);
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2427
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2428 PImpl::PluginHttpOutput pluginOutput(output);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2429
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2430 OrthancPluginErrorCode error = handler(
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2431 reinterpret_cast<OrthancPluginRestOutput*>(&pluginOutput),
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2432 matcher.GetFlatUri().c_str(), &converter.GetRequest());
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2433
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2434 pluginOutput.Close(error, GetErrorDictionary());
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2435 }
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2436
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
2437 return true;
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2438 }
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2439 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2440
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2441
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
2442 bool OrthancPlugins::Handle(HttpOutput& output,
1571
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
2443 RequestOrigin /*origin*/,
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
2444 const char* /*remoteIp*/,
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
2445 const char* /*username*/,
1329
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
2446 HttpMethod method,
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
2447 const UriComponents& uri,
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
2448 const HttpToolbox::Arguments& headers,
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
2449 const HttpToolbox::GetArguments& getArguments,
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3399
diff changeset
2450 const void* bodyData,
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1445
diff changeset
2451 size_t bodySize)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2452 {
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2453 RestCallbackMatcher matcher(uri);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2454
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
2455 PImpl::RestCallback* callback = NULL;
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
2456
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
2457 // Loop over the callbacks registered by the plugins
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2458 boost::shared_lock<boost::shared_mutex> lock(pimpl_->restCallbackRegistrationMutex_);
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2459 for (PImpl::RestCallbacks::const_iterator it = pimpl_->restCallbacks_.begin();
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2460 it != pimpl_->restCallbacks_.end(); ++it)
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
2461 {
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2462 if (matcher.IsMatch((*it)->GetRegularExpression()))
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
2463 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
2464 callback = *it;
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2465 break;
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
2466 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
2467 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
2468
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
2469 if (callback == NULL)
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
2470 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2471 // Callback not found, try to find a chunked callback
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2472 return HandleChunkedGetDelete(output, method, uri, headers, getArguments);
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
2473 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2474
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2475 CLOG(INFO, PLUGINS) << "Delegating HTTP request to plugin for URI: " << matcher.GetFlatUri();
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2476
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2477 HttpRequestConverter converter(matcher, method, headers);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2478 converter.SetGetArguments(getArguments);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2479 converter.GetRequest().body = bodyData;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2480 converter.GetRequest().bodySize = bodySize;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2481
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2482 PImpl::PluginHttpOutput pluginOutput(output);
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2483
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
2484 assert(callback != NULL);
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
2485 OrthancPluginErrorCode error = callback->Invoke
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2486 (pimpl_->restCallbackInvokationMutex_, pluginOutput, matcher.GetFlatUri(), converter.GetRequest());
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2487
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2488 pluginOutput.Close(error, GetErrorDictionary());
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2489 return true;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2490 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2491
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2492
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2493 class OrthancPlugins::IDicomInstance : public boost::noncopyable
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2494 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2495 public:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2496 virtual ~IDicomInstance()
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2497 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2498 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2499
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2500 virtual bool CanBeFreed() const = 0;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2501
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2502 virtual const DicomInstanceToStore& GetInstance() const = 0;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2503 };
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2504
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2505
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2506 class OrthancPlugins::DicomInstanceFromCallback : public IDicomInstance
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2507 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2508 private:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2509 const DicomInstanceToStore& instance_;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2510
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2511 public:
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
2512 explicit DicomInstanceFromCallback(const DicomInstanceToStore& instance) :
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2513 instance_(instance)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2514 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2515 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2516
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2517 virtual bool CanBeFreed() const ORTHANC_OVERRIDE
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2518 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2519 return false;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2520 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2521
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2522 virtual const DicomInstanceToStore& GetInstance() const ORTHANC_OVERRIDE
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2523 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2524 return instance_;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2525 };
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2526 };
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2527
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2528
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2529 class OrthancPlugins::DicomInstanceFromBuffer : public IDicomInstance
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2530 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2531 private:
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
2532 std::string buffer_;
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
2533 std::unique_ptr<DicomInstanceToStore> instance_;
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2534
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2535 void Setup(const void* buffer,
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2536 size_t size)
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2537 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2538 buffer_.assign(reinterpret_cast<const char*>(buffer), size);
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
2539
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
2540 instance_.reset(DicomInstanceToStore::CreateFromBuffer(buffer_));
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
2541 instance_->SetOrigin(DicomInstanceOrigin::FromPlugins());
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2542 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2543
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2544 public:
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2545 DicomInstanceFromBuffer(const void* buffer,
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2546 size_t size)
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2547 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2548 Setup(buffer, size);
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2549 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2550
5328
84150c5227f8 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5326
diff changeset
2551 explicit DicomInstanceFromBuffer(const std::string& buffer)
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2552 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2553 Setup(buffer.empty() ? NULL : buffer.c_str(), buffer.size());
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2554 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2555
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2556 virtual bool CanBeFreed() const ORTHANC_OVERRIDE
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2557 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2558 return true;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2559 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2560
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2561 virtual const DicomInstanceToStore& GetInstance() const ORTHANC_OVERRIDE
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2562 {
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
2563 return *instance_;
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2564 };
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2565 };
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2566
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2567
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2568 class OrthancPlugins::DicomInstanceFromParsed : public IDicomInstance
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2569 {
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2570 private:
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
2571 std::unique_ptr<ParsedDicomFile> parsed_;
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
2572 std::unique_ptr<DicomInstanceToStore> instance_;
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2573
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2574 void Setup(ParsedDicomFile* parsed)
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2575 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2576 parsed_.reset(parsed);
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2577
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
2578 if (parsed_.get() == NULL)
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
2579 {
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2580 throw OrthancException(ErrorCode_NullPointer);
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2581 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2582 else
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2583 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2584 instance_.reset(DicomInstanceToStore::CreateFromParsedDicomFile(*parsed_));
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2585 instance_->SetOrigin(DicomInstanceOrigin::FromPlugins());
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2586 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2587 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2588
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2589 public:
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2590 explicit DicomInstanceFromParsed(IDicomTranscoder::DicomImage& transcoded)
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2591 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2592 Setup(transcoded.ReleaseAsParsedDicomFile());
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2593 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2594
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2595 explicit DicomInstanceFromParsed(ParsedDicomFile* parsed /* takes ownership */)
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2596 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
2597 Setup(parsed);
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2598 }
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2599
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2600 virtual bool CanBeFreed() const ORTHANC_OVERRIDE
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2601 {
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2602 return true;
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2603 }
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2604
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2605 virtual const DicomInstanceToStore& GetInstance() const ORTHANC_OVERRIDE
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2606 {
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
2607 return *instance_;
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2608 };
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2609 };
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2610
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
2611
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
2612 void OrthancPlugins::SignalStoredInstance(const std::string& instanceId,
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2613 const DicomInstanceToStore& instance,
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
2614 const Json::Value& simplifiedTags)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2615 {
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2616 DicomInstanceFromCallback wrapped(instance);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2617
1466
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
2618 boost::recursive_mutex::scoped_lock lock(pimpl_->storedCallbackMutex_);
1185
cbd1f05b4ef2 plugin callbacks are executed in mutual exclusion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1178
diff changeset
2619
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2620 for (PImpl::OnStoredCallbacks::const_iterator
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2621 callback = pimpl_->onStoredCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2622 callback != pimpl_->onStoredCallbacks_.end(); ++callback)
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2623 {
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2624 OrthancPluginErrorCode error = (*callback) (
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2625 reinterpret_cast<OrthancPluginDicomInstance*>(&wrapped),
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2626 instanceId.c_str());
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
2627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
2628 if (error != OrthancPluginErrorCode_Success)
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
2629 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
2630 GetErrorDictionary().LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
2631 throw OrthancException(static_cast<ErrorCode>(error));
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
2632 }
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2633 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2634 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2635
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2636
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2637 bool OrthancPlugins::FilterIncomingInstance(const DicomInstanceToStore& instance,
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2638 const Json::Value& simplified)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2639 {
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2640 DicomInstanceFromCallback wrapped(instance);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2641
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2642 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2643
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2644 for (PImpl::IncomingDicomInstanceFilters::const_iterator
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2645 filter = pimpl_->incomingDicomInstanceFilters_.begin();
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2646 filter != pimpl_->incomingDicomInstanceFilters_.end(); ++filter)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2647 {
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2648 int32_t allowed = (*filter) (reinterpret_cast<const OrthancPluginDicomInstance*>(&wrapped));
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2649
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2650 if (allowed == 0)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2651 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2652 return false;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2653 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2654 else if (allowed != 1)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2655 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2656 // The callback is only allowed to answer 0 or 1
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2657 throw OrthancException(ErrorCode_Plugin);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2658 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2659 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2660
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2661 return true;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2662 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2663
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2664
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2665
4921
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2666 bool OrthancPlugins::FilterIncomingCStoreInstance(uint16_t& dimseStatus,
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2667 const DicomInstanceToStore& instance,
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2668 const Json::Value& simplified)
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2669 {
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2670 DicomInstanceFromCallback wrapped(instance);
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2671
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2672 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2673
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2674 for (PImpl::IncomingCStoreInstanceFilters::const_iterator
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2675 filter = pimpl_->incomingCStoreInstanceFilters_.begin();
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2676 filter != pimpl_->incomingCStoreInstanceFilters_.end(); ++filter)
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2677 {
4921
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2678 int32_t result = (*filter) (&dimseStatus, reinterpret_cast<const OrthancPluginDicomInstance*>(&wrapped));
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2679
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2680 if (result == 0)
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2681 {
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2682 // The instance must be discarded
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2683 return false;
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2684 }
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2685 else if (result == 1)
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2686 {
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2687 // The instance is accepted
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2688 return true;
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2689 }
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2690 else
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2691 {
4921
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2692 // Error
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2693 throw OrthancException(ErrorCode_Plugin);
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2694 }
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2695 }
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2696
4921
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
2697 return true; // By default, the instance is accepted
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2698 }
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2699
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2700
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
2701 OrthancPluginReceivedInstanceAction OrthancPlugins::ApplyReceivedInstanceCallbacks(
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2702 MallocMemoryBuffer& modified,
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2703 const void* receivedDicom,
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
2704 size_t receivedDicomSize,
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
2705 RequestOrigin origin)
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
2706 {
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
2707 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2708
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2709 if (pimpl_->receivedInstanceCallback_ == NULL)
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2710 {
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
2711 return OrthancPluginReceivedInstanceAction_KeepAsIs;
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2712 }
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2713 else
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2714 {
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
2715 OrthancPluginReceivedInstanceAction action;
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2716
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2717 {
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2718 OrthancPluginMemoryBuffer64 buffer;
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
2719 buffer.size = 0;
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
2720 buffer.data = NULL;
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
2721
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
2722 action = (*pimpl_->receivedInstanceCallback_) (&buffer, receivedDicom, receivedDicomSize, Plugins::Convert(origin));
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2723 modified.Assign(buffer.data, buffer.size, ::free);
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2724 }
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2725
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4915
diff changeset
2726 return action;
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2727 }
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
2728 }
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
2729
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2730 void OrthancPlugins::SignalChangeInternal(OrthancPluginChangeType changeType,
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2731 OrthancPluginResourceType resourceType,
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2732 const char* resource)
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2733 {
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
2734 boost::recursive_mutex::scoped_lock lock(pimpl_->changeCallbackMutex_);
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
2735
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
2736 for (std::list<OrthancPluginOnChangeCallback>::const_iterator
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
2737 callback = pimpl_->onChangeCallbacks_.begin();
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
2738 callback != pimpl_->onChangeCallbacks_.end(); ++callback)
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
2739 {
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2740 OrthancPluginErrorCode error = (*callback) (changeType, resourceType, resource);
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
2741
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
2742 if (error != OrthancPluginErrorCode_Success)
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
2743 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
2744 GetErrorDictionary().LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
2745 throw OrthancException(static_cast<ErrorCode>(error));
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
2746 }
1178
c71d25e6a63c improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1177
diff changeset
2747 }
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2748 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2749
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2750
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2751
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2752 void OrthancPlugins::SignalChange(const ServerIndexChange& change)
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2753 {
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2754 SignalChangeInternal(Plugins::Convert(change.GetChangeType()),
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2755 Plugins::Convert(change.GetResourceType()),
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2756 change.GetPublicId().c_str());
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2757 }
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2758
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2759
5410
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2760 void OrthancPlugins::SignalJobEvent(const JobEvent& event)
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2761 {
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2762 // job events are actually considered as changes inside plugins -> translate
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2763 switch (event.GetEventType())
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2764 {
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2765 case JobEventType_Submitted:
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2766 SignalChangeInternal(OrthancPluginChangeType_JobSubmitted, OrthancPluginResourceType_None, event.GetJobId().c_str());
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2767 break;
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2768 case JobEventType_Success:
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2769 SignalChangeInternal(OrthancPluginChangeType_JobSuccess, OrthancPluginResourceType_None, event.GetJobId().c_str());
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2770 break;
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2771 case JobEventType_Failure:
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2772 SignalChangeInternal(OrthancPluginChangeType_JobFailure, OrthancPluginResourceType_None, event.GetJobId().c_str());
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2773 break;
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2774 default:
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2775 throw OrthancException(ErrorCode_InternalError);
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2776 }
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2777 }
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2778
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
2779
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
2780 void OrthancPlugins::RegisterRestCallback(const void* parameters,
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2781 bool mutualExclusion)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2782 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2783 const _OrthancPluginRestCallback& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2784 *reinterpret_cast<const _OrthancPluginRestCallback*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2785
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2786 CLOG(INFO, PLUGINS) << "Plugin has registered a REST callback "
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2787 << (mutualExclusion ? "with" : "without")
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2788 << " mutual exclusion on: "
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2789 << p.pathRegularExpression;
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
2790
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2791 {
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2792 boost::unique_lock<boost::shared_mutex> lock(pimpl_->restCallbackRegistrationMutex_);
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2793 pimpl_->restCallbacks_.push_back(new PImpl::RestCallback(p.pathRegularExpression, p.callback, mutualExclusion));
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2794 }
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2795 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2796
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2797
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2798 void OrthancPlugins::RegisterChunkedRestCallback(const void* parameters)
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2799 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2800 const _OrthancPluginChunkedRestCallback& p =
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2801 *reinterpret_cast<const _OrthancPluginChunkedRestCallback*>(parameters);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
2802
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2803 CLOG(INFO, PLUGINS) << "Plugin has registered a REST callback for chunked streams on: "
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2804 << p.pathRegularExpression;
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2805
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2806 {
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2807 boost::unique_lock<boost::shared_mutex> lock(pimpl_->restCallbackRegistrationMutex_);
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2808 pimpl_->chunkedRestCallbacks_.push_back(new PImpl::ChunkedRestCallback(p));
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
2809 }
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2810 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
2811
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2812
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
2813 void OrthancPlugins::RegisterOnStoredInstanceCallback(const void* parameters)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2814 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2815 const _OrthancPluginOnStoredInstanceCallback& p =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2816 *reinterpret_cast<const _OrthancPluginOnStoredInstanceCallback*>(parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2817
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2818 CLOG(INFO, PLUGINS) << "Plugin has registered an OnStoredInstance callback";
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2819 pimpl_->onStoredCallbacks_.push_back(p.callback);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2820 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2821
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2822
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2823 void OrthancPlugins::RegisterOnChangeCallback(const void* parameters)
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2824 {
5410
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2825 boost::recursive_mutex::scoped_lock lock(pimpl_->changeCallbackMutex_);
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5389
diff changeset
2826
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2827 const _OrthancPluginOnChangeCallback& p =
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2828 *reinterpret_cast<const _OrthancPluginOnChangeCallback*>(parameters);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2829
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2830 CLOG(INFO, PLUGINS) << "Plugin has registered an OnChange callback";
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2831 pimpl_->onChangeCallbacks_.push_back(p.callback);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2832 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2833
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
2834
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2835 void OrthancPlugins::RegisterWorklistCallback(const void* parameters)
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2836 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2837 const _OrthancPluginWorklistCallback& p =
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2838 *reinterpret_cast<const _OrthancPluginWorklistCallback*>(parameters);
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2839
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
2840 boost::mutex::scoped_lock lock(pimpl_->worklistCallbackMutex_);
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
2841
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
2842 if (pimpl_->worklistCallback_ != NULL)
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
2843 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
2844 throw OrthancException(ErrorCode_Plugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
2845 "Can only register one plugin to handle modality worklists");
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
2846 }
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
2847 else
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
2848 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2849 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to handle modality worklists";
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
2850 pimpl_->worklistCallback_ = p.callback;
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
2851 }
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2852 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2853
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2854
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2855 void OrthancPlugins::RegisterFindCallback(const void* parameters)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2856 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2857 const _OrthancPluginFindCallback& p =
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2858 *reinterpret_cast<const _OrthancPluginFindCallback*>(parameters);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2859
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2860 boost::mutex::scoped_lock lock(pimpl_->findCallbackMutex_);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2861
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2862 if (pimpl_->findCallback_ != NULL)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2863 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
2864 throw OrthancException(ErrorCode_Plugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
2865 "Can only register one plugin to handle C-FIND requests");
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2866 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2867 else
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2868 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2869 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to handle C-FIND requests";
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2870 pimpl_->findCallback_ = p.callback;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2871 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2872 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2873
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2874
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2875 void OrthancPlugins::RegisterMoveCallback(const void* parameters)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2876 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2877 // invokeServiceMutex_ is assumed to be locked
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2878
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2879 const _OrthancPluginMoveCallback& p =
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2880 *reinterpret_cast<const _OrthancPluginMoveCallback*>(parameters);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2881
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2882 if (pimpl_->moveCallbacks_.callback != NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2883 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
2884 throw OrthancException(ErrorCode_Plugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
2885 "Can only register one plugin to handle C-MOVE requests");
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2886 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2887 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2888 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2889 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to handle C-MOVE requests";
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2890 pimpl_->moveCallbacks_ = p;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2891 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2892 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2893
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2894
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2895 void OrthancPlugins::RegisterDecodeImageCallback(const void* parameters)
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2896 {
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2897 const _OrthancPluginDecodeImageCallback& p =
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2898 *reinterpret_cast<const _OrthancPluginDecodeImageCallback*>(parameters);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2899
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
2900 boost::unique_lock<boost::shared_mutex> lock(pimpl_->decoderTranscoderMutex_);
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2901
2012
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
2902 pimpl_->decodeImageCallbacks_.push_back(p.callback);
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2903 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to decode DICOM images ("
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2904 << pimpl_->decodeImageCallbacks_.size() << " decoder(s) now active)";
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2905 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2906
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2907
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
2908 void OrthancPlugins::RegisterTranscoderCallback(const void* parameters)
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
2909 {
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
2910 const _OrthancPluginTranscoderCallback& p =
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
2911 *reinterpret_cast<const _OrthancPluginTranscoderCallback*>(parameters);
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
2912
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
2913 boost::unique_lock<boost::shared_mutex> lock(pimpl_->decoderTranscoderMutex_);
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
2914
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
2915 pimpl_->transcoderCallbacks_.push_back(p.callback);
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2916 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to transcode DICOM images ("
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2917 << pimpl_->transcoderCallbacks_.size() << " transcoder(s) now active)";
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
2918 }
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
2919
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
2920
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2921 void OrthancPlugins::RegisterJobsUnserializer(const void* parameters)
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2922 {
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2923 const _OrthancPluginJobsUnserializer& p =
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2924 *reinterpret_cast<const _OrthancPluginJobsUnserializer*>(parameters);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2925
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2926 boost::mutex::scoped_lock lock(pimpl_->jobsUnserializersMutex_);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2927
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2928 pimpl_->jobsUnserializers_.push_back(p.unserializer);
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2929 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to unserialize jobs ("
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2930 << pimpl_->jobsUnserializers_.size() << " unserializer(s) now active)";
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2931 }
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2932
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2933
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2934 void OrthancPlugins::RegisterIncomingHttpRequestFilter(const void* parameters)
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2935 {
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2936 const _OrthancPluginIncomingHttpRequestFilter& p =
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2937 *reinterpret_cast<const _OrthancPluginIncomingHttpRequestFilter*>(parameters);
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2938
4364
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
2939 boost::unique_lock<boost::shared_mutex> lock(pimpl_->incomingHttpRequestFilterMutex_);
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
2940
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2941 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to filter incoming HTTP requests";
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2942 pimpl_->incomingHttpRequestFilters_.push_back(p.callback);
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2943 }
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2944
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2945
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2946 void OrthancPlugins::RegisterIncomingHttpRequestFilter2(const void* parameters)
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2947 {
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2948 const _OrthancPluginIncomingHttpRequestFilter2& p =
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2949 *reinterpret_cast<const _OrthancPluginIncomingHttpRequestFilter2*>(parameters);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2950
4364
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
2951 boost::unique_lock<boost::shared_mutex> lock(pimpl_->incomingHttpRequestFilterMutex_);
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
2952
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2953 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to filter incoming HTTP requests";
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2954 pimpl_->incomingHttpRequestFilters2_.push_back(p.callback);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2955 }
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2956
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2957
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2958 void OrthancPlugins::RegisterIncomingDicomInstanceFilter(const void* parameters)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2959 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2960 const _OrthancPluginIncomingDicomInstanceFilter& p =
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2961 *reinterpret_cast<const _OrthancPluginIncomingDicomInstanceFilter*>(parameters);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2962
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
2963 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to filter incoming DICOM instances";
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2964 pimpl_->incomingDicomInstanceFilters_.push_back(p.callback);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2965 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2966
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2967
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2968 void OrthancPlugins::RegisterIncomingCStoreInstanceFilter(const void* parameters)
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2969 {
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2970 const _OrthancPluginIncomingCStoreInstanceFilter& p =
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2971 *reinterpret_cast<const _OrthancPluginIncomingCStoreInstanceFilter*>(parameters);
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2972
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2973 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to filter incoming C-Store DICOM instances";
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2974 pimpl_->incomingCStoreInstanceFilters_.push_back(p.callback);
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2975 }
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2976
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
2977 void OrthancPlugins::RegisterReceivedInstanceCallback(const void* parameters)
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
2978 {
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
2979 const _OrthancPluginReceivedInstanceCallback& p =
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
2980 *reinterpret_cast<const _OrthancPluginReceivedInstanceCallback*>(parameters);
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
2981
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2982 if (pimpl_->receivedInstanceCallback_ != NULL)
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2983 {
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2984 throw OrthancException(ErrorCode_Plugin,
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2985 "Can only register one plugin callback to process received instances");
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2986 }
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2987 else
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2988 {
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2989 CLOG(INFO, PLUGINS) << "Plugin has registered a received instance callback";
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2990 pimpl_->receivedInstanceCallback_ = p.callback;
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2991 }
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
2992 }
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4650
diff changeset
2993
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2994 void OrthancPlugins::RegisterRefreshMetricsCallback(const void* parameters)
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2995 {
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2996 const _OrthancPluginRegisterRefreshMetricsCallback& p =
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2997 *reinterpret_cast<const _OrthancPluginRegisterRefreshMetricsCallback*>(parameters);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2998
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2999 boost::mutex::scoped_lock lock(pimpl_->refreshMetricsMutex_);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
3000
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
3001 CLOG(INFO, PLUGINS) << "Plugin has registered a callback to refresh its metrics";
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
3002 pimpl_->refreshMetricsCallbacks_.push_back(p.callback);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
3003 }
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
3004
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
3005
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
3006 void OrthancPlugins::RegisterStorageCommitmentScpCallback(const void* parameters)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
3007 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
3008 const _OrthancPluginRegisterStorageCommitmentScpCallback& p =
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
3009 *reinterpret_cast<const _OrthancPluginRegisterStorageCommitmentScpCallback*>(parameters);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
3010
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
3011 boost::mutex::scoped_lock lock(pimpl_->storageCommitmentScpMutex_);
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
3012 CLOG(INFO, PLUGINS) << "Plugin has registered a storage commitment callback";
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
3013
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
3014 pimpl_->storageCommitmentScpCallbacks_.push_back(new PImpl::StorageCommitmentScp(p));
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
3015 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
3016
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
3017
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
3018 void OrthancPlugins::AnswerBuffer(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3019 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3020 const _OrthancPluginAnswerBuffer& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3021 *reinterpret_cast<const _OrthancPluginAnswerBuffer*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3022
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3023 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3024 translatedOutput.SetContentType(p.mimeType);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3025 translatedOutput.Answer(p.answer, p.answerSize);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3026 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3027
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3028
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
3029 void OrthancPlugins::Redirect(const void* parameters)
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
3030 {
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3031 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3032 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3033
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3034 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3035 translatedOutput.Redirect(p.argument);
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3036 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3037
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3038
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
3039 void OrthancPlugins::SendHttpStatusCode(const void* parameters)
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3040 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3041 const _OrthancPluginSendHttpStatusCode& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3042 *reinterpret_cast<const _OrthancPluginSendHttpStatusCode*>(parameters);
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
3043
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3044 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3045 translatedOutput.SendStatus(static_cast<HttpStatus>(p.status));
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3046 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3047
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3048
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3049 void OrthancPlugins::SendHttpStatus(const void* parameters)
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3050 {
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3051 const _OrthancPluginSendHttpStatus& p =
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3052 *reinterpret_cast<const _OrthancPluginSendHttpStatus*>(parameters);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3053
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3054 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3055 HttpStatus status = static_cast<HttpStatus>(p.status);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3056
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3057 if (p.bodySize > 0 && p.body != NULL)
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3058 {
5076
25844bc0b2cb fix signature of OrthancPluginSendHttpStatus() for the "body" argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5036
diff changeset
3059 translatedOutput.SendStatus(status, reinterpret_cast<const char*>(p.body), p.bodySize);
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3060 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3061 else
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3062 {
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3063 translatedOutput.SendStatus(status);
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3064 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3065 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3066
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3067
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
3068 void OrthancPlugins::SendUnauthorized(const void* parameters)
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3069 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3070 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3071 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3072
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3073 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3074 translatedOutput.SendUnauthorized(p.argument);
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3075 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3076
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3077
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
3078 void OrthancPlugins::SendMethodNotAllowed(const void* parameters)
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3079 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3080 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3081 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3082
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3083 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3084 translatedOutput.SendMethodNotAllowed(p.argument);
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3085 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3086
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3087
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
3088 void OrthancPlugins::SetCookie(const void* parameters)
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3089 {
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3090 const _OrthancPluginSetHttpHeader& p =
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3091 *reinterpret_cast<const _OrthancPluginSetHttpHeader*>(parameters);
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3092
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3093 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3094 translatedOutput.SetCookie(p.key, p.value);
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3095 }
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3096
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3097
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3098 void OrthancPlugins::SetHttpHeader(const void* parameters)
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3099 {
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3100 const _OrthancPluginSetHttpHeader& p =
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3101 *reinterpret_cast<const _OrthancPluginSetHttpHeader*>(parameters);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3102
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3103 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3104 translatedOutput.AddHeader(p.key, p.value);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3105 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3106
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3107
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3108 void OrthancPlugins::SetHttpErrorDetails(const void* parameters)
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3109 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3110 const _OrthancPluginSetHttpErrorDetails& p =
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3111 *reinterpret_cast<const _OrthancPluginSetHttpErrorDetails*>(parameters);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3112
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
3113 PImpl::PluginHttpOutput* output =
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
3114 reinterpret_cast<PImpl::PluginHttpOutput*>(p.output);
4056
55727d85f419 fix for msvc2008
s.jodogne@gmail.com
parents: 4055
diff changeset
3115 output->SetErrorDetails(p.details, (p.log != 0));
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
3116 }
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
3117
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
3118
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
3119 void OrthancPlugins::CompressAndAnswerPngImage(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3120 {
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3121 // Bridge for backward compatibility with Orthanc <= 0.9.3
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3122 const _OrthancPluginCompressAndAnswerPngImage& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3123 *reinterpret_cast<const _OrthancPluginCompressAndAnswerPngImage*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3124
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3125 _OrthancPluginCompressAndAnswerImage p2;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3126 p2.output = p.output;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3127 p2.imageFormat = OrthancPluginImageFormat_Png;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3128 p2.pixelFormat = p.format;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3129 p2.width = p.width;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3130 p2.height = p.height;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3131 p2.pitch = p.height;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3132 p2.buffer = p.buffer;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3133 p2.quality = 0;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3134
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3135 CompressAndAnswerImage(&p2);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3136 }
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3137
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3138
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3139 void OrthancPlugins::CompressAndAnswerImage(const void* parameters)
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3140 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3141 const _OrthancPluginCompressAndAnswerImage& p =
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3142 *reinterpret_cast<const _OrthancPluginCompressAndAnswerImage*>(parameters);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3143
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3144 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3145
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3146 ImageAccessor accessor;
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
3147 accessor.AssignReadOnly(Plugins::Convert(p.pixelFormat), p.width, p.height, p.pitch, p.buffer);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3148
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3149 std::string compressed;
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3150
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3151 switch (p.imageFormat)
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3152 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3153 case OrthancPluginImageFormat_Png:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3154 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3155 PngWriter writer;
4311
cb9aef006229 turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4271
diff changeset
3156 IImageWriter::WriteToMemory(writer, compressed, accessor);
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3157 translatedOutput.SetContentType(MimeType_Png);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3158 break;
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3159 }
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3160
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3161 case OrthancPluginImageFormat_Jpeg:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3162 {
1603
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3163 JpegWriter writer;
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3164 writer.SetQuality(p.quality);
4311
cb9aef006229 turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4271
diff changeset
3165 IImageWriter::WriteToMemory(writer, compressed, accessor);
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3166 translatedOutput.SetContentType(MimeType_Jpeg);
1603
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
3167 break;
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3168 }
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3169
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3170 default:
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3171 throw OrthancException(ErrorCode_ParameterOutOfRange);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3172 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3173
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3174 translatedOutput.Answer(compressed);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3175 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3176
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3177
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
3178 void OrthancPlugins::GetDicomForInstance(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3179 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3180 const _OrthancPluginGetDicomForInstance& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3181 *reinterpret_cast<const _OrthancPluginGetDicomForInstance*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3182
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3183 std::string dicom;
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
3184
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3185 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
3186 PImpl::ServerContextReference lock(*pimpl_);
2124
2b1520efa282 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
3187 lock.GetContext().ReadDicom(dicom, p.instanceId);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3188 }
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
3189
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3190 CopyToMemoryBuffer(*p.target, dicom);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3191 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3192
5099
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3193 static void ThrowOnHttpError(HttpStatus httpStatus)
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3194 {
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3195 int intHttpStatus = static_cast<int>(httpStatus);
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3196 if (intHttpStatus >= 200 && intHttpStatus <= 300)
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3197 {
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3198 return; // not an error
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3199 }
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3200 else if (intHttpStatus == 401 || intHttpStatus == 403)
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3201 {
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3202 throw OrthancException(ErrorCode_Unauthorized);
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3203 }
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3204 else if (intHttpStatus == 404)
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3205 {
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3206 throw OrthancException(ErrorCode_UnknownResource);
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3207 }
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3208 else
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3209 {
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3210 throw OrthancException(ErrorCode_BadRequest);
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3211 }
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3212 }
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3213
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3214
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3215 void OrthancPlugins::RestApiGet(const void* parameters,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3216 bool afterPlugins)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3217 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3218 const _OrthancPluginRestApiGet& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3219 *reinterpret_cast<const _OrthancPluginRestApiGet*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3220
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
3221 CLOG(INFO, PLUGINS) << "Plugin making REST GET call on URI " << p.uri
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
3222 << (afterPlugins ? " (after plugins)" : " (built-in API)");
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3223
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3224 IHttpHandler* handler;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3225
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3226 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
3227 PImpl::ServerContextReference lock(*pimpl_);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3228 handler = &lock.GetContext().GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3229 }
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3230
3442
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
3231 std::map<std::string, std::string> httpHeaders;
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
3232
1445
d26c8a93d05a refactoring: SimpleGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
3233 std::string result;
5099
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3234
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3235 ThrowOnHttpError(IHttpHandler::SimpleGet(result, NULL, *handler, RequestOrigin_Plugins, p.uri, httpHeaders));
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3236 CopyToMemoryBuffer(*p.target, result);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3237 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3238
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3239
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3240 void OrthancPlugins::RestApiGet2(const void* parameters)
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3241 {
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3242 const _OrthancPluginRestApiGet2& p =
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3243 *reinterpret_cast<const _OrthancPluginRestApiGet2*>(parameters);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3244
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
3245 CLOG(INFO, PLUGINS) << "Plugin making REST GET call on URI " << p.uri
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
3246 << (p.afterPlugins ? " (after plugins)" : " (built-in API)");
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3247
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
3248 HttpToolbox::Arguments headers;
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3249
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3250 for (uint32_t i = 0; i < p.headersCount; i++)
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3251 {
1918
e8c2f993f6b3 fix case for HTTP headers keys in OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1916
diff changeset
3252 std::string name(p.headersKeys[i]);
e8c2f993f6b3 fix case for HTTP headers keys in OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1916
diff changeset
3253 std::transform(name.begin(), name.end(), name.begin(), ::tolower);
e8c2f993f6b3 fix case for HTTP headers keys in OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1916
diff changeset
3254 headers[name] = p.headersValues[i];
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3255 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3256
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3257 IHttpHandler* handler;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3258
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3259 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
3260 PImpl::ServerContextReference lock(*pimpl_);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3261 handler = &lock.GetContext().GetHttpHandler().RestrictToOrthancRestApi(!p.afterPlugins);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3262 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3263
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3264 std::string result;
5099
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3265
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3266 ThrowOnHttpError(IHttpHandler::SimpleGet(result, NULL, *handler, RequestOrigin_Plugins, p.uri, headers));
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3267 CopyToMemoryBuffer(*p.target, result);
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3268 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3269
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3270
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3271 void OrthancPlugins::RestApiPostPut(bool isPost,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3272 const void* parameters,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3273 bool afterPlugins)
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3274 {
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3275 const _OrthancPluginRestApiPostPut& p =
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3276 *reinterpret_cast<const _OrthancPluginRestApiPostPut*>(parameters);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3277
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
3278 CLOG(INFO, PLUGINS) << "Plugin making REST " << EnumerationToString(isPost ? HttpMethod_Post : HttpMethod_Put)
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
3279 << " call on URI " << p.uri << (afterPlugins ? " (after plugins)" : " (built-in API)");
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3280
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3281 IHttpHandler* handler;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3282
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3283 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
3284 PImpl::ServerContextReference lock(*pimpl_);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3285 handler = &lock.GetContext().GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3286 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3287
3442
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
3288 std::map<std::string, std::string> httpHeaders;
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
3289
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3290 std::string result;
5099
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3291
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3292 ThrowOnHttpError((isPost ?
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3293 IHttpHandler::SimplePost(result, NULL, *handler, RequestOrigin_Plugins, p.uri,
5099
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3294 p.body, p.bodySize, httpHeaders) :
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3295 IHttpHandler::SimplePut(result, NULL, *handler, RequestOrigin_Plugins, p.uri,
5099
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3296 p.body, p.bodySize, httpHeaders)));
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3297 CopyToMemoryBuffer(*p.target, result);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3298 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3299
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3300
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3301 void OrthancPlugins::RestApiDelete(const void* parameters,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3302 bool afterPlugins)
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3303 {
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
3304 const char* uri = reinterpret_cast<const char*>(parameters);
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
3305 CLOG(INFO, PLUGINS) << "Plugin making REST DELETE call on URI " << uri
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
3306 << (afterPlugins ? " (after plugins)" : " (built-in API)");
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3307
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3308 IHttpHandler* handler;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3309
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3310 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
3311 PImpl::ServerContextReference lock(*pimpl_);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3312 handler = &lock.GetContext().GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3313 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3314
3442
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
3315 std::map<std::string, std::string> httpHeaders;
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
3316
5099
edefb278cb77 cleanup
Alain Mazy <am@osimis.io>
parents: 5076
diff changeset
3317 ThrowOnHttpError(IHttpHandler::SimpleDelete(NULL, *handler, RequestOrigin_Plugins, uri, httpHeaders));
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3318 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3319
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3320
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
3321 void OrthancPlugins::LookupResource(_OrthancPluginService service,
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
3322 const void* parameters)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3323 {
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
3324 const _OrthancPluginRetrieveDynamicString& p =
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
3325 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3326
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3327 /**
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3328 * The enumeration below only uses the tags that are indexed in
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3329 * the Orthanc database. It reflects the
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3330 * "CandidateResources::ApplyFilter()" method of the
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3331 * "OrthancFindRequestHandler" class.
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3332 **/
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3333
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3334 DicomTag tag(0, 0);
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3335 ResourceType level;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3336 switch (service)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3337 {
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3338 case _OrthancPluginService_LookupPatient:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3339 tag = DICOM_TAG_PATIENT_ID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3340 level = ResourceType_Patient;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3341 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3342
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3343 case _OrthancPluginService_LookupStudy:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3344 tag = DICOM_TAG_STUDY_INSTANCE_UID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3345 level = ResourceType_Study;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3346 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3347
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3348 case _OrthancPluginService_LookupStudyWithAccessionNumber:
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3349 tag = DICOM_TAG_ACCESSION_NUMBER;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3350 level = ResourceType_Study;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3351 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3352
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3353 case _OrthancPluginService_LookupSeries:
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3354 tag = DICOM_TAG_SERIES_INSTANCE_UID;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3355 level = ResourceType_Series;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3356 break;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3357
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3358 case _OrthancPluginService_LookupInstance:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3359 tag = DICOM_TAG_SOP_INSTANCE_UID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3360 level = ResourceType_Instance;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3361 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3362
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3363 default:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3364 throw OrthancException(ErrorCode_InternalError);
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3365 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3366
3034
54e422fe31ce moving LookupResource to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2984
diff changeset
3367 std::vector<std::string> result;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3368
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3369 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
3370 PImpl::ServerContextReference lock(*pimpl_);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3371 lock.GetContext().GetIndex().LookupIdentifierExact(result, level, tag, p.argument);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3372 }
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3373
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3374 if (result.size() == 1)
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3375 {
3034
54e422fe31ce moving LookupResource to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2984
diff changeset
3376 *p.result = CopyString(result[0]);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3377 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3378 else
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3379 {
3507
69e49fc044f8 Fix generation of "SOP Instance UID" on split and merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3442
diff changeset
3380 if (result.size() > 1)
69e49fc044f8 Fix generation of "SOP Instance UID" on split and merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3442
diff changeset
3381 {
69e49fc044f8 Fix generation of "SOP Instance UID" on split and merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3442
diff changeset
3382 LOG(WARNING) << "LookupResource(): Multiple resources match the query (instead of 0 or 1), which indicates "
69e49fc044f8 Fix generation of "SOP Instance UID" on split and merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3442
diff changeset
3383 << "your DICOM database breaks the DICOM model of the real world";
69e49fc044f8 Fix generation of "SOP Instance UID" on split and merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3442
diff changeset
3384 }
69e49fc044f8 Fix generation of "SOP Instance UID" on split and merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3442
diff changeset
3385
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3386 throw OrthancException(ErrorCode_UnknownResource);
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3387 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3388 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3389
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3390
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3391 static void AccessInstanceMetadataInternal(bool checkExistence,
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3392 const _OrthancPluginAccessDicomInstance& params,
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3393 const DicomInstanceToStore& instance)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3394 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3395 MetadataType metadata;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3396
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3397 try
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3398 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3399 metadata = StringToMetadata(params.key);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3400 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3401 catch (OrthancException&)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3402 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3403 // Unknown metadata
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3404 if (checkExistence)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3405 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3406 *params.resultInt64 = -1;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3407 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3408 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3409 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3410 *params.resultString = NULL;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3411 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3412
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3413 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3414 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3415
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3416 ServerIndex::MetadataMap::const_iterator it =
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3417 instance.GetMetadata().find(std::make_pair(ResourceType_Instance, metadata));
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3418
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3419 if (checkExistence)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3420 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3421 if (it != instance.GetMetadata().end())
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3422 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3423 *params.resultInt64 = 1;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3424 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3425 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3426 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3427 *params.resultInt64 = 0;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3428 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3429 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3430 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3431 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3432 if (it != instance.GetMetadata().end())
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3433 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3434 *params.resultString = it->second.c_str();
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3435 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3436 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3437 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3438 // Error: Missing metadata
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3439 *params.resultString = NULL;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3440 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3441 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3442 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3443
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3444
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3445 void OrthancPlugins::AccessDicomInstance(_OrthancPluginService service,
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3446 const void* parameters)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3447 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3448 const _OrthancPluginAccessDicomInstance& p =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3449 *reinterpret_cast<const _OrthancPluginAccessDicomInstance*>(parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3450
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3451 if (p.instance == NULL)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3452 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3453 throw OrthancException(ErrorCode_NullPointer);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3454 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3455
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3456 const DicomInstanceToStore& instance =
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3457 reinterpret_cast<const IDicomInstance*>(p.instance)->GetInstance();
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3458
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3459 switch (service)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3460 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3461 case _OrthancPluginService_GetInstanceRemoteAet:
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
3462 *p.resultString = instance.GetOrigin().GetRemoteAetC();
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3463 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3464
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3465 case _OrthancPluginService_GetInstanceSize:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3466 *p.resultInt64 = instance.GetBufferSize();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3467 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3468
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3469 case _OrthancPluginService_GetInstanceData:
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
3470 *p.resultString = reinterpret_cast<const char*>(instance.GetBufferData());
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3471 return;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3472
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3473 case _OrthancPluginService_HasInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3474 AccessInstanceMetadataInternal(true, p, instance);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3475 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3476
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3477 case _OrthancPluginService_GetInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3478 AccessInstanceMetadataInternal(false, p, instance);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3479 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3480
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3481 case _OrthancPluginService_GetInstanceJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3482 case _OrthancPluginService_GetInstanceSimplifiedJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3483 {
4504
7d1eabfac6e0 removed cached dicom-as-json from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4498
diff changeset
3484 Json::Value dicomAsJson;
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 5030
diff changeset
3485 std::set<DicomTag> ignoreTagLength;
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 5030
diff changeset
3486 instance.GetDicomAsJson(dicomAsJson, ignoreTagLength);
4504
7d1eabfac6e0 removed cached dicom-as-json from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4498
diff changeset
3487
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3488 std::string s;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3489 if (service == _OrthancPluginService_GetInstanceJson)
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3490 {
4504
7d1eabfac6e0 removed cached dicom-as-json from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4498
diff changeset
3491 Toolbox::WriteStyledJson(s, dicomAsJson);
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3492 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3493 else
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3494 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3495 Json::Value simplified;
4504
7d1eabfac6e0 removed cached dicom-as-json from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4498
diff changeset
3496 Toolbox::SimplifyDicomAsJson(simplified, dicomAsJson, DicomToJsonFormat_Human);
4394
f7104e9d044c functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4392
diff changeset
3497 Toolbox::WriteStyledJson(s, simplified);
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3498 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3499
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3500 *p.resultStringToFree = CopyString(s);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3501 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3502 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3503
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
3504 case _OrthancPluginService_GetInstanceOrigin: // New in Orthanc 0.9.5
2640
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
3505 *p.resultOrigin = Plugins::Convert(instance.GetOrigin().GetRequestOrigin());
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
3506 return;
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
3507
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3508 case _OrthancPluginService_GetInstanceTransferSyntaxUid: // New in Orthanc 1.6.1
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3509 {
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
3510 DicomTransferSyntax s;
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
3511 if (instance.LookupTransferSyntax(s))
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3512 {
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
3513 *p.resultStringToFree = CopyString(GetTransferSyntaxUid(s));
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
3514 }
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
3515 else
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
3516 {
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
3517 *p.resultStringToFree = CopyString("");
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3518 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3519
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3520 return;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3521 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3522
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3523 case _OrthancPluginService_HasInstancePixelData: // New in Orthanc 1.6.1
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3524 *p.resultInt64 = instance.HasPixelData();
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3525 return;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3526
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3527 case _OrthancPluginService_GetInstanceFramesCount: // New in Orthanc 1.7.0
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
3528 *p.resultInt64 = instance.GetFramesCount();
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3529 return;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3530
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3531 default:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3532 throw OrthancException(ErrorCode_InternalError);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3533 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3534 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3535
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3536
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3537 void OrthancPlugins::BufferCompression(const void* parameters)
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3538 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3539 const _OrthancPluginBufferCompression& p =
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3540 *reinterpret_cast<const _OrthancPluginBufferCompression*>(parameters);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3541
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3542 std::string result;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3543
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3544 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
3545 std::unique_ptr<DeflateBaseCompressor> compressor;
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3546
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3547 switch (p.compression)
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3548 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3549 case OrthancPluginCompressionType_Zlib:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3550 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3551 compressor.reset(new ZlibCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3552 compressor->SetPrefixWithUncompressedSize(false);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3553 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3554 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3555
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3556 case OrthancPluginCompressionType_ZlibWithSize:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3557 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3558 compressor.reset(new ZlibCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3559 compressor->SetPrefixWithUncompressedSize(true);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3560 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3561 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3562
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3563 case OrthancPluginCompressionType_Gzip:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3564 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3565 compressor.reset(new GzipCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3566 compressor->SetPrefixWithUncompressedSize(false);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3567 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3568 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3569
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3570 case OrthancPluginCompressionType_GzipWithSize:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3571 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3572 compressor.reset(new GzipCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3573 compressor->SetPrefixWithUncompressedSize(true);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3574 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3575 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3576
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3577 default:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3578 throw OrthancException(ErrorCode_ParameterOutOfRange);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3579 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3580
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3581 if (p.uncompress)
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3582 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3583 compressor->Uncompress(result, p.source, p.size);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3584 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3585 else
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3586 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3587 compressor->Compress(result, p.source, p.size);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3588 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3589 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3590
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3591 CopyToMemoryBuffer(*p.target, result);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3592 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3593
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3594
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
3595 static OrthancPluginImage* ReturnImage(std::unique_ptr<ImageAccessor>& image)
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3596 {
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3597 // Images returned to plugins are assumed to be writeable. If the
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3598 // input image is read-only, we return a copy so that it can be modified.
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3599
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3926
diff changeset
3600 if (image.get() == NULL)
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3926
diff changeset
3601 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3926
diff changeset
3602 throw OrthancException(ErrorCode_NullPointer);
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3926
diff changeset
3603 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3926
diff changeset
3604
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3605 if (image->IsReadOnly())
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3606 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
3607 std::unique_ptr<Image> copy(new Image(image->GetFormat(), image->GetWidth(), image->GetHeight(), false));
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3608 ImageProcessing::Copy(*copy, *image);
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3609 image.reset(NULL);
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3610 return reinterpret_cast<OrthancPluginImage*>(copy.release());
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3611 }
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3612 else
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3613 {
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3614 return reinterpret_cast<OrthancPluginImage*>(image.release());
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3615 }
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3616 }
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3617
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3618
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3619 void OrthancPlugins::AccessDicomInstance2(_OrthancPluginService service,
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3620 const void* parameters)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3621 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3622 const _OrthancPluginAccessDicomInstance2& p =
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3623 *reinterpret_cast<const _OrthancPluginAccessDicomInstance2*>(parameters);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3624
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3625 if (p.instance == NULL)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3626 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3627 throw OrthancException(ErrorCode_NullPointer);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3628 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3629
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3630 const DicomInstanceToStore& instance =
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3631 reinterpret_cast<const IDicomInstance*>(p.instance)->GetInstance();
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3632
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3633 switch (service)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3634 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3635 case _OrthancPluginService_GetInstanceFramesCount:
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
3636 *p.targetUint32 = instance.GetFramesCount();
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3637 return;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3638
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3639 case _OrthancPluginService_GetInstanceRawFrame:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3640 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3641 if (p.targetBuffer == NULL)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3642 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3643 throw OrthancException(ErrorCode_NullPointer);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3644 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3645
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3646 p.targetBuffer->data = NULL;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3647 p.targetBuffer->size = 0;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3648
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3649 MimeType mime;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3650 std::string frame;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3651 instance.GetParsedDicomFile().GetRawFrame(frame, mime, p.frameIndex);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3652 CopyToMemoryBuffer(*p.targetBuffer, frame);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3653 return;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3654 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3655
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3656 case _OrthancPluginService_GetInstanceDecodedFrame:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3657 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3658 if (p.targetImage == NULL)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3659 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3660 throw OrthancException(ErrorCode_NullPointer);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3661 }
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3926
diff changeset
3662
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3926
diff changeset
3663 std::unique_ptr<ImageAccessor> decoded;
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3664 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
3665 PImpl::ServerContextReference lock(*pimpl_);
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3926
diff changeset
3666 decoded.reset(lock.GetContext().DecodeDicomFrame(instance, p.frameIndex));
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3667 }
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3926
diff changeset
3668
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3669 *(p.targetImage) = ReturnImage(decoded);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3670 return;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3671 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3672
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
3673 case _OrthancPluginService_SerializeDicomInstance:
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
3674 {
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
3675 if (p.targetBuffer == NULL)
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
3676 {
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
3677 throw OrthancException(ErrorCode_NullPointer);
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
3678 }
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
3679
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
3680 p.targetBuffer->data = NULL;
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
3681 p.targetBuffer->size = 0;
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
3682 CopyToMemoryBuffer(*p.targetBuffer, instance.GetBufferData(), instance.GetBufferSize());
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
3683 return;
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
3684 }
3925
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3685
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3686 case _OrthancPluginService_GetInstanceAdvancedJson:
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3687 {
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3688 if (p.targetStringToFree == NULL)
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3689 {
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3690 throw OrthancException(ErrorCode_NullPointer);
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3691 }
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
3692
3925
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3693 Json::Value json;
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
3694 instance.DatasetToJson(json, Plugins::Convert(p.format),
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
3695 static_cast<DicomToJsonFlags>(p.flags), p.maxStringLength);
3925
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3696
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4374
diff changeset
3697 std::string s;
4394
f7104e9d044c functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4392
diff changeset
3698 Toolbox::WriteFastJson(s, json);
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4374
diff changeset
3699 *p.targetStringToFree = CopyString(s);
3925
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3700 return;
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3701 }
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3702
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3703 case _OrthancPluginService_GetInstanceDicomWebJson:
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3704 case _OrthancPluginService_GetInstanceDicomWebXml:
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3705 {
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3706 if (p.targetStringToFree == NULL)
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3707 {
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3708 throw OrthancException(ErrorCode_NullPointer);
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3709 }
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3710
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3711 DicomWebBinaryFormatter formatter(p.dicomWebCallback, p.dicomWebPayload);
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3712 formatter.Apply(p.targetStringToFree,
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3713 (service == _OrthancPluginService_GetInstanceDicomWebJson),
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3714 instance.GetParsedDicomFile());
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3715 return;
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3716 }
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
3717
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3718 default:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3719 throw OrthancException(ErrorCode_InternalError);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3720 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3721 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3722
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3723
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3724 void OrthancPlugins::UncompressImage(const void* parameters)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3725 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
3726 const _OrthancPluginUncompressImage& p = *reinterpret_cast<const _OrthancPluginUncompressImage*>(parameters);
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3727
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
3728 std::unique_ptr<ImageAccessor> image;
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3729
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3730 switch (p.format)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3731 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3732 case OrthancPluginImageFormat_Png:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3733 {
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3734 image.reset(new PngReader);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3735 reinterpret_cast<PngReader&>(*image).ReadFromMemory(p.data, p.size);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3736 break;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3737 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3738
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3739 case OrthancPluginImageFormat_Jpeg:
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3740 {
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3741 image.reset(new JpegReader);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3742 reinterpret_cast<JpegReader&>(*image).ReadFromMemory(p.data, p.size);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3743 break;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3744 }
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3745
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3746 case OrthancPluginImageFormat_Dicom:
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3747 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
3748 PImpl::ServerContextReference lock(*pimpl_);
3980
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3964
diff changeset
3749 image.reset(lock.GetContext().DecodeDicomFrame(p.data, p.size, 0));
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3750 break;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3751 }
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3752
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3753 default:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3754 throw OrthancException(ErrorCode_ParameterOutOfRange);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3755 }
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3756
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3757 *(p.target) = ReturnImage(image);
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3758 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3759
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3760
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3761 void OrthancPlugins::CompressImage(const void* parameters)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3762 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
3763 const _OrthancPluginCompressImage& p = *reinterpret_cast<const _OrthancPluginCompressImage*>(parameters);
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3764
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3765 std::string compressed;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3766
1916
5bcf721bde4f IImageWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1906
diff changeset
3767 ImageAccessor accessor;
5bcf721bde4f IImageWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1906
diff changeset
3768 accessor.AssignReadOnly(Plugins::Convert(p.pixelFormat), p.width, p.height, p.pitch, p.buffer);
5bcf721bde4f IImageWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1906
diff changeset
3769
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3770 switch (p.imageFormat)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3771 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3772 case OrthancPluginImageFormat_Png:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3773 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3774 PngWriter writer;
4311
cb9aef006229 turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4271
diff changeset
3775 IImageWriter::WriteToMemory(writer, compressed, accessor);
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3776 break;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3777 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3778
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3779 case OrthancPluginImageFormat_Jpeg:
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3780 {
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3781 JpegWriter writer;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3782 writer.SetQuality(p.quality);
4311
cb9aef006229 turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4271
diff changeset
3783 IImageWriter::WriteToMemory(writer, compressed, accessor);
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3784 break;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
3785 }
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3786
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3787 default:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3788 throw OrthancException(ErrorCode_ParameterOutOfRange);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3789 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3790
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3791 CopyToMemoryBuffer(*p.target, compressed.size() > 0 ? compressed.c_str() : NULL, compressed.size());
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3792 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3793
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3794
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3795 static void SetupHttpClient(HttpClient& client,
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3796 const _OrthancPluginCallHttpClient2& parameters)
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3797 {
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3798 client.SetUrl(parameters.url);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3799 client.SetConvertHeadersToLowerCase(false);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3800
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3801 if (parameters.timeout != 0)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3802 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3803 client.SetTimeout(parameters.timeout);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3804 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3805
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3806 if (parameters.username != NULL &&
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3807 parameters.password != NULL)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3808 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3809 client.SetCredentials(parameters.username, parameters.password);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3810 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3811
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3812 if (parameters.certificateFile != NULL)
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3813 {
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3814 std::string certificate(parameters.certificateFile);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3815 std::string key, password;
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3816
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3817 if (parameters.certificateKeyFile)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3818 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3819 key.assign(parameters.certificateKeyFile);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3820 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3821
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3822 if (parameters.certificateKeyPassword)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3823 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3824 password.assign(parameters.certificateKeyPassword);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3825 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3826
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3827 client.SetClientCertificate(certificate, key, password);
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3828 }
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3829
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3830 client.SetPkcs11Enabled(parameters.pkcs11 ? true : false);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3831
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3832 for (uint32_t i = 0; i < parameters.headersCount; i++)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3833 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3834 if (parameters.headersKeys[i] == NULL ||
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3835 parameters.headersValues[i] == NULL)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3836 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3837 throw OrthancException(ErrorCode_NullPointer);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3838 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3839
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3840 client.AddHeader(parameters.headersKeys[i], parameters.headersValues[i]);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3841 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3842
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3843 switch (parameters.method)
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3844 {
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3845 case OrthancPluginHttpMethod_Get:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3846 client.SetMethod(HttpMethod_Get);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3847 break;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3848
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3849 case OrthancPluginHttpMethod_Post:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3850 client.SetMethod(HttpMethod_Post);
4650
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4628
diff changeset
3851 client.SetExternalBody(parameters.body, parameters.bodySize);
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3852 break;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3853
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3854 case OrthancPluginHttpMethod_Put:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3855 client.SetMethod(HttpMethod_Put);
4650
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4628
diff changeset
3856 client.SetExternalBody(parameters.body, parameters.bodySize);
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3857 break;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3858
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3859 case OrthancPluginHttpMethod_Delete:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3860 client.SetMethod(HttpMethod_Delete);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3861 break;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3862
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3863 default:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3864 throw OrthancException(ErrorCode_ParameterOutOfRange);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3865 }
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3866 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3867
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3868
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3869 static void ExecuteHttpClientWithoutChunkedBody(uint16_t& httpStatus,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3870 OrthancPluginMemoryBuffer* answerBody,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3871 OrthancPluginMemoryBuffer* answerHeaders,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3872 HttpClient& client)
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3873 {
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
3874 std::string body;
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
3875 HttpClient::HttpHeaders headers;
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
3876
2787
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
3877 bool success = client.Apply(body, headers);
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
3878
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
3879 // The HTTP request has succeeded
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3880 httpStatus = static_cast<uint16_t>(client.GetLastStatus());
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
3881
2787
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
3882 if (!success)
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
3883 {
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
3884 HttpClient::ThrowException(client.GetLastStatus());
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
3885 }
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
3886
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
3887 // Copy the HTTP headers of the answer, if the plugin requested them
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3888 if (answerHeaders != NULL)
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3889 {
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3890 CopyDictionary(*answerHeaders, headers);
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3891 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3892
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
3893 // Copy the body of the answer if it makes sense
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3894 if (client.GetMethod() != HttpMethod_Delete)
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3895 {
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3896 try
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3897 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3898 if (answerBody != NULL)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3899 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3900 CopyToMemoryBuffer(*answerBody, body);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3901 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3902 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3903 catch (OrthancException&)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3904 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3905 if (answerHeaders != NULL)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3906 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3907 free(answerHeaders->data);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3908 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3909 throw;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
3910 }
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3911 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3912 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3913
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3914
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3915 void OrthancPlugins::CallHttpClient(const void* parameters)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3916 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3917 const _OrthancPluginCallHttpClient& p = *reinterpret_cast<const _OrthancPluginCallHttpClient*>(parameters);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3918
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3919 HttpClient client;
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3920
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3921 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3922 _OrthancPluginCallHttpClient2 converted;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3923 memset(&converted, 0, sizeof(converted));
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3924
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3925 converted.answerBody = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3926 converted.answerHeaders = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3927 converted.httpStatus = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3928 converted.method = p.method;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3929 converted.url = p.url;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3930 converted.headersCount = 0;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3931 converted.headersKeys = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3932 converted.headersValues = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3933 converted.body = p.body;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3934 converted.bodySize = p.bodySize;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3935 converted.username = p.username;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3936 converted.password = p.password;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3937 converted.timeout = 0; // Use default timeout
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3938 converted.certificateFile = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3939 converted.certificateKeyFile = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3940 converted.certificateKeyPassword = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3941 converted.pkcs11 = false;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3942
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3943 SetupHttpClient(client, converted);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3944 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3945
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3946 uint16_t status;
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3947 ExecuteHttpClientWithoutChunkedBody(status, p.target, NULL, client);
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3948 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3949
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3950
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3951 void OrthancPlugins::CallHttpClient2(const void* parameters)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3952 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3953 const _OrthancPluginCallHttpClient2& p = *reinterpret_cast<const _OrthancPluginCallHttpClient2*>(parameters);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3954
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3955 if (p.httpStatus == NULL)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3956 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3957 throw OrthancException(ErrorCode_NullPointer);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3958 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3959
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3960 HttpClient client;
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3961
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3962 if (p.method == OrthancPluginHttpMethod_Post ||
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3963 p.method == OrthancPluginHttpMethod_Put)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3964 {
4650
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4628
diff changeset
3965 client.SetExternalBody(p.body, p.bodySize);
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3966 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3967
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3968 SetupHttpClient(client, p);
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3969 ExecuteHttpClientWithoutChunkedBody(*p.httpStatus, p.answerBody, p.answerHeaders, client);
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3970 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3971
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3972
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3973 void OrthancPlugins::ChunkedHttpClient(const void* parameters)
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3974 {
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3975 const _OrthancPluginChunkedHttpClient& p =
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3976 *reinterpret_cast<const _OrthancPluginChunkedHttpClient*>(parameters);
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3977
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3978 if (p.httpStatus == NULL)
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3979 {
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3980 throw OrthancException(ErrorCode_NullPointer);
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3981 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3982
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3983 HttpClient client;
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3984
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3985 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3986 _OrthancPluginCallHttpClient2 converted;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3987 memset(&converted, 0, sizeof(converted));
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3988
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3989 converted.answerBody = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3990 converted.answerHeaders = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3991 converted.httpStatus = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3992 converted.method = p.method;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3993 converted.url = p.url;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3994 converted.headersCount = p.headersCount;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3995 converted.headersKeys = p.headersKeys;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3996 converted.headersValues = p.headersValues;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3997 converted.body = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3998 converted.bodySize = 0;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3999 converted.username = p.username;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4000 converted.password = p.password;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4001 converted.timeout = p.timeout;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4002 converted.certificateFile = p.certificateFile;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4003 converted.certificateKeyFile = p.certificateKeyFile;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4004 converted.certificateKeyPassword = p.certificateKeyPassword;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4005 converted.pkcs11 = p.pkcs11;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4006
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4007 SetupHttpClient(client, converted);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4008 }
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
4009
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4010 HttpClientChunkedRequest body(p, pimpl_->dictionary_);
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4011 client.SetBody(body);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4012
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4013 HttpClientChunkedAnswer answer(p, pimpl_->dictionary_);
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4014
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4015 bool success = client.Apply(answer);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4016
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4017 *p.httpStatus = static_cast<uint16_t>(client.GetLastStatus());
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4018
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4019 if (!success)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4020 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4021 HttpClient::ThrowException(client.GetLastStatus());
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
4022 }
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
4023 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
4024
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
4025
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4026 void OrthancPlugins::CallRestApi(const void* parameters)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4027 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4028 const _OrthancPluginCallRestApi& p = *reinterpret_cast<const _OrthancPluginCallRestApi*>(parameters);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4029
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4030 if (p.httpStatus == NULL)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4031 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4032 throw OrthancException(ErrorCode_NullPointer);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4033 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4034
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4035 const char* methodString;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4036 switch (p.method)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4037 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4038 case OrthancPluginHttpMethod_Get:
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4039 methodString = "GET";
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4040 break;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4041
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4042 case OrthancPluginHttpMethod_Post:
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4043 methodString = "POST";
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4044 break;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4045
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4046 case OrthancPluginHttpMethod_Put:
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4047 methodString = "PUT";
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4048 break;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4049
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4050 case OrthancPluginHttpMethod_Delete:
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4051 methodString = "DELETE";
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4052 break;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4053
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4054 default:
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4055 throw OrthancException(ErrorCode_ParameterOutOfRange);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4056 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4057
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4058 CLOG(INFO, PLUGINS) << "Plugin making REST " << methodString << " call to URI " << p.uri
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4059 << (p.afterPlugins ? " (after plugins)" : " (built-in API)");
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4060
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4061 HttpToolbox::Arguments headers;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4062
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4063 for (uint32_t i = 0; i < p.headersCount; i++)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4064 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4065 std::string name(p.headersKeys[i]);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4066 std::transform(name.begin(), name.end(), name.begin(), ::tolower);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4067 headers[name] = p.headersValues[i];
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4068 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4069
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4070 IHttpHandler* handler;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4071
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4072 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
4073 PImpl::ServerContextReference lock(*pimpl_);
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4074 handler = &lock.GetContext().GetHttpHandler().RestrictToOrthancRestApi(!p.afterPlugins);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4075 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4076
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4077 std::string answerBody;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4078 std::map<std::string, std::string> answerHeaders;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4079 HttpStatus status;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4080
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4081 switch (p.method)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4082 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4083 case OrthancPluginHttpMethod_Get:
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4084 status = IHttpHandler::SimpleGet(
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4085 answerBody, &answerHeaders, *handler, RequestOrigin_Plugins, p.uri, headers);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4086 break;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4087
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4088 case OrthancPluginHttpMethod_Post:
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4089 status = IHttpHandler::SimplePost(
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4090 answerBody, &answerHeaders, *handler, RequestOrigin_Plugins, p.uri, p.body, p.bodySize, headers);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4091 break;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4092
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4093 case OrthancPluginHttpMethod_Put:
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4094 status = IHttpHandler::SimplePut(
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4095 answerBody, &answerHeaders, *handler, RequestOrigin_Plugins, p.uri, p.body, p.bodySize, headers);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4096 break;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4097
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4098 case OrthancPluginHttpMethod_Delete:
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4099 status = IHttpHandler::SimpleDelete(
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4100 &answerHeaders, *handler, RequestOrigin_Plugins, p.uri, headers);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4101 break;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4102
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4103 default:
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4104 throw OrthancException(ErrorCode_ParameterOutOfRange);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4105 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4106
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4107 *p.httpStatus = static_cast<uint16_t>(status);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4108
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4109 if (p.answerHeaders != NULL)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4110 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4111 CopyDictionary(*p.answerHeaders, answerHeaders);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4112 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4113
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4114 try
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4115 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4116 if (p.answerBody != NULL)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4117 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4118 CopyToMemoryBuffer(*p.answerBody, answerBody);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4119 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4120 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4121 catch (OrthancException&)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4122 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4123 if (p.answerHeaders != NULL)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4124 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4125 free(p.answerHeaders->data);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4126 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4127 throw;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4128 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4129 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4130
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4131
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4132 void OrthancPlugins::CallPeerApi(const void* parameters)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4133 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4134 const _OrthancPluginCallPeerApi& p = *reinterpret_cast<const _OrthancPluginCallPeerApi*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4135 const OrthancPeers& peers = *reinterpret_cast<const OrthancPeers*>(p.peers);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4136
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4137 HttpClient client(peers.GetPeerParameters(p.peerIndex), p.uri);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4138 client.SetConvertHeadersToLowerCase(false);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4139
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4140 if (p.timeout != 0)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4141 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4142 client.SetTimeout(p.timeout);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4143 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4144
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4145 for (uint32_t i = 0; i < p.additionalHeadersCount; i++)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4146 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4147 if (p.additionalHeadersKeys[i] == NULL ||
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4148 p.additionalHeadersValues[i] == NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4149 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4150 throw OrthancException(ErrorCode_NullPointer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4151 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4152
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4153 client.AddHeader(p.additionalHeadersKeys[i], p.additionalHeadersValues[i]);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4154 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4155
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4156 switch (p.method)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4157 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4158 case OrthancPluginHttpMethod_Get:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4159 client.SetMethod(HttpMethod_Get);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4160 break;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4161
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4162 case OrthancPluginHttpMethod_Post:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4163 client.SetMethod(HttpMethod_Post);
4650
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4628
diff changeset
4164 client.SetExternalBody(p.body, p.bodySize);
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4165 break;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4166
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4167 case OrthancPluginHttpMethod_Put:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4168 client.SetMethod(HttpMethod_Put);
4650
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4628
diff changeset
4169 client.SetExternalBody(p.body, p.bodySize);
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4170 break;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4171
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4172 case OrthancPluginHttpMethod_Delete:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4173 client.SetMethod(HttpMethod_Delete);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4174 break;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4175
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4176 default:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4177 throw OrthancException(ErrorCode_ParameterOutOfRange);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4178 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4179
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4180 std::string body;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4181 HttpClient::HttpHeaders headers;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4182
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4183 bool success = client.Apply(body, headers);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4184
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4185 // The HTTP request has succeeded
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4186 *p.httpStatus = static_cast<uint16_t>(client.GetLastStatus());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4187
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4188 if (!success)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4189 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4190 HttpClient::ThrowException(client.GetLastStatus());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4191 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4192
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4193 // Copy the HTTP headers of the answer, if the plugin requested them
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4194 if (p.answerHeaders != NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4195 {
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4196 CopyDictionary(*p.answerHeaders, headers);
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4197 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4198
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4199 // Copy the body of the answer if it makes sense
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4200 if (p.method != OrthancPluginHttpMethod_Delete)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4201 {
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4202 try
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4203 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4204 if (p.answerBody != NULL)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4205 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4206 CopyToMemoryBuffer(*p.answerBody, body);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4207 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4208 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4209 catch (OrthancException&)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4210 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4211 if (p.answerHeaders != NULL)
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4212 {
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4213 free(p.answerHeaders->data);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4214 }
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4215 throw;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4216 }
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4217 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4218 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4219
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4220
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4221 void OrthancPlugins::ConvertPixelFormat(const void* parameters)
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4222 {
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4223 const _OrthancPluginConvertPixelFormat& p = *reinterpret_cast<const _OrthancPluginConvertPixelFormat*>(parameters);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4224 const ImageAccessor& source = *reinterpret_cast<const ImageAccessor*>(p.source);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4225
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
4226 std::unique_ptr<ImageAccessor> target(new Image(Plugins::Convert(p.targetFormat), source.GetWidth(), source.GetHeight(), false));
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4227 ImageProcessing::Convert(*target, source);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4228
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
4229 *(p.target) = ReturnImage(target);
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4230 }
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4231
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4232
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4233
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4234 void OrthancPlugins::GetFontInfo(const void* parameters)
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4235 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4236 const _OrthancPluginGetFontInfo& p = *reinterpret_cast<const _OrthancPluginGetFontInfo*>(parameters);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4237
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4238 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4239 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4240
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4241 const Font& font = lock.GetConfiguration().GetFontRegistry().GetFont(p.fontIndex);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4242
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4243 if (p.name != NULL)
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4244 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4245 *(p.name) = font.GetName().c_str();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4246 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4247 else if (p.size != NULL)
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4248 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4249 *(p.size) = font.GetSize();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4250 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4251 else
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4252 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4253 throw OrthancException(ErrorCode_InternalError);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4254 }
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4255 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4256 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4257
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4258
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4259 void OrthancPlugins::DrawText(const void* parameters)
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4260 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4261 const _OrthancPluginDrawText& p = *reinterpret_cast<const _OrthancPluginDrawText*>(parameters);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4262
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4263 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4264 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4265 const Font& font = lock.GetConfiguration().GetFontRegistry().GetFont(p.fontIndex);
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
4266
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
4267 ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4268 font.Draw(target, p.utf8Text, p.x, p.y, p.r, p.g, p.b);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4269 }
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4270 }
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4271
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4272
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4273 void OrthancPlugins::ApplyDicomToJson(_OrthancPluginService service,
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4274 const void* parameters)
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4275 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4276 const _OrthancPluginDicomToJson& p =
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4277 *reinterpret_cast<const _OrthancPluginDicomToJson*>(parameters);
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4278
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
4279 std::unique_ptr<ParsedDicomFile> dicom;
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4280
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4281 if (service == _OrthancPluginService_DicomBufferToJson)
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4282 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4283 dicom.reset(new ParsedDicomFile(p.buffer, p.size));
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4284 }
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4285 else
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4286 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4287 if (p.instanceId == NULL)
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4288 {
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4289 throw OrthancException(ErrorCode_NullPointer);
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4290 }
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4291
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4292 std::string content;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4293
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4294 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
4295 PImpl::ServerContextReference lock(*pimpl_);
2124
2b1520efa282 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
4296 lock.GetContext().ReadDicom(content, p.instanceId);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4297 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4298
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4299 dicom.reset(new ParsedDicomFile(content));
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4300 }
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4301
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4302 Json::Value json;
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
4303 dicom->DatasetToJson(json, Plugins::Convert(p.format),
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
4304 static_cast<DicomToJsonFlags>(p.flags), p.maxStringLength);
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4305
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4374
diff changeset
4306 std::string s;
4394
f7104e9d044c functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4392
diff changeset
4307 Toolbox::WriteFastJson(s, json);
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4374
diff changeset
4308 *p.result = CopyString(s);
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
4309 }
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4310
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4311
4477
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4312 void OrthancPlugins::ApplyCreateDicom(const _OrthancPluginCreateDicom& parameters,
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4313 const char* privateCreatorC)
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4314 {
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4315 Json::Value json;
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4316
4477
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4317 if (parameters.json == NULL)
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4318 {
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4319 json = Json::objectValue;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4320 }
4477
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4321 else if (!Toolbox::ReadJson(json, parameters.json))
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4374
diff changeset
4322 {
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4374
diff changeset
4323 throw OrthancException(ErrorCode_BadJson);
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4324 }
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4325
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4326 std::string dicom;
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4327
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4328 {
3709
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4329 // Fix issue 168 (Plugins can't read private tags from the
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4330 // configuration file)
4476
c1f36fd13730 migrate remaining links to issues in bitbucket to mercurial server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4459
diff changeset
4331 // https://bugs.orthanc-server.com/show_bug.cgi?id=168
3709
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4332 std::string privateCreator;
4477
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4333
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4334 if (privateCreatorC == NULL)
3709
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4335 {
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4336 OrthancConfiguration::ReaderLock lock;
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4337 privateCreator = lock.GetConfiguration().GetDefaultPrivateCreator();
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4338 }
4477
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4339 else
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4340 {
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4341 // New in Orthanc 1.9.0
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4342 privateCreator.assign(privateCreatorC);
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4343 }
3709
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4344
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
4345 std::unique_ptr<ParsedDicomFile> file
4477
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4346 (ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(parameters.flags),
3709
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4347 privateCreator));
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4348
4477
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4349 if (parameters.pixelData)
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4350 {
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4351 file->EmbedImage(*reinterpret_cast<const ImageAccessor*>(parameters.pixelData));
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4352 }
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4353
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4354 file->SaveToMemoryBuffer(dicom);
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4355 }
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4356
4477
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
4357 CopyToMemoryBuffer(*parameters.target, dicom);
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4358 }
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4359
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4360
1833
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4361 void OrthancPlugins::ComputeHash(_OrthancPluginService service,
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4362 const void* parameters)
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4363 {
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4364 const _OrthancPluginComputeHash& p =
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4365 *reinterpret_cast<const _OrthancPluginComputeHash*>(parameters);
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4366
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4367 std::string hash;
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4368 switch (service)
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4369 {
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4370 case _OrthancPluginService_ComputeMd5:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4371 Toolbox::ComputeMD5(hash, p.buffer, p.size);
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4372 break;
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4373
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4374 case _OrthancPluginService_ComputeSha1:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4375 Toolbox::ComputeSHA1(hash, p.buffer, p.size);
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4376 break;
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4377
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4378 default:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4379 throw OrthancException(ErrorCode_ParameterOutOfRange);
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4380 }
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4381
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4382 *p.result = CopyString(hash);
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4383 }
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4384
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
4385
3429
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4386 void OrthancPlugins::GetTagName(const void* parameters)
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4387 {
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4388 const _OrthancPluginGetTagName& p =
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4389 *reinterpret_cast<const _OrthancPluginGetTagName*>(parameters);
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4390
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4391 std::string privateCreator;
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4392
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4393 if (p.privateCreator != NULL)
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4394 {
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4395 privateCreator = p.privateCreator;
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4396 }
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4397
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4398 DicomTag tag(p.group, p.element);
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4399 *p.result = CopyString(FromDcmtkBridge::GetTagName(tag, privateCreator));
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4400 }
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4401
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4402
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4403 void OrthancPlugins::ApplyCreateImage(_OrthancPluginService service,
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4404 const void* parameters)
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4405 {
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4406 const _OrthancPluginCreateImage& p =
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4407 *reinterpret_cast<const _OrthancPluginCreateImage*>(parameters);
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4408
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
4409 std::unique_ptr<ImageAccessor> result;
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4410
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4411 switch (service)
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4412 {
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4413 case _OrthancPluginService_CreateImage:
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2045
diff changeset
4414 result.reset(new Image(Plugins::Convert(p.format), p.width, p.height, false));
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4415 break;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4416
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4417 case _OrthancPluginService_CreateImageAccessor:
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4418 result.reset(new ImageAccessor);
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4419 result->AssignWritable(Plugins::Convert(p.format), p.width, p.height, p.pitch, p.buffer);
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4420 break;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4421
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4422 case _OrthancPluginService_DecodeDicomImage:
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4423 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
4424 PImpl::ServerContextReference lock(*pimpl_);
3980
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3964
diff changeset
4425 result.reset(lock.GetContext().DecodeDicomFrame(p.constBuffer, p.bufferSize, p.frameIndex));
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4426 break;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4427 }
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4428
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4429 default:
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
4430 throw OrthancException(ErrorCode_InternalError);
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4431 }
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4432
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
4433 *(p.target) = ReturnImage(result);
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
4434 }
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4435
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4436
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4437 void OrthancPlugins::ApplySendMultipartItem(const void* parameters)
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4438 {
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4439 // An exception might be raised in this function if the
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4440 // connection was closed by the HTTP client.
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4441 const _OrthancPluginAnswerBuffer& p =
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4442 *reinterpret_cast<const _OrthancPluginAnswerBuffer*>(parameters);
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4443
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4444 std::map<std::string, std::string> headers; // No custom headers
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
4445 reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->SendMultipartItem(p.answer, p.answerSize, headers);
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4446 }
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4447
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4448
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4449 void OrthancPlugins::ApplySendMultipartItem2(const void* parameters)
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4450 {
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4451 // An exception might be raised in this function if the
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4452 // connection was closed by the HTTP client.
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4453 const _OrthancPluginSendMultipartItem2& p =
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4454 *reinterpret_cast<const _OrthancPluginSendMultipartItem2*>(parameters);
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4455
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4456 std::map<std::string, std::string> headers;
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4457 for (uint32_t i = 0; i < p.headersCount; i++)
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4458 {
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4459 headers[p.headersKeys[i]] = p.headersValues[i];
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4460 }
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4461
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
4462 reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->SendMultipartItem(p.answer, p.answerSize, headers);
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4463 }
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4464
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4465
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4466 void OrthancPlugins::ApplyLoadDicomInstance(const _OrthancPluginLoadDicomInstance& params)
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4467 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4468 std::unique_ptr<IDicomInstance> target;
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4469
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4470 switch (params.mode)
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4471 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4472 case OrthancPluginLoadDicomInstanceMode_WholeDicom:
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4473 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4474 std::string buffer;
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4475
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4476 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
4477 PImpl::ServerContextReference lock(*pimpl_);
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4478 lock.GetContext().ReadDicom(buffer, params.instanceId);
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4479 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4480
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4481 target.reset(new DicomInstanceFromBuffer(buffer));
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4482 break;
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4483 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4484
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4485 case OrthancPluginLoadDicomInstanceMode_UntilPixelData:
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4486 case OrthancPluginLoadDicomInstanceMode_EmptyPixelData:
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4487 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4488 std::unique_ptr<ParsedDicomFile> parsed;
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4489
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4490 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4491 std::string buffer;
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4492
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4493 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
4494 PImpl::ServerContextReference lock(*pimpl_);
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4495 if (!lock.GetContext().ReadDicomUntilPixelData(buffer, params.instanceId))
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4496 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4497 lock.GetContext().ReadDicom(buffer, params.instanceId);
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4498 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4499 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4500
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4501 parsed.reset(new ParsedDicomFile(buffer));
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4502 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4503
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4504 parsed->RemoveFromPixelData();
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4505
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4506 if (params.mode == OrthancPluginLoadDicomInstanceMode_EmptyPixelData)
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4507 {
5332
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4508 bool hasPixelData = false;
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4509 ValueRepresentation pixelDataVR = parsed->GuessPixelDataValueRepresentation();
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4510
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4511 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
4512 PImpl::ServerContextReference lock(*pimpl_);
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4513
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4514 std::string s;
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4515 int64_t revision; // unused
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4516 if (lock.GetContext().GetIndex().LookupMetadata(
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4517 s, revision, params.instanceId,
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4518 ResourceType_Instance, MetadataType_Instance_PixelDataVR))
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4519 {
5332
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4520 hasPixelData = true;
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4521 if (s == "OB")
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4522 {
5332
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4523 pixelDataVR = ValueRepresentation_OtherByte;
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4524 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4525 else if (s == "OW")
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4526 {
5332
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4527 pixelDataVR = ValueRepresentation_OtherWord;
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4528 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4529 else
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4530 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4531 LOG(WARNING) << "Corrupted PixelDataVR metadata associated with instance "
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4532 << params.instanceId << ": " << s;
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4533 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4534 }
5332
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4535 else if (lock.GetContext().GetIndex().LookupMetadata(
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4536 s, revision, params.instanceId,
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4537 ResourceType_Instance, MetadataType_Instance_PixelDataOffset))
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4538 {
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4539 // This file was stored by an older version of Orthanc,
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4540 // "PixelDataVR" is not available, so use the guess
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4541 hasPixelData = true;
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4542 }
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4543 else
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4544 {
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4545 hasPixelData = false;
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4546 }
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4547 }
5332
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4548
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4549 if (hasPixelData)
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4550 {
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4551 parsed->InjectEmptyPixelData(pixelDataVR);
f5cb6310e0dc fix handling of DICOM files without pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
4552 }
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4553 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4554
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4555 target.reset(new DicomInstanceFromParsed(parsed.release()));
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4556 break;
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4557 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4558
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4559 default:
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4560 throw OrthancException(ErrorCode_ParameterOutOfRange);
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4561 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4562
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4563 if (target.get() == NULL)
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4564 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4565 throw OrthancException(ErrorCode_InternalError);
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4566 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4567 else
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4568 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4569 *params.target = reinterpret_cast<OrthancPluginDicomInstance*>(target.release());
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4570 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4571 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4572
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
4573
1771
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4574 void OrthancPlugins::DatabaseAnswer(const void* parameters)
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4575 {
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4576 const _OrthancPluginDatabaseAnswer& p =
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4577 *reinterpret_cast<const _OrthancPluginDatabaseAnswer*>(parameters);
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4578
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4579 if (pimpl_->database_.get() != NULL)
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4580 {
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4581 pimpl_->database_->AnswerReceived(p);
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4582 }
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4583 else
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4584 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
4585 throw OrthancException(ErrorCode_BadRequest,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
4586 "Cannot invoke this service without a custom database back-end");
1771
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4587 }
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4588 }
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4589
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
4590
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4591 namespace
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4592 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4593 class DictionaryReadLocker
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4594 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4595 private:
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4596 const DcmDataDictionary& dictionary_;
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4597
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4598 public:
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4599 DictionaryReadLocker() : dictionary_(dcmDataDict.rdlock())
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4600 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4601 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4602
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4603 ~DictionaryReadLocker()
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4604 {
3118
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
4605 #if DCMTK_VERSION_NUMBER >= 364
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
4606 dcmDataDict.rdunlock();
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
4607 #else
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4608 dcmDataDict.unlock();
3118
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
4609 #endif
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4610 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4611
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4612 const DcmDataDictionary* operator->()
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4613 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4614 return &dictionary_;
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4615 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4616 };
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4617 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4618
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4619
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4620 void OrthancPlugins::ApplyLookupDictionary(const void* parameters)
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4621 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4622 const _OrthancPluginLookupDictionary& p =
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4623 *reinterpret_cast<const _OrthancPluginLookupDictionary*>(parameters);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4624
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4625 DicomTag tag(FromDcmtkBridge::ParseTag(p.name));
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4626 DcmTagKey tag2(tag.GetGroup(), tag.GetElement());
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4627
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4628 DictionaryReadLocker locker;
3709
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4629 const DcmDictEntry* entry = NULL;
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4630
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4631 if (tag.IsPrivate())
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4632 {
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4633 // Fix issue 168 (Plugins can't read private tags from the
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4634 // configuration file)
4476
c1f36fd13730 migrate remaining links to issues in bitbucket to mercurial server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4459
diff changeset
4635 // https://bugs.orthanc-server.com/show_bug.cgi?id=168
3709
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4636 std::string privateCreator;
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4637 {
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4638 OrthancConfiguration::ReaderLock lock;
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4639 privateCreator = lock.GetConfiguration().GetDefaultPrivateCreator();
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4640 }
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4641
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4642 entry = locker->findEntry(tag2, privateCreator.c_str());
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4643 }
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4644 else
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4645 {
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4646 entry = locker->findEntry(tag2, NULL);
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
4647 }
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4648
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4649 if (entry == NULL)
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4650 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4651 throw OrthancException(ErrorCode_UnknownDicomTag);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4652 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4653 else
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4654 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4655 p.target->group = entry->getKey().getGroup();
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4656 p.target->element = entry->getKey().getElement();
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2000
diff changeset
4657 p.target->vr = Plugins::Convert(FromDcmtkBridge::Convert(entry->getEVR()));
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4658 p.target->minMultiplicity = static_cast<uint32_t>(entry->getVMMin());
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4659 p.target->maxMultiplicity = (entry->getVMMax() == DcmVariableVM ? 0 : static_cast<uint32_t>(entry->getVMMax()));
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4660 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4661 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4662
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
4663
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4664 bool OrthancPlugins::InvokeSafeService(SharedLibrary& plugin,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4665 _OrthancPluginService service,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4666 const void* parameters)
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
4667 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4668 // Services that can be run without mutual exclusion
1553
7c4b487b3b4a ensure mutual exclusion in InvokeService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
4669
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
4670 switch (service)
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
4671 {
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4672 case _OrthancPluginService_GetOrthancPath:
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4673 {
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2136
diff changeset
4674 std::string s = SystemToolbox::GetPathToExecutable();
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4675 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = CopyString(s);
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4676 return true;
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4677 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4678
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4679 case _OrthancPluginService_GetOrthancDirectory:
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4680 {
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2136
diff changeset
4681 std::string s = SystemToolbox::GetDirectoryOfExecutable();
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4682 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = CopyString(s);
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4683 return true;
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4684 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4685
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4686 case _OrthancPluginService_GetConfigurationPath:
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4687 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4688 std::string s;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4689
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4690 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4691 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4692 s = lock.GetConfiguration().GetConfigurationAbsolutePath();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4693 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4694
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4695 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = CopyString(s);
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4696 return true;
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4697 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4698
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
4699 case _OrthancPluginService_GetConfiguration:
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
4700 {
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
4701 std::string s;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4702
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4703 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4704 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4705 lock.GetConfiguration().Format(s);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
4706 }
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
4707
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
4708 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = CopyString(s);
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
4709 return true;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
4710 }
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
4711
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
4712 case _OrthancPluginService_BufferCompression:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
4713 BufferCompression(parameters);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
4714 return true;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
4715
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
4716 case _OrthancPluginService_AnswerBuffer:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
4717 AnswerBuffer(parameters);
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
4718 return true;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
4719
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
4720 case _OrthancPluginService_CompressAndAnswerPngImage:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
4721 CompressAndAnswerPngImage(parameters);
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
4722 return true;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
4723
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
4724 case _OrthancPluginService_CompressAndAnswerImage:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
4725 CompressAndAnswerImage(parameters);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
4726 return true;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
4727
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
4728 case _OrthancPluginService_GetDicomForInstance:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
4729 GetDicomForInstance(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
4730 return true;
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
4731
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
4732 case _OrthancPluginService_RestApiGet:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4733 RestApiGet(parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4734 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4735
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4736 case _OrthancPluginService_RestApiGetAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4737 RestApiGet(parameters, true);
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
4738 return true;
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
4739
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
4740 case _OrthancPluginService_RestApiGet2:
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
4741 RestApiGet2(parameters);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
4742 return true;
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
4743
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
4744 case _OrthancPluginService_RestApiPost:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4745 RestApiPostPut(true, parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4746 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4747
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4748 case _OrthancPluginService_RestApiPostAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4749 RestApiPostPut(true, parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
4750 return true;
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
4751
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
4752 case _OrthancPluginService_RestApiDelete:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4753 RestApiDelete(parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4754 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4755
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4756 case _OrthancPluginService_RestApiDeleteAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4757 RestApiDelete(parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
4758 return true;
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
4759
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
4760 case _OrthancPluginService_RestApiPut:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4761 RestApiPostPut(false, parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4762 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4763
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4764 case _OrthancPluginService_RestApiPutAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
4765 RestApiPostPut(false, parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
4766 return true;
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
4767
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
4768 case _OrthancPluginService_Redirect:
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
4769 Redirect(parameters);
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
4770 return true;
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
4771
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4772 case _OrthancPluginService_SendUnauthorized:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4773 SendUnauthorized(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4774 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4775
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4776 case _OrthancPluginService_SendMethodNotAllowed:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4777 SendMethodNotAllowed(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4778 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4779
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
4780 case _OrthancPluginService_SendHttpStatus:
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
4781 SendHttpStatus(parameters);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
4782 return true;
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
4783
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4784 case _OrthancPluginService_SendHttpStatusCode:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4785 SendHttpStatusCode(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4786 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4787
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4788 case _OrthancPluginService_SetCookie:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4789 SetCookie(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4790 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
4791
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
4792 case _OrthancPluginService_SetHttpHeader:
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
4793 SetHttpHeader(parameters);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
4794 return true;
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
4795
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
4796 case _OrthancPluginService_SetHttpErrorDetails:
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
4797 SetHttpErrorDetails(parameters);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
4798 return true;
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
4799
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
4800 case _OrthancPluginService_LookupPatient:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
4801 case _OrthancPluginService_LookupStudy:
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
4802 case _OrthancPluginService_LookupStudyWithAccessionNumber:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
4803 case _OrthancPluginService_LookupSeries:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
4804 case _OrthancPluginService_LookupInstance:
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
4805 LookupResource(service, parameters);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
4806 return true;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
4807
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
4808 case _OrthancPluginService_GetInstanceRemoteAet:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
4809 case _OrthancPluginService_GetInstanceSize:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
4810 case _OrthancPluginService_GetInstanceData:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
4811 case _OrthancPluginService_GetInstanceJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
4812 case _OrthancPluginService_GetInstanceSimplifiedJson:
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
4813 case _OrthancPluginService_HasInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
4814 case _OrthancPluginService_GetInstanceMetadata:
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
4815 case _OrthancPluginService_GetInstanceOrigin:
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4816 case _OrthancPluginService_GetInstanceTransferSyntaxUid:
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4817 case _OrthancPluginService_HasInstancePixelData:
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
4818 AccessDicomInstance(service, parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
4819 return true;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
4820
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4821 case _OrthancPluginService_GetInstanceFramesCount:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4822 case _OrthancPluginService_GetInstanceRawFrame:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4823 case _OrthancPluginService_GetInstanceDecodedFrame:
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
4824 case _OrthancPluginService_SerializeDicomInstance:
3925
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
4825 case _OrthancPluginService_GetInstanceAdvancedJson:
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
4826 case _OrthancPluginService_GetInstanceDicomWebJson:
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
4827 case _OrthancPluginService_GetInstanceDicomWebXml:
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4828 AccessDicomInstance2(service, parameters);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4829 return true;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4830
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4831 case _OrthancPluginService_SetGlobalProperty:
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4832 {
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4833 const _OrthancPluginGlobalProperty& p =
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4834 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4835 if (p.property < 1024)
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4836 {
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4837 return false;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4838 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4839 else
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4840 {
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4606
diff changeset
4841 // TODO - Plugins can only access global properties of their
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4606
diff changeset
4842 // own Orthanc server (no access to the shared global properties)
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
4843 PImpl::ServerContextReference lock(*pimpl_);
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4606
diff changeset
4844 lock.GetContext().GetIndex().SetGlobalProperty(static_cast<GlobalProperty>(p.property),
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4606
diff changeset
4845 false /* not shared */, p.value);
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4846 return true;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4847 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4848 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4849
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4850 case _OrthancPluginService_GetGlobalProperty:
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4851 {
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4852 const _OrthancPluginGlobalProperty& p =
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4853 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4854
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4855 std::string result;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4856
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4857 {
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4606
diff changeset
4858 // TODO - Plugins can only access global properties of their
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4606
diff changeset
4859 // own Orthanc server (no access to the shared global properties)
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
4860 PImpl::ServerContextReference lock(*pimpl_);
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4606
diff changeset
4861 result = lock.GetContext().GetIndex().GetGlobalProperty(static_cast<GlobalProperty>(p.property),
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4606
diff changeset
4862 false /* not shared */, p.value);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4863 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4864
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
4865 *(p.result) = CopyString(result);
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4866 return true;
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4867 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4868
1407
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
4869 case _OrthancPluginService_GetExpectedDatabaseVersion:
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
4870 {
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
4871 const _OrthancPluginReturnSingleValue& p =
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
4872 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
4873 *(p.resultUint32) = ORTHANC_DATABASE_VERSION;
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
4874 return true;
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
4875 }
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
4876
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
4877 case _OrthancPluginService_StartMultipartAnswer:
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
4878 {
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
4879 const _OrthancPluginStartMultipartAnswer& p =
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
4880 *reinterpret_cast<const _OrthancPluginStartMultipartAnswer*>(parameters);
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
4881 reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->StartMultipart(p.subType, p.contentType);
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
4882 return true;
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
4883 }
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
4884
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
4885 case _OrthancPluginService_SendMultipartItem:
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4886 ApplySendMultipartItem(parameters);
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
4887 return true;
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4888
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4889 case _OrthancPluginService_SendMultipartItem2:
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4890 ApplySendMultipartItem2(parameters);
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
4891 return true;
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
4892
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4893 case _OrthancPluginService_ReadFile:
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4894 {
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4895 const _OrthancPluginReadFile& p =
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4896 *reinterpret_cast<const _OrthancPluginReadFile*>(parameters);
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4897
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4898 std::string content;
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2136
diff changeset
4899 SystemToolbox::ReadFile(content, p.path);
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4900 CopyToMemoryBuffer(*p.target, content.size() > 0 ? content.c_str() : NULL, content.size());
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4901
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4902 return true;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4903 }
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4904
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4905 case _OrthancPluginService_WriteFile:
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4906 {
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4907 const _OrthancPluginWriteFile& p =
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4908 *reinterpret_cast<const _OrthancPluginWriteFile*>(parameters);
4189
15572f0bd743 run fsync() in OrthancPluginWriteFile()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4105
diff changeset
4909 SystemToolbox::WriteFile(p.data, p.size, p.path, true /* run fsync() */);
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4910 return true;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4911 }
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
4912
1593
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
4913 case _OrthancPluginService_GetErrorDescription:
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
4914 {
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
4915 const _OrthancPluginGetErrorDescription& p =
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
4916 *reinterpret_cast<const _OrthancPluginGetErrorDescription*>(parameters);
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
4917 *(p.target) = EnumerationToString(static_cast<ErrorCode>(p.error));
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
4918 return true;
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
4919 }
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
4920
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4921 case _OrthancPluginService_GetImagePixelFormat:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4922 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
4923 const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
4924 *(p.resultPixelFormat) = Plugins::Convert(reinterpret_cast<const ImageAccessor*>(p.image)->GetFormat());
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4925 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4926 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4927
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4928 case _OrthancPluginService_GetImageWidth:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4929 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
4930 const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4931 *(p.resultUint32) = reinterpret_cast<const ImageAccessor*>(p.image)->GetWidth();
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4932 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4933 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4934
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4935 case _OrthancPluginService_GetImageHeight:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4936 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
4937 const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4938 *(p.resultUint32) = reinterpret_cast<const ImageAccessor*>(p.image)->GetHeight();
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4939 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4940 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4941
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4942 case _OrthancPluginService_GetImagePitch:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4943 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
4944 const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4945 *(p.resultUint32) = reinterpret_cast<const ImageAccessor*>(p.image)->GetPitch();
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4946 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4947 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4948
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4949 case _OrthancPluginService_GetImageBuffer:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4950 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
4951 const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
4201
2d5209153b32 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4189
diff changeset
4952 *(p.resultBuffer) = const_cast<void*>(reinterpret_cast<const ImageAccessor*>(p.image)->GetConstBuffer());
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4953 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4954 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4955
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4956 case _OrthancPluginService_FreeImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4957 {
1605
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1604
diff changeset
4958 const _OrthancPluginFreeImage& p = *reinterpret_cast<const _OrthancPluginFreeImage*>(parameters);
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4959
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4960 if (p.image != NULL)
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
4961 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
4962 delete reinterpret_cast<ImageAccessor*>(p.image);
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
4963 }
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4964
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4965 return true;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4966 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4967
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4968 case _OrthancPluginService_UncompressImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4969 UncompressImage(parameters);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4970 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4971
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4972 case _OrthancPluginService_CompressImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4973 CompressImage(parameters);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4974 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4975
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
4976 case _OrthancPluginService_CallHttpClient:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
4977 CallHttpClient(parameters);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
4978 return true;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
4979
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
4980 case _OrthancPluginService_CallHttpClient2:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
4981 CallHttpClient2(parameters);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
4982 return true;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
4983
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
4984 case _OrthancPluginService_ChunkedHttpClient:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
4985 ChunkedHttpClient(parameters);
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
4986 return true;
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
4987
4605
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4988 case _OrthancPluginService_CallRestApi:
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4989 CallRestApi(parameters);
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4990 return true;
c8f444e8556d new function in the plugin SDK: OrthancPluginCallRestApi()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
4991
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4992 case _OrthancPluginService_ConvertPixelFormat:
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4993 ConvertPixelFormat(parameters);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4994 return true;
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
4995
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4996 case _OrthancPluginService_GetFontsCount:
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4997 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4998 const _OrthancPluginReturnSingleValue& p =
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
4999 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
5000
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
5001 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
5002 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
5003 *(p.resultUint32) = lock.GetConfiguration().GetFontRegistry().GetSize();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
5004 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
5005
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
5006 return true;
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
5007 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
5008
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
5009 case _OrthancPluginService_GetFontInfo:
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
5010 GetFontInfo(parameters);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
5011 return true;
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
5012
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
5013 case _OrthancPluginService_DrawText:
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
5014 DrawText(parameters);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
5015 return true;
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
5016
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5017 case _OrthancPluginService_StorageAreaCreate:
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5018 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5019 const _OrthancPluginStorageAreaCreate& p =
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5020 *reinterpret_cast<const _OrthancPluginStorageAreaCreate*>(parameters);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5021 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
2028
d108412411e5 fix msvc warnings
sjodogne
parents: 2022
diff changeset
5022 storage.Create(p.uuid, p.content, static_cast<size_t>(p.size), Plugins::Convert(p.type));
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5023 return true;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5024 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5025
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5026 case _OrthancPluginService_StorageAreaRead:
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5027 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5028 const _OrthancPluginStorageAreaRead& p =
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5029 *reinterpret_cast<const _OrthancPluginStorageAreaRead*>(parameters);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5030 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
4484
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
5031 std::unique_ptr<IMemoryBuffer> content(storage.Read(p.uuid, Plugins::Convert(p.type)));
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4483
diff changeset
5032 CopyToMemoryBuffer(*p.target, content->GetData(), content->GetSize());
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5033 return true;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5034 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5035
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5036 case _OrthancPluginService_StorageAreaRemove:
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5037 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5038 const _OrthancPluginStorageAreaRemove& p =
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5039 *reinterpret_cast<const _OrthancPluginStorageAreaRemove*>(parameters);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5040 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
5041 storage.Remove(p.uuid, Plugins::Convert(p.type));
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5042 return true;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5043 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
5044
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
5045 case _OrthancPluginService_DicomBufferToJson:
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
5046 case _OrthancPluginService_DicomInstanceToJson:
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
5047 ApplyDicomToJson(service, parameters);
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
5048 return true;
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
5049
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
5050 case _OrthancPluginService_CreateDicom:
4477
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5051 {
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5052 const _OrthancPluginCreateDicom& p =
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5053 *reinterpret_cast<const _OrthancPluginCreateDicom*>(parameters);
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5054 ApplyCreateDicom(p, NULL);
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
5055 return true;
4477
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5056 }
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5057
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5058 case _OrthancPluginService_CreateDicom2:
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5059 {
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5060 // New in Orthanc 1.9.0
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5061 const _OrthancPluginCreateDicom2& p =
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5062 *reinterpret_cast<const _OrthancPluginCreateDicom2*>(parameters);
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5063 ApplyCreateDicom(p.createDicom, p.privateCreator);
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5064 return true;
0a2c9790cb41 new primitive in plugin SDK: OrthancPluginCreateDicom2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4476
diff changeset
5065 }
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
5066
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
5067 case _OrthancPluginService_WorklistAddAnswer:
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
5068 {
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5069 const _OrthancPluginWorklistAnswersOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5070 *reinterpret_cast<const _OrthancPluginWorklistAnswersOperation*>(parameters);
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
5071 reinterpret_cast<const WorklistHandler*>(p.query)->AddAnswer(p.answers, p.dicom, p.size);
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5072 return true;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5073 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5074
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
5075 case _OrthancPluginService_WorklistMarkIncomplete:
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5076 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5077 const _OrthancPluginWorklistAnswersOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5078 *reinterpret_cast<const _OrthancPluginWorklistAnswersOperation*>(parameters);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5079 reinterpret_cast<DicomFindAnswers*>(p.answers)->SetComplete(false);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5080 return true;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5081 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5082
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
5083 case _OrthancPluginService_WorklistIsMatch:
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5084 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5085 const _OrthancPluginWorklistQueryOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5086 *reinterpret_cast<const _OrthancPluginWorklistQueryOperation*>(parameters);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5087 *p.isMatch = reinterpret_cast<const WorklistHandler*>(p.query)->IsMatch(p.dicom, p.size);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5088 return true;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5089 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5090
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
5091 case _OrthancPluginService_WorklistGetDicomQuery:
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5092 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5093 const _OrthancPluginWorklistQueryOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
5094 *reinterpret_cast<const _OrthancPluginWorklistQueryOperation*>(parameters);
1812
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
5095 reinterpret_cast<const WorklistHandler*>(p.query)->GetDicomQuery(*p.target);
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
5096 return true;
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
5097 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
5098
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5099 case _OrthancPluginService_FindAddAnswer:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5100 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5101 const _OrthancPluginFindOperation& p =
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5102 *reinterpret_cast<const _OrthancPluginFindOperation*>(parameters);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5103 reinterpret_cast<DicomFindAnswers*>(p.answers)->Add(p.dicom, p.size);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5104 return true;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5105 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5106
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5107 case _OrthancPluginService_FindMarkIncomplete:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5108 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5109 const _OrthancPluginFindOperation& p =
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5110 *reinterpret_cast<const _OrthancPluginFindOperation*>(parameters);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5111 reinterpret_cast<DicomFindAnswers*>(p.answers)->SetComplete(false);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5112 return true;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5113 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5114
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5115 case _OrthancPluginService_GetFindQuerySize:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5116 case _OrthancPluginService_GetFindQueryTag:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5117 case _OrthancPluginService_GetFindQueryTagName:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5118 case _OrthancPluginService_GetFindQueryValue:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5119 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5120 const _OrthancPluginFindOperation& p =
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5121 *reinterpret_cast<const _OrthancPluginFindOperation*>(parameters);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5122 reinterpret_cast<const FindHandler*>(p.query)->Invoke(service, p);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5123 return true;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5124 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
5125
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
5126 case _OrthancPluginService_CreateImage:
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
5127 case _OrthancPluginService_CreateImageAccessor:
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
5128 case _OrthancPluginService_DecodeDicomImage:
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
5129 ApplyCreateImage(service, parameters);
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
5130 return true;
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
5131
1833
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
5132 case _OrthancPluginService_ComputeMd5:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
5133 case _OrthancPluginService_ComputeSha1:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
5134 ComputeHash(service, parameters);
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
5135 return true;
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
5136
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
5137 case _OrthancPluginService_LookupDictionary:
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
5138 ApplyLookupDictionary(parameters);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
5139 return true;
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
5140
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
5141 case _OrthancPluginService_GenerateUuid:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
5142 {
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
5143 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result =
2512
4dcafa8d6633 SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
5144 CopyString(Toolbox::GenerateUuid());
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
5145 return true;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
5146 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
5147
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5148 case _OrthancPluginService_CreateFindMatcher:
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5149 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5150 const _OrthancPluginCreateFindMatcher& p =
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5151 *reinterpret_cast<const _OrthancPluginCreateFindMatcher*>(parameters);
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5152 ParsedDicomFile query(p.query, p.size);
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
5153 *(p.target) = reinterpret_cast<OrthancPluginFindMatcher*>(new HierarchicalMatcher(query));
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5154 return true;
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5155 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5156
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5157 case _OrthancPluginService_FreeFindMatcher:
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5158 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5159 const _OrthancPluginFreeFindMatcher& p =
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5160 *reinterpret_cast<const _OrthancPluginFreeFindMatcher*>(parameters);
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5161
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5162 if (p.matcher != NULL)
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5163 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5164 delete reinterpret_cast<HierarchicalMatcher*>(p.matcher);
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5165 }
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5166
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5167 return true;
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5168 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5169
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5170 case _OrthancPluginService_FindMatcherIsMatch:
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5171 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5172 const _OrthancPluginFindMatcherIsMatch& p =
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5173 *reinterpret_cast<const _OrthancPluginFindMatcherIsMatch*>(parameters);
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5174
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5175 if (p.matcher == NULL)
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5176 {
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5177 throw OrthancException(ErrorCode_NullPointer);
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5178 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5179 else
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5180 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5181 ParsedDicomFile query(p.dicom, p.size);
2215
028214a95194 refactoring the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2210
diff changeset
5182 *p.isMatch = reinterpret_cast<const HierarchicalMatcher*>(p.matcher)->Match(query) ? 1 : 0;
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5183 return true;
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5184 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5185 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
5186
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5187 case _OrthancPluginService_GetPeers:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5188 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5189 const _OrthancPluginGetPeers& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5190 *reinterpret_cast<const _OrthancPluginGetPeers*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5191 *(p.peers) = reinterpret_cast<OrthancPluginPeers*>(new OrthancPeers);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5192 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5193 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5194
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5195 case _OrthancPluginService_FreePeers:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5196 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5197 const _OrthancPluginFreePeers& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5198 *reinterpret_cast<const _OrthancPluginFreePeers*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5199
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5200 if (p.peers != NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5201 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5202 delete reinterpret_cast<OrthancPeers*>(p.peers);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5203 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5204
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5205 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5206 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5207
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5208 case _OrthancPluginService_GetPeersCount:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5209 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5210 const _OrthancPluginGetPeersCount& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5211 *reinterpret_cast<const _OrthancPluginGetPeersCount*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5212
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5213 if (p.peers == NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5214 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5215 throw OrthancException(ErrorCode_NullPointer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5216 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5217 else
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5218 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5219 *(p.target) = reinterpret_cast<const OrthancPeers*>(p.peers)->GetPeersCount();
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5220 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5221 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5222 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5223
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5224 case _OrthancPluginService_GetPeerName:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5225 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5226 const _OrthancPluginGetPeerProperty& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5227 *reinterpret_cast<const _OrthancPluginGetPeerProperty*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5228
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5229 if (p.peers == NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5230 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5231 throw OrthancException(ErrorCode_NullPointer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5232 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5233 else
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5234 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5235 *(p.target) = reinterpret_cast<const OrthancPeers*>(p.peers)->GetPeerName(p.peerIndex).c_str();
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5236 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5237 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5238 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5239
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5240 case _OrthancPluginService_GetPeerUrl:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5241 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5242 const _OrthancPluginGetPeerProperty& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5243 *reinterpret_cast<const _OrthancPluginGetPeerProperty*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5244
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5245 if (p.peers == NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5246 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5247 throw OrthancException(ErrorCode_NullPointer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5248 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5249 else
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5250 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5251 *(p.target) = reinterpret_cast<const OrthancPeers*>(p.peers)->GetPeerParameters(p.peerIndex).GetUrl().c_str();
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5252 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5253 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5254 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5255
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5256 case _OrthancPluginService_GetPeerUserProperty:
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5257 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5258 const _OrthancPluginGetPeerProperty& p =
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5259 *reinterpret_cast<const _OrthancPluginGetPeerProperty*>(parameters);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5260
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5261 if (p.peers == NULL ||
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5262 p.userProperty == NULL)
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5263 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5264 throw OrthancException(ErrorCode_NullPointer);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5265 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5266 else
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5267 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5268 const WebServiceParameters::Dictionary& properties =
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5269 reinterpret_cast<const OrthancPeers*>(p.peers)->GetPeerParameters(p.peerIndex).GetUserProperties();
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5270
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5271 WebServiceParameters::Dictionary::const_iterator found =
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5272 properties.find(p.userProperty);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5273
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5274 if (found == properties.end())
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5275 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5276 *(p.target) = NULL;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5277 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5278 else
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5279 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5280 *(p.target) = found->second.c_str();
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5281 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5282
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5283 return true;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5284 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5285 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
5286
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5287 case _OrthancPluginService_CallPeerApi:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5288 CallPeerApi(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5289 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
5290
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5291 case _OrthancPluginService_CreateJob:
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5292 {
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5293 const _OrthancPluginCreateJob& p =
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5294 *reinterpret_cast<const _OrthancPluginCreateJob*>(parameters);
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5295 *(p.target) = reinterpret_cast<OrthancPluginJob*>(new PluginsJob(p));
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5296 return true;
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5297 }
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5298
5138
d00db9fb48fb added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5099
diff changeset
5299 case _OrthancPluginService_CreateJob2:
d00db9fb48fb added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5099
diff changeset
5300 {
d00db9fb48fb added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5099
diff changeset
5301 const _OrthancPluginCreateJob2& p =
d00db9fb48fb added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5099
diff changeset
5302 *reinterpret_cast<const _OrthancPluginCreateJob2*>(parameters);
d00db9fb48fb added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5099
diff changeset
5303 *(p.target) = reinterpret_cast<OrthancPluginJob*>(new PluginsJob(p));
d00db9fb48fb added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5099
diff changeset
5304 return true;
d00db9fb48fb added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5099
diff changeset
5305 }
d00db9fb48fb added OrthancPluginCreateJob2() in the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5099
diff changeset
5306
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5307 case _OrthancPluginService_FreeJob:
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5308 {
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5309 const _OrthancPluginFreeJob& p =
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5310 *reinterpret_cast<const _OrthancPluginFreeJob*>(parameters);
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5311
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5312 if (p.job != NULL)
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5313 {
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5314 delete reinterpret_cast<PluginsJob*>(p.job);
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5315 }
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5316
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5317 return true;
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5318 }
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5319
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5320 case _OrthancPluginService_SubmitJob:
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5321 {
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5322 const _OrthancPluginSubmitJob& p =
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5323 *reinterpret_cast<const _OrthancPluginSubmitJob*>(parameters);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5324
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5325 std::string uuid;
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5326
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
5327 PImpl::ServerContextReference lock(*pimpl_);
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5328 lock.GetContext().GetJobsEngine().GetRegistry().Submit
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
5329 (uuid, reinterpret_cast<PluginsJob*>(p.job), p.priority);
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5330
2814
7d1d3136f6cf more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2813
diff changeset
5331 *p.resultId = CopyString(uuid);
2813
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
5332
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5333 return true;
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5334 }
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5335
2984
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
5336 case _OrthancPluginService_AutodetectMimeType:
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
5337 {
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
5338 const _OrthancPluginRetrieveStaticString& p =
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
5339 *reinterpret_cast<const _OrthancPluginRetrieveStaticString*>(parameters);
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
5340 *p.result = EnumerationToString(SystemToolbox::AutodetectMimeType(p.argument));
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
5341 return true;
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
5342 }
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
5343
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5344 case _OrthancPluginService_SetMetricsValue:
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5345 {
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5346 const _OrthancPluginSetMetricsValue& p =
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5347 *reinterpret_cast<const _OrthancPluginSetMetricsValue*>(parameters);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5348
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5349 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
5350 PImpl::ServerContextReference lock(*pimpl_);
5337
b376abae664a Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5332
diff changeset
5351 lock.GetContext().GetMetricsRegistry().SetFloatValue(p.name, p.value, Plugins::Convert(p.type));
5326
fbe857e942cd store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5319
diff changeset
5352 }
fbe857e942cd store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5319
diff changeset
5353
fbe857e942cd store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5319
diff changeset
5354 return true;
fbe857e942cd store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5319
diff changeset
5355 }
fbe857e942cd store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5319
diff changeset
5356
fbe857e942cd store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5319
diff changeset
5357 case _OrthancPluginService_SetMetricsIntegerValue:
fbe857e942cd store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5319
diff changeset
5358 {
fbe857e942cd store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5319
diff changeset
5359 const _OrthancPluginSetMetricsIntegerValue& p =
fbe857e942cd store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5319
diff changeset
5360 *reinterpret_cast<const _OrthancPluginSetMetricsIntegerValue*>(parameters);
fbe857e942cd store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5319
diff changeset
5361
fbe857e942cd store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5319
diff changeset
5362 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
5363 PImpl::ServerContextReference lock(*pimpl_);
5337
b376abae664a Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5332
diff changeset
5364 lock.GetContext().GetMetricsRegistry().SetIntegerValue(p.name, p.value, Plugins::Convert(p.type));
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5365 }
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5366
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5367 return true;
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5368 }
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5369
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
5370 case _OrthancPluginService_EncodeDicomWebJson:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
5371 case _OrthancPluginService_EncodeDicomWebXml:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
5372 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
5373 const _OrthancPluginEncodeDicomWeb& p =
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
5374 *reinterpret_cast<const _OrthancPluginEncodeDicomWeb*>(parameters);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
5375
3925
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
5376 DicomWebBinaryFormatter formatter(p.callback);
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
5377 formatter.Apply(p.target,
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
5378 (service == _OrthancPluginService_EncodeDicomWebJson),
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
5379 p.dicom, p.dicomSize);
3924
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
5380 return true;
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
5381 }
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
5382
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
5383 case _OrthancPluginService_EncodeDicomWebJson2:
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
5384 case _OrthancPluginService_EncodeDicomWebXml2:
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
5385 {
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
5386 const _OrthancPluginEncodeDicomWeb2& p =
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
5387 *reinterpret_cast<const _OrthancPluginEncodeDicomWeb2*>(parameters);
395c59208f10 new functions in SDK: OrthancPluginEncodeDicomWebJson2() and OrthancPluginEncodeDicomWebXml2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3919
diff changeset
5388
3925
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
5389 DicomWebBinaryFormatter formatter(p.callback, p.payload);
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
5390 formatter.Apply(p.target,
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
5391 (service == _OrthancPluginService_EncodeDicomWebJson2),
dd112d2b83f0 new SDK: OrthancPluginGetInstanceAdvancedJson(), OrthancPluginGetInstanceDicomWebJson() and OrthancPluginGetInstanceDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3924
diff changeset
5392 p.dicom, p.dicomSize);
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
5393 return true;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
5394 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
5395
3429
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
5396 case _OrthancPluginService_GetTagName:
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
5397 GetTagName(parameters);
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
5398 return true;
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
5399
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5400 case _OrthancPluginService_CreateDicomInstance:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5401 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5402 const _OrthancPluginCreateDicomInstance& p =
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5403 *reinterpret_cast<const _OrthancPluginCreateDicomInstance*>(parameters);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5404 *(p.target) = reinterpret_cast<OrthancPluginDicomInstance*>(
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5405 new DicomInstanceFromBuffer(p.buffer, p.size));
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5406 return true;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5407 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5408
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5409 case _OrthancPluginService_FreeDicomInstance:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5410 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5411 const _OrthancPluginFreeDicomInstance& p =
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5412 *reinterpret_cast<const _OrthancPluginFreeDicomInstance*>(parameters);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5413
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5414 if (p.dicom != NULL)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5415 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5416 IDicomInstance* obj = reinterpret_cast<IDicomInstance*>(p.dicom);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5417
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5418 if (obj->CanBeFreed())
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5419 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5420 delete obj;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5421 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5422 else
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5423 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5424 throw OrthancException(ErrorCode_Plugin, "Cannot free a DICOM instance provided to a callback");
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5425 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5426 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5427
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5428 return true;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5429 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
5430
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5431 case _OrthancPluginService_TranscodeDicomInstance:
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5432 {
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5433 const _OrthancPluginCreateDicomInstance& p =
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5434 *reinterpret_cast<const _OrthancPluginCreateDicomInstance*>(parameters);
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5435
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5436 DicomTransferSyntax transferSyntax;
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5437 if (p.transferSyntax == NULL ||
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5438 !LookupTransferSyntax(transferSyntax, p.transferSyntax))
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5439 {
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5440 throw OrthancException(ErrorCode_ParameterOutOfRange, "Unsupported transfer syntax: " +
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5441 std::string(p.transferSyntax == NULL ? "(null)" : p.transferSyntax));
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5442 }
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5443 else
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5444 {
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5445 std::set<DicomTransferSyntax> syntaxes;
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5446 syntaxes.insert(transferSyntax);
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
5447
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
5448 IDicomTranscoder::DicomImage source;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
5449 source.SetExternalBuffer(p.buffer, p.size);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
5450
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
5451 IDicomTranscoder::DicomImage transcoded;
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3946
diff changeset
5452 bool success;
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5453
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5454 {
5411
ca9cf4d46883 ServerContextLock transformed into ServerContextReference /usr/bin/env /bin/sh /tmp/Microsoft-MIEngine-Cmd-owukncoo.ob4
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
5455 PImpl::ServerContextReference lock(*pimpl_);
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3946
diff changeset
5456 success = lock.GetContext().Transcode(
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3946
diff changeset
5457 transcoded, source, syntaxes, true /* allow new sop */);
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5458 }
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5459
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
5460 if (success)
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5461 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
5462 *(p.target) = reinterpret_cast<OrthancPluginDicomInstance*>(
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
5463 new DicomInstanceFromParsed(transcoded));
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
5464 return true;
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5465 }
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5466 else
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5467 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
5468 throw OrthancException(ErrorCode_NotImplemented, "Cannot transcode image");
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5469 }
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5470 }
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5471 }
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5472
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5473 case _OrthancPluginService_CreateMemoryBuffer:
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5474 {
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5475 const _OrthancPluginCreateMemoryBuffer& p =
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5476 *reinterpret_cast<const _OrthancPluginCreateMemoryBuffer*>(parameters);
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5477
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5478 p.target->data = NULL;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5479 p.target->size = 0;
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5480
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5481 if (p.size != 0)
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5482 {
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5483 p.target->data = malloc(p.size);
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5484 if (p.target->data == NULL)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5485 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5486 throw OrthancException(ErrorCode_NotEnoughMemory);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5487 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5488
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5489 p.target->size = p.size;
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5490 }
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5491
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5492 return true;
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5493 }
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5494
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5495 case _OrthancPluginService_CreateMemoryBuffer64:
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5496 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5497 const _OrthancPluginCreateMemoryBuffer64& p =
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5498 *reinterpret_cast<const _OrthancPluginCreateMemoryBuffer64*>(parameters);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5499
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5500 p.target->data = NULL;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5501 p.target->size = 0;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5502
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5503 if (p.size != 0)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5504 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5505 p.target->data = malloc(p.size);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5506 if (p.target->data == NULL)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5507 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5508 throw OrthancException(ErrorCode_NotEnoughMemory);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5509 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5510
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5511 p.target->size = p.size;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5512 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5513
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5514 return true;
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5515 }
3919
6f11b3233a06 OrthancPluginTranscodeDicomInstance() and OrthancPluginSerializeDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3916
diff changeset
5516
4364
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
5517 case _OrthancPluginService_RegisterIncomingHttpRequestFilter:
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
5518 RegisterIncomingHttpRequestFilter(parameters);
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
5519 return true;
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
5520
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
5521 case _OrthancPluginService_RegisterIncomingHttpRequestFilter2:
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
5522 RegisterIncomingHttpRequestFilter2(parameters);
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
5523 return true;
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
5524
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
5525 case _OrthancPluginService_LoadDicomInstance:
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
5526 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
5527 const _OrthancPluginLoadDicomInstance& p =
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
5528 *reinterpret_cast<const _OrthancPluginLoadDicomInstance*>(parameters);
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
5529 ApplyLoadDicomInstance(p);
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
5530 return true;
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
5531 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
5532
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
5533 default:
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5534 return false;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5535 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5536 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5537
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5538
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5539
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5540 bool OrthancPlugins::InvokeProtectedService(SharedLibrary& plugin,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5541 _OrthancPluginService service,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5542 const void* parameters)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5543 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5544 // Services that must be run in mutual exclusion. Guideline:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5545 // Whenever "pimpl_" is directly accessed by the service, it
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5546 // should be listed here.
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5547
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5548 switch (service)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5549 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5550 case _OrthancPluginService_RegisterRestCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5551 RegisterRestCallback(parameters, true);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5552 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5553
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5554 case _OrthancPluginService_RegisterRestCallbackNoLock:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5555 RegisterRestCallback(parameters, false);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5556 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5557
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
5558 case _OrthancPluginService_RegisterChunkedRestCallback:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
5559 RegisterChunkedRestCallback(parameters);
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
5560 return true;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
5561
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5562 case _OrthancPluginService_RegisterOnStoredInstanceCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5563 RegisterOnStoredInstanceCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5564 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5565
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5566 case _OrthancPluginService_RegisterOnChangeCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5567 RegisterOnChangeCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5568 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5569
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5570 case _OrthancPluginService_RegisterWorklistCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5571 RegisterWorklistCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5572 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5573
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5574 case _OrthancPluginService_RegisterFindCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5575 RegisterFindCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5576 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5577
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5578 case _OrthancPluginService_RegisterMoveCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5579 RegisterMoveCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5580 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5581
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5582 case _OrthancPluginService_RegisterDecodeImageCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5583 RegisterDecodeImageCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5584 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5585
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5586 case _OrthancPluginService_RegisterTranscoderCallback:
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5587 RegisterTranscoderCallback(parameters);
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5588 return true;
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
5589
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5590 case _OrthancPluginService_RegisterJobsUnserializer:
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5591 RegisterJobsUnserializer(parameters);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5592 return true;
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
5593
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
5594 case _OrthancPluginService_RegisterIncomingDicomInstanceFilter:
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
5595 RegisterIncomingDicomInstanceFilter(parameters);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
5596 return true;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
5597
4799
0bd98c52474b fixes after sdk tests
Alain Mazy <am@osimis.io>
parents: 4796
diff changeset
5598 case _OrthancPluginService_RegisterIncomingCStoreInstanceFilter:
0bd98c52474b fixes after sdk tests
Alain Mazy <am@osimis.io>
parents: 4796
diff changeset
5599 RegisterIncomingCStoreInstanceFilter(parameters);
0bd98c52474b fixes after sdk tests
Alain Mazy <am@osimis.io>
parents: 4796
diff changeset
5600 return true;
0bd98c52474b fixes after sdk tests
Alain Mazy <am@osimis.io>
parents: 4796
diff changeset
5601
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
5602 case _OrthancPluginService_RegisterReceivedInstanceCallback:
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
5603 RegisterReceivedInstanceCallback(parameters);
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
5604 return true;
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4840
diff changeset
5605
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5606 case _OrthancPluginService_RegisterRefreshMetricsCallback:
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5607 RegisterRefreshMetricsCallback(parameters);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5608 return true;
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
5609
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
5610 case _OrthancPluginService_RegisterStorageCommitmentScpCallback:
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
5611 RegisterStorageCommitmentScpCallback(parameters);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
5612 return true;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
5613
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5614 case _OrthancPluginService_RegisterStorageArea:
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5615 case _OrthancPluginService_RegisterStorageArea2:
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5616 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
5617 CLOG(INFO, PLUGINS) << "Plugin has registered a custom storage area";
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5618
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5619 if (pimpl_->storageArea_.get() == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5620 {
4440
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5621 if (service == _OrthancPluginService_RegisterStorageArea)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5622 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5623 const _OrthancPluginRegisterStorageArea& p =
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5624 *reinterpret_cast<const _OrthancPluginRegisterStorageArea*>(parameters);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5625 pimpl_->storageArea_.reset(new StorageAreaFactory(plugin, p, GetErrorDictionary()));
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5626 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5627 else if (service == _OrthancPluginService_RegisterStorageArea2)
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5628 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5629 const _OrthancPluginRegisterStorageArea2& p =
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5630 *reinterpret_cast<const _OrthancPluginRegisterStorageArea2*>(parameters);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5631 pimpl_->storageArea_.reset(new StorageAreaFactory(plugin, p, GetErrorDictionary()));
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5632 }
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5633 else
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5634 {
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5635 throw OrthancException(ErrorCode_InternalError);
eddb212b2df9 New functions in the SDK: OrthancPluginCreateMemoryBuffer64() and OrthancPluginRegisterStorageArea2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
5636 }
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5637 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5638 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5639 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5640 throw OrthancException(ErrorCode_StorageAreaAlreadyRegistered);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5641 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5642
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5643 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5644 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5645
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5646 case _OrthancPluginService_SetPluginProperty:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5647 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5648 const _OrthancPluginSetPluginProperty& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5649 *reinterpret_cast<const _OrthancPluginSetPluginProperty*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5650 pimpl_->properties_[std::make_pair(p.plugin, p.property)] = p.value;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5651 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5652 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5653
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5654 case _OrthancPluginService_GetCommandLineArgumentsCount:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5655 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5656 const _OrthancPluginReturnSingleValue& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5657 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5658 *(p.resultUint32) = pimpl_->argc_ - 1;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5659 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5660 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5661
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5662 case _OrthancPluginService_GetCommandLineArgument:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5663 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5664 const _OrthancPluginGlobalProperty& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5665 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5666
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5667 if (p.property + 1 > pimpl_->argc_)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5668 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5669 return false;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5670 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5671 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5672 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5673 std::string arg = std::string(pimpl_->argv_[p.property + 1]);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5674 *(p.result) = CopyString(arg);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5675 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5676 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5677 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5678
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5679 case _OrthancPluginService_RegisterDatabaseBackend:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5680 {
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5681 LOG(WARNING) << "Performance warning: Plugin has registered a custom database back-end with an old API (version 1)";
4628
5fabef29c4ff added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4618
diff changeset
5682 LOG(WARNING) << "The database backend has *no* support for revisions of metadata and attachments";
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5683
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5684 const _OrthancPluginRegisterDatabaseBackend& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5685 *reinterpret_cast<const _OrthancPluginRegisterDatabaseBackend*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5686
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5687 if (pimpl_->database_.get() == NULL &&
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5688 pimpl_->databaseV3_.get() == NULL &&
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5689 pimpl_->databaseV4_.get() == NULL)
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5690 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5691 pimpl_->database_.reset(new OrthancPluginDatabase(plugin, GetErrorDictionary(),
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5692 *p.backend, NULL, 0, p.payload));
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5693 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5694 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5695 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5696 throw OrthancException(ErrorCode_DatabaseBackendAlreadyRegistered);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5697 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5698
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5699 *(p.result) = reinterpret_cast<OrthancPluginDatabaseContext*>(pimpl_->database_.get());
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5700
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5701 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5702 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5703
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5704 case _OrthancPluginService_RegisterDatabaseBackendV2:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5705 {
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5706 LOG(WARNING) << "Performance warning: Plugin has registered a custom database back-end with an old API (version 2)";
4628
5fabef29c4ff added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4618
diff changeset
5707 LOG(WARNING) << "The database backend has *no* support for revisions of metadata and attachments";
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5708
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5709 const _OrthancPluginRegisterDatabaseBackendV2& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5710 *reinterpret_cast<const _OrthancPluginRegisterDatabaseBackendV2*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5711
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5712 if (pimpl_->database_.get() == NULL &&
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5713 pimpl_->databaseV3_.get() == NULL &&
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5714 pimpl_->databaseV4_.get() == NULL)
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5715 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5716 pimpl_->database_.reset(new OrthancPluginDatabase(plugin, GetErrorDictionary(),
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5717 *p.backend, p.extensions,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5718 p.extensionsSize, p.payload));
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5719 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5720 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5721 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5722 throw OrthancException(ErrorCode_DatabaseBackendAlreadyRegistered);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5723 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5724
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5725 *(p.result) = reinterpret_cast<OrthancPluginDatabaseContext*>(pimpl_->database_.get());
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5726
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5727 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5728 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5729
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5730 case _OrthancPluginService_RegisterDatabaseBackendV3:
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5731 {
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5732 LOG(WARNING) << "Performance warning: Plugin has registered a custom database back-end with an old API (version 3)";
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5733
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5734 const _OrthancPluginRegisterDatabaseBackendV3& p =
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5735 *reinterpret_cast<const _OrthancPluginRegisterDatabaseBackendV3*>(parameters);
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5736
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5737 if (pimpl_->database_.get() == NULL &&
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5738 pimpl_->databaseV3_.get() == NULL &&
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5739 pimpl_->databaseV4_.get() == NULL)
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5740 {
4604
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4603
diff changeset
5741 pimpl_->databaseV3_.reset(new OrthancPluginDatabaseV3(plugin, GetErrorDictionary(), p.backend,
2c702cfae274 New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4603
diff changeset
5742 p.backendSize, p.database, pimpl_->databaseServerIdentifier_));
4613
2684544ff03c maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
5743 pimpl_->maxDatabaseRetries_ = p.maxDatabaseRetries;
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5744 }
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5745 else
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5746 {
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5747 throw OrthancException(ErrorCode_DatabaseBackendAlreadyRegistered);
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5748 }
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5749
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5750 return true;
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5751 }
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5752
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5753 case _OrthancPluginService_RegisterDatabaseBackendV4:
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5754 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5755 CLOG(INFO, PLUGINS) << "Plugin has registered a custom database back-end";
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5756
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5757 const _OrthancPluginRegisterDatabaseBackendV4& p =
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5758 *reinterpret_cast<const _OrthancPluginRegisterDatabaseBackendV4*>(parameters);
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5759
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5760 if (pimpl_->database_.get() == NULL &&
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5761 pimpl_->databaseV3_.get() == NULL &&
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5762 pimpl_->databaseV4_.get() == NULL)
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5763 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5764 pimpl_->databaseV4_.reset(new OrthancPluginDatabaseV4(plugin, GetErrorDictionary(), p, pimpl_->databaseServerIdentifier_));
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5765 pimpl_->maxDatabaseRetries_ = p.maxDatabaseRetries;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5766 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5767 else
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5768 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5769 throw OrthancException(ErrorCode_DatabaseBackendAlreadyRegistered);
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5770 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5771
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5772 return true;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5773 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5774
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5775 case _OrthancPluginService_DatabaseAnswer:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5776 throw OrthancException(ErrorCode_InternalError); // Implemented before locking (*)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5777
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5778 case _OrthancPluginService_RegisterErrorCode:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5779 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5780 const _OrthancPluginRegisterErrorCode& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5781 *reinterpret_cast<const _OrthancPluginRegisterErrorCode*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5782 *(p.target) = pimpl_->dictionary_.Register(plugin, p.code, p.httpStatus, p.message);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5783 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5784 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5785
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5786 case _OrthancPluginService_RegisterDictionaryTag:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5787 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5788 const _OrthancPluginRegisterDictionaryTag& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5789 *reinterpret_cast<const _OrthancPluginRegisterDictionaryTag*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5790 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(p.group, p.element),
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5791 Plugins::Convert(p.vr), p.name,
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
5792 p.minMultiplicity, p.maxMultiplicity, "");
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
5793 return true;
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
5794 }
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
5795
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
5796 case _OrthancPluginService_RegisterPrivateDictionaryTag:
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
5797 {
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
5798 const _OrthancPluginRegisterPrivateDictionaryTag& p =
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
5799 *reinterpret_cast<const _OrthancPluginRegisterPrivateDictionaryTag*>(parameters);
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
5800 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(p.group, p.element),
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
5801 Plugins::Convert(p.vr), p.name,
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
5802 p.minMultiplicity, p.maxMultiplicity, p.privateCreator);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5803 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5804 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5805
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5806 case _OrthancPluginService_ReconstructMainDicomTags:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5807 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5808 const _OrthancPluginReconstructMainDicomTags& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5809 *reinterpret_cast<const _OrthancPluginReconstructMainDicomTags*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5810
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5811 if (pimpl_->database_.get() == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5812 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
5813 throw OrthancException(ErrorCode_DatabasePlugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
5814 "The service ReconstructMainDicomTags can only be invoked by custom database plugins");
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5815 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5816
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
5817 VoidDatabaseListener listener;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
5818
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
5819 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
5820 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
5821
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
5822 std::unique_ptr<IDatabaseWrapper::ITransaction> transaction(
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
5823 pimpl_->database_->StartTransaction(TransactionType_ReadWrite, listener));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
5824 ServerToolbox::ReconstructMainDicomTags(*transaction, storage, Plugins::Convert(p.level));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
5825 transaction->Commit(0);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4516
diff changeset
5826 }
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5827
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5828 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5829 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5830
4343
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5831 case _OrthancPluginService_GenerateRestApiAuthorizationToken:
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5832 {
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5833 const _OrthancPluginRetrieveDynamicString& p =
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5834 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters);
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5835 const std::string token = Toolbox::GenerateUuid();
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5836
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5837 pimpl_->authorizationTokens_.insert(token);
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5838 *p.result = CopyString("Bearer " + token);
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5839
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5840 return true;
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5841 }
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
5842
4943
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
5843 case _OrthancPluginService_RegisterWebDavCollection:
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
5844 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
5845 CLOG(INFO, PLUGINS) << "Plugin has registered a WebDAV collection";
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
5846 const _OrthancPluginRegisterWebDavCollection& p =
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
5847 *reinterpret_cast<const _OrthancPluginRegisterWebDavCollection*>(parameters);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
5848 pimpl_->webDavCollections_.push_back(new WebDavCollection(GetErrorDictionary(), p));
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
5849 return true;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
5850 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
5851
5030
d6ed4c73c719 SDK: Added GetDatabaseServerIdentifier
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
5852 case _OrthancPluginService_GetDatabaseServerIdentifier:
d6ed4c73c719 SDK: Added GetDatabaseServerIdentifier
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
5853 {
d6ed4c73c719 SDK: Added GetDatabaseServerIdentifier
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
5854 const _OrthancPluginRetrieveStaticString& p =
d6ed4c73c719 SDK: Added GetDatabaseServerIdentifier
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
5855 *reinterpret_cast<const _OrthancPluginRetrieveStaticString*>(parameters);
d6ed4c73c719 SDK: Added GetDatabaseServerIdentifier
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
5856
d6ed4c73c719 SDK: Added GetDatabaseServerIdentifier
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
5857 *p.result = pimpl_->databaseServerIdentifier_.c_str();
d6ed4c73c719 SDK: Added GetDatabaseServerIdentifier
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
5858
d6ed4c73c719 SDK: Added GetDatabaseServerIdentifier
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
5859 return true;
d6ed4c73c719 SDK: Added GetDatabaseServerIdentifier
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
5860 }
d6ed4c73c719 SDK: Added GetDatabaseServerIdentifier
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
5861
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5862 default:
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
5863 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
5864 // This service is unknown to the Orthanc plugin engine
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
5865 return false;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
5866 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
5867 }
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
5868 }
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
5869
908
e078ea944089 refactoring HttpOutput
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
5870
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5871
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5872 bool OrthancPlugins::InvokeService(SharedLibrary& plugin,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5873 _OrthancPluginService service,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5874 const void* parameters)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5875 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
5876 CLOG(TRACE, PLUGINS) << "Calling service " << service << " from plugin " << plugin.GetPath();
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5877
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5878 if (service == _OrthancPluginService_DatabaseAnswer)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5879 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5880 // This case solves a deadlock at (*) reported by James Webster
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5881 // on 2015-10-27 that was present in versions of Orthanc <=
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5882 // 0.9.4 and related to database plugins implementing a custom
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5883 // index. The problem was that locking the database is already
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5884 // ensured by the "ServerIndex" class if the invoked service is
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5885 // "DatabaseAnswer".
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5886 DatabaseAnswer(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5887 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5888 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5889
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5890 if (InvokeSafeService(plugin, service, parameters))
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5891 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5892 // The invoked service does not require locking
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5893 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5894 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5895 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5896 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5897 // The invoked service requires locking
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5898 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_); // (*)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5899 return InvokeProtectedService(plugin, service, parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5900 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5901 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5902
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5903
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
5904 bool OrthancPlugins::HasStorageArea() const
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
5905 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5906 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5907 return pimpl_->storageArea_.get() != NULL;
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
5908 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
5909
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5910 bool OrthancPlugins::HasDatabaseBackend() const
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
5911 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
5912 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5913 return (pimpl_->database_.get() != NULL ||
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5914 pimpl_->databaseV3_.get() != NULL ||
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5915 pimpl_->databaseV4_.get() != NULL);
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
5916 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
5917
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
5918
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
5919 IStorageArea* OrthancPlugins::CreateStorageArea()
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
5920 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
5921 if (!HasStorageArea())
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
5922 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
5923 throw OrthancException(ErrorCode_BadSequenceOfCalls);
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
5924 }
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5925 else
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5926 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5927 return pimpl_->storageArea_->Create();
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5928 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5929 }
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
5930
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5931
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5932 const SharedLibrary& OrthancPlugins::GetStorageAreaLibrary() const
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5933 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5934 if (!HasStorageArea())
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5935 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5936 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5937 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5938 else
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5939 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5940 return pimpl_->storageArea_->GetSharedLibrary();
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5941 }
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
5942 }
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5943
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5944
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5945 IDatabaseWrapper& OrthancPlugins::GetDatabaseBackend()
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
5946 {
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5947 if (pimpl_->database_.get() != NULL)
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5948 {
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5949 return *pimpl_->database_;
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5950 }
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5951 else if (pimpl_->databaseV3_.get() != NULL)
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5952 {
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5953 return *pimpl_->databaseV3_;
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5954 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5955 else if (pimpl_->databaseV4_.get() != NULL)
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5956 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5957 return *pimpl_->databaseV4_;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5958 }
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5959 else
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
5960 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
5961 throw OrthancException(ErrorCode_BadSequenceOfCalls);
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
5962 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
5963 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
5964
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
5965
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5966 const SharedLibrary& OrthancPlugins::GetDatabaseBackendLibrary() const
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5967 {
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5968 if (pimpl_->database_.get() != NULL)
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5969 {
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5970 return pimpl_->database_->GetSharedLibrary();
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5971 }
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5972 else if (pimpl_->databaseV3_.get() != NULL)
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5973 {
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5974 return pimpl_->databaseV3_->GetSharedLibrary();
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5975 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5976 else if (pimpl_->databaseV4_.get() != NULL)
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5977 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5978 return pimpl_->databaseV4_->GetSharedLibrary();
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5979 }
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
5980 else
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5981 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5982 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5983 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
5984 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
5985
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5986
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5987 const char* OrthancPlugins::GetProperty(const char* plugin,
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5988 _OrthancPluginProperty property) const
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5989 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5990 PImpl::Property p = std::make_pair(plugin, property);
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5991 PImpl::Properties::const_iterator it = pimpl_->properties_.find(p);
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5992
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5993 if (it == pimpl_->properties_.end())
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5994 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5995 return NULL;
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5996 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5997 else
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5998 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
5999 return it->second.c_str();
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
6000 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
6001 }
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
6002
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
6003
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
6004 void OrthancPlugins::SetCommandLineArguments(int argc, char* argv[])
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
6005 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
6006 if (argc < 1 || argv == NULL)
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
6007 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
6008 throw OrthancException(ErrorCode_ParameterOutOfRange);
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
6009 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
6010
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
6011 pimpl_->argc_ = argc;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
6012 pimpl_->argv_ = argv;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
6013 }
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
6014
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
6015
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
6016 PluginsManager& OrthancPlugins::GetManager()
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
6017 {
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
6018 return pimpl_->manager_;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
6019 }
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
6020
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
6021
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
6022 const PluginsManager& OrthancPlugins::GetManager() const
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
6023 {
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
6024 return pimpl_->manager_;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
6025 }
1644
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
6026
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
6027
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
6028 PluginsErrorDictionary& OrthancPlugins::GetErrorDictionary()
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
6029 {
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
6030 return pimpl_->dictionary_;
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
6031 }
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
6032
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
6033
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
6034 IWorklistRequestHandler* OrthancPlugins::ConstructWorklistRequestHandler()
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
6035 {
1809
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
6036 if (HasWorklistHandler())
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
6037 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
6038 return new WorklistHandler(*this);
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
6039 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
6040 else
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
6041 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
6042 return NULL;
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
6043 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
6044 }
1809
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
6045
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
6046
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
6047 bool OrthancPlugins::HasWorklistHandler()
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
6048 {
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
6049 boost::mutex::scoped_lock lock(pimpl_->worklistCallbackMutex_);
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
6050 return pimpl_->worklistCallback_ != NULL;
1809
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
6051 }
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
6052
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
6053
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6054 IFindRequestHandler* OrthancPlugins::ConstructFindRequestHandler()
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6055 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6056 if (HasFindHandler())
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6057 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6058 return new FindHandler(*this);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6059 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6060 else
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6061 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6062 return NULL;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6063 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6064 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6065
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6066
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6067 bool OrthancPlugins::HasFindHandler()
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6068 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6069 boost::mutex::scoped_lock lock(pimpl_->findCallbackMutex_);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6070 return pimpl_->findCallback_ != NULL;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6071 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6072
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
6073
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6074 IMoveRequestHandler* OrthancPlugins::ConstructMoveRequestHandler()
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6075 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6076 if (HasMoveHandler())
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6077 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6078 return new MoveHandler(*this);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6079 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6080 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6081 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6082 return NULL;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6083 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6084 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6085
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6086
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6087 bool OrthancPlugins::HasMoveHandler()
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6088 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
6089 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6090 return pimpl_->moveCallbacks_.callback != NULL;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6091 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6092
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
6093
1906
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
6094 bool OrthancPlugins::HasCustomImageDecoder()
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
6095 {
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6096 boost::shared_lock<boost::shared_mutex> lock(pimpl_->decoderTranscoderMutex_);
2012
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
6097 return !pimpl_->decodeImageCallbacks_.empty();
1906
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
6098 }
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
6099
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
6100
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
6101 bool OrthancPlugins::HasCustomTranscoder()
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
6102 {
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
6103 boost::shared_lock<boost::shared_mutex> lock(pimpl_->decoderTranscoderMutex_);
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
6104 return !pimpl_->transcoderCallbacks_.empty();
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
6105 }
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
6106
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
6107
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3926
diff changeset
6108 ImageAccessor* OrthancPlugins::Decode(const void* dicom,
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3926
diff changeset
6109 size_t size,
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3926
diff changeset
6110 unsigned int frame)
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
6111 {
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6112 boost::shared_lock<boost::shared_mutex> lock(pimpl_->decoderTranscoderMutex_);
2012
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
6113
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
6114 for (PImpl::DecodeImageCallbacks::const_iterator
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
6115 decoder = pimpl_->decodeImageCallbacks_.begin();
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
6116 decoder != pimpl_->decodeImageCallbacks_.end(); ++decoder)
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
6117 {
2012
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
6118 OrthancPluginImage* pluginImage = NULL;
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
6119 if ((*decoder) (&pluginImage, dicom, size, frame) == OrthancPluginErrorCode_Success &&
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
6120 pluginImage != NULL)
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
6121 {
2012
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
6122 return reinterpret_cast<ImageAccessor*>(pluginImage);
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
6123 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
6124 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
6125
2012
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
6126 return NULL;
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
6127 }
50b9bc19dc62 More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2009
diff changeset
6128
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6129
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6130 bool OrthancPlugins::IsAllowed(HttpMethod method,
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6131 const char* uri,
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6132 const char* ip,
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6133 const char* username,
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
6134 const HttpToolbox::Arguments& httpHeaders,
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
6135 const HttpToolbox::GetArguments& getArguments)
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6136 {
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6137 OrthancPluginHttpMethod cMethod = Plugins::Convert(method);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6138
1962
22ddb22fce83 sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1961
diff changeset
6139 std::vector<const char*> httpKeys(httpHeaders.size());
22ddb22fce83 sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1961
diff changeset
6140 std::vector<const char*> httpValues(httpHeaders.size());
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6141
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6142 size_t pos = 0;
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
6143 for (HttpToolbox::Arguments::const_iterator
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6144 it = httpHeaders.begin(); it != httpHeaders.end(); ++it, pos++)
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6145 {
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6146 httpKeys[pos] = it->first.c_str();
1962
22ddb22fce83 sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1961
diff changeset
6147 httpValues[pos] = it->second.c_str();
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6148 }
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6149
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6150 std::vector<const char*> getKeys(getArguments.size());
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6151 std::vector<const char*> getValues(getArguments.size());
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6152
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6153 for (size_t i = 0; i < getArguments.size(); i++)
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6154 {
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6155 getKeys[i] = getArguments[i].first.c_str();
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6156 getValues[i] = getArguments[i].second.c_str();
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6157 }
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6158
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6159 {
4364
d527a081f92d Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4343
diff changeset
6160 boost::shared_lock<boost::shared_mutex> lock(pimpl_->incomingHttpRequestFilterMutex_);
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6161
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6162 // Improved callback with support for GET arguments, since Orthanc 1.3.0
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6163 for (PImpl::IncomingHttpRequestFilters2::const_iterator
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6164 filter = pimpl_->incomingHttpRequestFilters2_.begin();
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6165 filter != pimpl_->incomingHttpRequestFilters2_.end(); ++filter)
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6166 {
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6167 int32_t allowed = (*filter) (cMethod, uri, ip,
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6168 httpKeys.size(),
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6169 httpKeys.empty() ? NULL : &httpKeys[0],
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6170 httpValues.empty() ? NULL : &httpValues[0],
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6171 getKeys.size(),
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6172 getKeys.empty() ? NULL : &getKeys[0],
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6173 getValues.empty() ? NULL : &getValues[0]);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6174
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6175 if (allowed == 0)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6176 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6177 return false;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6178 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6179 else if (allowed != 1)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6180 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6181 // The callback is only allowed to answer 0 or 1
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6182 throw OrthancException(ErrorCode_Plugin);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6183 }
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6184 }
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6185
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6186 for (PImpl::IncomingHttpRequestFilters::const_iterator
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6187 filter = pimpl_->incomingHttpRequestFilters_.begin();
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6188 filter != pimpl_->incomingHttpRequestFilters_.end(); ++filter)
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6189 {
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6190 int32_t allowed = (*filter) (cMethod, uri, ip, httpKeys.size(),
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6191 httpKeys.empty() ? NULL : &httpKeys[0],
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6192 httpValues.empty() ? NULL : &httpValues[0]);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6193
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6194 if (allowed == 0)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6195 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6196 return false;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6197 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6198 else if (allowed != 1)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6199 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6200 // The callback is only allowed to answer 0 or 1
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6201 throw OrthancException(ErrorCode_Plugin);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
6202 }
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
6203 }
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6204 }
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6205
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6206 return true;
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
6207 }
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6208
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6209
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
6210 IJob* OrthancPlugins::UnserializeJob(const std::string& type,
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
6211 const Json::Value& value)
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6212 {
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6213 const std::string serialized = value.toStyledString();
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6214
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6215 boost::mutex::scoped_lock lock(pimpl_->jobsUnserializersMutex_);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6216
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6217 for (PImpl::JobsUnserializers::iterator
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6218 unserializer = pimpl_->jobsUnserializers_.begin();
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6219 unserializer != pimpl_->jobsUnserializers_.end(); ++unserializer)
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6220 {
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
6221 OrthancPluginJob* job = (*unserializer) (type.c_str(), serialized.c_str());
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
6222 if (job != NULL)
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6223 {
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
6224 return reinterpret_cast<PluginsJob*>(job);
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6225 }
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6226 }
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6227
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
6228 return NULL;
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
6229 }
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6230
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6231
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6232 void OrthancPlugins::RefreshMetrics()
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6233 {
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6234 boost::mutex::scoped_lock lock(pimpl_->refreshMetricsMutex_);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6235
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6236 for (PImpl::RefreshMetricsCallbacks::iterator
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6237 it = pimpl_->refreshMetricsCallbacks_.begin();
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6238 it != pimpl_->refreshMetricsCallbacks_.end(); ++it)
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6239 {
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6240 if (*it != NULL)
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6241 {
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6242 (*it) ();
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6243 }
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6244 }
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
6245 }
3395
0ce9b4f5fdf5 new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3393
diff changeset
6246
0ce9b4f5fdf5 new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3393
diff changeset
6247
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6248 class OrthancPlugins::HttpServerChunkedReader : public IHttpHandler::IChunkedRequestReader
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6249 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6250 private:
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6251 OrthancPluginServerChunkedRequestReader* reader_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6252 _OrthancPluginChunkedRestCallback parameters_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6253 PluginsErrorDictionary& errorDictionary_;
3399
4e8205871967 OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3397
diff changeset
6254
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6255 public:
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6256 HttpServerChunkedReader(OrthancPluginServerChunkedRequestReader* reader,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6257 const _OrthancPluginChunkedRestCallback& parameters,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6258 PluginsErrorDictionary& errorDictionary) :
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6259 reader_(reader),
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6260 parameters_(parameters),
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6261 errorDictionary_(errorDictionary)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6262 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6263 assert(reader_ != NULL);
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6264 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6265
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6266 virtual ~HttpServerChunkedReader()
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6267 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6268 assert(reader_ != NULL);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6269 parameters_.finalize(reader_);
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6270 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6271
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6272 virtual void AddBodyChunk(const void* data,
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
6273 size_t size) ORTHANC_OVERRIDE
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6274 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6275 if (static_cast<uint32_t>(size) != size)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6276 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6277 throw OrthancException(ErrorCode_NotEnoughMemory, ERROR_MESSAGE_64BIT);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6278 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6279
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6280 assert(reader_ != NULL);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6281 parameters_.addChunk(reader_, data, size);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6282 }
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
6283
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4201
diff changeset
6284 virtual void Execute(HttpOutput& output) ORTHANC_OVERRIDE
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6285 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6286 assert(reader_ != NULL);
3399
4e8205871967 OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3397
diff changeset
6287
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6288 PImpl::PluginHttpOutput pluginOutput(output);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6289
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6290 OrthancPluginErrorCode error = parameters_.execute(
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6291 reader_, reinterpret_cast<OrthancPluginRestOutput*>(&pluginOutput));
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6292
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6293 pluginOutput.Close(error, errorDictionary_);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6294 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6295 };
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6296
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6297
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
6298 bool OrthancPlugins::CreateChunkedRequestReader(std::unique_ptr<IChunkedRequestReader>& target,
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6299 RequestOrigin origin,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6300 const char* remoteIp,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6301 const char* username,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6302 HttpMethod method,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6303 const UriComponents& uri,
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4329
diff changeset
6304 const HttpToolbox::Arguments& headers)
3395
0ce9b4f5fdf5 new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3393
diff changeset
6305 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6306 if (method != HttpMethod_Post &&
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6307 method != HttpMethod_Put)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6308 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6309 throw OrthancException(ErrorCode_InternalError);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6310 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6311
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6312 RestCallbackMatcher matcher(uri);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6313
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6314 PImpl::ChunkedRestCallback* callback = NULL;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6315
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6316 // Loop over the callbacks registered by the plugins
4459
16392fe89ce0 new mutex to protect registration of REST callbacks: restCallbackRegistrationMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4441
diff changeset
6317 boost::shared_lock<boost::shared_mutex> lock(pimpl_->restCallbackRegistrationMutex_);
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6318 for (PImpl::ChunkedRestCallbacks::const_iterator it = pimpl_->chunkedRestCallbacks_.begin();
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6319 it != pimpl_->chunkedRestCallbacks_.end(); ++it)
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6320 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6321 if (matcher.IsMatch((*it)->GetRegularExpression()))
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6322 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6323 callback = *it;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6324 break;
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6325 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
6326 }
3395
0ce9b4f5fdf5 new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3393
diff changeset
6327
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6328 if (callback == NULL)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6329 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6330 // Callback not found
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6331 return false;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6332 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6333 else
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6334 {
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6335 OrthancPluginServerChunkedRequestReaderFactory handler;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6336
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6337 switch (method)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6338 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6339 case HttpMethod_Post:
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6340 handler = callback->GetParameters().postHandler;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6341 break;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6342
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6343 case HttpMethod_Put:
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6344 handler = callback->GetParameters().putHandler;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6345 break;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6346
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6347 default:
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6348 handler = NULL;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6349 break;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6350 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6351
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6352 if (handler == NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6353 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6354 return false;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6355 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6356 else
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6357 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
6358 CLOG(INFO, PLUGINS) << "Delegating chunked HTTP request to plugin for URI: " << matcher.GetFlatUri();
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6359
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6360 HttpRequestConverter converter(matcher, method, headers);
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6361 converter.GetRequest().body = NULL;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6362 converter.GetRequest().bodySize = 0;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6363
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6364 OrthancPluginServerChunkedRequestReader* reader = NULL;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6365
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6366 OrthancPluginErrorCode errorCode = handler(
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6367 &reader, matcher.GetFlatUri().c_str(), &converter.GetRequest());
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6368
4086
4cd94ed75a5b Issue #182: Better handling of errors in plugins reading chunked HTTP body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3980
diff changeset
6369 if (errorCode != OrthancPluginErrorCode_Success)
4cd94ed75a5b Issue #182: Better handling of errors in plugins reading chunked HTTP body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3980
diff changeset
6370 {
4cd94ed75a5b Issue #182: Better handling of errors in plugins reading chunked HTTP body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3980
diff changeset
6371 throw OrthancException(static_cast<ErrorCode>(errorCode));
4cd94ed75a5b Issue #182: Better handling of errors in plugins reading chunked HTTP body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3980
diff changeset
6372 }
4cd94ed75a5b Issue #182: Better handling of errors in plugins reading chunked HTTP body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3980
diff changeset
6373 else if (reader == NULL)
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6374 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6375 // The plugin has not created a reader for chunked body
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6376 return false;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6377 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6378 else
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6379 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6380 target.reset(new HttpServerChunkedReader(reader, callback->GetParameters(), GetErrorDictionary()));
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6381 return true;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6382 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
6383 }
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
6384 }
3395
0ce9b4f5fdf5 new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3393
diff changeset
6385 }
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6386
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6387
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6388 IStorageCommitmentFactory::ILookupHandler* OrthancPlugins::CreateStorageCommitment(
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6389 const std::string& jobId,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6390 const std::string& transactionUid,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6391 const std::vector<std::string>& sopClassUids,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6392 const std::vector<std::string>& sopInstanceUids,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6393 const std::string& remoteAet,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6394 const std::string& calledAet)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6395 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6396 boost::mutex::scoped_lock lock(pimpl_->storageCommitmentScpMutex_);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6397
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6398 for (PImpl::StorageCommitmentScpCallbacks::iterator
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6399 it = pimpl_->storageCommitmentScpCallbacks_.begin();
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6400 it != pimpl_->storageCommitmentScpCallbacks_.end(); ++it)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6401 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6402 assert(*it != NULL);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6403 IStorageCommitmentFactory::ILookupHandler* handler = (*it)->CreateStorageCommitment
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6404 (jobId, transactionUid, sopClassUids, sopInstanceUids, remoteAet, calledAet);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6405
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6406 if (handler != NULL)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6407 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6408 return handler;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6409 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6410 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6411
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6412 return NULL;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
6413 }
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
6414
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
6415
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3931
diff changeset
6416 bool OrthancPlugins::TranscodeBuffer(std::string& target,
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3931
diff changeset
6417 const void* buffer,
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3931
diff changeset
6418 size_t size,
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3931
diff changeset
6419 const std::set<DicomTransferSyntax>& allowedSyntaxes,
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3931
diff changeset
6420 bool allowNewSopInstanceUid)
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
6421 {
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6422 boost::shared_lock<boost::shared_mutex> lock(pimpl_->decoderTranscoderMutex_);
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6423
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6424 if (pimpl_->transcoderCallbacks_.empty())
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6425 {
3964
821715370890 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
6426 return false;
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6427 }
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6428
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6429 std::vector<const char*> uids;
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6430 uids.reserve(allowedSyntaxes.size());
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6431 for (std::set<DicomTransferSyntax>::const_iterator
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6432 it = allowedSyntaxes.begin(); it != allowedSyntaxes.end(); ++it)
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6433 {
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6434 uids.push_back(GetTransferSyntaxUid(*it));
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6435 }
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6436
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6437 for (PImpl::TranscoderCallbacks::const_iterator
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6438 transcoder = pimpl_->transcoderCallbacks_.begin();
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6439 transcoder != pimpl_->transcoderCallbacks_.end(); ++transcoder)
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6440 {
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6441 MemoryBufferRaii a;
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3946
diff changeset
6442
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3946
diff changeset
6443 if ((*transcoder) (a.GetObject(), buffer, size, uids.empty() ? NULL : &uids[0],
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6444 static_cast<uint32_t>(uids.size()), allowNewSopInstanceUid) ==
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6445 OrthancPluginErrorCode_Success)
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6446 {
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6447 a.ToString(target);
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6448 return true;
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6449 }
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6450 }
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3929
diff changeset
6451
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
6452 return false;
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
6453 }
4343
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
6454
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
6455
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
6456 bool OrthancPlugins::IsValidAuthorizationToken(const std::string& token) const
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
6457 {
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
6458 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
6459 return (pimpl_->authorizationTokens_.find(token) != pimpl_->authorizationTokens_.end());
e1e918e790e8 New function in the SDK: OrthancPluginGenerateRestApiAuthorizationToken()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
6460 }
4613
2684544ff03c maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
6461
2684544ff03c maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
6462
2684544ff03c maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
6463 unsigned int OrthancPlugins::GetMaxDatabaseRetries() const
2684544ff03c maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
6464 {
2684544ff03c maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
6465 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
2684544ff03c maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
6466 return pimpl_->maxDatabaseRetries_;
2684544ff03c maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
6467 }
4943
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6468
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6469
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6470 void OrthancPlugins::RegisterWebDavCollections(HttpServer& target)
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6471 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6472 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6473
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6474 while (!pimpl_->webDavCollections_.empty())
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6475 {
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6476 WebDavCollection* collection = pimpl_->webDavCollections_.front();
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6477 assert(collection != NULL);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6478
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6479 UriComponents components;
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6480 Toolbox::SplitUriComponents(components, collection->GetUri());
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6481 target.Register(components, collection);
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6482
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6483 pimpl_->webDavCollections_.pop_front();
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6484 }
47d734fa30f6 adding function OrthancPluginRegisterWebDavCollection() to the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4921
diff changeset
6485 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6486 }