annotate Plugins/Engine/OrthancPlugins.cpp @ 3916:0e3849268a55 transcoding

new plugin SDK primitives related to OrthancPluginDicomInstance
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 11 May 2020 21:07:36 +0200
parents f0dd5ded8927
children 6f11b3233a06
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
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3528
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * 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
8 * 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
9 * 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
10 * License, or (at your option) any later version.
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * 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
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * 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
30 * 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
31 **/
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
34 #include "../../OrthancServer/PrecompiledHeadersServer.h"
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
35 #include "OrthancPlugins.h"
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2135
diff changeset
37 #if ORTHANC_ENABLE_PLUGINS != 1
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
38 #error The plugin support is disabled
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
39 #endif
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
40
3118
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
41 #if !defined(DCMTK_VERSION_NUMBER)
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
42 # error The macro DCMTK_VERSION_NUMBER must be defined
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
43 #endif
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
44
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
45
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
46 #include "../../Core/Compression/GzipCompressor.h"
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
47 #include "../../Core/Compression/ZlibCompressor.h"
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
48 #include "../../Core/DicomFormat/DicomArray.h"
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
49 #include "../../Core/DicomParsing/DicomWebJsonVisitor.h"
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
50 #include "../../Core/DicomParsing/FromDcmtkBridge.h"
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
51 #include "../../Core/DicomParsing/Internals/DicomImageDecoder.h"
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
52 #include "../../Core/DicomParsing/ToDcmtkBridge.h"
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
53 #include "../../Core/HttpServer/HttpToolbox.h"
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
54 #include "../../Core/Images/Image.h"
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
55 #include "../../Core/Images/ImageProcessing.h"
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
56 #include "../../Core/Images/JpegReader.h"
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
57 #include "../../Core/Images/JpegWriter.h"
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
58 #include "../../Core/Images/PngReader.h"
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
59 #include "../../Core/Images/PngWriter.h"
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1466
diff changeset
60 #include "../../Core/Logging.h"
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
61 #include "../../Core/MetricsRegistry.h"
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
62 #include "../../Core/OrthancException.h"
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
63 #include "../../Core/SerializationToolbox.h"
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
64 #include "../../Core/Toolbox.h"
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
65 #include "../../OrthancServer/DefaultDicomImageDecoder.h"
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
66 #include "../../OrthancServer/OrthancConfiguration.h"
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
67 #include "../../OrthancServer/OrthancFindRequestHandler.h"
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
68 #include "../../OrthancServer/Search/HierarchicalMatcher.h"
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
69 #include "../../OrthancServer/ServerContext.h"
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
70 #include "../../OrthancServer/ServerToolbox.h"
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
71 #include "PluginsEnumerations.h"
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
72 #include "PluginsJob.h"
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 #include <boost/regex.hpp>
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
75 #include <dcmtk/dcmdata/dcdict.h>
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
76 #include <dcmtk/dcmdata/dcdicent.h>
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
78 #define ERROR_MESSAGE_64BIT "A 64bit version of the Orthanc API is necessary"
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
79
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 namespace Orthanc
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
82 static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
83 const void* data,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
84 size_t size)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
85 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
86 if (static_cast<uint32_t>(size) != size)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
87 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
88 throw OrthancException(ErrorCode_NotEnoughMemory, ERROR_MESSAGE_64BIT);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
89 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
90
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
91 target.size = size;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
92
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
93 if (size == 0)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
94 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
95 target.data = NULL;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
96 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
97 else
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
98 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
99 target.data = malloc(size);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
100 if (target.data != NULL)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
101 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
102 memcpy(target.data, data, size);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
103 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
104 else
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
105 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
106 throw OrthancException(ErrorCode_NotEnoughMemory);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
107 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
108 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
109 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
110
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
111
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
112 static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
113 const std::string& str)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
114 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
115 if (str.size() == 0)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
116 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
117 target.size = 0;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
118 target.data = NULL;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
119 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
120 else
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
121 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
122 CopyToMemoryBuffer(target, str.c_str(), str.size());
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
123 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
124 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
125
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
126
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
127 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
128 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
129 if (static_cast<uint32_t>(str.size()) != str.size())
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
130 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
131 throw OrthancException(ErrorCode_NotEnoughMemory, ERROR_MESSAGE_64BIT);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
132 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
133
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
134 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
135 if (result == NULL)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
136 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
137 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
138 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
139
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
140 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
141 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
142 result[0] = '\0';
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
143 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
144 else
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
145 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
146 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
147 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
148
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
149 return result;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
150 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
151
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
152
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
153 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
154 {
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
155 class PluginStorageArea : public IStorageArea
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
156 {
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
157 private:
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
158 _OrthancPluginRegisterStorageArea callbacks_;
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
159 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
160
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
161 void Free(void* buffer) 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
162 {
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
163 if (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
164 {
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
165 callbacks_.free(buffer);
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
166 }
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
167 }
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
168
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
169 public:
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
170 PluginStorageArea(const _OrthancPluginRegisterStorageArea& callbacks,
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
171 PluginsErrorDictionary& errorDictionary) :
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
172 callbacks_(callbacks),
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
173 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
174 {
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
175 }
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
176
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
177
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
178 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
179 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
180 size_t size,
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
181 FileContentType 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
182 {
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
183 OrthancPluginErrorCode error = callbacks_.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
184 (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
185
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
186 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
187 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
188 errorDictionary_.LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
189 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
190 }
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
191 }
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
192
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
193
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
194 virtual void Read(std::string& 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
195 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
196 FileContentType 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
197 {
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
198 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
199 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
200
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
201 OrthancPluginErrorCode error = callbacks_.read
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
202 (&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
203
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
204 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
205 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
206 errorDictionary_.LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
207 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
208 }
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
209
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
210 try
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
211 {
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
212 content.resize(static_cast<size_t>(size));
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
213 }
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
214 catch (...)
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
215 {
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
216 Free(buffer);
1643
87c77b9b3679 provision for error codes in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
217 throw OrthancException(ErrorCode_NotEnoughMemory);
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
218 }
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
219
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
220 if (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
221 {
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
222 memcpy(&content[0], buffer, static_cast<size_t>(size));
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
223 }
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
224
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
225 Free(buffer);
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
226 }
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
227
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
228
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
229 virtual void Remove(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
230 FileContentType 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
231 {
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
232 OrthancPluginErrorCode error = callbacks_.remove
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
233 (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
234
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
235 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
236 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
237 errorDictionary_.LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
238 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
239 }
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
240 }
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
241 };
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
242
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
243
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
244 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
245 {
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
246 private:
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
247 SharedLibrary& 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
248 _OrthancPluginRegisterStorageArea callbacks_;
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
249 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
250
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
251 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
252 StorageAreaFactory(SharedLibrary& sharedLibrary,
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
253 const _OrthancPluginRegisterStorageArea& callbacks,
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
254 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
255 sharedLibrary_(sharedLibrary),
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
256 callbacks_(callbacks),
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
257 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
258 {
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
259 }
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
260
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
261 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
262 {
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
263 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
264 }
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
265
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
266 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
267 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
268 return new PluginStorageArea(callbacks_, 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
269 }
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
270 };
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
271
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
272
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
273 class OrthancPeers : public boost::noncopyable
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
274 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
275 private:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
276 std::vector<std::string> names_;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
277 std::vector<WebServiceParameters> parameters_;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
278
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
279 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
280 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
281 assert(names_.size() == parameters_.size());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
282 if (i >= names_.size())
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
283 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
284 throw OrthancException(ErrorCode_ParameterOutOfRange);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
285 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
286 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
287
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
288 public:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
289 OrthancPeers()
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
290 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
291 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
292
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
293 std::set<std::string> peers;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
294 lock.GetConfiguration().GetListOfOrthancPeers(peers);
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
295
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
296 names_.reserve(peers.size());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
297 parameters_.reserve(peers.size());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
298
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
299 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
300 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
301 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
302 WebServiceParameters peer;
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
303 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
304 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
305 names_.push_back(*it);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
306 parameters_.push_back(peer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
307 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
308 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
309 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
310
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
311 size_t GetPeersCount() const
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
312 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
313 return names_.size();
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
314 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
315
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
316 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
317 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
318 CheckIndex(i);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
319 return names_[i];
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
320 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
321
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
322 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
323 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
324 CheckIndex(i);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
325 return parameters_[i];
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
326 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
327 };
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
328
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
329
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
330 class DicomWebBinaryFormatter : public DicomWebJsonVisitor::IBinaryFormatter
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
331 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
332 private:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
333 OrthancPluginDicomWebBinaryCallback callback_;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
334 DicomWebJsonVisitor::BinaryMode currentMode_;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
335 std::string currentBulkDataUri_;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
336
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
337 static void Setter(OrthancPluginDicomWebNode* node,
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
338 OrthancPluginDicomWebBinaryMode mode,
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
339 const char* bulkDataUri)
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
340 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
341 DicomWebBinaryFormatter& that = *reinterpret_cast<DicomWebBinaryFormatter*>(node);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
342
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
343 switch (mode)
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
344 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
345 case OrthancPluginDicomWebBinaryMode_Ignore:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
346 that.currentMode_ = DicomWebJsonVisitor::BinaryMode_Ignore;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
347 break;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
348
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
349 case OrthancPluginDicomWebBinaryMode_InlineBinary:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
350 that.currentMode_ = DicomWebJsonVisitor::BinaryMode_InlineBinary;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
351 break;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
352
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
353 case OrthancPluginDicomWebBinaryMode_BulkDataUri:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
354 if (bulkDataUri == NULL)
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
355 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
356 throw OrthancException(ErrorCode_NullPointer);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
357 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
358
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
359 that.currentBulkDataUri_ = bulkDataUri;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
360 that.currentMode_ = DicomWebJsonVisitor::BinaryMode_BulkDataUri;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
361 break;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
362
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
363 default:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
364 throw OrthancException(ErrorCode_ParameterOutOfRange);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
365 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
366 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
367
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
368 public:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
369 DicomWebBinaryFormatter(const _OrthancPluginEncodeDicomWeb& parameters) :
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
370 callback_(parameters.callback)
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
371 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
372 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
373
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
374 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
375 const std::vector<DicomTag>& parentTags,
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
376 const std::vector<size_t>& parentIndexes,
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
377 const DicomTag& tag,
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
378 ValueRepresentation vr)
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
379 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
380 if (callback_ == NULL)
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
381 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
382 return DicomWebJsonVisitor::BinaryMode_InlineBinary;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
383 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
384 else
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
385 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
386 assert(parentTags.size() == parentIndexes.size());
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
387 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
388 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
389 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
390
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
391 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
392 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
393 groups[i] = parentTags[i].GetGroup();
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
394 elements[i] = parentTags[i].GetElement();
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
395 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
396 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
397 bool empty = parentTags.empty();
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
398
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
399 currentMode_ = DicomWebJsonVisitor::BinaryMode_Ignore;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
400
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
401 callback_(reinterpret_cast<OrthancPluginDicomWebNode*>(this),
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
402 DicomWebBinaryFormatter::Setter,
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
403 static_cast<uint32_t>(parentTags.size()),
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
404 (empty ? NULL : &groups[0]),
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
405 (empty ? NULL : &elements[0]),
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
406 (empty ? NULL : &indexes[0]),
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
407 tag.GetGroup(),
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
408 tag.GetElement(),
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
409 Plugins::Convert(vr));
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
410
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
411 bulkDataUri = currentBulkDataUri_;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
412 return currentMode_;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
413 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
414 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
415 };
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
416 }
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
417
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
418
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
419 class OrthancPlugins::PImpl
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
420 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
421 private:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
422 boost::mutex contextMutex_;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
423 ServerContext* context_;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
424
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
425 public:
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
426 class PluginHttpOutput : public boost::noncopyable
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
427 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
428 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
429 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
430 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
431 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
432 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
433 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
434 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
435 };
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
436
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
437 HttpOutput& output_;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
438 std::unique_ptr<std::string> errorDetails_;
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
439 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
440 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
441 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
442 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
443 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
444 std::map<std::string, std::string> multipartFirstHeaders_;
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
445
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
446 public:
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
447 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
448 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
449 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
450 multipartState_(MultipartState_None)
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
451 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
452 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
453
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
454 HttpOutput& GetOutput()
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
455 {
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
456 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
457 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
458 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
459 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
460 else
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
461 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
462 // 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
463 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
464 }
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
465 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
466
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
467 void SetErrorDetails(const std::string& details,
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
468 bool logDetails)
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
469 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
470 errorDetails_.reset(new std::string(details));
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
471 logDetails_ = logDetails;
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
472 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
473
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
474 bool HasErrorDetails() const
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
475 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
476 return errorDetails_.get() != NULL;
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
477 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
478
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
479 bool IsLogDetails() const
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
480 {
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
481 return logDetails_;
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
482 }
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
483
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
484 const std::string& GetErrorDetails() const
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
485 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
486 if (errorDetails_.get() == NULL)
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
487 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
488 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
489 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
490 else
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
491 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
492 return *errorDetails_;
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
493 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
494 }
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
495
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
496 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
497 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
498 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
499 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
500 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
501 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
502 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
503 else
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
504 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
505 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
506 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
507 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
508 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
509 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
510
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
511 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
512 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
513 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
514 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
515 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
516 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
517 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
518 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
519
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
520 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
521 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
522 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
523 // 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
524 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
525
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
526 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
527 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
528 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
529 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
530 break;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
531
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
532 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
533 // 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
534 // 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
535 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
536 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
537 multipartFirstHeaders_);
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
538 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
539
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
540 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
541 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
542 break;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
543
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
544 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
545 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
546 break;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
547
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
548 default:
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
549 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
550 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
551 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
552
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
553 void Close(OrthancPluginErrorCode error,
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
554 PluginsErrorDictionary& dictionary)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
555 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
556 if (error == OrthancPluginErrorCode_Success)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
557 {
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
558 switch (multipartState_)
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
559 {
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
560 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
561 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
562 break;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
563
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
564 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
565 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
566 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
567 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
568 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
569 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
570 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
571
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
572 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
573 {
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
574 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
575 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
576 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
577 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
578
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
579 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
580 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
581 break;
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
582 }
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
583
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
584 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
585 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
586 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
587
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
588 default:
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
589 throw OrthancException(ErrorCode_InternalError);
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
590 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
591 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
592 else
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
593 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
594 dictionary.LogError(error, false);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
595
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
596 if (HasErrorDetails())
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
597 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
598 throw OrthancException(static_cast<ErrorCode>(error),
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
599 GetErrorDetails(),
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
600 IsLogDetails());
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
601 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
602 else
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
603 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
604 throw OrthancException(static_cast<ErrorCode>(error));
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
605 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
606 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
607 }
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
608 };
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
609
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
610
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
611 class RestCallback : public boost::noncopyable
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
612 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
613 private:
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
614 boost::regex regex_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
615 OrthancPluginRestCallback callback_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
616 bool lock_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
617
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
618 OrthancPluginErrorCode InvokeInternal(PluginHttpOutput& output,
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
619 const std::string& flatUri,
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
620 const OrthancPluginHttpRequest& request)
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
621 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
622 return callback_(reinterpret_cast<OrthancPluginRestOutput*>(&output),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
623 flatUri.c_str(),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
624 &request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
625 }
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
626
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
627 public:
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
628 RestCallback(const char* regex,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
629 OrthancPluginRestCallback callback,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
630 bool lockRestCallbacks) :
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
631 regex_(regex),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
632 callback_(callback),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
633 lock_(lockRestCallbacks)
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
634 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
635 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
636
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
637 const boost::regex& GetRegularExpression() const
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
638 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
639 return regex_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
640 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
641
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
642 OrthancPluginErrorCode Invoke(boost::recursive_mutex& restCallbackMutex,
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
643 PluginHttpOutput& output,
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
644 const std::string& flatUri,
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
645 const OrthancPluginHttpRequest& request)
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
646 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
647 if (lock_)
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
648 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
649 boost::recursive_mutex::scoped_lock lock(restCallbackMutex);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
650 return InvokeInternal(output, flatUri, request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
651 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
652 else
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
653 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
654 return InvokeInternal(output, flatUri, request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
655 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
656 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
657 };
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
658
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
659
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
660 class ChunkedRestCallback : public boost::noncopyable
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
661 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
662 private:
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
663 _OrthancPluginChunkedRestCallback parameters_;
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
664 boost::regex regex_;
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
665
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
666 public:
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
667 ChunkedRestCallback(_OrthancPluginChunkedRestCallback parameters) :
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
668 parameters_(parameters),
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
669 regex_(parameters.pathRegularExpression)
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
670 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
671 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
672
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
673 const boost::regex& GetRegularExpression() const
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
674 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
675 return regex_;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
676 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
677
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
678 const _OrthancPluginChunkedRestCallback& GetParameters() const
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
679 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
680 return parameters_;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
681 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
682 };
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
683
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
684
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
685
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
686 class StorageCommitmentScp : public IStorageCommitmentFactory
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
687 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
688 private:
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
689 class Handler : public IStorageCommitmentFactory::ILookupHandler
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
690 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
691 private:
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
692 _OrthancPluginRegisterStorageCommitmentScpCallback parameters_;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
693 void* handler_;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
694
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
695 public:
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
696 Handler(_OrthancPluginRegisterStorageCommitmentScpCallback parameters,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
697 void* handler) :
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3662
diff changeset
698 parameters_(parameters),
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3662
diff changeset
699 handler_(handler)
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
700 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
701 if (handler == NULL)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
702 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
703 throw OrthancException(ErrorCode_NullPointer);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
704 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
705 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
706
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
707 virtual ~Handler()
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
708 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
709 assert(handler_ != NULL);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
710 parameters_.destructor(handler_);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
711 handler_ = NULL;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
712 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
713
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
714 virtual StorageCommitmentFailureReason Lookup(const std::string& sopClassUid,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
715 const std::string& sopInstanceUid)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
716 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
717 assert(handler_ != NULL);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
718 OrthancPluginStorageCommitmentFailureReason reason =
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
719 OrthancPluginStorageCommitmentFailureReason_Success;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
720 OrthancPluginErrorCode error = parameters_.lookup(
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
721 &reason, handler_, sopClassUid.c_str(), sopInstanceUid.c_str());
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
722 if (error == OrthancPluginErrorCode_Success)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
723 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
724 return Plugins::Convert(reason);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
725 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
726 else
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
727 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
728 throw OrthancException(static_cast<ErrorCode>(error));
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
729 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
730 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
731 };
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
732
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
733 _OrthancPluginRegisterStorageCommitmentScpCallback parameters_;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
734
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
735 public:
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
736 StorageCommitmentScp(_OrthancPluginRegisterStorageCommitmentScpCallback parameters) :
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
737 parameters_(parameters)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
738 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
739 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
740
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
741 virtual ILookupHandler* CreateStorageCommitment(
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
742 const std::string& jobId,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
743 const std::string& transactionUid,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
744 const std::vector<std::string>& sopClassUids,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
745 const std::vector<std::string>& sopInstanceUids,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
746 const std::string& remoteAet,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
747 const std::string& calledAet) ORTHANC_OVERRIDE
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
748 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
749 const size_t n = sopClassUids.size();
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
750
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
751 if (sopInstanceUids.size() != n)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
752 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
753 throw OrthancException(ErrorCode_ParameterOutOfRange);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
754 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
755
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
756 std::vector<const char*> a, b;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
757 a.resize(n);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
758 b.resize(n);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
759
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
760 for (size_t i = 0; i < n; i++)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
761 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
762 a[i] = sopClassUids[i].c_str();
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
763 b[i] = sopInstanceUids[i].c_str();
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
764 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
765
3665
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
766 void* handler = NULL;
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
767 OrthancPluginErrorCode error = parameters_.factory(
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
768 &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
769 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
770 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
771
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
772 if (error != OrthancPluginErrorCode_Success)
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
773 {
3665
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
774 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
775 }
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
776 else if (handler == NULL)
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
777 {
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
778 // This plugin won't handle this storage commitment request
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
779 return NULL;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
780 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
781 else
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
782 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
783 return new Handler(parameters_, handler);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
784 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
785 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
786 };
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
787
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
788
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
789 class ServerContextLock
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
790 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
791 private:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
792 boost::mutex::scoped_lock lock_;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
793 ServerContext* context_;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
794
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
795 public:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
796 ServerContextLock(PImpl& that) :
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
797 lock_(that.contextMutex_),
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
798 context_(that.context_)
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
799 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
800 if (context_ == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
801 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
802 throw OrthancException(ErrorCode_DatabaseNotInitialized);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
803 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
804 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
805
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
806 ServerContext& GetContext()
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
807 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
808 assert(context_ != NULL);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
809 return *context_;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
810 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
811 };
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
812
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
813
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
814 void SetServerContext(ServerContext* context)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
815 {
2836
7133ad478eea fix Debian warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
816 boost::mutex::scoped_lock lock(contextMutex_);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
817 context_ = context;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
818 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
819
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
820
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
821 typedef std::pair<std::string, _OrthancPluginProperty> Property;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
822 typedef std::list<RestCallback*> RestCallbacks;
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
823 typedef std::list<ChunkedRestCallback*> ChunkedRestCallbacks;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
824 typedef std::list<OrthancPluginOnStoredInstanceCallback> OnStoredCallbacks;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
825 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
826 typedef std::list<OrthancPluginIncomingHttpRequestFilter> IncomingHttpRequestFilters;
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
827 typedef std::list<OrthancPluginIncomingHttpRequestFilter2> IncomingHttpRequestFilters2;
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
828 typedef std::list<OrthancPluginIncomingDicomInstanceFilter> IncomingDicomInstanceFilters;
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
829 typedef std::list<OrthancPluginDecodeImageCallback> DecodeImageCallbacks;
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
830 typedef std::list<OrthancPluginJobsUnserializer> JobsUnserializers;
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
831 typedef std::list<OrthancPluginRefreshMetricsCallback> RefreshMetricsCallbacks;
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
832 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
833 typedef std::map<Property, std::string> Properties;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
834
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
835 PluginsManager manager_;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
836
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
837 RestCallbacks restCallbacks_;
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
838 ChunkedRestCallbacks chunkedRestCallbacks_;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
839 OnStoredCallbacks onStoredCallbacks_;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
840 OnChangeCallbacks onChangeCallbacks_;
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
841 OrthancPluginFindCallback findCallback_;
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
842 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
843 DecodeImageCallbacks decodeImageCallbacks_;
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
844 JobsUnserializers jobsUnserializers_;
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
845 _OrthancPluginMoveCallback moveCallbacks_;
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
846 IncomingHttpRequestFilters incomingHttpRequestFilters_;
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
847 IncomingHttpRequestFilters2 incomingHttpRequestFilters2_;
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
848 IncomingDicomInstanceFilters incomingDicomInstanceFilters_;
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
849 RefreshMetricsCallbacks refreshMetricsCallbacks_;
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
850 StorageCommitmentScpCallbacks storageCommitmentScpCallbacks_;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
851 std::unique_ptr<StorageAreaFactory> storageArea_;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
852
1466
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
853 boost::recursive_mutex restCallbackMutex_;
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
854 boost::recursive_mutex storedCallbackMutex_;
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
855 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
856 boost::mutex findCallbackMutex_;
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
857 boost::mutex worklistCallbackMutex_;
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
858 boost::mutex decodeImageCallbackMutex_;
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
859 boost::mutex jobsUnserializersMutex_;
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
860 boost::mutex refreshMetricsMutex_;
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
861 boost::mutex storageCommitmentScpMutex_;
1553
7c4b487b3b4a ensure mutual exclusion in InvokeService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
862 boost::recursive_mutex invokeServiceMutex_;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
863
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
864 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
865 int argc_;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
866 char** argv_;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
867 std::unique_ptr<OrthancPluginDatabase> database_;
1644
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
868 PluginsErrorDictionary dictionary_;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
869
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
870 PImpl() :
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
871 context_(NULL),
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
872 findCallback_(NULL),
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
873 worklistCallback_(NULL),
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
874 argc_(1),
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
875 argv_(NULL)
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
876 {
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
877 memset(&moveCallbacks_, 0, sizeof(moveCallbacks_));
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
878 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
879 };
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
880
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
881
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
882
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
883 class OrthancPlugins::WorklistHandler : public IWorklistRequestHandler
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
884 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
885 private:
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
886 OrthancPlugins& that_;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
887 std::unique_ptr<HierarchicalMatcher> matcher_;
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
888 std::unique_ptr<ParsedDicomFile> filtered_;
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
889 ParsedDicomFile* currentQuery_;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
890
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
891 void Reset()
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
892 {
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
893 matcher_.reset();
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
894 filtered_.reset();
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
895 currentQuery_ = NULL;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
896 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
897
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
898 public:
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
899 WorklistHandler(OrthancPlugins& that) : that_(that)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
900 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
901 Reset();
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
902 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
903
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
904 virtual void Handle(DicomFindAnswers& answers,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
905 ParsedDicomFile& query,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
906 const std::string& remoteIp,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
907 const std::string& remoteAet,
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
908 const std::string& calledAet,
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
909 ModalityManufacturer manufacturer)
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
910 {
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
911 static const char* LUA_CALLBACK = "IncomingWorklistRequestFilter";
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
912
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
913 {
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
914 PImpl::ServerContextLock lock(*that_.pimpl_);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
915 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
916
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
917 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
918 {
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
919 currentQuery_ = &query;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
920 }
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
921 else
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
922 {
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
923 Json::Value source, origin;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
924 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
925
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
926 OrthancFindRequestHandler::FormatOrigin
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
927 (origin, remoteIp, remoteAet, calledAet, manufacturer);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
928
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
929 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
930 call.PushJson(source);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
931 call.PushJson(origin);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
932
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
933 Json::Value target;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
934 call.ExecuteToJson(target, true);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
935
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
936 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
937 "" /* no private creator */));
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
938 currentQuery_ = filtered_.get();
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
939 }
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
940 }
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
941
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
942 matcher_.reset(new HierarchicalMatcher(*currentQuery_));
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
943
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
944 {
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
945 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
946
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
947 if (that_.pimpl_->worklistCallback_)
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
948 {
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
949 OrthancPluginErrorCode error = that_.pimpl_->worklistCallback_
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
950 (reinterpret_cast<OrthancPluginWorklistAnswers*>(&answers),
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
951 reinterpret_cast<const OrthancPluginWorklistQuery*>(this),
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
952 remoteAet.c_str(),
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
953 calledAet.c_str());
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
954
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
955 if (error != OrthancPluginErrorCode_Success)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
956 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
957 Reset();
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
958 that_.GetErrorDictionary().LogError(error, true);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
959 throw OrthancException(static_cast<ErrorCode>(error));
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
960 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
961 }
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
962
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
963 Reset();
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
964 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
965 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
966
1812
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
967 void GetDicomQuery(OrthancPluginMemoryBuffer& target) const
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
968 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
969 if (currentQuery_ == NULL)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
970 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
971 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
972 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
973
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
974 std::string dicom;
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
975 currentQuery_->SaveToMemoryBuffer(dicom);
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
976 CopyToMemoryBuffer(target, dicom.c_str(), dicom.size());
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
977 }
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
978
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
979 bool IsMatch(const void* dicom,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
980 size_t size) const
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
981 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
982 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
983 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
984 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
985 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
986
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
987 ParsedDicomFile f(dicom, size);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
988 return matcher_->Match(f);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
989 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
990
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
991 void AddAnswer(OrthancPluginWorklistAnswers* answers,
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
992 const void* dicom,
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
993 size_t size) const
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
994 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
995 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
996 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
997 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
998 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
999
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1000 ParsedDicomFile f(dicom, size);
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
1001 std::unique_ptr<ParsedDicomFile> summary(matcher_->Extract(f));
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
1002 reinterpret_cast<DicomFindAnswers*>(answers)->Add(*summary);
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1003 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1004 };
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1005
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
1006
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1007 class OrthancPlugins::FindHandler : public IFindRequestHandler
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1008 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1009 private:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1010 OrthancPlugins& that_;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
1011 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
1012
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1013 void Reset()
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1014 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1015 currentQuery_.reset(NULL);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1016 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1017
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1018 public:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1019 FindHandler(OrthancPlugins& that) : that_(that)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1020 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1021 Reset();
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1022 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1023
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1024 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
1025 const DicomMap& input,
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1026 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
1027 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
1028 const std::string& remoteAet,
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1029 const std::string& calledAet,
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1030 ModalityManufacturer manufacturer)
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1031 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1032 DicomMap tmp;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1033 tmp.Assign(input);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1034
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1035 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
1036 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
1037 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1038 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
1039 {
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
1040 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
1041 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1042 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1043
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1044 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1045 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
1046 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
1047
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1048 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
1049 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1050 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
1051 (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
1052 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
1053 remoteAet.c_str(),
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1054 calledAet.c_str());
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1055
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1056 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
1057 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1058 Reset();
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1059 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
1060 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
1061 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1062 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1063
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1064 Reset();
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1065 }
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1066 }
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1067
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1068 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
1069 const _OrthancPluginFindOperation& operation) const
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1070 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1071 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
1072 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1073 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
1074 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1075
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1076 switch (service)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1077 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1078 case _OrthancPluginService_GetFindQuerySize:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1079 *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
1080 break;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1081
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1082 case _OrthancPluginService_GetFindQueryTag:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1083 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1084 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
1085 *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
1086 *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
1087 break;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1088 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1089
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1090 case _OrthancPluginService_GetFindQueryTagName:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1091 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
1092 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
1093 *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
1094 break;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1095 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1096
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1097 case _OrthancPluginService_GetFindQueryValue:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1098 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1099 *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
1100 break;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1101 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1102
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1103 default:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1104 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
1105 }
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1106 }
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1107 };
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1108
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1109
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1110
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1111 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
1112 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1113 private:
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1114 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
1115 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1116 private:
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1117 void* driver_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1118 unsigned int count_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1119 unsigned int pos_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1120 OrthancPluginApplyMove apply_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1121 OrthancPluginFreeMove free_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1122
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1123 public:
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1124 Driver(void* driver,
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1125 unsigned int count,
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1126 OrthancPluginApplyMove apply,
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1127 OrthancPluginFreeMove free) :
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1128 driver_(driver),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1129 count_(count),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1130 pos_(0),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1131 apply_(apply),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1132 free_(free)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1133 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1134 if (driver_ == NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1135 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1136 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
1137 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1138 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1139
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1140 virtual ~Driver()
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1141 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1142 if (driver_ != NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1143 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1144 free_(driver_);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1145 driver_ = NULL;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1146 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1147 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1148
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1149 virtual unsigned int GetSubOperationCount() const
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1150 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1151 return count_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1152 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1153
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1154 virtual Status DoNext()
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1155 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1156 if (pos_ >= count_)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1157 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1158 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
1159 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1160 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1161 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1162 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
1163 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
1164 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1165 LOG(ERROR) << "Error while doing C-Move from plugin: "
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1166 << 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
1167 return Status_Failure;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1168 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1169 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1170 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1171 pos_++;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1172 return Status_Success;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1173 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1174 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1175 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1176 };
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1177
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1178
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1179 _OrthancPluginMoveCallback params_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1180
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1181
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1182 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
1183 const DicomTag& tag)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1184 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1185 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
1186 if (value != NULL &&
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1187 !value->IsBinary() &&
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1188 !value->IsNull())
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1189 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1190 return value->GetContent();
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1191 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1192 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1193 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1194 return std::string();
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1195 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1196 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1197
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1198
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1199
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1200 public:
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1201 MoveHandler(OrthancPlugins& that)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1202 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1203 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
1204 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
1205
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1206 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
1207 params_.getMoveSize == NULL ||
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1208 params_.applyMove == NULL ||
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1209 params_.freeMove == NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1210 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1211 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
1212 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1213 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1214
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1215 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
1216 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
1217 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
1218 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
1219 const std::string& calledAet,
2222
21713ce8717b Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2215
diff changeset
1220 uint16_t originatorId)
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1221 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1222 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
1223 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
1224 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
1225 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
1226 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
1227 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
1228
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1229 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
1230
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1231 if (!levelString.empty())
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1232 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1233 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
1234 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1235
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1236 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
1237 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
1238 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
1239 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
1240 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
1241 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
1242 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
1243 calledAet.c_str(),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1244 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
1245 originatorId);
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1246
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1247 if (driver == NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1248 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1249 throw OrthancException(ErrorCode_Plugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1250 "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
1251 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1252
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1253 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
1254
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1255 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
1256 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1257 };
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1258
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1259
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1260
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1261 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
1262 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1263 private:
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
1264 const _OrthancPluginChunkedHttpClient& params_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
1265 PluginsErrorDictionary& errorDictionary_;
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1266
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1267 public:
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1268 HttpClientChunkedRequest(const _OrthancPluginChunkedHttpClient& params,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1269 PluginsErrorDictionary& errorDictionary) :
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1270 params_(params),
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1271 errorDictionary_(errorDictionary)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1272 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1273 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1274
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1275 virtual bool ReadNextChunk(std::string& chunk)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1276 {
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1277 if (params_.requestIsDone(params_.request))
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1278 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1279 return false;
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1280 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1281 else
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1282 {
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1283 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
1284
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1285 chunk.resize(size);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1286
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1287 if (size != 0)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1288 {
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1289 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
1290 memcpy(&chunk[0], data, size);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1291 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1292
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1293 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
1294
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1295 if (error != OrthancPluginErrorCode_Success)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1296 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1297 errorDictionary_.LogError(error, true);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1298 throw OrthancException(static_cast<ErrorCode>(error));
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1299 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1300 else
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1301 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1302 return true;
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1303 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1304 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1305 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
1306 };
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1307
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1308
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1309 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
1310 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1311 private:
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
1312 const _OrthancPluginChunkedHttpClient& params_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
1313 PluginsErrorDictionary& errorDictionary_;
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1314
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1315 public:
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1316 HttpClientChunkedAnswer(const _OrthancPluginChunkedHttpClient& params,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1317 PluginsErrorDictionary& errorDictionary) :
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1318 params_(params),
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1319 errorDictionary_(errorDictionary)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1320 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1321 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1322
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1323 virtual void AddHeader(const std::string& key,
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1324 const std::string& value)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1325 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1326 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
1327
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1328 if (error != OrthancPluginErrorCode_Success)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1329 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1330 errorDictionary_.LogError(error, true);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1331 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
1332 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1333 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1334
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1335 virtual void AddChunk(const void* data,
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1336 size_t size)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1337 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1338 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
1339
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1340 if (error != OrthancPluginErrorCode_Success)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1341 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1342 errorDictionary_.LogError(error, true);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1343 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
1344 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1345 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1346 };
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1347
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
1348
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1349 OrthancPlugins::OrthancPlugins()
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1350 {
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1351 /* Sanity check of the compiler */
1579
b93c398f934d check the size of the enumerations in the plugin engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
1352 if (sizeof(int32_t) != sizeof(OrthancPluginErrorCode) ||
b93c398f934d check the size of the enumerations in the plugin engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
1353 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
1354 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
1355 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
1356 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
1357 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
1358 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
1359 sizeof(int32_t) != sizeof(OrthancPluginChangeType) ||
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1360 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
1361 sizeof(int32_t) != sizeof(OrthancPluginCompressionType) ||
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
1362 sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) ||
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1363 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) ||
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1364 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) ||
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1365 sizeof(int32_t) != sizeof(OrthancPluginCreateDicomFlags) ||
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1366 sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType) ||
1760
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1744
diff changeset
1367 sizeof(int32_t) != sizeof(OrthancPluginIdentifierConstraint) ||
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
1368 sizeof(int32_t) != sizeof(OrthancPluginInstanceOrigin) ||
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1369 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
1370 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
1371 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
1372 sizeof(int32_t) != sizeof(OrthancPluginDicomWebBinaryMode) ||
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1373 sizeof(int32_t) != sizeof(OrthancPluginStorageCommitmentFailureReason) ||
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1374 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
1375 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
1376 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
1377 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
1378 static_cast<int>(OrthancPluginDicomToJsonFlags_ConvertBinaryToNull) != static_cast<int>(DicomToJsonFlags_ConvertBinaryToNull) ||
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1379 static_cast<int>(OrthancPluginDicomToJsonFlags_ConvertBinaryToAscii) != static_cast<int>(DicomToJsonFlags_ConvertBinaryToAscii) ||
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1380 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
1381 static_cast<int>(OrthancPluginCreateDicomFlags_GenerateIdentifiers) != static_cast<int>(DicomFromJsonFlags_GenerateIdentifiers))
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1382
1578
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
1383 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
1384 throw OrthancException(ErrorCode_Plugin);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
1385 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
1386
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1387 pimpl_.reset(new PImpl());
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1388 pimpl_->manager_.RegisterServiceProvider(*this);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1389 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1390
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1391
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1392 void OrthancPlugins::SetServerContext(ServerContext& context)
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1393 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1394 pimpl_->SetServerContext(&context);
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1395 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1396
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1397
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1398 void OrthancPlugins::ResetServerContext()
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1399 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1400 pimpl_->SetServerContext(NULL);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1401 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1402
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1403
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1404 OrthancPlugins::~OrthancPlugins()
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1405 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1406 for (PImpl::RestCallbacks::iterator it = pimpl_->restCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1407 it != pimpl_->restCallbacks_.end(); ++it)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1408 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1409 delete *it;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1410 }
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1411
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1412 for (PImpl::ChunkedRestCallbacks::iterator it = pimpl_->chunkedRestCallbacks_.begin();
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1413 it != pimpl_->chunkedRestCallbacks_.end(); ++it)
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1414 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1415 delete *it;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1416 }
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1417
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1418 for (PImpl::StorageCommitmentScpCallbacks::iterator
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1419 it = pimpl_->storageCommitmentScpCallbacks_.begin();
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1420 it != pimpl_->storageCommitmentScpCallbacks_.end(); ++it)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1421 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1422 delete *it;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1423 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1424 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1425
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1426
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1427 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
1428 std::vector<const char*>& values,
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
1429 const IHttpHandler::Arguments& arguments)
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1430 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1431 keys.resize(arguments.size());
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1432 values.resize(arguments.size());
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1433
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1434 size_t pos = 0;
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
1435 for (IHttpHandler::Arguments::const_iterator
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1436 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
1437 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1438 keys[pos] = it->first.c_str();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1439 values[pos] = it->second.c_str();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1440 pos++;
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1441 }
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1442 }
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1443
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1444
1363
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
1445 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
1446 std::vector<const char*>& values,
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
1447 const IHttpHandler::GetArguments& arguments)
1363
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
1448 {
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
1449 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
1450 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
1451
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
1452 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
1453 {
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
1454 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
1455 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
1456 }
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
1457 }
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
1458
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
1459
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1460 namespace
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1461 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1462 class RestCallbackMatcher : public boost::noncopyable
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1463 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1464 private:
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1465 std::string flatUri_;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1466 std::vector<std::string> groups_;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1467 std::vector<const char*> cgroups_;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1468
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1469 public:
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1470 RestCallbackMatcher(const UriComponents& uri) :
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
1471 flatUri_(Toolbox::FlattenUri(uri))
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1472 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1473 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1474
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1475 bool IsMatch(const boost::regex& re)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1476 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1477 // Check whether the regular expression associated to this
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1478 // callback matches the URI
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1479 boost::cmatch what;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1480
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1481 if (boost::regex_match(flatUri_.c_str(), what, re))
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1482 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1483 // 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
1484 if (what.size() > 1)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1485 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1486 groups_.resize(what.size() - 1);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1487 cgroups_.resize(what.size() - 1);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1488 for (size_t i = 1; i < what.size(); i++)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1489 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1490 groups_[i - 1] = what[i];
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1491 cgroups_[i - 1] = groups_[i - 1].c_str();
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1492 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1493 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1494
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1495 return true;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1496 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1497 else
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1498 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1499 // Not a match
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1500 return false;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1501 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1502 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1503
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1504 uint32_t GetGroupsCount() const
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1505 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1506 return cgroups_.size();
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1507 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1508
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1509 const char* const* GetGroups() const
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1510 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1511 return cgroups_.empty() ? NULL : &cgroups_[0];
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1512 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1513
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1514 const std::string& GetFlatUri() const
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1515 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1516 return flatUri_;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1517 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1518 };
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1519
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1520
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1521 // WARNING - The lifetime of this internal object must be smaller
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1522 // than "matcher", "headers" and "getArguments" objects
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1523 class HttpRequestConverter
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1524 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1525 private:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1526 std::vector<const char*> getKeys_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1527 std::vector<const char*> getValues_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1528 std::vector<const char*> headersKeys_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1529 std::vector<const char*> headersValues_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1530 OrthancPluginHttpRequest converted_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1531
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1532 public:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1533 HttpRequestConverter(const RestCallbackMatcher& matcher,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1534 HttpMethod method,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1535 const IHttpHandler::Arguments& headers)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1536 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1537 memset(&converted_, 0, sizeof(OrthancPluginHttpRequest));
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1538
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1539 ArgumentsToPlugin(headersKeys_, headersValues_, headers);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1540 assert(headersKeys_.size() == headersValues_.size());
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1541
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1542 switch (method)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1543 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1544 case HttpMethod_Get:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1545 converted_.method = OrthancPluginHttpMethod_Get;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1546 break;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1547
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1548 case HttpMethod_Post:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1549 converted_.method = OrthancPluginHttpMethod_Post;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1550 break;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1551
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1552 case HttpMethod_Delete:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1553 converted_.method = OrthancPluginHttpMethod_Delete;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1554 break;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1555
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1556 case HttpMethod_Put:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1557 converted_.method = OrthancPluginHttpMethod_Put;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1558 break;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1559
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1560 default:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1561 throw OrthancException(ErrorCode_InternalError);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1562 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1563
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1564 converted_.groups = matcher.GetGroups();
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1565 converted_.groupsCount = matcher.GetGroupsCount();
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1566 converted_.getCount = 0;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1567 converted_.getKeys = NULL;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1568 converted_.getValues = NULL;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1569 converted_.body = NULL;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1570 converted_.bodySize = 0;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1571 converted_.headersCount = headers.size();
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1572
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1573 if (headers.size() > 0)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1574 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1575 converted_.headersKeys = &headersKeys_[0];
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1576 converted_.headersValues = &headersValues_[0];
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1577 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1578 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1579
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1580 void SetGetArguments(const IHttpHandler::GetArguments& getArguments)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1581 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1582 ArgumentsToPlugin(getKeys_, getValues_, getArguments);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1583 assert(getKeys_.size() == getValues_.size());
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1584
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1585 converted_.getCount = getArguments.size();
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1586
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1587 if (getArguments.size() > 0)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1588 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1589 converted_.getKeys = &getKeys_[0];
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1590 converted_.getValues = &getValues_[0];
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1591 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1592 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1593
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1594 OrthancPluginHttpRequest& GetRequest()
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1595 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1596 return converted_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1597 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1598 };
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1599 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1600
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1601
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1602 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
1603 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1604 std::string s;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1605
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1606 if (parameters.getHandler != NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1607 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1608 s += "GET";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1609 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1610
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1611 if (parameters.postHandler != NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1612 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1613 if (!s.empty())
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1614 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1615 s+= ",";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1616 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1617
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1618 s += "POST";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1619 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1620
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1621 if (parameters.deleteHandler != NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1622 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1623 if (!s.empty())
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1624 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1625 s+= ",";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1626 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1627
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1628 s += "DELETE";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1629 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1630
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1631 if (parameters.putHandler != NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1632 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1633 if (!s.empty())
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1634 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1635 s+= ",";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1636 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1637
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1638 s += "PUT";
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1639 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1640
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1641 return s;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1642 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1643
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1644
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1645 bool OrthancPlugins::HandleChunkedGetDelete(HttpOutput& output,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1646 HttpMethod method,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1647 const UriComponents& uri,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1648 const Arguments& headers,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1649 const GetArguments& getArguments)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1650 {
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1651 RestCallbackMatcher matcher(uri);
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1652
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1653 PImpl::ChunkedRestCallback* callback = NULL;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1654
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1655 // Loop over the callbacks registered by the plugins
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1656 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
1657 it != pimpl_->chunkedRestCallbacks_.end(); ++it)
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1658 {
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1659 if (matcher.IsMatch((*it)->GetRegularExpression()))
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1660 {
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1661 callback = *it;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1662 break;
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1663 }
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1664 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1665
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1666 if (callback == NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1667 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1668 return false;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1669 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1670 else
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1671 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1672 LOG(INFO) << "Delegating HTTP request to plugin for URI: " << matcher.GetFlatUri();
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1673
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1674 OrthancPluginRestCallback handler;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1675
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1676 switch (method)
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1677 {
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1678 case HttpMethod_Get:
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1679 handler = callback->GetParameters().getHandler;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1680 break;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1681
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1682 case HttpMethod_Delete:
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1683 handler = callback->GetParameters().deleteHandler;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1684 break;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1685
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1686 default:
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1687 handler = NULL;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1688 break;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1689 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1690
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1691 if (handler == NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1692 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1693 output.SendMethodNotAllowed(GetAllowedMethods(callback->GetParameters()));
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1694 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1695 else
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1696 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1697 HttpRequestConverter converter(matcher, method, headers);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1698 converter.SetGetArguments(getArguments);
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1699
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1700 PImpl::PluginHttpOutput pluginOutput(output);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1701
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1702 OrthancPluginErrorCode error = handler(
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1703 reinterpret_cast<OrthancPluginRestOutput*>(&pluginOutput),
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1704 matcher.GetFlatUri().c_str(), &converter.GetRequest());
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1705
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1706 pluginOutput.Close(error, GetErrorDictionary());
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1707 }
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1708
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
1709 return true;
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1710 }
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1711 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1712
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1713
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1714 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
1715 RequestOrigin /*origin*/,
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
1716 const char* /*remoteIp*/,
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
1717 const char* /*username*/,
1329
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
1718 HttpMethod method,
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
1719 const UriComponents& uri,
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
1720 const Arguments& headers,
1363
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
1721 const GetArguments& getArguments,
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3399
diff changeset
1722 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
1723 size_t bodySize)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1724 {
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1725 RestCallbackMatcher matcher(uri);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1726
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1727 PImpl::RestCallback* callback = NULL;
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1728
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1729 // Loop over the callbacks registered by the plugins
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1730 for (PImpl::RestCallbacks::const_iterator it = pimpl_->restCallbacks_.begin();
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1731 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
1732 {
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1733 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
1734 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1735 callback = *it;
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1736 break;
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1737 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1738 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1739
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1740 if (callback == NULL)
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1741 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1742 // Callback not found, try to find a chunked callback
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1743 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
1744 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1745
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1746 LOG(INFO) << "Delegating HTTP request to plugin for URI: " << matcher.GetFlatUri();
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1747
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1748 HttpRequestConverter converter(matcher, method, headers);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1749 converter.SetGetArguments(getArguments);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1750 converter.GetRequest().body = bodyData;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1751 converter.GetRequest().bodySize = bodySize;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1752
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1753 PImpl::PluginHttpOutput pluginOutput(output);
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1754
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1755 assert(callback != NULL);
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1756 OrthancPluginErrorCode error = callback->Invoke
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1757 (pimpl_->restCallbackMutex_, pluginOutput, matcher.GetFlatUri(), converter.GetRequest());
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1758
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1759 pluginOutput.Close(error, GetErrorDictionary());
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1760 return true;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1761 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1762
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1763
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1764 class OrthancPlugins::IDicomInstance : public boost::noncopyable
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1765 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1766 public:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1767 virtual ~IDicomInstance()
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1768 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1769 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1770
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1771 virtual bool CanBeFreed() const = 0;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1772
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1773 virtual const DicomInstanceToStore& GetInstance() const = 0;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1774 };
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1775
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1776
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1777 class OrthancPlugins::DicomInstanceFromCallback : public IDicomInstance
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1778 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1779 private:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1780 const DicomInstanceToStore& instance_;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1781
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1782 public:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1783 DicomInstanceFromCallback(const DicomInstanceToStore& instance) :
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1784 instance_(instance)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1785 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1786 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1787
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1788 virtual bool CanBeFreed() const ORTHANC_OVERRIDE
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1789 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1790 return false;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1791 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1792
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1793 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
1794 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1795 return instance_;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1796 };
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1797 };
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1798
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1799
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1800 class OrthancPlugins::DicomInstanceFromBuffer : public IDicomInstance
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1801 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1802 private:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1803 std::string buffer_;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1804 DicomInstanceToStore instance_;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1805
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1806 public:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1807 DicomInstanceFromBuffer(const void* buffer,
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1808 size_t size)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1809 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1810 buffer_.assign(reinterpret_cast<const char*>(buffer), size);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1811 instance_.SetBuffer(buffer_.empty() ? NULL : buffer_.c_str(), buffer_.size());
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1812 instance_.SetOrigin(DicomInstanceOrigin::FromPlugins());
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1813 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1814
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1815 virtual bool CanBeFreed() const ORTHANC_OVERRIDE
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1816 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1817 return true;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1818 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1819
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1820 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
1821 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1822 return instance_;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1823 };
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1824 };
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1825
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1826
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
1827 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
1828 const DicomInstanceToStore& instance,
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
1829 const Json::Value& simplifiedTags)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1830 {
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1831 DicomInstanceFromCallback wrapped(instance);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1832
1466
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
1833 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
1834
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1835 for (PImpl::OnStoredCallbacks::const_iterator
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1836 callback = pimpl_->onStoredCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1837 callback != pimpl_->onStoredCallbacks_.end(); ++callback)
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1838 {
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1839 OrthancPluginErrorCode error = (*callback) (
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1840 reinterpret_cast<OrthancPluginDicomInstance*>(&wrapped),
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1841 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
1842
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
1843 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
1844 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
1845 GetErrorDictionary().LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1846 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
1847 }
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1848 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1849 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1850
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1851
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1852 bool OrthancPlugins::FilterIncomingInstance(const DicomInstanceToStore& instance,
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1853 const Json::Value& simplified)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1854 {
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1855 DicomInstanceFromCallback wrapped(instance);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1856
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1857 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1858
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1859 for (PImpl::IncomingDicomInstanceFilters::const_iterator
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1860 filter = pimpl_->incomingDicomInstanceFilters_.begin();
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1861 filter != pimpl_->incomingDicomInstanceFilters_.end(); ++filter)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1862 {
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
1863 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
1864
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1865 if (allowed == 0)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1866 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1867 return false;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1868 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1869 else if (allowed != 1)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1870 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1871 // 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
1872 throw OrthancException(ErrorCode_Plugin);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1873 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1874 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1875
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1876 return true;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1877 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1878
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
1879
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1880 void OrthancPlugins::SignalChangeInternal(OrthancPluginChangeType changeType,
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1881 OrthancPluginResourceType resourceType,
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1882 const char* resource)
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1883 {
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
1884 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
1885
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
1886 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
1887 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
1888 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
1889 {
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1890 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
1891
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
1892 if (error != OrthancPluginErrorCode_Success)
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
1893 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
1894 GetErrorDictionary().LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1895 throw OrthancException(static_cast<ErrorCode>(error));
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
1896 }
1178
c71d25e6a63c improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1177
diff changeset
1897 }
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1898 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1899
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1900
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1901
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1902 void OrthancPlugins::SignalChange(const ServerIndexChange& change)
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1903 {
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1904 SignalChangeInternal(Plugins::Convert(change.GetChangeType()),
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1905 Plugins::Convert(change.GetResourceType()),
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1906 change.GetPublicId().c_str());
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1907 }
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1908
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1909
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1910
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1911 void OrthancPlugins::RegisterRestCallback(const void* parameters,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1912 bool lock)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1913 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1914 const _OrthancPluginRestCallback& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1915 *reinterpret_cast<const _OrthancPluginRestCallback*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1916
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1917 LOG(INFO) << "Plugin has registered a REST callback "
2820
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
1918 << (lock ? "with" : "without")
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1919 << " mutual exclusion on: "
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1920 << p.pathRegularExpression;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1921
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1922 pimpl_->restCallbacks_.push_back(new PImpl::RestCallback(p.pathRegularExpression, p.callback, lock));
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1923 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1924
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1925
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1926 void OrthancPlugins::RegisterChunkedRestCallback(const void* parameters)
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1927 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1928 const _OrthancPluginChunkedRestCallback& p =
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1929 *reinterpret_cast<const _OrthancPluginChunkedRestCallback*>(parameters);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1930
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1931 LOG(INFO) << "Plugin has registered a REST callback for chunked streams on: "
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1932 << p.pathRegularExpression;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1933
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
1934 pimpl_->chunkedRestCallbacks_.push_back(new PImpl::ChunkedRestCallback(p));
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1935 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
1936
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1937
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1938 void OrthancPlugins::RegisterOnStoredInstanceCallback(const void* parameters)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1939 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1940 const _OrthancPluginOnStoredInstanceCallback& p =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1941 *reinterpret_cast<const _OrthancPluginOnStoredInstanceCallback*>(parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1942
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1943 LOG(INFO) << "Plugin has registered an OnStoredInstance callback";
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1944 pimpl_->onStoredCallbacks_.push_back(p.callback);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1945 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1946
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1947
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1948 void OrthancPlugins::RegisterOnChangeCallback(const void* parameters)
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1949 {
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1950 const _OrthancPluginOnChangeCallback& p =
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1951 *reinterpret_cast<const _OrthancPluginOnChangeCallback*>(parameters);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1952
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1953 LOG(INFO) << "Plugin has registered an OnChange callback";
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1954 pimpl_->onChangeCallbacks_.push_back(p.callback);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1955 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1956
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1957
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1958 void OrthancPlugins::RegisterWorklistCallback(const void* parameters)
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1959 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1960 const _OrthancPluginWorklistCallback& p =
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1961 *reinterpret_cast<const _OrthancPluginWorklistCallback*>(parameters);
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1962
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1963 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
1964
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1965 if (pimpl_->worklistCallback_ != NULL)
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1966 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1967 throw OrthancException(ErrorCode_Plugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1968 "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
1969 }
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1970 else
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1971 {
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1972 LOG(INFO) << "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
1973 pimpl_->worklistCallback_ = p.callback;
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1974 }
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1975 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1976
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1977
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1978 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
1979 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1980 const _OrthancPluginFindCallback& p =
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1981 *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
1982
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1983 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
1984
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1985 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
1986 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1987 throw OrthancException(ErrorCode_Plugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1988 "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
1989 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1990 else
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1991 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1992 LOG(INFO) << "Plugin has registered a callback to handle C-FIND requests";
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1993 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
1994 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1995 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1996
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1997
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1998 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
1999 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2000 // invokeServiceMutex_ is assumed to be locked
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2001
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2002 const _OrthancPluginMoveCallback& p =
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2003 *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
2004
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2005 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
2006 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
2007 throw OrthancException(ErrorCode_Plugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
2008 "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
2009 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2010 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2011 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2012 LOG(INFO) << "Plugin has registered a callback to handle C-MOVE requests";
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2013 pimpl_->moveCallbacks_ = p;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2014 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2015 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2016
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
2017
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2018 void OrthancPlugins::RegisterDecodeImageCallback(const void* parameters)
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2019 {
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2020 const _OrthancPluginDecodeImageCallback& p =
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2021 *reinterpret_cast<const _OrthancPluginDecodeImageCallback*>(parameters);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2022
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2023 boost::mutex::scoped_lock lock(pimpl_->decodeImageCallbackMutex_);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2024
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
2025 pimpl_->decodeImageCallbacks_.push_back(p.callback);
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
2026 LOG(INFO) << "Plugin has registered a callback to decode DICOM images ("
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
2027 << pimpl_->decodeImageCallbacks_.size() << " decoder(s) now active)";
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2028 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2029
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2030
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2031 void OrthancPlugins::RegisterJobsUnserializer(const void* parameters)
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2032 {
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2033 const _OrthancPluginJobsUnserializer& p =
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2034 *reinterpret_cast<const _OrthancPluginJobsUnserializer*>(parameters);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2035
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2036 boost::mutex::scoped_lock lock(pimpl_->jobsUnserializersMutex_);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2037
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2038 pimpl_->jobsUnserializers_.push_back(p.unserializer);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2039 LOG(INFO) << "Plugin has registered a callback to unserialize jobs ("
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2040 << pimpl_->jobsUnserializers_.size() << " unserializer(s) now active)";
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2041 }
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2042
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2043
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2044 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
2045 {
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2046 const _OrthancPluginIncomingHttpRequestFilter& p =
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2047 *reinterpret_cast<const _OrthancPluginIncomingHttpRequestFilter*>(parameters);
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2048
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2049 LOG(INFO) << "Plugin has registered a callback to filter incoming HTTP requests";
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
2050 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
2051 }
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2052
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2053
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2054 void OrthancPlugins::RegisterIncomingHttpRequestFilter2(const void* parameters)
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2055 {
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2056 const _OrthancPluginIncomingHttpRequestFilter2& p =
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2057 *reinterpret_cast<const _OrthancPluginIncomingHttpRequestFilter2*>(parameters);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2058
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2059 LOG(INFO) << "Plugin has registered a callback to filter incoming HTTP requests";
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2060 pimpl_->incomingHttpRequestFilters2_.push_back(p.callback);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2061 }
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2062
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
2063
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2064 void OrthancPlugins::RegisterIncomingDicomInstanceFilter(const void* parameters)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2065 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2066 const _OrthancPluginIncomingDicomInstanceFilter& p =
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2067 *reinterpret_cast<const _OrthancPluginIncomingDicomInstanceFilter*>(parameters);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2068
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2069 LOG(INFO) << "Plugin has registered a callback to filter incoming DICOM instances";
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2070 pimpl_->incomingDicomInstanceFilters_.push_back(p.callback);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2071 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2072
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2073
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2074 void OrthancPlugins::RegisterRefreshMetricsCallback(const void* parameters)
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2075 {
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2076 const _OrthancPluginRegisterRefreshMetricsCallback& p =
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2077 *reinterpret_cast<const _OrthancPluginRegisterRefreshMetricsCallback*>(parameters);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2078
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2079 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
2080
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2081 LOG(INFO) << "Plugin has registered a callback to refresh its metrics";
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2082 pimpl_->refreshMetricsCallbacks_.push_back(p.callback);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2083 }
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2084
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
2085
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2086 void OrthancPlugins::RegisterStorageCommitmentScpCallback(const void* parameters)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2087 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2088 const _OrthancPluginRegisterStorageCommitmentScpCallback& p =
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2089 *reinterpret_cast<const _OrthancPluginRegisterStorageCommitmentScpCallback*>(parameters);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2090
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2091 boost::mutex::scoped_lock lock(pimpl_->storageCommitmentScpMutex_);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2092 LOG(INFO) << "Plugin has registered a storage commitment callback";
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2093
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2094 pimpl_->storageCommitmentScpCallbacks_.push_back(new PImpl::StorageCommitmentScp(p));
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2095 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2096
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
2097
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
2098 void OrthancPlugins::AnswerBuffer(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2099 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2100 const _OrthancPluginAnswerBuffer& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2101 *reinterpret_cast<const _OrthancPluginAnswerBuffer*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2102
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2103 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
2104 translatedOutput.SetContentType(p.mimeType);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2105 translatedOutput.Answer(p.answer, p.answerSize);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2106 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2107
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2108
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
2109 void OrthancPlugins::Redirect(const void* parameters)
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
2110 {
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2111 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2112 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2113
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2114 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
2115 translatedOutput.Redirect(p.argument);
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2116 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2117
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2118
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
2119 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
2120 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2121 const _OrthancPluginSendHttpStatusCode& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2122 *reinterpret_cast<const _OrthancPluginSendHttpStatusCode*>(parameters);
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
2123
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2124 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
2125 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
2126 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2127
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2128
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2129 void OrthancPlugins::SendHttpStatus(const void* parameters)
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2130 {
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2131 const _OrthancPluginSendHttpStatus& p =
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2132 *reinterpret_cast<const _OrthancPluginSendHttpStatus*>(parameters);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2133
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2134 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2135 HttpStatus status = static_cast<HttpStatus>(p.status);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2136
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2137 if (p.bodySize > 0 && p.body != NULL)
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2138 {
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2139 translatedOutput.SendStatus(status, p.body, p.bodySize);
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2140 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2141 else
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2142 {
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2143 translatedOutput.SendStatus(status);
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2144 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2145 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2146
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2147
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
2148 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
2149 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2150 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2151 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2152
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2153 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
2154 translatedOutput.SendUnauthorized(p.argument);
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2155 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2156
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2157
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
2158 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
2159 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2160 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2161 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2162
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2163 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
2164 translatedOutput.SendMethodNotAllowed(p.argument);
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2165 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2166
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2167
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
2168 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
2169 {
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2170 const _OrthancPluginSetHttpHeader& p =
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2171 *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
2172
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2173 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
2174 translatedOutput.SetCookie(p.key, p.value);
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2175 }
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2176
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2177
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2178 void OrthancPlugins::SetHttpHeader(const void* parameters)
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2179 {
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2180 const _OrthancPluginSetHttpHeader& p =
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2181 *reinterpret_cast<const _OrthancPluginSetHttpHeader*>(parameters);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2182
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2183 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
2184 translatedOutput.AddHeader(p.key, p.value);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2185 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2186
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2187
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2188 void OrthancPlugins::SetHttpErrorDetails(const void* parameters)
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2189 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2190 const _OrthancPluginSetHttpErrorDetails& p =
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2191 *reinterpret_cast<const _OrthancPluginSetHttpErrorDetails*>(parameters);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2192
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
2193 PImpl::PluginHttpOutput* output =
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
2194 reinterpret_cast<PImpl::PluginHttpOutput*>(p.output);
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
2195 output->SetErrorDetails(p.details, p.log);
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
2196 }
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
2197
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
2198
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
2199 void OrthancPlugins::CompressAndAnswerPngImage(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2200 {
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2201 // Bridge for backward compatibility with Orthanc <= 0.9.3
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2202 const _OrthancPluginCompressAndAnswerPngImage& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2203 *reinterpret_cast<const _OrthancPluginCompressAndAnswerPngImage*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2204
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2205 _OrthancPluginCompressAndAnswerImage p2;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2206 p2.output = p.output;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2207 p2.imageFormat = OrthancPluginImageFormat_Png;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2208 p2.pixelFormat = p.format;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2209 p2.width = p.width;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2210 p2.height = p.height;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2211 p2.pitch = p.height;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2212 p2.buffer = p.buffer;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2213 p2.quality = 0;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2214
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2215 CompressAndAnswerImage(&p2);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2216 }
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2217
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2218
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2219 void OrthancPlugins::CompressAndAnswerImage(const void* parameters)
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2220 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2221 const _OrthancPluginCompressAndAnswerImage& p =
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2222 *reinterpret_cast<const _OrthancPluginCompressAndAnswerImage*>(parameters);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2223
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2224 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2225
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2226 ImageAccessor accessor;
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
2227 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
2228
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2229 std::string compressed;
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2230
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2231 switch (p.imageFormat)
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2232 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2233 case OrthancPluginImageFormat_Png:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2234 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2235 PngWriter writer;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2236 writer.WriteToMemory(compressed, accessor);
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2237 translatedOutput.SetContentType(MimeType_Png);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2238 break;
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2239 }
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2240
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2241 case OrthancPluginImageFormat_Jpeg:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2242 {
1603
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2243 JpegWriter writer;
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2244 writer.SetQuality(p.quality);
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2245 writer.WriteToMemory(compressed, accessor);
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2246 translatedOutput.SetContentType(MimeType_Jpeg);
1603
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
2247 break;
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2248 }
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2249
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2250 default:
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2251 throw OrthancException(ErrorCode_ParameterOutOfRange);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2252 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2253
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2254 translatedOutput.Answer(compressed);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2255 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2256
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2257
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
2258 void OrthancPlugins::GetDicomForInstance(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2259 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2260 const _OrthancPluginGetDicomForInstance& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2261 *reinterpret_cast<const _OrthancPluginGetDicomForInstance*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2262
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2263 std::string dicom;
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
2264
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2265 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2266 PImpl::ServerContextLock lock(*pimpl_);
2124
2b1520efa282 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
2267 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
2268 }
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
2269
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2270 CopyToMemoryBuffer(*p.target, dicom);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2271 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2272
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2273
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2274 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
2275 bool afterPlugins)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2276 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2277 const _OrthancPluginRestApiGet& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2278 *reinterpret_cast<const _OrthancPluginRestApiGet*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2279
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2280 LOG(INFO) << "Plugin making REST GET call on URI " << p.uri
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2281 << (afterPlugins ? " (after plugins)" : " (built-in API)");
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2282
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2283 IHttpHandler* handler;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2284
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2285 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2286 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2287 handler = &lock.GetContext().GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2288 }
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2289
3442
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
2290 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
2291
1445
d26c8a93d05a refactoring: SimpleGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
2292 std::string result;
3442
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
2293 if (HttpToolbox::SimpleGet(result, *handler, RequestOrigin_Plugins, p.uri, httpHeaders))
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2294 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2295 CopyToMemoryBuffer(*p.target, result);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2296 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2297 else
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2298 {
1984
9f09a20e41e2 corrected error code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1962
diff changeset
2299 throw OrthancException(ErrorCode_UnknownResource);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2300 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2301 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2302
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2303
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2304 void OrthancPlugins::RestApiGet2(const void* parameters)
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2305 {
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2306 const _OrthancPluginRestApiGet2& p =
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2307 *reinterpret_cast<const _OrthancPluginRestApiGet2*>(parameters);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2308
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2309 LOG(INFO) << "Plugin making REST GET call on URI " << p.uri
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2310 << (p.afterPlugins ? " (after plugins)" : " (built-in API)");
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2311
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2312 IHttpHandler::Arguments headers;
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2313
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2314 for (uint32_t i = 0; i < p.headersCount; i++)
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2315 {
1918
e8c2f993f6b3 fix case for HTTP headers keys in OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1916
diff changeset
2316 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
2317 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
2318 headers[name] = p.headersValues[i];
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2319 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2320
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2321 IHttpHandler* handler;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2322
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2323 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2324 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2325 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
2326 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2327
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2328 std::string result;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2329 if (HttpToolbox::SimpleGet(result, *handler, RequestOrigin_Plugins, p.uri, headers))
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2330 {
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2331 CopyToMemoryBuffer(*p.target, result);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2332 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2333 else
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2334 {
1984
9f09a20e41e2 corrected error code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1962
diff changeset
2335 throw OrthancException(ErrorCode_UnknownResource);
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2336 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2337 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2338
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2339
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2340 void OrthancPlugins::RestApiPostPut(bool isPost,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2341 const void* parameters,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2342 bool afterPlugins)
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2343 {
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2344 const _OrthancPluginRestApiPostPut& p =
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2345 *reinterpret_cast<const _OrthancPluginRestApiPostPut*>(parameters);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2346
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
2347 LOG(INFO) << "Plugin making REST " << EnumerationToString(isPost ? HttpMethod_Post : HttpMethod_Put)
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
2348 << " 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
2349
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2350 IHttpHandler* handler;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2351
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2352 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2353 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2354 handler = &lock.GetContext().GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2355 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2356
3442
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
2357 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
2358
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2359 std::string result;
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
2360 if (isPost ?
3442
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
2361 HttpToolbox::SimplePost(result, *handler, RequestOrigin_Plugins, p.uri, p.body, p.bodySize, httpHeaders) :
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
2362 HttpToolbox::SimplePut (result, *handler, RequestOrigin_Plugins, p.uri, p.body, p.bodySize, httpHeaders))
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2363 {
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2364 CopyToMemoryBuffer(*p.target, result);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2365 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2366 else
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2367 {
1984
9f09a20e41e2 corrected error code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1962
diff changeset
2368 throw OrthancException(ErrorCode_UnknownResource);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2369 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2370 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2371
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2372
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2373 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
2374 bool afterPlugins)
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2375 {
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
2376 const char* uri = reinterpret_cast<const char*>(parameters);
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
2377 LOG(INFO) << "Plugin making REST DELETE call on URI " << uri
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2378 << (afterPlugins ? " (after plugins)" : " (built-in API)");
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2379
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2380 IHttpHandler* handler;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2381
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2382 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2383 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2384 handler = &lock.GetContext().GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2385 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2386
3442
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
2387 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
2388
dd1e68f2d0c0 Fix issue #106 (Unable to export preview as jpeg from Lua script)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3429
diff changeset
2389 if (!HttpToolbox::SimpleDelete(*handler, RequestOrigin_Plugins, uri, httpHeaders))
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2390 {
1984
9f09a20e41e2 corrected error code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1962
diff changeset
2391 throw OrthancException(ErrorCode_UnknownResource);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2392 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2393 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2394
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2395
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
2396 void OrthancPlugins::LookupResource(_OrthancPluginService service,
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
2397 const void* parameters)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2398 {
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
2399 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
2400 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2401
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2402 /**
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2403 * 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
2404 * the Orthanc database. It reflects the
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2405 * "CandidateResources::ApplyFilter()" method of the
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2406 * "OrthancFindRequestHandler" class.
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2407 **/
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2408
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2409 DicomTag tag(0, 0);
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2410 ResourceType level;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2411 switch (service)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2412 {
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2413 case _OrthancPluginService_LookupPatient:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2414 tag = DICOM_TAG_PATIENT_ID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2415 level = ResourceType_Patient;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2416 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2417
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2418 case _OrthancPluginService_LookupStudy:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2419 tag = DICOM_TAG_STUDY_INSTANCE_UID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2420 level = ResourceType_Study;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2421 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2422
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2423 case _OrthancPluginService_LookupStudyWithAccessionNumber:
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2424 tag = DICOM_TAG_ACCESSION_NUMBER;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2425 level = ResourceType_Study;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2426 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2427
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2428 case _OrthancPluginService_LookupSeries:
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2429 tag = DICOM_TAG_SERIES_INSTANCE_UID;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2430 level = ResourceType_Series;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2431 break;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2432
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2433 case _OrthancPluginService_LookupInstance:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2434 tag = DICOM_TAG_SOP_INSTANCE_UID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2435 level = ResourceType_Instance;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2436 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2437
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2438 default:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2439 throw OrthancException(ErrorCode_InternalError);
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2440 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2441
3034
54e422fe31ce moving LookupResource to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2984
diff changeset
2442 std::vector<std::string> result;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2443
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2444 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2445 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2446 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
2447 }
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2448
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2449 if (result.size() == 1)
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2450 {
3034
54e422fe31ce moving LookupResource to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2984
diff changeset
2451 *p.result = CopyString(result[0]);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2452 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2453 else
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2454 {
3507
69e49fc044f8 Fix generation of "SOP Instance UID" on split and merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3442
diff changeset
2455 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
2456 {
69e49fc044f8 Fix generation of "SOP Instance UID" on split and merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3442
diff changeset
2457 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
2458 << "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
2459 }
69e49fc044f8 Fix generation of "SOP Instance UID" on split and merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3442
diff changeset
2460
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2461 throw OrthancException(ErrorCode_UnknownResource);
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2462 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2463 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2464
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2465
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2466 static void AccessInstanceMetadataInternal(bool checkExistence,
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2467 const _OrthancPluginAccessDicomInstance& params,
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2468 const DicomInstanceToStore& instance)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2469 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2470 MetadataType metadata;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2471
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2472 try
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2473 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2474 metadata = StringToMetadata(params.key);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2475 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2476 catch (OrthancException&)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2477 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2478 // Unknown metadata
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2479 if (checkExistence)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2480 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2481 *params.resultInt64 = -1;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2482 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2483 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2484 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2485 *params.resultString = NULL;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2486 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2487
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2488 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2489 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2490
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2491 ServerIndex::MetadataMap::const_iterator it =
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2492 instance.GetMetadata().find(std::make_pair(ResourceType_Instance, metadata));
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2493
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2494 if (checkExistence)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2495 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2496 if (it != instance.GetMetadata().end())
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2497 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2498 *params.resultInt64 = 1;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2499 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2500 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2501 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2502 *params.resultInt64 = 0;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2503 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2504 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2505 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2506 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2507 if (it != instance.GetMetadata().end())
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2508 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2509 *params.resultString = it->second.c_str();
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2510 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2511 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2512 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2513 // Error: Missing metadata
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2514 *params.resultString = NULL;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2515 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2516 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2517 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2518
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2519
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2520 void OrthancPlugins::AccessDicomInstance(_OrthancPluginService service,
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2521 const void* parameters)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2522 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2523 const _OrthancPluginAccessDicomInstance& p =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2524 *reinterpret_cast<const _OrthancPluginAccessDicomInstance*>(parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2525
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2526 if (p.instance == NULL)
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 throw OrthancException(ErrorCode_NullPointer);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2529 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2530
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2531 const DicomInstanceToStore& instance =
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2532 reinterpret_cast<const IDicomInstance*>(p.instance)->GetInstance();
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2533
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2534 switch (service)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2535 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2536 case _OrthancPluginService_GetInstanceRemoteAet:
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
2537 *p.resultString = instance.GetOrigin().GetRemoteAetC();
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2538 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2539
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2540 case _OrthancPluginService_GetInstanceSize:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2541 *p.resultInt64 = instance.GetBufferSize();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2542 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2543
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2544 case _OrthancPluginService_GetInstanceData:
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2545 *p.resultString = reinterpret_cast<const char*>(instance.GetBufferData());
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2546 return;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2547
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2548 case _OrthancPluginService_HasInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2549 AccessInstanceMetadataInternal(true, p, instance);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2550 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2551
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2552 case _OrthancPluginService_GetInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2553 AccessInstanceMetadataInternal(false, p, instance);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2554 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2555
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2556 case _OrthancPluginService_GetInstanceJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2557 case _OrthancPluginService_GetInstanceSimplifiedJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2558 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2559 Json::StyledWriter writer;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2560 std::string s;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2561
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2562 if (service == _OrthancPluginService_GetInstanceJson)
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2563 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2564 s = writer.write(instance.GetJson());
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2565 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2566 else
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2567 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2568 Json::Value simplified;
2120
4b02ec79728a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
2569 ServerToolbox::SimplifyTags(simplified, instance.GetJson(), DicomToJsonFormat_Human);
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2570 s = writer.write(simplified);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2571 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2572
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2573 *p.resultStringToFree = CopyString(s);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2574 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2575 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2576
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
2577 case _OrthancPluginService_GetInstanceOrigin: // New in Orthanc 0.9.5
2640
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
2578 *p.resultOrigin = Plugins::Convert(instance.GetOrigin().GetRequestOrigin());
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
2579 return;
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
2580
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2581 case _OrthancPluginService_GetInstanceTransferSyntaxUid: // New in Orthanc 1.6.1
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2582 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2583 std::string s;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2584 if (!instance.LookupTransferSyntax(s))
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2585 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2586 s.clear();
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2587 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2588
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2589 *p.resultStringToFree = CopyString(s);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2590 return;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2591 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2592
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2593 case _OrthancPluginService_HasInstancePixelData: // New in Orthanc 1.6.1
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2594 *p.resultInt64 = instance.HasPixelData();
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2595 return;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
2596
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2597 case _OrthancPluginService_GetInstanceFramesCount: // New in Orthanc 1.7.0
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2598 *p.resultInt64 = instance.GetParsedDicomFile().GetFramesCount();
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2599 return;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2600
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2601 default:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2602 throw OrthancException(ErrorCode_InternalError);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2603 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2604 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2605
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2606
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2607 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
2608 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2609 const _OrthancPluginBufferCompression& p =
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2610 *reinterpret_cast<const _OrthancPluginBufferCompression*>(parameters);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2611
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2612 std::string result;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2613
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2614 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
2615 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
2616
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2617 switch (p.compression)
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2618 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2619 case OrthancPluginCompressionType_Zlib:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2620 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2621 compressor.reset(new ZlibCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2622 compressor->SetPrefixWithUncompressedSize(false);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2623 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2624 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2625
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2626 case OrthancPluginCompressionType_ZlibWithSize:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2627 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2628 compressor.reset(new ZlibCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2629 compressor->SetPrefixWithUncompressedSize(true);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2630 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2631 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2632
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2633 case OrthancPluginCompressionType_Gzip:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2634 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2635 compressor.reset(new GzipCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2636 compressor->SetPrefixWithUncompressedSize(false);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2637 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2638 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2639
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2640 case OrthancPluginCompressionType_GzipWithSize:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2641 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2642 compressor.reset(new GzipCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2643 compressor->SetPrefixWithUncompressedSize(true);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2644 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2645 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2646
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2647 default:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2648 throw OrthancException(ErrorCode_ParameterOutOfRange);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2649 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2650
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2651 if (p.uncompress)
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2652 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2653 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
2654 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2655 else
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2656 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2657 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
2658 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2659 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2660
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2661 CopyToMemoryBuffer(*p.target, result);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2662 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2663
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2664
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
2665 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
2666 {
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2667 // 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
2668 // 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
2669
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2670 if (image->IsReadOnly())
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2671 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
2672 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
2673 ImageProcessing::Copy(*copy, *image);
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2674 image.reset(NULL);
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2675 return reinterpret_cast<OrthancPluginImage*>(copy.release());
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2676 }
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2677 else
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2678 {
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2679 return reinterpret_cast<OrthancPluginImage*>(image.release());
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2680 }
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2681 }
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2682
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2683
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2684 void OrthancPlugins::AccessDicomInstance2(_OrthancPluginService service,
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2685 const void* parameters)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2686 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2687 const _OrthancPluginAccessDicomInstance2& p =
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2688 *reinterpret_cast<const _OrthancPluginAccessDicomInstance2*>(parameters);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2689
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2690 if (p.instance == NULL)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2691 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2692 throw OrthancException(ErrorCode_NullPointer);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2693 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2694
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2695 const DicomInstanceToStore& instance =
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2696 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
2697
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2698 switch (service)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2699 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2700 case _OrthancPluginService_GetInstanceFramesCount:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2701 *p.targetUint32 = instance.GetParsedDicomFile().GetFramesCount();
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2702 return;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2703
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2704 case _OrthancPluginService_GetInstanceRawFrame:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2705 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2706 if (p.targetBuffer == NULL)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2707 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2708 throw OrthancException(ErrorCode_NullPointer);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2709 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2710
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2711 p.targetBuffer->data = NULL;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2712 p.targetBuffer->size = 0;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2713
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2714 MimeType mime;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2715 std::string frame;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2716 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
2717 CopyToMemoryBuffer(*p.targetBuffer, frame);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2718 return;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2719 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2720
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2721 case _OrthancPluginService_GetInstanceDecodedFrame:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2722 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2723 bool hasDecoderPlugin;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2724
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2725 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2726 boost::mutex::scoped_lock lock(pimpl_->decodeImageCallbackMutex_);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2727 hasDecoderPlugin = !pimpl_->decodeImageCallbacks_.empty();
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2728 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2729
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2730 std::unique_ptr<ImageAccessor> decoded;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2731 if (p.targetImage == NULL)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2732 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2733 throw OrthancException(ErrorCode_NullPointer);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2734 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2735 else if (hasDecoderPlugin)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2736 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2737 // TODO - This call could be speeded up the future, if a
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2738 // "decoding context" gets introduced in the decoder plugins
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2739
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2740 decoded.reset(Decode(instance.GetBufferData(), instance.GetBufferSize(), p.frameIndex));
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2741 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2742 else
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2743 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2744 decoded.reset(DicomImageDecoder::Decode(instance.GetParsedDicomFile(), p.frameIndex));
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2745 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2746
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2747 *(p.targetImage) = ReturnImage(decoded);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2748 return;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2749 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2750
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2751 default:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2752 throw OrthancException(ErrorCode_InternalError);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2753 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2754 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2755
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
2756
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2757 void OrthancPlugins::UncompressImage(const void* parameters)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2758 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
2759 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
2760
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
2761 std::unique_ptr<ImageAccessor> image;
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2762
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2763 switch (p.format)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2764 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2765 case OrthancPluginImageFormat_Png:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2766 {
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2767 image.reset(new PngReader);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2768 reinterpret_cast<PngReader&>(*image).ReadFromMemory(p.data, p.size);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2769 break;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2770 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2771
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2772 case OrthancPluginImageFormat_Jpeg:
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2773 {
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2774 image.reset(new JpegReader);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2775 reinterpret_cast<JpegReader&>(*image).ReadFromMemory(p.data, p.size);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2776 break;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2777 }
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2778
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2779 case OrthancPluginImageFormat_Dicom:
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2780 {
1902
8b0ee8d5e6d0 Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
2781 image.reset(Decode(p.data, p.size, 0));
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2782 break;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2783 }
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2784
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2785 default:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2786 throw OrthancException(ErrorCode_ParameterOutOfRange);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2787 }
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2788
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2789 *(p.target) = ReturnImage(image);
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2790 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2791
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2792
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2793 void OrthancPlugins::CompressImage(const void* parameters)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2794 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
2795 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
2796
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2797 std::string compressed;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2798
1916
5bcf721bde4f IImageWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1906
diff changeset
2799 ImageAccessor accessor;
5bcf721bde4f IImageWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1906
diff changeset
2800 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
2801
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2802 switch (p.imageFormat)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2803 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2804 case OrthancPluginImageFormat_Png:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2805 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2806 PngWriter writer;
1916
5bcf721bde4f IImageWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1906
diff changeset
2807 writer.WriteToMemory(compressed, accessor);
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2808 break;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2809 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2810
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2811 case OrthancPluginImageFormat_Jpeg:
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2812 {
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2813 JpegWriter writer;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2814 writer.SetQuality(p.quality);
1916
5bcf721bde4f IImageWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1906
diff changeset
2815 writer.WriteToMemory(compressed, accessor);
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2816 break;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
2817 }
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2818
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2819 default:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2820 throw OrthancException(ErrorCode_ParameterOutOfRange);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2821 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2822
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2823 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
2824 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2825
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2826
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2827 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
2828 const _OrthancPluginCallHttpClient2& parameters)
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2829 {
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2830 client.SetUrl(parameters.url);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2831 client.SetConvertHeadersToLowerCase(false);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2832
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2833 if (parameters.timeout != 0)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2834 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2835 client.SetTimeout(parameters.timeout);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2836 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2837
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2838 if (parameters.username != NULL &&
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2839 parameters.password != NULL)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2840 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2841 client.SetCredentials(parameters.username, parameters.password);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2842 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2843
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2844 if (parameters.certificateFile != NULL)
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2845 {
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2846 std::string certificate(parameters.certificateFile);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2847 std::string key, password;
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2848
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2849 if (parameters.certificateKeyFile)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2850 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2851 key.assign(parameters.certificateKeyFile);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2852 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2853
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2854 if (parameters.certificateKeyPassword)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2855 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2856 password.assign(parameters.certificateKeyPassword);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2857 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2858
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2859 client.SetClientCertificate(certificate, key, password);
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2860 }
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2861
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2862 client.SetPkcs11Enabled(parameters.pkcs11 ? true : false);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2863
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2864 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
2865 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2866 if (parameters.headersKeys[i] == NULL ||
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2867 parameters.headersValues[i] == NULL)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2868 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2869 throw OrthancException(ErrorCode_NullPointer);
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2870 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2871
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2872 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
2873 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2874
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2875 switch (parameters.method)
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2876 {
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2877 case OrthancPluginHttpMethod_Get:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2878 client.SetMethod(HttpMethod_Get);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2879 break;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2880
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2881 case OrthancPluginHttpMethod_Post:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2882 client.SetMethod(HttpMethod_Post);
3892
fe0e4ef52a72 Fix missing body in "OrthancPluginHttpPost()" and "OrthancPluginHttpPut()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
2883 client.GetBody().assign(reinterpret_cast<const char*>(parameters.body), parameters.bodySize);
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2884 break;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2885
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2886 case OrthancPluginHttpMethod_Put:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2887 client.SetMethod(HttpMethod_Put);
3892
fe0e4ef52a72 Fix missing body in "OrthancPluginHttpPost()" and "OrthancPluginHttpPut()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
2888 client.GetBody().assign(reinterpret_cast<const char*>(parameters.body), parameters.bodySize);
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2889 break;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2890
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2891 case OrthancPluginHttpMethod_Delete:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2892 client.SetMethod(HttpMethod_Delete);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2893 break;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2894
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2895 default:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2896 throw OrthancException(ErrorCode_ParameterOutOfRange);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2897 }
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2898 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2899
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2900
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
2901 static void ExecuteHttpClientWithoutChunkedBody(uint16_t& httpStatus,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
2902 OrthancPluginMemoryBuffer* answerBody,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
2903 OrthancPluginMemoryBuffer* answerHeaders,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
2904 HttpClient& client)
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2905 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2906 if (answerBody == NULL)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2907 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2908 throw OrthancException(ErrorCode_NullPointer);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2909 }
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2910
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2911 std::string body;
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2912 HttpClient::HttpHeaders headers;
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2913
2787
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
2914 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
2915
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2916 // 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
2917 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
2918
2787
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
2919 if (!success)
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
2920 {
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
2921 HttpClient::ThrowException(client.GetLastStatus());
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
2922 }
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
2923
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2924 // 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
2925 if (answerHeaders != NULL)
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2926 {
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2927 Json::Value json = Json::objectValue;
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2928
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2929 for (HttpClient::HttpHeaders::const_iterator
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2930 it = headers.begin(); it != headers.end(); ++it)
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2931 {
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2932 json[it->first] = it->second;
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2933 }
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2934
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2935 std::string s = json.toStyledString();
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2936 CopyToMemoryBuffer(*answerHeaders, s);
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2937 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2938
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2939 // 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
2940 if (client.GetMethod() != HttpMethod_Delete)
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2941 {
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2942 CopyToMemoryBuffer(*answerBody, body);
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2943 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2944 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2945
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2946
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2947 void OrthancPlugins::CallHttpClient(const void* parameters)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2948 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2949 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
2950
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2951 HttpClient client;
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2952
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2953 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2954 _OrthancPluginCallHttpClient2 converted;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2955 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
2956
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2957 converted.answerBody = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2958 converted.answerHeaders = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2959 converted.httpStatus = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2960 converted.method = p.method;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2961 converted.url = p.url;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2962 converted.headersCount = 0;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2963 converted.headersKeys = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2964 converted.headersValues = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2965 converted.body = p.body;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2966 converted.bodySize = p.bodySize;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2967 converted.username = p.username;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2968 converted.password = p.password;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2969 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
2970 converted.certificateFile = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2971 converted.certificateKeyFile = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2972 converted.certificateKeyPassword = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2973 converted.pkcs11 = false;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2974
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2975 SetupHttpClient(client, converted);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2976 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2977
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2978 uint16_t status;
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
2979 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
2980 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2981
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2982
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2983 void OrthancPlugins::CallHttpClient2(const void* parameters)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2984 {
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2985 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
2986
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2987 if (p.httpStatus == NULL)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2988 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2989 throw OrthancException(ErrorCode_NullPointer);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2990 }
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
2991
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2992 HttpClient client;
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2993
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2994 if (p.method == OrthancPluginHttpMethod_Post ||
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2995 p.method == OrthancPluginHttpMethod_Put)
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2996 {
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3399
diff changeset
2997 client.GetBody().assign(reinterpret_cast<const char*>(p.body), p.bodySize);
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2998 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
2999
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3000 SetupHttpClient(client, p);
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3001 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
3002 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3003
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3004
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3005 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
3006 {
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3007 const _OrthancPluginChunkedHttpClient& p =
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3008 *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
3009
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3010 if (p.httpStatus == NULL)
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3011 {
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3012 throw OrthancException(ErrorCode_NullPointer);
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3013 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3014
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3015 HttpClient client;
3393
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3016
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3017 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3018 _OrthancPluginCallHttpClient2 converted;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3019 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
3020
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3021 converted.answerBody = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3022 converted.answerHeaders = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3023 converted.httpStatus = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3024 converted.method = p.method;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3025 converted.url = p.url;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3026 converted.headersCount = p.headersCount;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3027 converted.headersKeys = p.headersKeys;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3028 converted.headersValues = p.headersValues;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3029 converted.body = NULL;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3030 converted.bodySize = 0;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3031 converted.username = p.username;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3032 converted.password = p.password;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3033 converted.timeout = p.timeout;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3034 converted.certificateFile = p.certificateFile;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3035 converted.certificateKeyFile = p.certificateKeyFile;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3036 converted.certificateKeyPassword = p.certificateKeyPassword;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3037 converted.pkcs11 = p.pkcs11;
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3038
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3039 SetupHttpClient(client, converted);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3040 }
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3041
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
3042 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
3043 client.SetBody(body);
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3044
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
3045 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
3046
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3047 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
3048
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3049 *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
3050
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3051 if (!success)
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3052 {
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3053 HttpClient::ThrowException(client.GetLastStatus());
2cd0369a156f support of chunked answers in HttpClient and in SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3392
diff changeset
3054 }
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3055 }
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3056
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3057
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3058 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
3059 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3060 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
3061 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
3062
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3063 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
3064 client.SetConvertHeadersToLowerCase(false);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3065
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3066 if (p.timeout != 0)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3067 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3068 client.SetTimeout(p.timeout);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3069 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3070
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3071 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
3072 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3073 if (p.additionalHeadersKeys[i] == NULL ||
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3074 p.additionalHeadersValues[i] == NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3075 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3076 throw OrthancException(ErrorCode_NullPointer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3077 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3078
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3079 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
3080 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3081
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3082 switch (p.method)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3083 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3084 case OrthancPluginHttpMethod_Get:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3085 client.SetMethod(HttpMethod_Get);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3086 break;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3087
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3088 case OrthancPluginHttpMethod_Post:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3089 client.SetMethod(HttpMethod_Post);
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3399
diff changeset
3090 client.GetBody().assign(reinterpret_cast<const char*>(p.body), p.bodySize);
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3091 break;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3092
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3093 case OrthancPluginHttpMethod_Put:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3094 client.SetMethod(HttpMethod_Put);
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3399
diff changeset
3095 client.GetBody().assign(reinterpret_cast<const char*>(p.body), p.bodySize);
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3096 break;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3097
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3098 case OrthancPluginHttpMethod_Delete:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3099 client.SetMethod(HttpMethod_Delete);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3100 break;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3101
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3102 default:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3103 throw OrthancException(ErrorCode_ParameterOutOfRange);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3104 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3105
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3106 std::string body;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3107 HttpClient::HttpHeaders headers;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3108
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3109 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
3110
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3111 // The HTTP request has succeeded
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3112 *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
3113
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3114 if (!success)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3115 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3116 HttpClient::ThrowException(client.GetLastStatus());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3117 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3118
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3119 // 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
3120 if (p.answerHeaders != NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3121 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3122 Json::Value json = Json::objectValue;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3123
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3124 for (HttpClient::HttpHeaders::const_iterator
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3125 it = headers.begin(); it != headers.end(); ++it)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3126 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3127 json[it->first] = it->second;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3128 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3129
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3130 std::string s = json.toStyledString();
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3131 CopyToMemoryBuffer(*p.answerHeaders, s);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3132 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3133
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3134 // 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
3135 if (p.method != OrthancPluginHttpMethod_Delete)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3136 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3137 CopyToMemoryBuffer(*p.answerBody, body);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3138 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3139 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3140
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3141
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3142 void OrthancPlugins::ConvertPixelFormat(const void* parameters)
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3143 {
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3144 const _OrthancPluginConvertPixelFormat& p = *reinterpret_cast<const _OrthancPluginConvertPixelFormat*>(parameters);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3145 const ImageAccessor& source = *reinterpret_cast<const ImageAccessor*>(p.source);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3146
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
3147 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
3148 ImageProcessing::Convert(*target, source);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3149
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3150 *(p.target) = ReturnImage(target);
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3151 }
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3152
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3153
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3154
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3155 void OrthancPlugins::GetFontInfo(const void* parameters)
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3156 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3157 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
3158
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3159 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3160 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3161
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3162 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
3163
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3164 if (p.name != NULL)
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3165 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3166 *(p.name) = font.GetName().c_str();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3167 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3168 else if (p.size != NULL)
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3169 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3170 *(p.size) = font.GetSize();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3171 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3172 else
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3173 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3174 throw OrthancException(ErrorCode_InternalError);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3175 }
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3176 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3177 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3178
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3179
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3180 void OrthancPlugins::DrawText(const void* parameters)
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3181 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3182 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
3183
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3184 ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3185
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3186 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3187 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3188 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
3189 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
3190 }
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3191 }
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3192
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3193
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3194 void OrthancPlugins::ApplyDicomToJson(_OrthancPluginService service,
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3195 const void* parameters)
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3196 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3197 const _OrthancPluginDicomToJson& p =
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3198 *reinterpret_cast<const _OrthancPluginDicomToJson*>(parameters);
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3199
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
3200 std::unique_ptr<ParsedDicomFile> dicom;
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3201
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3202 if (service == _OrthancPluginService_DicomBufferToJson)
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3203 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3204 dicom.reset(new ParsedDicomFile(p.buffer, p.size));
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3205 }
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3206 else
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3207 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3208 if (p.instanceId == NULL)
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3209 {
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3210 throw OrthancException(ErrorCode_NullPointer);
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3211 }
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3212
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3213 std::string content;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3214
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3215 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3216 PImpl::ServerContextLock lock(*pimpl_);
2124
2b1520efa282 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
3217 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
3218 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3219
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3220 dicom.reset(new ParsedDicomFile(content));
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3221 }
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3222
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3223 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
3224 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
3225 static_cast<DicomToJsonFlags>(p.flags), p.maxStringLength);
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3226
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3227 Json::FastWriter writer;
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3228 *p.result = CopyString(writer.write(json));
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3229 }
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3230
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3231
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3232 void OrthancPlugins::ApplyCreateDicom(_OrthancPluginService service,
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3233 const void* parameters)
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3234 {
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3235 const _OrthancPluginCreateDicom& p =
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3236 *reinterpret_cast<const _OrthancPluginCreateDicom*>(parameters);
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3237
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3238 Json::Value json;
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3239
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3240 if (p.json == NULL)
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3241 {
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3242 json = Json::objectValue;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3243 }
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3244 else
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3245 {
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3246 Json::Reader reader;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3247 if (!reader.parse(p.json, json))
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3248 {
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3249 throw OrthancException(ErrorCode_BadJson);
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3250 }
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3251 }
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3252
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3253 std::string dicom;
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3254
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3255 {
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
3256 // 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
3257 // configuration file)
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3258 // https://bitbucket.org/sjodogne/orthanc/issues/168/
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3259 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
3260 {
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3261 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
3262 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
3263 }
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3264
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
3265 std::unique_ptr<ParsedDicomFile> file
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
3266 (ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(p.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
3267 privateCreator));
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3268
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3269 if (p.pixelData)
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3270 {
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3271 file->EmbedImage(*reinterpret_cast<const ImageAccessor*>(p.pixelData));
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3272 }
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3273
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3274 file->SaveToMemoryBuffer(dicom);
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3275 }
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3276
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3277 CopyToMemoryBuffer(*p.target, dicom);
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3278 }
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3279
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3280
1833
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3281 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
3282 const void* parameters)
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3283 {
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3284 const _OrthancPluginComputeHash& p =
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3285 *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
3286
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3287 std::string hash;
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3288 switch (service)
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3289 {
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3290 case _OrthancPluginService_ComputeMd5:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3291 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
3292 break;
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3293
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3294 case _OrthancPluginService_ComputeSha1:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3295 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
3296 break;
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3297
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3298 default:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3299 throw OrthancException(ErrorCode_ParameterOutOfRange);
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3300 }
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3301
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3302 *p.result = CopyString(hash);
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3303 }
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3304
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3305
3429
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3306 void OrthancPlugins::GetTagName(const void* parameters)
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3307 {
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3308 const _OrthancPluginGetTagName& p =
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3309 *reinterpret_cast<const _OrthancPluginGetTagName*>(parameters);
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3310
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3311 std::string privateCreator;
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3312
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3313 if (p.privateCreator != NULL)
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3314 {
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3315 privateCreator = p.privateCreator;
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3316 }
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3317
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3318 DicomTag tag(p.group, p.element);
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3319 *p.result = CopyString(FromDcmtkBridge::GetTagName(tag, privateCreator));
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3320 }
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3321
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
3322
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3323 void OrthancPlugins::ApplyCreateImage(_OrthancPluginService service,
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3324 const void* parameters)
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3325 {
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3326 const _OrthancPluginCreateImage& p =
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3327 *reinterpret_cast<const _OrthancPluginCreateImage*>(parameters);
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3328
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
3329 std::unique_ptr<ImageAccessor> result;
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3330
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3331 switch (service)
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3332 {
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3333 case _OrthancPluginService_CreateImage:
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2045
diff changeset
3334 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
3335 break;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3336
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3337 case _OrthancPluginService_CreateImageAccessor:
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3338 result.reset(new ImageAccessor);
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3339 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
3340 break;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3341
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3342 case _OrthancPluginService_DecodeDicomImage:
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3343 {
1902
8b0ee8d5e6d0 Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
3344 result.reset(Decode(p.constBuffer, p.bufferSize, p.frameIndex));
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3345 break;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3346 }
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3347
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3348 default:
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3349 throw OrthancException(ErrorCode_InternalError);
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3350 }
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3351
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3352 *(p.target) = ReturnImage(result);
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3353 }
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3354
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3355
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3356 void OrthancPlugins::ApplySendMultipartItem(const void* parameters)
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3357 {
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3358 // An exception might be raised in this function if the
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3359 // connection was closed by the HTTP client.
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3360 const _OrthancPluginAnswerBuffer& p =
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3361 *reinterpret_cast<const _OrthancPluginAnswerBuffer*>(parameters);
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3362
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3363 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
3364 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
3365 }
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3366
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3367
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3368 void OrthancPlugins::ApplySendMultipartItem2(const void* parameters)
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3369 {
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3370 // An exception might be raised in this function if the
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3371 // connection was closed by the HTTP client.
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3372 const _OrthancPluginSendMultipartItem2& p =
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3373 *reinterpret_cast<const _OrthancPluginSendMultipartItem2*>(parameters);
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3374
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3375 std::map<std::string, std::string> headers;
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3376 for (uint32_t i = 0; i < p.headersCount; i++)
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3377 {
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3378 headers[p.headersKeys[i]] = p.headersValues[i];
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3379 }
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3380
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3507
diff changeset
3381 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
3382 }
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3383
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3384
1771
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3385 void OrthancPlugins::DatabaseAnswer(const void* parameters)
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3386 {
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3387 const _OrthancPluginDatabaseAnswer& p =
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3388 *reinterpret_cast<const _OrthancPluginDatabaseAnswer*>(parameters);
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3389
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3390 if (pimpl_->database_.get() != NULL)
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3391 {
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3392 pimpl_->database_->AnswerReceived(p);
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3393 }
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3394 else
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3395 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
3396 throw OrthancException(ErrorCode_BadRequest,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
3397 "Cannot invoke this service without a custom database back-end");
1771
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3398 }
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3399 }
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3400
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
3401
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3402 namespace
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3403 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3404 class DictionaryReadLocker
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3405 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3406 private:
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3407 const DcmDataDictionary& dictionary_;
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3408
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3409 public:
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3410 DictionaryReadLocker() : dictionary_(dcmDataDict.rdlock())
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3411 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3412 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3413
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3414 ~DictionaryReadLocker()
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3415 {
3118
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
3416 #if DCMTK_VERSION_NUMBER >= 364
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
3417 dcmDataDict.rdunlock();
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
3418 #else
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3419 dcmDataDict.unlock();
3118
8849677c2cbc compatibility with dcmtk 3.6.4
s.jodogne@gmail.com
parents: 3060
diff changeset
3420 #endif
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3421 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3422
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3423 const DcmDataDictionary* operator->()
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3424 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3425 return &dictionary_;
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3426 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3427 };
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3428 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3429
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3430
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3431 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
3432 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3433 const _OrthancPluginLookupDictionary& p =
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3434 *reinterpret_cast<const _OrthancPluginLookupDictionary*>(parameters);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3435
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3436 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
3437 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
3438
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3439 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
3440 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
3441
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3442 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
3443 {
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3444 // 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
3445 // configuration file)
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3446 // https://bitbucket.org/sjodogne/orthanc/issues/168/
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3447 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
3448 {
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3449 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
3450 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
3451 }
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3452
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3453 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
3454 }
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3455 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
3456 {
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
3457 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
3458 }
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3459
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3460 if (entry == NULL)
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3461 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3462 throw OrthancException(ErrorCode_UnknownDicomTag);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3463 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3464 else
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3465 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3466 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
3467 p.target->element = entry->getKey().getElement();
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2000
diff changeset
3468 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
3469 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
3470 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
3471 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3472 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3473
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3474
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3475 bool OrthancPlugins::InvokeSafeService(SharedLibrary& plugin,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3476 _OrthancPluginService service,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3477 const void* parameters)
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
3478 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3479 // 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
3480
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
3481 switch (service)
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
3482 {
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
3483 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
3484 {
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2136
diff changeset
3485 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
3486 *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
3487 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
3488 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
3489
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
3490 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
3491 {
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2136
diff changeset
3492 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
3493 *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
3494 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
3495 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
3496
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
3497 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
3498 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3499 std::string s;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3500
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3501 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3502 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3503 s = lock.GetConfiguration().GetConfigurationAbsolutePath();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3504 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3505
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3506 *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
3507 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
3508 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
3509
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
3510 case _OrthancPluginService_GetConfiguration:
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
3511 {
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
3512 std::string s;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3513
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3514 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3515 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3516 lock.GetConfiguration().Format(s);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3517 }
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
3518
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
3519 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = CopyString(s);
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
3520 return true;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
3521 }
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
3522
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3523 case _OrthancPluginService_BufferCompression:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3524 BufferCompression(parameters);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3525 return true;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
3526
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
3527 case _OrthancPluginService_AnswerBuffer:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3528 AnswerBuffer(parameters);
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
3529 return true;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
3530
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
3531 case _OrthancPluginService_CompressAndAnswerPngImage:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3532 CompressAndAnswerPngImage(parameters);
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
3533 return true;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
3534
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3535 case _OrthancPluginService_CompressAndAnswerImage:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3536 CompressAndAnswerImage(parameters);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3537 return true;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
3538
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
3539 case _OrthancPluginService_GetDicomForInstance:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3540 GetDicomForInstance(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3541 return true;
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
3542
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
3543 case _OrthancPluginService_RestApiGet:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3544 RestApiGet(parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3545 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3546
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3547 case _OrthancPluginService_RestApiGetAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3548 RestApiGet(parameters, true);
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
3549 return true;
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3550
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3551 case _OrthancPluginService_RestApiGet2:
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3552 RestApiGet2(parameters);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3553 return true;
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
3554
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3555 case _OrthancPluginService_RestApiPost:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3556 RestApiPostPut(true, parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3557 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3558
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3559 case _OrthancPluginService_RestApiPostAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3560 RestApiPostPut(true, parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3561 return true;
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3562
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3563 case _OrthancPluginService_RestApiDelete:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3564 RestApiDelete(parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3565 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3566
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3567 case _OrthancPluginService_RestApiDeleteAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3568 RestApiDelete(parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3569 return true;
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3570
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3571 case _OrthancPluginService_RestApiPut:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3572 RestApiPostPut(false, parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3573 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3574
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3575 case _OrthancPluginService_RestApiPutAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
3576 RestApiPostPut(false, parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
3577 return true;
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
3578
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
3579 case _OrthancPluginService_Redirect:
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
3580 Redirect(parameters);
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
3581 return true;
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
3582
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3583 case _OrthancPluginService_SendUnauthorized:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3584 SendUnauthorized(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3585 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3586
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3587 case _OrthancPluginService_SendMethodNotAllowed:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3588 SendMethodNotAllowed(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3589 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3590
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3591 case _OrthancPluginService_SendHttpStatus:
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3592 SendHttpStatus(parameters);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3593 return true;
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
3594
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3595 case _OrthancPluginService_SendHttpStatusCode:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3596 SendHttpStatusCode(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3597 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3598
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3599 case _OrthancPluginService_SetCookie:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3600 SetCookie(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3601 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
3602
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3603 case _OrthancPluginService_SetHttpHeader:
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3604 SetHttpHeader(parameters);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3605 return true;
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
3606
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3607 case _OrthancPluginService_SetHttpErrorDetails:
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3608 SetHttpErrorDetails(parameters);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3609 return true;
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
3610
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3611 case _OrthancPluginService_LookupPatient:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3612 case _OrthancPluginService_LookupStudy:
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3613 case _OrthancPluginService_LookupStudyWithAccessionNumber:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3614 case _OrthancPluginService_LookupSeries:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3615 case _OrthancPluginService_LookupInstance:
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
3616 LookupResource(service, parameters);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3617 return true;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
3618
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3619 case _OrthancPluginService_GetInstanceRemoteAet:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3620 case _OrthancPluginService_GetInstanceSize:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3621 case _OrthancPluginService_GetInstanceData:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3622 case _OrthancPluginService_GetInstanceJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3623 case _OrthancPluginService_GetInstanceSimplifiedJson:
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3624 case _OrthancPluginService_HasInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
3625 case _OrthancPluginService_GetInstanceMetadata:
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
3626 case _OrthancPluginService_GetInstanceOrigin:
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3627 case _OrthancPluginService_GetInstanceTransferSyntaxUid:
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
3628 case _OrthancPluginService_HasInstancePixelData:
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3629 AccessDicomInstance(service, parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3630 return true;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
3631
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3632 case _OrthancPluginService_GetInstanceFramesCount:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3633 case _OrthancPluginService_GetInstanceRawFrame:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3634 case _OrthancPluginService_GetInstanceDecodedFrame:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3635 AccessDicomInstance2(service, parameters);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3636 return true;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
3637
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3638 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
3639 {
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3640 const _OrthancPluginGlobalProperty& p =
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3641 *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
3642 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
3643 {
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3644 return false;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3645 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3646 else
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3647 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3648 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3649 lock.GetContext().GetIndex().SetGlobalProperty(static_cast<GlobalProperty>(p.property), p.value);
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3650 return true;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3651 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3652 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3653
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3654 case _OrthancPluginService_GetGlobalProperty:
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3655 {
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3656 const _OrthancPluginGlobalProperty& p =
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3657 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3658
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3659 std::string result;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3660
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3661 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3662 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3663 result = lock.GetContext().GetIndex().GetGlobalProperty(static_cast<GlobalProperty>(p.property), p.value);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3664 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3665
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
3666 *(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
3667 return true;
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3668 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3669
1407
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
3670 case _OrthancPluginService_GetExpectedDatabaseVersion:
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
3671 {
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
3672 const _OrthancPluginReturnSingleValue& p =
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
3673 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
3674 *(p.resultUint32) = ORTHANC_DATABASE_VERSION;
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
3675 return true;
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
3676 }
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
3677
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
3678 case _OrthancPluginService_StartMultipartAnswer:
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
3679 {
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
3680 const _OrthancPluginStartMultipartAnswer& p =
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
3681 *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
3682 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
3683 return true;
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
3684 }
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
3685
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
3686 case _OrthancPluginService_SendMultipartItem:
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3687 ApplySendMultipartItem(parameters);
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
3688 return true;
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3689
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3690 case _OrthancPluginService_SendMultipartItem2:
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3691 ApplySendMultipartItem2(parameters);
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
3692 return true;
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
3693
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3694 case _OrthancPluginService_ReadFile:
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3695 {
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3696 const _OrthancPluginReadFile& p =
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3697 *reinterpret_cast<const _OrthancPluginReadFile*>(parameters);
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3698
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3699 std::string content;
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2136
diff changeset
3700 SystemToolbox::ReadFile(content, p.path);
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3701 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
3702
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3703 return true;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3704 }
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3705
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3706 case _OrthancPluginService_WriteFile:
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3707 {
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3708 const _OrthancPluginWriteFile& p =
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3709 *reinterpret_cast<const _OrthancPluginWriteFile*>(parameters);
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2136
diff changeset
3710 SystemToolbox::WriteFile(p.data, p.size, p.path);
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3711 return true;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3712 }
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
3713
1593
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
3714 case _OrthancPluginService_GetErrorDescription:
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
3715 {
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
3716 const _OrthancPluginGetErrorDescription& p =
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
3717 *reinterpret_cast<const _OrthancPluginGetErrorDescription*>(parameters);
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
3718 *(p.target) = EnumerationToString(static_cast<ErrorCode>(p.error));
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
3719 return true;
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
3720 }
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
3721
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3722 case _OrthancPluginService_GetImagePixelFormat:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3723 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
3724 const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
3725 *(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
3726 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3727 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3728
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3729 case _OrthancPluginService_GetImageWidth:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3730 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
3731 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
3732 *(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
3733 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3734 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3735
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3736 case _OrthancPluginService_GetImageHeight:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3737 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
3738 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
3739 *(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
3740 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3741 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3742
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3743 case _OrthancPluginService_GetImagePitch:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3744 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
3745 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
3746 *(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
3747 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3748 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3749
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3750 case _OrthancPluginService_GetImageBuffer:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3751 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
3752 const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
3753 *(p.resultBuffer) = reinterpret_cast<const ImageAccessor*>(p.image)->GetBuffer();
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3754 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3755 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3756
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3757 case _OrthancPluginService_FreeImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3758 {
1605
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1604
diff changeset
3759 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
3760
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3761 if (p.image != NULL)
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
3762 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
3763 delete reinterpret_cast<ImageAccessor*>(p.image);
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
3764 }
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3765
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3766 return true;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3767 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3768
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3769 case _OrthancPluginService_UncompressImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3770 UncompressImage(parameters);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3771 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3772
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3773 case _OrthancPluginService_CompressImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3774 CompressImage(parameters);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3775 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3776
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3777 case _OrthancPluginService_CallHttpClient:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3778 CallHttpClient(parameters);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3779 return true;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
3780
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3781 case _OrthancPluginService_CallHttpClient2:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3782 CallHttpClient2(parameters);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3783 return true;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3784
3413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3785 case _OrthancPluginService_ChunkedHttpClient:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3407
diff changeset
3786 ChunkedHttpClient(parameters);
3387
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3787 return true;
a48d652f1500 new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
3788
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3789 case _OrthancPluginService_ConvertPixelFormat:
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3790 ConvertPixelFormat(parameters);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3791 return true;
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
3792
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3793 case _OrthancPluginService_GetFontsCount:
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3794 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3795 const _OrthancPluginReturnSingleValue& p =
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3796 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3797
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3798 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3799 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3800 *(p.resultUint32) = lock.GetConfiguration().GetFontRegistry().GetSize();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3801 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
3802
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3803 return true;
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3804 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3805
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3806 case _OrthancPluginService_GetFontInfo:
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3807 GetFontInfo(parameters);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3808 return true;
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3809
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3810 case _OrthancPluginService_DrawText:
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3811 DrawText(parameters);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3812 return true;
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
3813
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3814 case _OrthancPluginService_StorageAreaCreate:
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3815 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3816 const _OrthancPluginStorageAreaCreate& p =
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3817 *reinterpret_cast<const _OrthancPluginStorageAreaCreate*>(parameters);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3818 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
2028
d108412411e5 fix msvc warnings
sjodogne
parents: 2022
diff changeset
3819 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
3820 return true;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3821 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3822
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3823 case _OrthancPluginService_StorageAreaRead:
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3824 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3825 const _OrthancPluginStorageAreaRead& p =
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3826 *reinterpret_cast<const _OrthancPluginStorageAreaRead*>(parameters);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3827 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3828 std::string content;
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
3829 storage.Read(content, 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
3830 CopyToMemoryBuffer(*p.target, content);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3831 return true;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3832 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3833
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3834 case _OrthancPluginService_StorageAreaRemove:
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3835 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3836 const _OrthancPluginStorageAreaRemove& p =
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3837 *reinterpret_cast<const _OrthancPluginStorageAreaRemove*>(parameters);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3838 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
3839 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
3840 return true;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3841 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
3842
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3843 case _OrthancPluginService_DicomBufferToJson:
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3844 case _OrthancPluginService_DicomInstanceToJson:
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3845 ApplyDicomToJson(service, parameters);
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3846 return true;
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
3847
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3848 case _OrthancPluginService_CreateDicom:
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3849 ApplyCreateDicom(service, parameters);
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3850 return true;
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
3851
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
3852 case _OrthancPluginService_WorklistAddAnswer:
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3853 {
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3854 const _OrthancPluginWorklistAnswersOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3855 *reinterpret_cast<const _OrthancPluginWorklistAnswersOperation*>(parameters);
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
3856 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
3857 return true;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3858 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3859
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
3860 case _OrthancPluginService_WorklistMarkIncomplete:
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3861 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3862 const _OrthancPluginWorklistAnswersOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3863 *reinterpret_cast<const _OrthancPluginWorklistAnswersOperation*>(parameters);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3864 reinterpret_cast<DicomFindAnswers*>(p.answers)->SetComplete(false);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3865 return true;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3866 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3867
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
3868 case _OrthancPluginService_WorklistIsMatch:
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3869 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3870 const _OrthancPluginWorklistQueryOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3871 *reinterpret_cast<const _OrthancPluginWorklistQueryOperation*>(parameters);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3872 *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
3873 return true;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3874 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3875
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
3876 case _OrthancPluginService_WorklistGetDicomQuery:
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3877 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3878 const _OrthancPluginWorklistQueryOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
3879 *reinterpret_cast<const _OrthancPluginWorklistQueryOperation*>(parameters);
1812
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
3880 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
3881 return true;
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3882 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3883
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3884 case _OrthancPluginService_FindAddAnswer:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3885 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3886 const _OrthancPluginFindOperation& p =
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3887 *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
3888 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
3889 return true;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3890 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3891
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3892 case _OrthancPluginService_FindMarkIncomplete:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3893 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3894 const _OrthancPluginFindOperation& p =
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3895 *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
3896 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
3897 return true;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3898 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3899
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3900 case _OrthancPluginService_GetFindQuerySize:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3901 case _OrthancPluginService_GetFindQueryTag:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3902 case _OrthancPluginService_GetFindQueryTagName:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3903 case _OrthancPluginService_GetFindQueryValue:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3904 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3905 const _OrthancPluginFindOperation& p =
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3906 *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
3907 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
3908 return true;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3909 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3910
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3911 case _OrthancPluginService_CreateImage:
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3912 case _OrthancPluginService_CreateImageAccessor:
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
3913 case _OrthancPluginService_DecodeDicomImage:
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3914 ApplyCreateImage(service, parameters);
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3915 return true;
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
3916
1833
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3917 case _OrthancPluginService_ComputeMd5:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3918 case _OrthancPluginService_ComputeSha1:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3919 ComputeHash(service, parameters);
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3920 return true;
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
3921
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3922 case _OrthancPluginService_LookupDictionary:
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3923 ApplyLookupDictionary(parameters);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3924 return true;
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3925
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3926 case _OrthancPluginService_GenerateUuid:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3927 {
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3928 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result =
2512
4dcafa8d6633 SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
3929 CopyString(Toolbox::GenerateUuid());
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3930 return true;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3931 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
3932
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3933 case _OrthancPluginService_CreateFindMatcher:
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3934 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3935 const _OrthancPluginCreateFindMatcher& p =
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3936 *reinterpret_cast<const _OrthancPluginCreateFindMatcher*>(parameters);
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3937 ParsedDicomFile query(p.query, p.size);
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
3938 *(p.target) = reinterpret_cast<OrthancPluginFindMatcher*>(new HierarchicalMatcher(query));
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3939 return true;
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3940 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3941
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3942 case _OrthancPluginService_FreeFindMatcher:
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3943 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3944 const _OrthancPluginFreeFindMatcher& p =
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3945 *reinterpret_cast<const _OrthancPluginFreeFindMatcher*>(parameters);
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3946
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3947 if (p.matcher != NULL)
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3948 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3949 delete reinterpret_cast<HierarchicalMatcher*>(p.matcher);
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3950 }
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3951
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3952 return true;
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3953 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3954
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3955 case _OrthancPluginService_FindMatcherIsMatch:
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3956 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3957 const _OrthancPluginFindMatcherIsMatch& p =
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3958 *reinterpret_cast<const _OrthancPluginFindMatcherIsMatch*>(parameters);
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3959
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3960 if (p.matcher == NULL)
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3961 {
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3962 throw OrthancException(ErrorCode_NullPointer);
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3963 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3964 else
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3965 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3966 ParsedDicomFile query(p.dicom, p.size);
2215
028214a95194 refactoring the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2210
diff changeset
3967 *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
3968 return true;
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3969 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3970 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
3971
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3972 case _OrthancPluginService_GetPeers:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3973 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3974 const _OrthancPluginGetPeers& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3975 *reinterpret_cast<const _OrthancPluginGetPeers*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3976 *(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
3977 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3978 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3979
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3980 case _OrthancPluginService_FreePeers:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3981 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3982 const _OrthancPluginFreePeers& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3983 *reinterpret_cast<const _OrthancPluginFreePeers*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3984
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3985 if (p.peers != NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3986 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3987 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
3988 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3989
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3990 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3991 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3992
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3993 case _OrthancPluginService_GetPeersCount:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3994 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3995 const _OrthancPluginGetPeersCount& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3996 *reinterpret_cast<const _OrthancPluginGetPeersCount*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3997
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3998 if (p.peers == NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3999 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4000 throw OrthancException(ErrorCode_NullPointer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4001 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4002 else
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4003 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4004 *(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
4005 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4006 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4007 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4008
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4009 case _OrthancPluginService_GetPeerName:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4010 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4011 const _OrthancPluginGetPeerProperty& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4012 *reinterpret_cast<const _OrthancPluginGetPeerProperty*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4013
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4014 if (p.peers == NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4015 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4016 throw OrthancException(ErrorCode_NullPointer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4017 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4018 else
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4019 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4020 *(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
4021 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4022 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4023 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4024
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4025 case _OrthancPluginService_GetPeerUrl:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4026 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4027 const _OrthancPluginGetPeerProperty& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4028 *reinterpret_cast<const _OrthancPluginGetPeerProperty*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4029
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4030 if (p.peers == NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4031 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4032 throw OrthancException(ErrorCode_NullPointer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4033 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4034 else
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4035 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4036 *(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
4037 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4038 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4039 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4040
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4041 case _OrthancPluginService_GetPeerUserProperty:
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4042 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4043 const _OrthancPluginGetPeerProperty& p =
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4044 *reinterpret_cast<const _OrthancPluginGetPeerProperty*>(parameters);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4045
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4046 if (p.peers == NULL ||
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4047 p.userProperty == NULL)
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4048 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4049 throw OrthancException(ErrorCode_NullPointer);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4050 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4051 else
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4052 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4053 const WebServiceParameters::Dictionary& properties =
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4054 reinterpret_cast<const OrthancPeers*>(p.peers)->GetPeerParameters(p.peerIndex).GetUserProperties();
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4055
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4056 WebServiceParameters::Dictionary::const_iterator found =
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4057 properties.find(p.userProperty);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4058
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4059 if (found == properties.end())
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4060 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4061 *(p.target) = NULL;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4062 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4063 else
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4064 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4065 *(p.target) = found->second.c_str();
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4066 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4067
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4068 return true;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4069 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4070 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
4071
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4072 case _OrthancPluginService_CallPeerApi:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4073 CallPeerApi(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4074 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
4075
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4076 case _OrthancPluginService_CreateJob:
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4077 {
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4078 const _OrthancPluginCreateJob& p =
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4079 *reinterpret_cast<const _OrthancPluginCreateJob*>(parameters);
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4080 *(p.target) = reinterpret_cast<OrthancPluginJob*>(new PluginsJob(p));
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4081 return true;
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4082 }
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4083
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4084 case _OrthancPluginService_FreeJob:
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4085 {
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4086 const _OrthancPluginFreeJob& p =
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4087 *reinterpret_cast<const _OrthancPluginFreeJob*>(parameters);
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4088
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4089 if (p.job != NULL)
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4090 {
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4091 delete reinterpret_cast<PluginsJob*>(p.job);
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4092 }
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4093
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4094 return true;
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4095 }
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4096
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4097 case _OrthancPluginService_SubmitJob:
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4098 {
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4099 const _OrthancPluginSubmitJob& p =
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4100 *reinterpret_cast<const _OrthancPluginSubmitJob*>(parameters);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4101
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4102 std::string uuid;
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4103
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4104 PImpl::ServerContextLock lock(*pimpl_);
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4105 lock.GetContext().GetJobsEngine().GetRegistry().Submit
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4106 (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
4107
2814
7d1d3136f6cf more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2813
diff changeset
4108 *p.resultId = CopyString(uuid);
2813
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
4109
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4110 return true;
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4111 }
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4112
2984
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
4113 case _OrthancPluginService_AutodetectMimeType:
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
4114 {
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
4115 const _OrthancPluginRetrieveStaticString& p =
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
4116 *reinterpret_cast<const _OrthancPluginRetrieveStaticString*>(parameters);
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
4117 *p.result = EnumerationToString(SystemToolbox::AutodetectMimeType(p.argument));
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
4118 return true;
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
4119 }
db8f360fcb41 OrthancPluginAutodetectMimeType()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2960
diff changeset
4120
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4121 case _OrthancPluginService_SetMetricsValue:
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4122 {
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4123 const _OrthancPluginSetMetricsValue& p =
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4124 *reinterpret_cast<const _OrthancPluginSetMetricsValue*>(parameters);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4125
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4126 MetricsType type;
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4127 switch (p.type)
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4128 {
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4129 case OrthancPluginMetricsType_Default:
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4130 type = MetricsType_Default;
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4131 break;
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4132
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4133 case OrthancPluginMetricsType_Timer:
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4134 type = MetricsType_MaxOver10Seconds;
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4135 break;
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4136
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4137 default:
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4138 throw OrthancException(ErrorCode_ParameterOutOfRange);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4139 }
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4140
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4141 {
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4142 PImpl::ServerContextLock lock(*pimpl_);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4143 lock.GetContext().GetMetricsRegistry().SetValue(p.name, p.value, type);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4144 }
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4145
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4146 return true;
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4147 }
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4148
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4149 case _OrthancPluginService_EncodeDicomWebJson:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4150 case _OrthancPluginService_EncodeDicomWebXml:
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4151 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4152 const _OrthancPluginEncodeDicomWeb& p =
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4153 *reinterpret_cast<const _OrthancPluginEncodeDicomWeb*>(parameters);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4154
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4155 DicomWebBinaryFormatter formatter(p);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4156
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4157 DicomWebJsonVisitor visitor;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4158 visitor.SetFormatter(formatter);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4159
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4160 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4161 ParsedDicomFile dicom(p.dicom, p.dicomSize);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4162 dicom.Apply(visitor);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4163 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4164
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4165 std::string s;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4166
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4167 if (service == _OrthancPluginService_EncodeDicomWebJson)
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4168 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4169 s = visitor.GetResult().toStyledString();
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4170 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4171 else
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4172 {
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4173 visitor.FormatXml(s);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4174 }
3420
0a0e7eca95ae fix encoding in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3415
diff changeset
4175
3205
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4176 *p.target = CopyString(s);
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4177 return true;
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4178 }
6c86d4d407da new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3179
diff changeset
4179
3429
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4180 case _OrthancPluginService_GetTagName:
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4181 GetTagName(parameters);
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4182 return true;
954d15f24366 new function in SDK: OrthancPluginGetTagName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
4183
3916
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4184 case _OrthancPluginService_CreateDicomInstance:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4185 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4186 const _OrthancPluginCreateDicomInstance& p =
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4187 *reinterpret_cast<const _OrthancPluginCreateDicomInstance*>(parameters);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4188 *(p.target) = reinterpret_cast<OrthancPluginDicomInstance*>(
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4189 new DicomInstanceFromBuffer(p.buffer, p.size));
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4190 return true;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4191 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4192
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4193 case _OrthancPluginService_FreeDicomInstance:
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4194 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4195 const _OrthancPluginFreeDicomInstance& p =
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4196 *reinterpret_cast<const _OrthancPluginFreeDicomInstance*>(parameters);
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4197
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4198 if (p.dicom != NULL)
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4199 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4200 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
4201
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4202 if (obj->CanBeFreed())
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4203 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4204 delete obj;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4205 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4206 else
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4207 {
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4208 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
4209 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4210 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4211
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4212 return true;
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4213 }
0e3849268a55 new plugin SDK primitives related to OrthancPluginDicomInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3906
diff changeset
4214
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
4215 default:
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4216 return false;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4217 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4218 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4219
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4220
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4221
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4222 bool OrthancPlugins::InvokeProtectedService(SharedLibrary& plugin,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4223 _OrthancPluginService service,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4224 const void* parameters)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4225 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4226 // 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
4227 // 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
4228 // should be listed here.
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4229
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4230 switch (service)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4231 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4232 case _OrthancPluginService_RegisterRestCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4233 RegisterRestCallback(parameters, true);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4234 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4235
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4236 case _OrthancPluginService_RegisterRestCallbackNoLock:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4237 RegisterRestCallback(parameters, false);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4238 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4239
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4240 case _OrthancPluginService_RegisterChunkedRestCallback:
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4241 RegisterChunkedRestCallback(parameters);
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4242 return true;
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4243
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4244 case _OrthancPluginService_RegisterOnStoredInstanceCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4245 RegisterOnStoredInstanceCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4246 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4247
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4248 case _OrthancPluginService_RegisterOnChangeCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4249 RegisterOnChangeCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4250 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4251
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4252 case _OrthancPluginService_RegisterWorklistCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4253 RegisterWorklistCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4254 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4255
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4256 case _OrthancPluginService_RegisterFindCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4257 RegisterFindCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4258 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4259
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4260 case _OrthancPluginService_RegisterMoveCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4261 RegisterMoveCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4262 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4263
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4264 case _OrthancPluginService_RegisterDecodeImageCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4265 RegisterDecodeImageCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4266 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4267
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4268 case _OrthancPluginService_RegisterJobsUnserializer:
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4269 RegisterJobsUnserializer(parameters);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4270 return true;
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4271
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4272 case _OrthancPluginService_RegisterIncomingHttpRequestFilter:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4273 RegisterIncomingHttpRequestFilter(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4274 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4275
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4276 case _OrthancPluginService_RegisterIncomingHttpRequestFilter2:
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4277 RegisterIncomingHttpRequestFilter2(parameters);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4278 return true;
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4279
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4280 case _OrthancPluginService_RegisterIncomingDicomInstanceFilter:
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4281 RegisterIncomingDicomInstanceFilter(parameters);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4282 return true;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4283
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4284 case _OrthancPluginService_RegisterRefreshMetricsCallback:
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4285 RegisterRefreshMetricsCallback(parameters);
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4286 return true;
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4287
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4288 case _OrthancPluginService_RegisterStorageCommitmentScpCallback:
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4289 RegisterStorageCommitmentScpCallback(parameters);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4290 return true;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4291
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4292 case _OrthancPluginService_RegisterStorageArea:
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 LOG(INFO) << "Plugin has registered a custom storage area";
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4295 const _OrthancPluginRegisterStorageArea& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4296 *reinterpret_cast<const _OrthancPluginRegisterStorageArea*>(parameters);
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 if (pimpl_->storageArea_.get() == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4299 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4300 pimpl_->storageArea_.reset(new StorageAreaFactory(plugin, p, GetErrorDictionary()));
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4301 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4302 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4303 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4304 throw OrthancException(ErrorCode_StorageAreaAlreadyRegistered);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4305 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4306
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4307 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4308 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4309
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4310 case _OrthancPluginService_SetPluginProperty:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4311 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4312 const _OrthancPluginSetPluginProperty& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4313 *reinterpret_cast<const _OrthancPluginSetPluginProperty*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4314 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
4315 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4316 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4317
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4318 case _OrthancPluginService_GetCommandLineArgumentsCount:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4319 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4320 const _OrthancPluginReturnSingleValue& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4321 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4322 *(p.resultUint32) = pimpl_->argc_ - 1;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4323 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4324 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4325
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4326 case _OrthancPluginService_GetCommandLineArgument:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4327 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4328 const _OrthancPluginGlobalProperty& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4329 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4330
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4331 if (p.property + 1 > pimpl_->argc_)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4332 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4333 return false;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4334 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4335 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4336 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4337 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
4338 *(p.result) = CopyString(arg);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4339 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4340 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4341 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4342
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4343 case _OrthancPluginService_RegisterDatabaseBackend:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4344 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4345 LOG(INFO) << "Plugin has registered a custom database back-end";
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4346
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4347 const _OrthancPluginRegisterDatabaseBackend& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4348 *reinterpret_cast<const _OrthancPluginRegisterDatabaseBackend*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4349
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4350 if (pimpl_->database_.get() == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4351 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4352 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
4353 *p.backend, NULL, 0, p.payload));
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4354 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4355 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4356 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4357 throw OrthancException(ErrorCode_DatabaseBackendAlreadyRegistered);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4358 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4359
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4360 *(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
4361
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4362 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4363 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4364
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4365 case _OrthancPluginService_RegisterDatabaseBackendV2:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4366 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4367 LOG(INFO) << "Plugin has registered a custom database back-end";
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4368
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4369 const _OrthancPluginRegisterDatabaseBackendV2& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4370 *reinterpret_cast<const _OrthancPluginRegisterDatabaseBackendV2*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4371
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4372 if (pimpl_->database_.get() == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4373 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4374 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
4375 *p.backend, p.extensions,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4376 p.extensionsSize, p.payload));
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4377 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4378 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4379 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4380 throw OrthancException(ErrorCode_DatabaseBackendAlreadyRegistered);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4381 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4382
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4383 *(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
4384
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4385 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4386 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4387
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4388 case _OrthancPluginService_DatabaseAnswer:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4389 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
4390
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4391 case _OrthancPluginService_RegisterErrorCode:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4392 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4393 const _OrthancPluginRegisterErrorCode& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4394 *reinterpret_cast<const _OrthancPluginRegisterErrorCode*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4395 *(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
4396 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4397 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4398
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4399 case _OrthancPluginService_RegisterDictionaryTag:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4400 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4401 const _OrthancPluginRegisterDictionaryTag& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4402 *reinterpret_cast<const _OrthancPluginRegisterDictionaryTag*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4403 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
4404 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
4405 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
4406 return true;
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
4407 }
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
4408
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
4409 case _OrthancPluginService_RegisterPrivateDictionaryTag:
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
4410 {
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
4411 const _OrthancPluginRegisterPrivateDictionaryTag& p =
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
4412 *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
4413 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
4414 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
4415 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
4416 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4417 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4418
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4419 case _OrthancPluginService_ReconstructMainDicomTags:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4420 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4421 const _OrthancPluginReconstructMainDicomTags& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4422 *reinterpret_cast<const _OrthancPluginReconstructMainDicomTags*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4423
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4424 if (pimpl_->database_.get() == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4425 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
4426 throw OrthancException(ErrorCode_DatabasePlugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
4427 "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
4428 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4429
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4430 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
2120
4b02ec79728a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
4431 ServerToolbox::ReconstructMainDicomTags(*pimpl_->database_, storage, Plugins::Convert(p.level));
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4432
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4433 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4434 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4435
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4436 default:
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4437 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4438 // This service is unknown to the Orthanc plugin engine
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
4439 return false;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
4440 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
4441 }
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
4442 }
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
4443
908
e078ea944089 refactoring HttpOutput
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
4444
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4445
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4446 bool OrthancPlugins::InvokeService(SharedLibrary& plugin,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4447 _OrthancPluginService service,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4448 const void* parameters)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4449 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4450 VLOG(1) << "Calling service " << service << " from plugin " << plugin.GetPath();
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4451
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4452 if (service == _OrthancPluginService_DatabaseAnswer)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4453 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4454 // 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
4455 // 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
4456 // 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
4457 // 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
4458 // 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
4459 // "DatabaseAnswer".
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4460 DatabaseAnswer(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4461 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4462 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4463
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4464 if (InvokeSafeService(plugin, service, parameters))
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4465 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4466 // 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
4467 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4468 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4469 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4470 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4471 // The invoked service requires locking
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4472 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
4473 return InvokeProtectedService(plugin, service, parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4474 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4475 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4476
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4477
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
4478 bool OrthancPlugins::HasStorageArea() const
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
4479 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4480 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
4481 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
4482 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4483
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
4484 bool OrthancPlugins::HasDatabaseBackend() const
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4485 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4486 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4487 return pimpl_->database_.get() != NULL;
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4488 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4489
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
4490
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
4491 IStorageArea* OrthancPlugins::CreateStorageArea()
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
4492 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
4493 if (!HasStorageArea())
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
4494 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
4495 throw OrthancException(ErrorCode_BadSequenceOfCalls);
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
4496 }
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
4497 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
4498 {
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
4499 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
4500 }
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
4501 }
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
4502
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
4503
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
4504 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
4505 {
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
4506 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
4507 {
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
4508 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
4509 }
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
4510 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
4511 {
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
4512 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
4513 }
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
4514 }
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4515
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4516
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
4517 IDatabaseWrapper& OrthancPlugins::GetDatabaseBackend()
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4518 {
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
4519 if (!HasDatabaseBackend())
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4520 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4521 throw OrthancException(ErrorCode_BadSequenceOfCalls);
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4522 }
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
4523 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
4524 {
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
4525 return *pimpl_->database_;
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
4526 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4527 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4528
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4529
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
4530 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
4531 {
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
4532 if (!HasDatabaseBackend())
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
4533 {
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
4534 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
4535 }
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
4536 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
4537 {
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
4538 return pimpl_->database_->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
4539 }
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
4540 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
4541
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4542
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4543 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
4544 _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
4545 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4546 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
4547 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
4548
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4549 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
4550 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4551 return NULL;
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4552 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4553 else
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4554 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4555 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
4556 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
4557 }
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
4558
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
4559
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
4560 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
4561 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
4562 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
4563 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
4564 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
4565 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
4566
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
4567 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
4568 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
4569 }
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
4570
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
4571
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
4572 PluginsManager& OrthancPlugins::GetManager()
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
4573 {
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
4574 return pimpl_->manager_;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
4575 }
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
4576
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
4577
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
4578 const PluginsManager& OrthancPlugins::GetManager() const
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
4579 {
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
4580 return pimpl_->manager_;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
4581 }
1644
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
4582
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
4583
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
4584 PluginsErrorDictionary& OrthancPlugins::GetErrorDictionary()
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
4585 {
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
4586 return pimpl_->dictionary_;
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
4587 }
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
4588
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
4589
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
4590 IWorklistRequestHandler* OrthancPlugins::ConstructWorklistRequestHandler()
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
4591 {
1809
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
4592 if (HasWorklistHandler())
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
4593 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
4594 return new WorklistHandler(*this);
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
4595 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
4596 else
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
4597 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
4598 return NULL;
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
4599 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
4600 }
1809
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
4601
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
4602
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
4603 bool OrthancPlugins::HasWorklistHandler()
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
4604 {
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
4605 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
4606 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
4607 }
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
4608
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
4609
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4610 IFindRequestHandler* OrthancPlugins::ConstructFindRequestHandler()
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4611 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4612 if (HasFindHandler())
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4613 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4614 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
4615 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4616 else
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4617 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4618 return NULL;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4619 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4620 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4621
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4622
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4623 bool OrthancPlugins::HasFindHandler()
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4624 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4625 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
4626 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
4627 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4628
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
4629
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4630 IMoveRequestHandler* OrthancPlugins::ConstructMoveRequestHandler()
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4631 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4632 if (HasMoveHandler())
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4633 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4634 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
4635 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4636 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4637 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4638 return NULL;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4639 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4640 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4641
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4642
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4643 bool OrthancPlugins::HasMoveHandler()
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4644 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
4645 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
4646 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
4647 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4648
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
4649
1906
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
4650 bool OrthancPlugins::HasCustomImageDecoder()
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
4651 {
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
4652 boost::mutex::scoped_lock lock(pimpl_->decodeImageCallbackMutex_);
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
4653 return !pimpl_->decodeImageCallbacks_.empty();
1906
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
4654 }
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
4655
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
4656
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
4657 ImageAccessor* OrthancPlugins::DecodeUnsafe(const void* dicom,
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
4658 size_t size,
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
4659 unsigned int frame)
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
4660 {
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
4661 boost::mutex::scoped_lock lock(pimpl_->decodeImageCallbackMutex_);
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
4662
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
4663 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
4664 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
4665 decoder != pimpl_->decodeImageCallbacks_.end(); ++decoder)
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
4666 {
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
4667 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
4668 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
4669 pluginImage != NULL)
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
4670 {
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
4671 return reinterpret_cast<ImageAccessor*>(pluginImage);
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
4672 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
4673 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
4674
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
4675 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
4676 }
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
4677
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
4678
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
4679 ImageAccessor* OrthancPlugins::Decode(const void* dicom,
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
4680 size_t size,
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
4681 unsigned int frame)
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
4682 {
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
4683 ImageAccessor* result = DecodeUnsafe(dicom, size, frame);
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
4684
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
4685 if (result != 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
4686 {
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
4687 return result;
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
4688 }
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
4689 else
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
4690 {
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
4691 LOG(INFO) << "The installed image decoding plugins cannot handle an image, fallback to the built-in decoder";
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
4692 DefaultDicomImageDecoder defaultDecoder;
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
4693 return defaultDecoder.Decode(dicom, size, frame);
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
4694 }
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
4695 }
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4696
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4697
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4698 bool OrthancPlugins::IsAllowed(HttpMethod method,
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4699 const char* uri,
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4700 const char* ip,
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4701 const char* username,
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4702 const IHttpHandler::Arguments& httpHeaders,
2616
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2512
diff changeset
4703 const IHttpHandler::GetArguments& getArguments)
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4704 {
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4705 OrthancPluginHttpMethod cMethod = Plugins::Convert(method);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4706
1962
22ddb22fce83 sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1961
diff changeset
4707 std::vector<const char*> httpKeys(httpHeaders.size());
22ddb22fce83 sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1961
diff changeset
4708 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
4709
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4710 size_t pos = 0;
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4711 for (IHttpHandler::Arguments::const_iterator
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4712 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
4713 {
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4714 httpKeys[pos] = it->first.c_str();
1962
22ddb22fce83 sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1961
diff changeset
4715 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
4716 }
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4717
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4718 std::vector<const char*> getKeys(getArguments.size());
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4719 std::vector<const char*> getValues(getArguments.size());
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4720
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4721 for (size_t i = 0; i < getArguments.size(); i++)
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4722 {
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4723 getKeys[i] = getArguments[i].first.c_str();
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4724 getValues[i] = getArguments[i].second.c_str();
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4725 }
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4726
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4727 {
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4728 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4729
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4730 // 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
4731 for (PImpl::IncomingHttpRequestFilters2::const_iterator
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4732 filter = pimpl_->incomingHttpRequestFilters2_.begin();
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4733 filter != pimpl_->incomingHttpRequestFilters2_.end(); ++filter)
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4734 {
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4735 int32_t allowed = (*filter) (cMethod, uri, ip,
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4736 httpKeys.size(),
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4737 httpKeys.empty() ? NULL : &httpKeys[0],
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4738 httpValues.empty() ? NULL : &httpValues[0],
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4739 getKeys.size(),
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4740 getKeys.empty() ? NULL : &getKeys[0],
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4741 getValues.empty() ? NULL : &getValues[0]);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4742
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4743 if (allowed == 0)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4744 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4745 return false;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4746 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4747 else if (allowed != 1)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4748 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4749 // 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
4750 throw OrthancException(ErrorCode_Plugin);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4751 }
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4752 }
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4753
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4754 for (PImpl::IncomingHttpRequestFilters::const_iterator
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4755 filter = pimpl_->incomingHttpRequestFilters_.begin();
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4756 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
4757 {
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4758 int32_t allowed = (*filter) (cMethod, uri, ip, httpKeys.size(),
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4759 httpKeys.empty() ? NULL : &httpKeys[0],
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4760 httpValues.empty() ? NULL : &httpValues[0]);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4761
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4762 if (allowed == 0)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4763 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4764 return false;
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4765 }
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4766 else if (allowed != 1)
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4767 {
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4768 // 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
4769 throw OrthancException(ErrorCode_Plugin);
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3840
diff changeset
4770 }
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
4771 }
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4772 }
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4773
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4774 return true;
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
4775 }
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4776
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4777
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4778 IJob* OrthancPlugins::UnserializeJob(const std::string& type,
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4779 const Json::Value& value)
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4780 {
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4781 const std::string serialized = value.toStyledString();
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4782
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4783 boost::mutex::scoped_lock lock(pimpl_->jobsUnserializersMutex_);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4784
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4785 for (PImpl::JobsUnserializers::iterator
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4786 unserializer = pimpl_->jobsUnserializers_.begin();
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4787 unserializer != pimpl_->jobsUnserializers_.end(); ++unserializer)
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4788 {
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4789 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
4790 if (job != NULL)
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4791 {
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4792 return reinterpret_cast<PluginsJob*>(job);
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4793 }
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4794 }
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4795
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
4796 return NULL;
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
4797 }
3179
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4798
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4799
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4800 void OrthancPlugins::RefreshMetrics()
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4801 {
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4802 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
4803
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4804 for (PImpl::RefreshMetricsCallbacks::iterator
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4805 it = pimpl_->refreshMetricsCallbacks_.begin();
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4806 it != pimpl_->refreshMetricsCallbacks_.end(); ++it)
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4807 {
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4808 if (*it != NULL)
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4809 {
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4810 (*it) ();
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4811 }
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4812 }
fca730c267d7 New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3120
diff changeset
4813 }
3395
0ce9b4f5fdf5 new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3393
diff changeset
4814
0ce9b4f5fdf5 new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3393
diff changeset
4815
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4816 class OrthancPlugins::HttpServerChunkedReader : public IHttpHandler::IChunkedRequestReader
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4817 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4818 private:
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4819 OrthancPluginServerChunkedRequestReader* reader_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4820 _OrthancPluginChunkedRestCallback parameters_;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4821 PluginsErrorDictionary& errorDictionary_;
3399
4e8205871967 OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3397
diff changeset
4822
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4823 public:
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4824 HttpServerChunkedReader(OrthancPluginServerChunkedRequestReader* reader,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4825 const _OrthancPluginChunkedRestCallback& parameters,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4826 PluginsErrorDictionary& errorDictionary) :
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4827 reader_(reader),
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4828 parameters_(parameters),
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4829 errorDictionary_(errorDictionary)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4830 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4831 assert(reader_ != NULL);
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4832 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4833
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4834 virtual ~HttpServerChunkedReader()
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4835 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4836 assert(reader_ != NULL);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4837 parameters_.finalize(reader_);
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4838 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4839
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4840 virtual void AddBodyChunk(const void* data,
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4841 size_t size)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4842 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4843 if (static_cast<uint32_t>(size) != size)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4844 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4845 throw OrthancException(ErrorCode_NotEnoughMemory, ERROR_MESSAGE_64BIT);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4846 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4847
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4848 assert(reader_ != NULL);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4849 parameters_.addChunk(reader_, data, size);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4850 }
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4851
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4852 virtual void Execute(HttpOutput& output)
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4853 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4854 assert(reader_ != NULL);
3399
4e8205871967 OrthancPluginRegisterMultipartRestCallback() is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3397
diff changeset
4855
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4856 PImpl::PluginHttpOutput pluginOutput(output);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4857
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4858 OrthancPluginErrorCode error = parameters_.execute(
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4859 reader_, reinterpret_cast<OrthancPluginRestOutput*>(&pluginOutput));
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4860
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4861 pluginOutput.Close(error, errorDictionary_);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4862 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4863 };
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4864
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4865
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
4866 bool OrthancPlugins::CreateChunkedRequestReader(std::unique_ptr<IChunkedRequestReader>& target,
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4867 RequestOrigin origin,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4868 const char* remoteIp,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4869 const char* username,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4870 HttpMethod method,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4871 const UriComponents& uri,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4872 const Arguments& headers)
3395
0ce9b4f5fdf5 new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3393
diff changeset
4873 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4874 if (method != HttpMethod_Post &&
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4875 method != HttpMethod_Put)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4876 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4877 throw OrthancException(ErrorCode_InternalError);
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4878 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4879
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4880 RestCallbackMatcher matcher(uri);
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4881
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4882 PImpl::ChunkedRestCallback* callback = NULL;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4883
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4884 // Loop over the callbacks registered by the plugins
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4885 for (PImpl::ChunkedRestCallbacks::const_iterator it = pimpl_->chunkedRestCallbacks_.begin();
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4886 it != pimpl_->chunkedRestCallbacks_.end(); ++it)
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4887 {
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4888 if (matcher.IsMatch((*it)->GetRegularExpression()))
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4889 {
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4890 callback = *it;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4891 break;
3396
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4892 }
4981405e6c5c new sdk: OrthancPluginRegisterMultipartRestCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
4893 }
3395
0ce9b4f5fdf5 new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3393
diff changeset
4894
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4895 if (callback == NULL)
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4896 {
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4897 // Callback not found
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4898 return false;
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4899 }
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4900 else
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4901 {
3415
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4902 OrthancPluginServerChunkedRequestReaderFactory handler;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4903
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4904 switch (method)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4905 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4906 case HttpMethod_Post:
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4907 handler = callback->GetParameters().postHandler;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4908 break;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4909
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4910 case HttpMethod_Put:
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4911 handler = callback->GetParameters().putHandler;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4912 break;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4913
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4914 default:
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4915 handler = NULL;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4916 break;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4917 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4918
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4919 if (handler == NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4920 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4921 return false;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4922 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4923 else
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4924 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4925 LOG(INFO) << "Delegating chunked HTTP request to plugin for URI: " << matcher.GetFlatUri();
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4926
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4927 HttpRequestConverter converter(matcher, method, headers);
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4928 converter.GetRequest().body = NULL;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4929 converter.GetRequest().bodySize = 0;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4930
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4931 OrthancPluginServerChunkedRequestReader* reader = NULL;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4932
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4933 OrthancPluginErrorCode errorCode = handler(
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4934 &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
4935
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4936 if (reader == NULL)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4937 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4938 // 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
4939 return false;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4940 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4941 else if (errorCode != OrthancPluginErrorCode_Success)
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4942 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4943 throw OrthancException(static_cast<ErrorCode>(errorCode));
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4944 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4945 else
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4946 {
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4947 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
4948 return true;
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4949 }
2a821deece64 refactoring to handle "not allowed" HTTP status 405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3414
diff changeset
4950 }
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3413
diff changeset
4951 }
3395
0ce9b4f5fdf5 new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3393
diff changeset
4952 }
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4953
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4954
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4955 IStorageCommitmentFactory::ILookupHandler* OrthancPlugins::CreateStorageCommitment(
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4956 const std::string& jobId,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4957 const std::string& transactionUid,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4958 const std::vector<std::string>& sopClassUids,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4959 const std::vector<std::string>& sopInstanceUids,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4960 const std::string& remoteAet,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4961 const std::string& calledAet)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4962 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4963 boost::mutex::scoped_lock lock(pimpl_->storageCommitmentScpMutex_);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4964
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4965 for (PImpl::StorageCommitmentScpCallbacks::iterator
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4966 it = pimpl_->storageCommitmentScpCallbacks_.begin();
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4967 it != pimpl_->storageCommitmentScpCallbacks_.end(); ++it)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4968 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4969 assert(*it != NULL);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4970 IStorageCommitmentFactory::ILookupHandler* handler = (*it)->CreateStorageCommitment
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4971 (jobId, transactionUid, sopClassUids, sopInstanceUids, remoteAet, calledAet);
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4972
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4973 if (handler != NULL)
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4974 {
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4975 return handler;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4976 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4977 }
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4978
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4979 return NULL;
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
4980 }
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
4981
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
4982
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
4983 bool OrthancPlugins::Transcode(std::string& target,
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3900
diff changeset
4984 DicomTransferSyntax& sourceSyntax /* out */,
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3900
diff changeset
4985 DicomTransferSyntax& targetSyntax /* out */,
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
4986 bool& hasSopInstanceUidChanged /* out */,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
4987 const void* buffer,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
4988 size_t size,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
4989 const std::set<DicomTransferSyntax>& allowedSyntaxes,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
4990 bool allowNewSopInstanceUid)
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
4991 {
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
4992 // TODO
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
4993 return false;
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
4994 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4995 }