annotate Plugins/Engine/OrthancPlugins.cpp @ 2960:74a5a7fd6e0e

log flag to OrthancPluginSetHttpErrorDetails
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 04 Dec 2018 18:56:39 +0100
parents ccf61f6e22ef
children db8f360fcb41
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
2447
878b59270859 upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
5 * Copyright (C) 2017-2018 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
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
41
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
42 #include "../../Core/ChunkedBuffer.h"
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
43 #include "../../Core/DicomFormat/DicomArray.h"
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
44 #include "../../Core/HttpServer/HttpToolbox.h"
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1466
diff changeset
45 #include "../../Core/Logging.h"
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
46 #include "../../Core/OrthancException.h"
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
47 #include "../../Core/SerializationToolbox.h"
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
48 #include "../../Core/Toolbox.h"
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2354
diff changeset
49 #include "../../Core/DicomParsing/FromDcmtkBridge.h"
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2354
diff changeset
50 #include "../../Core/DicomParsing/ToDcmtkBridge.h"
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
51 #include "../../OrthancServer/OrthancConfiguration.h"
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
52 #include "../../OrthancServer/ServerContext.h"
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
53 #include "../../OrthancServer/ServerToolbox.h"
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
54 #include "../../OrthancServer/Search/HierarchicalMatcher.h"
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2354
diff changeset
55 #include "../../Core/DicomParsing/Internals/DicomImageDecoder.h"
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
56 #include "../../Core/Compression/ZlibCompressor.h"
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
57 #include "../../Core/Compression/GzipCompressor.h"
1612
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
58 #include "../../Core/Images/Image.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
59 #include "../../Core/Images/PngReader.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
60 #include "../../Core/Images/PngWriter.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
61 #include "../../Core/Images/JpegReader.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
62 #include "../../Core/Images/JpegWriter.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
63 #include "../../Core/Images/ImageProcessing.h"
1902
8b0ee8d5e6d0 Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
64 #include "../../OrthancServer/DefaultDicomImageDecoder.h"
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
65 #include "../../OrthancServer/OrthancFindRequestHandler.h"
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
66 #include "PluginsEnumerations.h"
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
67 #include "PluginsJob.h"
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 #include <boost/regex.hpp>
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
70 #include <dcmtk/dcmdata/dcdict.h>
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
71 #include <dcmtk/dcmdata/dcdicent.h>
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 namespace Orthanc
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
75 static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
76 const void* data,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
77 size_t size)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
78 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
79 target.size = size;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
80
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
81 if (size == 0)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
82 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
83 target.data = NULL;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
84 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
85 else
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
86 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
87 target.data = malloc(size);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
88 if (target.data != NULL)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
89 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
90 memcpy(target.data, data, size);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
91 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
92 else
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
93 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
94 throw OrthancException(ErrorCode_NotEnoughMemory);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
95 }
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 }
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
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
100 static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
101 const std::string& str)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
102 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
103 if (str.size() == 0)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
104 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
105 target.size = 0;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
106 target.data = NULL;
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 else
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 CopyToMemoryBuffer(target, str.c_str(), str.size());
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 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
113
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
114
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
115 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
116 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
117 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
118 if (result == NULL)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
119 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
120 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
121 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
122
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
123 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
124 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
125 result[0] = '\0';
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
126 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
127 else
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
128 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
129 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
130 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
131
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
132 return result;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
133 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
134
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
135
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
136 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
137 {
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
138 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
139 {
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
140 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
141 _OrthancPluginRegisterStorageArea callbacks_;
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
142 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
143
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
144 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
145 {
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
146 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
147 {
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
148 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
149 }
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
150 }
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
151
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
152 public:
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
153 PluginStorageArea(const _OrthancPluginRegisterStorageArea& callbacks,
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
154 PluginsErrorDictionary& errorDictionary) :
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
155 callbacks_(callbacks),
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
156 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
157 {
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 }
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
159
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 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
162 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
163 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
164 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
165 {
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 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
167 (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
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 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
170 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
171 errorDictionary_.LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
172 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
173 }
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 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
178 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 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
180 {
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 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
182 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
183
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 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
185 (&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
186
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 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
188 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
189 errorDictionary_.LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
190 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
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 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
194 {
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 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
196 }
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 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
198 {
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 Free(buffer);
1643
87c77b9b3679 provision for error codes in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
200 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
201 }
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
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 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
204 {
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 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
206 }
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
207
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 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
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
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 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
213 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
214 {
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 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
216 (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
217
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 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
219 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
220 errorDictionary_.LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
221 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
222 }
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
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 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
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 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
230 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
231 _OrthancPluginRegisterStorageArea callbacks_;
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
232 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
233
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 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
235 StorageAreaFactory(SharedLibrary& sharedLibrary,
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
236 const _OrthancPluginRegisterStorageArea& callbacks,
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
237 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
238 sharedLibrary_(sharedLibrary),
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
239 callbacks_(callbacks),
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
240 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
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 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
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 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
247 }
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
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
249 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
250 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
251 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
252 }
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
253 };
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
254
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
255
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
256 class OrthancPeers : public boost::noncopyable
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
257 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
258 private:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
259 std::vector<std::string> names_;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
260 std::vector<WebServiceParameters> parameters_;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
261
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
262 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
263 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
264 assert(names_.size() == parameters_.size());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
265 if (i >= names_.size())
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
266 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
267 throw OrthancException(ErrorCode_ParameterOutOfRange);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
268 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
269 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
270
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
271 public:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
272 OrthancPeers()
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
273 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
274 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
275
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
276 std::set<std::string> peers;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
277 lock.GetConfiguration().GetListOfOrthancPeers(peers);
2799
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 names_.reserve(peers.size());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
280 parameters_.reserve(peers.size());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
281
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
282 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
283 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
284 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
285 WebServiceParameters peer;
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
286 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
287 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
288 names_.push_back(*it);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
289 parameters_.push_back(peer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
290 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
291 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
292 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
293
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
294 size_t GetPeersCount() const
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 return names_.size();
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
297 }
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 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
300 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
301 CheckIndex(i);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
302 return names_[i];
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
303 }
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 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
306 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
307 CheckIndex(i);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
308 return parameters_[i];
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 };
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
311 }
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
312
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
313
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
314 class OrthancPlugins::PImpl
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
315 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
316 private:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
317 boost::mutex contextMutex_;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
318 ServerContext* context_;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
319
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
320
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
321 public:
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
322 class PluginHttpOutput : public boost::noncopyable
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
323 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
324 private:
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
325 HttpOutput& output_;
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
326 std::auto_ptr<std::string> errorDetails_;
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
327 bool logDetails_;
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
328
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
329 public:
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
330 PluginHttpOutput(HttpOutput& output) :
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
331 output_(output),
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
332 logDetails_(false)
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
333 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
334 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
335
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
336 HttpOutput& GetOutput()
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
337 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
338 return output_;
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
339 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
340
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
341 void SetErrorDetails(const std::string& details,
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
342 bool logDetails)
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
343 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
344 errorDetails_.reset(new std::string(details));
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
345 logDetails_ = logDetails;
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
346 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
347
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
348 bool HasErrorDetails() const
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
349 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
350 return errorDetails_.get() != NULL;
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
351 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
352
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
353 bool IsLogDetails() const
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
354 {
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
355 return logDetails_;
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
356 }
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
357
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
358 const std::string& GetErrorDetails() const
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
359 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
360 if (errorDetails_.get() == NULL)
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
361 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
362 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
363 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
364 else
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
365 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
366 return *errorDetails_;
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
367 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
368 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
369 };
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
370
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
371
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
372 class RestCallback : public boost::noncopyable
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
373 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
374 private:
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
375 boost::regex regex_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
376 OrthancPluginRestCallback callback_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
377 bool lock_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
378
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
379 OrthancPluginErrorCode InvokeInternal(PluginHttpOutput& output,
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
380 const std::string& flatUri,
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
381 const OrthancPluginHttpRequest& request)
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
382 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
383 return callback_(reinterpret_cast<OrthancPluginRestOutput*>(&output),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
384 flatUri.c_str(),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
385 &request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
386 }
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
387
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
388 public:
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
389 RestCallback(const char* regex,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
390 OrthancPluginRestCallback callback,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
391 bool lockRestCallbacks) :
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
392 regex_(regex),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
393 callback_(callback),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
394 lock_(lockRestCallbacks)
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
395 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
396 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
397
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
398 const boost::regex& GetRegularExpression() const
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
399 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
400 return regex_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
401 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
402
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
403 OrthancPluginErrorCode Invoke(boost::recursive_mutex& restCallbackMutex,
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
404 PluginHttpOutput& output,
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
405 const std::string& flatUri,
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
406 const OrthancPluginHttpRequest& request)
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
407 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
408 if (lock_)
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
409 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
410 boost::recursive_mutex::scoped_lock lock(restCallbackMutex);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
411 return InvokeInternal(output, flatUri, request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
412 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
413 else
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
414 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
415 return InvokeInternal(output, flatUri, request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
416 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
417 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
418 };
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
419
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
420
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
421 class ServerContextLock
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
422 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
423 private:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
424 boost::mutex::scoped_lock lock_;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
425 ServerContext* context_;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
426
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
427 public:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
428 ServerContextLock(PImpl& that) :
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
429 lock_(that.contextMutex_),
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
430 context_(that.context_)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
431 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
432 if (context_ == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
433 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
434 throw OrthancException(ErrorCode_DatabaseNotInitialized);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
435 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
436 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
437
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
438 ServerContext& GetContext()
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
439 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
440 assert(context_ != NULL);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
441 return *context_;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
442 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
443 };
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
444
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
445
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
446 void SetServerContext(ServerContext* context)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
447 {
2836
7133ad478eea fix Debian warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
448 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
449 context_ = context;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
450 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
451
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
452
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
453 typedef std::pair<std::string, _OrthancPluginProperty> Property;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
454 typedef std::list<RestCallback*> RestCallbacks;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
455 typedef std::list<OrthancPluginOnStoredInstanceCallback> OnStoredCallbacks;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
456 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
457 typedef std::list<OrthancPluginIncomingHttpRequestFilter> IncomingHttpRequestFilters;
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
458 typedef std::list<OrthancPluginIncomingHttpRequestFilter2> IncomingHttpRequestFilters2;
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
459 typedef std::list<OrthancPluginDecodeImageCallback> DecodeImageCallbacks;
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
460 typedef std::list<OrthancPluginJobsUnserializer> JobsUnserializers;
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
461 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
462
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
463 PluginsManager manager_;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
464
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
465 RestCallbacks restCallbacks_;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
466 OnStoredCallbacks onStoredCallbacks_;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
467 OnChangeCallbacks onChangeCallbacks_;
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
468 OrthancPluginFindCallback findCallback_;
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
469 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
470 DecodeImageCallbacks decodeImageCallbacks_;
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
471 JobsUnserializers jobsUnserializers_;
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
472 _OrthancPluginMoveCallback moveCallbacks_;
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
473 IncomingHttpRequestFilters incomingHttpRequestFilters_;
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
474 IncomingHttpRequestFilters2 incomingHttpRequestFilters2_;
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
475 std::auto_ptr<StorageAreaFactory> storageArea_;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
476
1466
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
477 boost::recursive_mutex restCallbackMutex_;
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
478 boost::recursive_mutex storedCallbackMutex_;
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
479 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
480 boost::mutex findCallbackMutex_;
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
481 boost::mutex worklistCallbackMutex_;
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
482 boost::mutex decodeImageCallbackMutex_;
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
483 boost::mutex jobsUnserializersMutex_;
1553
7c4b487b3b4a ensure mutual exclusion in InvokeService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
484 boost::recursive_mutex invokeServiceMutex_;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
485
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
486 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
487 int argc_;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
488 char** argv_;
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
489 std::auto_ptr<OrthancPluginDatabase> database_;
1644
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
490 PluginsErrorDictionary dictionary_;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
491
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
492 PImpl() :
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
493 context_(NULL),
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
494 findCallback_(NULL),
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
495 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
496 argc_(1),
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
497 argv_(NULL)
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
498 {
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
499 memset(&moveCallbacks_, 0, sizeof(moveCallbacks_));
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
500 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
501 };
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
502
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
503
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
504
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
505 class OrthancPlugins::WorklistHandler : public IWorklistRequestHandler
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
506 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
507 private:
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
508 OrthancPlugins& that_;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
509 std::auto_ptr<HierarchicalMatcher> matcher_;
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
510 std::auto_ptr<ParsedDicomFile> filtered_;
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
511 ParsedDicomFile* currentQuery_;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
512
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
513 void Reset()
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
514 {
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
515 matcher_.reset();
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
516 filtered_.reset();
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
517 currentQuery_ = NULL;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
518 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
519
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
520 public:
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
521 WorklistHandler(OrthancPlugins& that) : that_(that)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
522 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
523 Reset();
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
524 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
525
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
526 virtual void Handle(DicomFindAnswers& answers,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
527 ParsedDicomFile& query,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
528 const std::string& remoteIp,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
529 const std::string& remoteAet,
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
530 const std::string& calledAet,
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
531 ModalityManufacturer manufacturer)
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
532 {
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
533 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
534
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
535 {
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
536 PImpl::ServerContextLock lock(*that_.pimpl_);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
537 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
538
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
539 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
540 {
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
541 currentQuery_ = &query;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
542 }
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
543 else
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
544 {
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
545 Json::Value source, origin;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
546 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
547
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
548 OrthancFindRequestHandler::FormatOrigin
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
549 (origin, remoteIp, remoteAet, calledAet, manufacturer);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
550
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
551 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
552 call.PushJson(source);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
553 call.PushJson(origin);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
554
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
555 Json::Value target;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
556 call.ExecuteToJson(target, true);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
557
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
558 filtered_.reset(ParsedDicomFile::CreateFromJson(target, DicomFromJsonFlags_None));
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
559 currentQuery_ = filtered_.get();
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
560 }
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
561 }
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
562
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
563 matcher_.reset(new HierarchicalMatcher(*currentQuery_));
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
564
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
565 {
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
566 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
567
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
568 if (that_.pimpl_->worklistCallback_)
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
569 {
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
570 OrthancPluginErrorCode error = that_.pimpl_->worklistCallback_
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
571 (reinterpret_cast<OrthancPluginWorklistAnswers*>(&answers),
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
572 reinterpret_cast<const OrthancPluginWorklistQuery*>(this),
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
573 remoteAet.c_str(),
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
574 calledAet.c_str());
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
575
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
576 if (error != OrthancPluginErrorCode_Success)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
577 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
578 Reset();
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
579 that_.GetErrorDictionary().LogError(error, true);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
580 throw OrthancException(static_cast<ErrorCode>(error));
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
581 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
582 }
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
583
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
584 Reset();
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
585 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
586 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
587
1812
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
588 void GetDicomQuery(OrthancPluginMemoryBuffer& target) const
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
589 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
590 if (currentQuery_ == NULL)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
591 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
592 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
593 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
594
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
595 std::string dicom;
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
596 currentQuery_->SaveToMemoryBuffer(dicom);
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
597 CopyToMemoryBuffer(target, dicom.c_str(), dicom.size());
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
598 }
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
599
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
600 bool IsMatch(const void* dicom,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
601 size_t size) const
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
602 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
603 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
604 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
605 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
606 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
607
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
608 ParsedDicomFile f(dicom, size);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
609 return matcher_->Match(f);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
610 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
611
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
612 void AddAnswer(OrthancPluginWorklistAnswers* answers,
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
613 const void* dicom,
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
614 size_t size) const
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
615 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
616 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
617 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
618 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
619 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
620
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
621 ParsedDicomFile f(dicom, size);
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
622 std::auto_ptr<ParsedDicomFile> summary(matcher_->Extract(f));
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
623 reinterpret_cast<DicomFindAnswers*>(answers)->Add(*summary);
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
624 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
625 };
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
626
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
627
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
628 class OrthancPlugins::FindHandler : public IFindRequestHandler
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
629 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
630 private:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
631 OrthancPlugins& that_;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
632 std::auto_ptr<DicomArray> currentQuery_;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
633
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
634 void Reset()
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
635 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
636 currentQuery_.reset(NULL);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
637 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
638
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
639 public:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
640 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
641 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
642 Reset();
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
643 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
644
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
645 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
646 const DicomMap& input,
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
647 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
648 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
649 const std::string& remoteAet,
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
650 const std::string& calledAet,
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
651 ModalityManufacturer manufacturer)
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
652 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
653 DicomMap tmp;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
654 tmp.Assign(input);
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
655
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
656 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
657 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
658 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
659 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
660 {
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
661 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
662 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
663 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
664
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
665 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
666 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
667 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
668
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
669 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
670 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
671 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
672 (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
673 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
674 remoteAet.c_str(),
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
675 calledAet.c_str());
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
676
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
677 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
678 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
679 Reset();
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
680 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
681 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
682 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
683 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
684
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
685 Reset();
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
686 }
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
687 }
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
688
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
689 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
690 const _OrthancPluginFindOperation& operation) const
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
691 {
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
692 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
693 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
694 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
695 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
696
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
697 switch (service)
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
698 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
699 case _OrthancPluginService_GetFindQuerySize:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
700 *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
701 break;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
702
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
703 case _OrthancPluginService_GetFindQueryTag:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
704 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
705 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
706 *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
707 *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
708 break;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
709 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
710
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
711 case _OrthancPluginService_GetFindQueryTagName:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
712 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
713 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
714 *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
715 break;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
716 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
717
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
718 case _OrthancPluginService_GetFindQueryValue:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
719 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
720 *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
721 break;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
722 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
723
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
724 default:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
725 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
726 }
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
727 }
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
728 };
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
729
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
730
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
731
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
732 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
733 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
734 private:
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
735 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
736 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
737 private:
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
738 void* driver_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
739 unsigned int count_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
740 unsigned int pos_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
741 OrthancPluginApplyMove apply_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
742 OrthancPluginFreeMove free_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
743
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
744 public:
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
745 Driver(void* driver,
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
746 unsigned int count,
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
747 OrthancPluginApplyMove apply,
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
748 OrthancPluginFreeMove free) :
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
749 driver_(driver),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
750 count_(count),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
751 pos_(0),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
752 apply_(apply),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
753 free_(free)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
754 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
755 if (driver_ == NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
756 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
757 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
758 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
759 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
760
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
761 virtual ~Driver()
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
762 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
763 if (driver_ != NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
764 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
765 free_(driver_);
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
766 driver_ = NULL;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
767 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
768 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
769
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
770 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
771 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
772 return count_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
773 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
774
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
775 virtual Status DoNext()
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
776 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
777 if (pos_ >= count_)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
778 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
779 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
780 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
781 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
782 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
783 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
784 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
785 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
786 LOG(ERROR) << "Error while doing C-Move from plugin: "
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
787 << 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
788 return Status_Failure;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
789 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
790 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
791 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
792 pos_++;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
793 return Status_Success;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
794 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
795 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
796 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
797 };
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
798
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
799
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
800 _OrthancPluginMoveCallback params_;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
801
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
802
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
803 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
804 const DicomTag& tag)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
805 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
806 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
807 if (value != NULL &&
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
808 !value->IsBinary() &&
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
809 !value->IsNull())
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
810 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
811 return value->GetContent();
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
812 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
813 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
814 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
815 return std::string();
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
816 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
817 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
818
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
819
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
820
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
821 public:
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
822 MoveHandler(OrthancPlugins& that)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
823 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
824 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
825 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
826
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
827 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
828 params_.getMoveSize == NULL ||
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
829 params_.applyMove == NULL ||
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
830 params_.freeMove == NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
831 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
832 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
833 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
834 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
835
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
836 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
837 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
838 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
839 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
840 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
841 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
842 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
843 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
844 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
845 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
846 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
847 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
848 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
849
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
850 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
851
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
852 if (!levelString.empty())
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
853 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
854 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
855 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
856
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
857 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
858 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
859 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
860 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
861 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
862 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
863 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
864 calledAet.c_str(),
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
865 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
866 originatorId);
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
867
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
868 if (driver == NULL)
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
869 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
870 throw OrthancException(ErrorCode_Plugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
871 "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
872 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
873
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
874 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
875
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
876 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
877 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
878 };
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
879
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
880
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
881
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
882 OrthancPlugins::OrthancPlugins()
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
883 {
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
884 /* 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
885 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
886 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
887 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
888 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
889 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
890 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
891 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
892 sizeof(int32_t) != sizeof(OrthancPluginChangeType) ||
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
893 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
894 sizeof(int32_t) != sizeof(OrthancPluginCompressionType) ||
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
895 sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) ||
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
896 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) ||
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
897 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) ||
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
898 sizeof(int32_t) != sizeof(OrthancPluginCreateDicomFlags) ||
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
899 sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType) ||
1760
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1744
diff changeset
900 sizeof(int32_t) != sizeof(OrthancPluginIdentifierConstraint) ||
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
901 sizeof(int32_t) != sizeof(OrthancPluginInstanceOrigin) ||
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
902 sizeof(int32_t) != sizeof(OrthancPluginJobStepStatus) ||
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
903 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
904 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
905 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
906 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
907 static_cast<int>(OrthancPluginDicomToJsonFlags_ConvertBinaryToNull) != static_cast<int>(DicomToJsonFlags_ConvertBinaryToNull) ||
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
908 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
909 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
910 static_cast<int>(OrthancPluginCreateDicomFlags_GenerateIdentifiers) != static_cast<int>(DicomFromJsonFlags_GenerateIdentifiers))
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
911
1578
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
912 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
913 throw OrthancException(ErrorCode_Plugin);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
914 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
915
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
916 pimpl_.reset(new PImpl());
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
917 pimpl_->manager_.RegisterServiceProvider(*this);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
918 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
919
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
920
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
921 void OrthancPlugins::SetServerContext(ServerContext& context)
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
922 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
923 pimpl_->SetServerContext(&context);
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
924 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
925
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
926
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
927 void OrthancPlugins::ResetServerContext()
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
928 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
929 pimpl_->SetServerContext(NULL);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
930 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
931
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
932
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
933 OrthancPlugins::~OrthancPlugins()
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
934 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
935 for (PImpl::RestCallbacks::iterator it = pimpl_->restCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
936 it != pimpl_->restCallbacks_.end(); ++it)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
937 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
938 delete *it;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
939 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
940 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
941
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
942
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
943 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
944 std::vector<const char*>& values,
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
945 const IHttpHandler::Arguments& arguments)
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
946 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
947 keys.resize(arguments.size());
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
948 values.resize(arguments.size());
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
949
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
950 size_t pos = 0;
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
951 for (IHttpHandler::Arguments::const_iterator
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
952 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
953 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
954 keys[pos] = it->first.c_str();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
955 values[pos] = it->second.c_str();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
956 pos++;
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
957 }
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
958 }
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
959
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
960
1363
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
961 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
962 std::vector<const char*>& values,
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
963 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
964 {
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
965 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
966 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
967
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
968 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
969 {
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
970 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
971 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
972 }
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
973 }
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
974
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
975
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
976 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
977 RequestOrigin /*origin*/,
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
978 const char* /*remoteIp*/,
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
979 const char* /*username*/,
1329
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
980 HttpMethod method,
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
981 const UriComponents& uri,
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
982 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
983 const GetArguments& getArguments,
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1445
diff changeset
984 const char* bodyData,
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1445
diff changeset
985 size_t bodySize)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
986 {
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
987 std::string flatUri = Toolbox::FlattenUri(uri);
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
988 PImpl::RestCallback* callback = NULL;
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
989
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
990 std::vector<std::string> groups;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
991 std::vector<const char*> cgroups;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
992
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
993 // Loop over the callbacks registered by the plugins
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
994 bool found = false;
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
995 for (PImpl::RestCallbacks::const_iterator it = pimpl_->restCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
996 it != pimpl_->restCallbacks_.end() && !found; ++it)
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
997 {
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
998 // Check whether the regular expression associated to this
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
999 // callback matches the URI
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1000 boost::cmatch what;
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1001 if (boost::regex_match(flatUri.c_str(), what, (*it)->GetRegularExpression()))
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1002 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1003 callback = *it;
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1004
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1005 // Extract the value of the free parameters of the regular expression
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1006 if (what.size() > 1)
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1007 {
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1008 groups.resize(what.size() - 1);
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1009 cgroups.resize(what.size() - 1);
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1010 for (size_t i = 1; i < what.size(); i++)
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1011 {
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1012 groups[i - 1] = what[i];
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1013 cgroups[i - 1] = groups[i - 1].c_str();
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1014 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1015 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1016 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1017 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1018
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1019 if (callback == NULL)
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1020 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1021 // Callback not found
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1022 return false;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1023 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1024
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1025 LOG(INFO) << "Delegating HTTP request to plugin for URI: " << flatUri;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1026
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1027 std::vector<const char*> getKeys, getValues, headersKeys, headersValues;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1028
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1029 OrthancPluginHttpRequest request;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1030 memset(&request, 0, sizeof(OrthancPluginHttpRequest));
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1031
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1032 ArgumentsToPlugin(headersKeys, headersValues, headers);
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1033
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1034 switch (method)
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1035 {
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1036 case HttpMethod_Get:
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1037 request.method = OrthancPluginHttpMethod_Get;
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1038 ArgumentsToPlugin(getKeys, getValues, getArguments);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1039 break;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1040
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1041 case HttpMethod_Post:
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1042 request.method = OrthancPluginHttpMethod_Post;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1043 break;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1044
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1045 case HttpMethod_Delete:
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1046 request.method = OrthancPluginHttpMethod_Delete;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1047 break;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1048
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1049 case HttpMethod_Put:
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1050 request.method = OrthancPluginHttpMethod_Put;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1051 break;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1052
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1053 default:
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1054 throw OrthancException(ErrorCode_InternalError);
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1055 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1056
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1057
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
1058 request.groups = (cgroups.size() ? &cgroups[0] : NULL);
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
1059 request.groupsCount = cgroups.size();
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1060 request.getCount = getArguments.size();
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1445
diff changeset
1061 request.body = bodyData;
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1445
diff changeset
1062 request.bodySize = bodySize;
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1063 request.headersCount = headers.size();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1064
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1065 if (getArguments.size() > 0)
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1066 {
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1067 request.getKeys = &getKeys[0];
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1068 request.getValues = &getValues[0];
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1069 }
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1070
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1071 if (headers.size() > 0)
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1072 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1073 request.headersKeys = &headersKeys[0];
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1074 request.headersValues = &headersValues[0];
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
1075 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1076
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1077 assert(callback != NULL);
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1078
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1079 PImpl::PluginHttpOutput pluginOutput(output);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1080
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1081 OrthancPluginErrorCode error = callback->Invoke
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1082 (pimpl_->restCallbackMutex_, pluginOutput, flatUri, request);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1083
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
1084 if (error == OrthancPluginErrorCode_Success &&
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1085 output.IsWritingMultipart())
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1086 {
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1087 output.CloseMultipart();
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1088 }
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1089
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
1090 if (error == OrthancPluginErrorCode_Success)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1091 {
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
1092 return true;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1093 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1094 else
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1095 {
2135
cadfe0a2a393 fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
1096 GetErrorDictionary().LogError(error, false);
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1097
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1098 if (pluginOutput.HasErrorDetails())
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1099 {
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1100 throw OrthancException(static_cast<ErrorCode>(error),
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1101 pluginOutput.GetErrorDetails(),
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1102 pluginOutput.IsLogDetails());
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1103 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1104 else
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1105 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1106 throw OrthancException(static_cast<ErrorCode>(error));
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1107 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1108 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1109 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1110
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1111
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
1112 void OrthancPlugins::SignalStoredInstance(const std::string& instanceId,
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
1113 DicomInstanceToStore& instance,
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
1114 const Json::Value& simplifiedTags)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1115 {
1466
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
1116 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
1117
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1118 for (PImpl::OnStoredCallbacks::const_iterator
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1119 callback = pimpl_->onStoredCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1120 callback != pimpl_->onStoredCallbacks_.end(); ++callback)
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1121 {
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
1122 OrthancPluginErrorCode error = (*callback)
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
1123 (reinterpret_cast<OrthancPluginDicomInstance*>(&instance),
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
1124 instanceId.c_str());
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
1125
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
1126 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
1127 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
1128 GetErrorDictionary().LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1129 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
1130 }
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1131 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1132 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1133
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1134
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1135
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1136 void OrthancPlugins::SignalChangeInternal(OrthancPluginChangeType changeType,
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1137 OrthancPluginResourceType resourceType,
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1138 const char* resource)
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1139 {
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
1140 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
1141
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
1142 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
1143 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
1144 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
1145 {
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1146 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
1147
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
1148 if (error != OrthancPluginErrorCode_Success)
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
1149 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
1150 GetErrorDictionary().LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
1151 throw OrthancException(static_cast<ErrorCode>(error));
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
1152 }
1178
c71d25e6a63c improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1177
diff changeset
1153 }
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1154 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1155
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1156
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1157
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1158 void OrthancPlugins::SignalChange(const ServerIndexChange& change)
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1159 {
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1160 SignalChangeInternal(Plugins::Convert(change.GetChangeType()),
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1161 Plugins::Convert(change.GetResourceType()),
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1162 change.GetPublicId().c_str());
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1163 }
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1164
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1165
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
1166
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1167 void OrthancPlugins::RegisterRestCallback(const void* parameters,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1168 bool lock)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1169 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1170 const _OrthancPluginRestCallback& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1171 *reinterpret_cast<const _OrthancPluginRestCallback*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1172
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1173 LOG(INFO) << "Plugin has registered a REST callback "
2820
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
1174 << (lock ? "with" : "without")
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1175 << " mutual exclusion on: "
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1176 << p.pathRegularExpression;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1177
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1178 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
1179 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1180
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1181
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1182
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1183 void OrthancPlugins::RegisterOnStoredInstanceCallback(const void* parameters)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1184 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1185 const _OrthancPluginOnStoredInstanceCallback& p =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1186 *reinterpret_cast<const _OrthancPluginOnStoredInstanceCallback*>(parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1187
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1188 LOG(INFO) << "Plugin has registered an OnStoredInstance callback";
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1189 pimpl_->onStoredCallbacks_.push_back(p.callback);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1190 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1191
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1192
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1193 void OrthancPlugins::RegisterOnChangeCallback(const void* parameters)
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1194 {
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1195 const _OrthancPluginOnChangeCallback& p =
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1196 *reinterpret_cast<const _OrthancPluginOnChangeCallback*>(parameters);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1197
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1198 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
1199 pimpl_->onChangeCallbacks_.push_back(p.callback);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1200 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1201
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1202
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1203 void OrthancPlugins::RegisterWorklistCallback(const void* parameters)
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1204 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1205 const _OrthancPluginWorklistCallback& p =
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1206 *reinterpret_cast<const _OrthancPluginWorklistCallback*>(parameters);
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1207
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1208 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
1209
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1210 if (pimpl_->worklistCallback_ != NULL)
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1211 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1212 throw OrthancException(ErrorCode_Plugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1213 "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
1214 }
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1215 else
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1216 {
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1217 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
1218 pimpl_->worklistCallback_ = p.callback;
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
1219 }
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1220 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1221
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1222
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1223 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
1224 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1225 const _OrthancPluginFindCallback& p =
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1226 *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
1227
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1228 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
1229
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1230 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
1231 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1232 throw OrthancException(ErrorCode_Plugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1233 "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
1234 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1235 else
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1236 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1237 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
1238 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
1239 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1240 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1241
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
1242
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1243 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
1244 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1245 // invokeServiceMutex_ is assumed to be locked
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1246
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1247 const _OrthancPluginMoveCallback& p =
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1248 *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
1249
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1250 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
1251 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1252 throw OrthancException(ErrorCode_Plugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
1253 "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
1254 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1255 else
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 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
1258 pimpl_->moveCallbacks_ = p;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1259 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1260 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1261
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
1262
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1263 void OrthancPlugins::RegisterDecodeImageCallback(const void* parameters)
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1264 {
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1265 const _OrthancPluginDecodeImageCallback& p =
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1266 *reinterpret_cast<const _OrthancPluginDecodeImageCallback*>(parameters);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1267
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1268 boost::mutex::scoped_lock lock(pimpl_->decodeImageCallbackMutex_);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1269
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
1270 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
1271 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
1272 << pimpl_->decodeImageCallbacks_.size() << " decoder(s) now active)";
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1273 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1274
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1275
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1276 void OrthancPlugins::RegisterJobsUnserializer(const void* parameters)
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1277 {
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1278 const _OrthancPluginJobsUnserializer& p =
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1279 *reinterpret_cast<const _OrthancPluginJobsUnserializer*>(parameters);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1280
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1281 boost::mutex::scoped_lock lock(pimpl_->jobsUnserializersMutex_);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1282
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1283 pimpl_->jobsUnserializers_.push_back(p.unserializer);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1284 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
1285 << pimpl_->jobsUnserializers_.size() << " unserializer(s) now active)";
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1286 }
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1287
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1288
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
1289 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
1290 {
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
1291 const _OrthancPluginIncomingHttpRequestFilter& p =
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
1292 *reinterpret_cast<const _OrthancPluginIncomingHttpRequestFilter*>(parameters);
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
1293
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
1294 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
1295 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
1296 }
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1297
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1298
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
1299 void OrthancPlugins::RegisterIncomingHttpRequestFilter2(const void* parameters)
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
1300 {
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
1301 const _OrthancPluginIncomingHttpRequestFilter2& p =
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
1302 *reinterpret_cast<const _OrthancPluginIncomingHttpRequestFilter2*>(parameters);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
1303
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
1304 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
1305 pimpl_->incomingHttpRequestFilters2_.push_back(p.callback);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
1306 }
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
1307
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
1308
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1309 void OrthancPlugins::AnswerBuffer(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1310 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1311 const _OrthancPluginAnswerBuffer& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1312 *reinterpret_cast<const _OrthancPluginAnswerBuffer*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1313
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1314 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
1315 translatedOutput.SetContentType(p.mimeType);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1316 translatedOutput.Answer(p.answer, p.answerSize);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1317 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1318
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1319
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1320 void OrthancPlugins::Redirect(const void* parameters)
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1321 {
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1322 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1323 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1324
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1325 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
1326 translatedOutput.Redirect(p.argument);
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1327 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1328
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1329
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1330 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
1331 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1332 const _OrthancPluginSendHttpStatusCode& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1333 *reinterpret_cast<const _OrthancPluginSendHttpStatusCode*>(parameters);
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1334
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1335 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
1336 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
1337 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1338
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1339
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1340 void OrthancPlugins::SendHttpStatus(const void* parameters)
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1341 {
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1342 const _OrthancPluginSendHttpStatus& p =
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1343 *reinterpret_cast<const _OrthancPluginSendHttpStatus*>(parameters);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1344
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1345 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1346 HttpStatus status = static_cast<HttpStatus>(p.status);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1347
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1348 if (p.bodySize > 0 && p.body != NULL)
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1349 {
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1350 translatedOutput.SendStatus(status, p.body, p.bodySize);
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1351 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1352 else
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1353 {
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1354 translatedOutput.SendStatus(status);
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1355 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1356 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1357
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1358
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1359 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
1360 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1361 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1362 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1363
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1364 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
1365 translatedOutput.SendUnauthorized(p.argument);
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1366 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1367
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1368
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1369 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
1370 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1371 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1372 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1373
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1374 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
1375 translatedOutput.SendMethodNotAllowed(p.argument);
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1376 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1377
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1378
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1379 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
1380 {
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1381 const _OrthancPluginSetHttpHeader& p =
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1382 *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
1383
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1384 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
1385 translatedOutput.SetCookie(p.key, p.value);
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1386 }
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1387
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1388
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1389 void OrthancPlugins::SetHttpHeader(const void* parameters)
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1390 {
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1391 const _OrthancPluginSetHttpHeader& p =
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1392 *reinterpret_cast<const _OrthancPluginSetHttpHeader*>(parameters);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1393
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1394 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
1395 translatedOutput.AddHeader(p.key, p.value);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1396 }
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1397
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1398
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1399 void OrthancPlugins::SetHttpErrorDetails(const void* parameters)
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1400 {
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1401 const _OrthancPluginSetHttpErrorDetails& p =
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1402 *reinterpret_cast<const _OrthancPluginSetHttpErrorDetails*>(parameters);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1403
2960
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1404 PImpl::PluginHttpOutput* output =
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1405 reinterpret_cast<PImpl::PluginHttpOutput*>(p.output);
74a5a7fd6e0e log flag to OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2957
diff changeset
1406 output->SetErrorDetails(p.details, p.log);
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1407 }
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1408
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1409
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1410 void OrthancPlugins::CompressAndAnswerPngImage(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1411 {
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1412 // Bridge for backward compatibility with Orthanc <= 0.9.3
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1413 const _OrthancPluginCompressAndAnswerPngImage& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1414 *reinterpret_cast<const _OrthancPluginCompressAndAnswerPngImage*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1415
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1416 _OrthancPluginCompressAndAnswerImage p2;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1417 p2.output = p.output;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1418 p2.imageFormat = OrthancPluginImageFormat_Png;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1419 p2.pixelFormat = p.format;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1420 p2.width = p.width;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1421 p2.height = p.height;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1422 p2.pitch = p.height;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1423 p2.buffer = p.buffer;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1424 p2.quality = 0;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1425
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1426 CompressAndAnswerImage(&p2);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1427 }
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1428
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1429
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1430 void OrthancPlugins::CompressAndAnswerImage(const void* parameters)
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1431 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1432 const _OrthancPluginCompressAndAnswerImage& p =
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1433 *reinterpret_cast<const _OrthancPluginCompressAndAnswerImage*>(parameters);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1434
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1435 HttpOutput& translatedOutput = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1436
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1437 ImageAccessor accessor;
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
1438 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
1439
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1440 std::string compressed;
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1441
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1442 switch (p.imageFormat)
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1443 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1444 case OrthancPluginImageFormat_Png:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1445 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1446 PngWriter writer;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1447 writer.WriteToMemory(compressed, accessor);
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1448 translatedOutput.SetContentType(MimeType_Png);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1449 break;
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1450 }
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1451
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1452 case OrthancPluginImageFormat_Jpeg:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1453 {
1603
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
1454 JpegWriter writer;
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
1455 writer.SetQuality(p.quality);
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
1456 writer.WriteToMemory(compressed, accessor);
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1457 translatedOutput.SetContentType(MimeType_Jpeg);
1603
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
1458 break;
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1459 }
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1460
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1461 default:
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1462 throw OrthancException(ErrorCode_ParameterOutOfRange);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1463 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1464
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1465 translatedOutput.Answer(compressed);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1466 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1467
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1468
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1469 void OrthancPlugins::GetDicomForInstance(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1470 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1471 const _OrthancPluginGetDicomForInstance& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1472 *reinterpret_cast<const _OrthancPluginGetDicomForInstance*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1473
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1474 std::string dicom;
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
1475
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1476 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1477 PImpl::ServerContextLock lock(*pimpl_);
2124
2b1520efa282 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
1478 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
1479 }
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
1480
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1481 CopyToMemoryBuffer(*p.target, dicom);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1482 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1483
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1484
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1485 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
1486 bool afterPlugins)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1487 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1488 const _OrthancPluginRestApiGet& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1489 *reinterpret_cast<const _OrthancPluginRestApiGet*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1490
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1491 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
1492 << (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
1493
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1494 IHttpHandler* handler;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1495
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1496 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1497 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1498 handler = &lock.GetContext().GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1499 }
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1500
1445
d26c8a93d05a refactoring: SimpleGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
1501 std::string result;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1502 if (HttpToolbox::SimpleGet(result, *handler, RequestOrigin_Plugins, p.uri))
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1503 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1504 CopyToMemoryBuffer(*p.target, result);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1505 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1506 else
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1507 {
1984
9f09a20e41e2 corrected error code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1962
diff changeset
1508 throw OrthancException(ErrorCode_UnknownResource);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1509 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1510 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1511
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1512
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1513 void OrthancPlugins::RestApiGet2(const void* parameters)
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1514 {
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1515 const _OrthancPluginRestApiGet2& p =
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1516 *reinterpret_cast<const _OrthancPluginRestApiGet2*>(parameters);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1517
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1518 LOG(INFO) << "Plugin making REST GET call on URI " << p.uri
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1519 << (p.afterPlugins ? " (after plugins)" : " (built-in API)");
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1520
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1521 IHttpHandler::Arguments headers;
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1522
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1523 for (uint32_t i = 0; i < p.headersCount; i++)
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1524 {
1918
e8c2f993f6b3 fix case for HTTP headers keys in OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1916
diff changeset
1525 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
1526 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
1527 headers[name] = p.headersValues[i];
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1528 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1529
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1530 IHttpHandler* handler;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1531
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1532 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1533 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1534 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
1535 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1536
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1537 std::string result;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1538 if (HttpToolbox::SimpleGet(result, *handler, RequestOrigin_Plugins, p.uri, headers))
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1539 {
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1540 CopyToMemoryBuffer(*p.target, result);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1541 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1542 else
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1543 {
1984
9f09a20e41e2 corrected error code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1962
diff changeset
1544 throw OrthancException(ErrorCode_UnknownResource);
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1545 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1546 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1547
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1548
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1549 void OrthancPlugins::RestApiPostPut(bool isPost,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1550 const void* parameters,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1551 bool afterPlugins)
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1552 {
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1553 const _OrthancPluginRestApiPostPut& p =
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1554 *reinterpret_cast<const _OrthancPluginRestApiPostPut*>(parameters);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1555
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
1556 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
1557 << " 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
1558
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1559 IHttpHandler* handler;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1560
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1561 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1562 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1563 handler = &lock.GetContext().GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1564 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1565
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1566 std::string result;
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
1567 if (isPost ?
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1568 HttpToolbox::SimplePost(result, *handler, RequestOrigin_Plugins, p.uri, p.body, p.bodySize) :
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1569 HttpToolbox::SimplePut (result, *handler, RequestOrigin_Plugins, p.uri, p.body, p.bodySize))
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1570 {
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1571 CopyToMemoryBuffer(*p.target, result);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1572 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1573 else
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1574 {
1984
9f09a20e41e2 corrected error code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1962
diff changeset
1575 throw OrthancException(ErrorCode_UnknownResource);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1576 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1577 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1578
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1579
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1580 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
1581 bool afterPlugins)
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1582 {
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
1583 const char* uri = reinterpret_cast<const char*>(parameters);
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
1584 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
1585 << (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
1586
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1587 IHttpHandler* handler;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1588
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1589 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1590 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1591 handler = &lock.GetContext().GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1592 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1593
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1594 if (!HttpToolbox::SimpleDelete(*handler, RequestOrigin_Plugins, uri))
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1595 {
1984
9f09a20e41e2 corrected error code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1962
diff changeset
1596 throw OrthancException(ErrorCode_UnknownResource);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1597 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1598 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1599
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1600
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1601 void OrthancPlugins::LookupResource(_OrthancPluginService service,
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1602 const void* parameters)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1603 {
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1604 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
1605 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1606
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1607 /**
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1608 * 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
1609 * the Orthanc database. It reflects the
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1610 * "CandidateResources::ApplyFilter()" method of the
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1611 * "OrthancFindRequestHandler" class.
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1612 **/
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1613
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1614 DicomTag tag(0, 0);
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1615 ResourceType level;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1616 switch (service)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1617 {
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1618 case _OrthancPluginService_LookupPatient:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1619 tag = DICOM_TAG_PATIENT_ID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1620 level = ResourceType_Patient;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1621 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1622
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1623 case _OrthancPluginService_LookupStudy:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1624 tag = DICOM_TAG_STUDY_INSTANCE_UID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1625 level = ResourceType_Study;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1626 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1627
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1628 case _OrthancPluginService_LookupStudyWithAccessionNumber:
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1629 tag = DICOM_TAG_ACCESSION_NUMBER;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1630 level = ResourceType_Study;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1631 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1632
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1633 case _OrthancPluginService_LookupSeries:
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1634 tag = DICOM_TAG_SERIES_INSTANCE_UID;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1635 level = ResourceType_Series;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1636 break;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1637
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1638 case _OrthancPluginService_LookupInstance:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1639 tag = DICOM_TAG_SOP_INSTANCE_UID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1640 level = ResourceType_Instance;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1641 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1642
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1643 default:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1644 throw OrthancException(ErrorCode_InternalError);
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1645 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1646
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1647 std::list<std::string> result;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1648
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1649 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1650 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
1651 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
1652 }
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1653
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1654 if (result.size() == 1)
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1655 {
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1656 *p.result = CopyString(result.front());
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1657 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1658 else
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1659 {
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1660 throw OrthancException(ErrorCode_UnknownResource);
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1661 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1662 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1663
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1664
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1665 static void AccessInstanceMetadataInternal(bool checkExistence,
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1666 const _OrthancPluginAccessDicomInstance& params,
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1667 const DicomInstanceToStore& instance)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1668 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1669 MetadataType metadata;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1670
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1671 try
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1672 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1673 metadata = StringToMetadata(params.key);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1674 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1675 catch (OrthancException&)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1676 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1677 // Unknown metadata
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1678 if (checkExistence)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1679 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1680 *params.resultInt64 = -1;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1681 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1682 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1683 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1684 *params.resultString = NULL;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1685 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1686
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1687 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1688 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1689
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1690 ServerIndex::MetadataMap::const_iterator it =
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1691 instance.GetMetadata().find(std::make_pair(ResourceType_Instance, metadata));
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1692
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1693 if (checkExistence)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1694 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1695 if (it != instance.GetMetadata().end())
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1696 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1697 *params.resultInt64 = 1;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1698 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1699 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1700 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1701 *params.resultInt64 = 0;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1702 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1703 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1704 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1705 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1706 if (it != instance.GetMetadata().end())
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1707 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1708 *params.resultString = it->second.c_str();
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1709 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1710 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1711 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1712 // Error: Missing metadata
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1713 *params.resultString = NULL;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1714 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1715 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1716 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1717
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1718
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1719 static void AccessDicomInstance(_OrthancPluginService service,
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1720 const void* parameters)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1721 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1722 const _OrthancPluginAccessDicomInstance& p =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1723 *reinterpret_cast<const _OrthancPluginAccessDicomInstance*>(parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1724
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1725 DicomInstanceToStore& instance =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1726 *reinterpret_cast<DicomInstanceToStore*>(p.instance);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1727
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1728 switch (service)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1729 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1730 case _OrthancPluginService_GetInstanceRemoteAet:
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
1731 *p.resultString = instance.GetOrigin().GetRemoteAetC();
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1732 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1733
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1734 case _OrthancPluginService_GetInstanceSize:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1735 *p.resultInt64 = instance.GetBufferSize();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1736 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1737
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1738 case _OrthancPluginService_GetInstanceData:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1739 *p.resultString = instance.GetBufferData();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1740 return;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1741
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1742 case _OrthancPluginService_HasInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1743 AccessInstanceMetadataInternal(true, p, instance);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1744 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1745
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1746 case _OrthancPluginService_GetInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1747 AccessInstanceMetadataInternal(false, p, instance);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1748 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1749
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1750 case _OrthancPluginService_GetInstanceJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1751 case _OrthancPluginService_GetInstanceSimplifiedJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1752 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1753 Json::StyledWriter writer;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1754 std::string s;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1755
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1756 if (service == _OrthancPluginService_GetInstanceJson)
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1757 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1758 s = writer.write(instance.GetJson());
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1759 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1760 else
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1761 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1762 Json::Value simplified;
2120
4b02ec79728a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
1763 ServerToolbox::SimplifyTags(simplified, instance.GetJson(), DicomToJsonFormat_Human);
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1764 s = writer.write(simplified);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1765 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1766
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1767 *p.resultStringToFree = CopyString(s);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1768 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1769 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1770
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
1771 case _OrthancPluginService_GetInstanceOrigin: // New in Orthanc 0.9.5
2640
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
1772 *p.resultOrigin = Plugins::Convert(instance.GetOrigin().GetRequestOrigin());
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
1773 return;
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
1774
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1775 default:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1776 throw OrthancException(ErrorCode_InternalError);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1777 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1778 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1779
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1780
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1781 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
1782 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1783 const _OrthancPluginBufferCompression& p =
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1784 *reinterpret_cast<const _OrthancPluginBufferCompression*>(parameters);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1785
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1786 std::string result;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1787
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1788 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1789 std::auto_ptr<DeflateBaseCompressor> compressor;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1790
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1791 switch (p.compression)
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1792 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1793 case OrthancPluginCompressionType_Zlib:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1794 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1795 compressor.reset(new ZlibCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1796 compressor->SetPrefixWithUncompressedSize(false);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1797 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1798 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1799
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1800 case OrthancPluginCompressionType_ZlibWithSize:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1801 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1802 compressor.reset(new ZlibCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1803 compressor->SetPrefixWithUncompressedSize(true);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1804 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1805 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1806
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1807 case OrthancPluginCompressionType_Gzip:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1808 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1809 compressor.reset(new GzipCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1810 compressor->SetPrefixWithUncompressedSize(false);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1811 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1812 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1813
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1814 case OrthancPluginCompressionType_GzipWithSize:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1815 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1816 compressor.reset(new GzipCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1817 compressor->SetPrefixWithUncompressedSize(true);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1818 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1819 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1820
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1821 default:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1822 throw OrthancException(ErrorCode_ParameterOutOfRange);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1823 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1824
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1825 if (p.uncompress)
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1826 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1827 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
1828 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1829 else
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1830 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1831 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
1832 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1833 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1834
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1835 CopyToMemoryBuffer(*p.target, result);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1836 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1837
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1838
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1839 static OrthancPluginImage* ReturnImage(std::auto_ptr<ImageAccessor>& image)
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1840 {
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1841 // 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
1842 // 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
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1844 if (image->IsReadOnly())
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1845 {
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2045
diff changeset
1846 std::auto_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
1847 ImageProcessing::Copy(*copy, *image);
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1848 image.reset(NULL);
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1849 return reinterpret_cast<OrthancPluginImage*>(copy.release());
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1850 }
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1851 else
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1852 {
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1853 return reinterpret_cast<OrthancPluginImage*>(image.release());
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1854 }
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1855 }
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1856
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1857
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1858 void OrthancPlugins::UncompressImage(const void* parameters)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1859 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1860 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
1861
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1862 std::auto_ptr<ImageAccessor> image;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1863
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1864 switch (p.format)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1865 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1866 case OrthancPluginImageFormat_Png:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1867 {
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1868 image.reset(new PngReader);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1869 reinterpret_cast<PngReader&>(*image).ReadFromMemory(p.data, p.size);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1870 break;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1871 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1872
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1873 case OrthancPluginImageFormat_Jpeg:
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1874 {
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1875 image.reset(new JpegReader);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1876 reinterpret_cast<JpegReader&>(*image).ReadFromMemory(p.data, p.size);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1877 break;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1878 }
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1879
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
1880 case OrthancPluginImageFormat_Dicom:
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
1881 {
1902
8b0ee8d5e6d0 Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1882 image.reset(Decode(p.data, p.size, 0));
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
1883 break;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
1884 }
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
1885
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1886 default:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1887 throw OrthancException(ErrorCode_ParameterOutOfRange);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1888 }
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1889
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
1890 *(p.target) = ReturnImage(image);
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1891 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1892
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1893
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1894 void OrthancPlugins::CompressImage(const void* parameters)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1895 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1896 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
1897
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1898 std::string compressed;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1899
1916
5bcf721bde4f IImageWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1906
diff changeset
1900 ImageAccessor accessor;
5bcf721bde4f IImageWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1906
diff changeset
1901 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
1902
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1903 switch (p.imageFormat)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1904 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1905 case OrthancPluginImageFormat_Png:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1906 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1907 PngWriter writer;
1916
5bcf721bde4f IImageWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1906
diff changeset
1908 writer.WriteToMemory(compressed, accessor);
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1909 break;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1910 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1911
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1912 case OrthancPluginImageFormat_Jpeg:
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1913 {
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1914 JpegWriter writer;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1915 writer.SetQuality(p.quality);
1916
5bcf721bde4f IImageWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1906
diff changeset
1916 writer.WriteToMemory(compressed, accessor);
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1917 break;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1918 }
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1919
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1920 default:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1921 throw OrthancException(ErrorCode_ParameterOutOfRange);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1922 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1923
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1924 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
1925 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1926
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1927
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1928 void OrthancPlugins::CallHttpClient(const void* parameters)
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1929 {
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1930 const _OrthancPluginCallHttpClient& p = *reinterpret_cast<const _OrthancPluginCallHttpClient*>(parameters);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1931
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1932 HttpClient client;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1933 client.SetUrl(p.url);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1934
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1935 if (p.username != NULL &&
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1936 p.password != NULL)
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1937 {
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1938 client.SetCredentials(p.username, p.password);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1939 }
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1940
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1941 switch (p.method)
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1942 {
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1943 case OrthancPluginHttpMethod_Get:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1944 client.SetMethod(HttpMethod_Get);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1945 break;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1946
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1947 case OrthancPluginHttpMethod_Post:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1948 client.SetMethod(HttpMethod_Post);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1949 client.GetBody().assign(p.body, p.bodySize);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1950 break;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1951
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1952 case OrthancPluginHttpMethod_Put:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1953 client.SetMethod(HttpMethod_Put);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1954 client.GetBody().assign(p.body, p.bodySize);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1955 break;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1956
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1957 case OrthancPluginHttpMethod_Delete:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1958 client.SetMethod(HttpMethod_Delete);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1959 break;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1960
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1961 default:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1962 throw OrthancException(ErrorCode_ParameterOutOfRange);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1963 }
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1964
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1965 std::string s;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1966 client.ApplyAndThrowException(s);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1967
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1968 if (p.method != OrthancPluginHttpMethod_Delete)
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1969 {
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1970 CopyToMemoryBuffer(*p.target, s);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1971 }
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1972 }
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1973
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1974
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1975 void OrthancPlugins::CallHttpClient2(const void* parameters)
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1976 {
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1977 const _OrthancPluginCallHttpClient2& p = *reinterpret_cast<const _OrthancPluginCallHttpClient2*>(parameters);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1978
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1979 HttpClient client;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1980 client.SetUrl(p.url);
2045
21a8ca9ad928 HttpClient::SetConvertHeadersToLowerCase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2041
diff changeset
1981 client.SetConvertHeadersToLowerCase(false);
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1982
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1983 if (p.timeout != 0)
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1984 {
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1985 client.SetTimeout(p.timeout);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1986 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1988 if (p.username != NULL &&
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1989 p.password != NULL)
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1990 {
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1991 client.SetCredentials(p.username, p.password);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1992 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
1993
2019
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
1994 if (p.certificateFile != NULL)
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
1995 {
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
1996 std::string certificate(p.certificateFile);
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
1997 std::string key, password;
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
1998
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
1999 if (p.certificateKeyFile)
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
2000 {
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
2001 key.assign(p.certificateKeyFile);
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
2002 }
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
2003
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
2004 if (p.certificateKeyPassword)
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
2005 {
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
2006 password.assign(p.certificateKeyPassword);
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
2007 }
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
2008
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
2009 client.SetClientCertificate(certificate, key, password);
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
2010 }
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2012
diff changeset
2011
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2012 client.SetPkcs11Enabled(p.pkcs11 ? true : false);
2022
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2019
diff changeset
2013
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2014 for (uint32_t i = 0; i < p.headersCount; i++)
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2015 {
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2016 if (p.headersKeys[i] == NULL ||
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2017 p.headersValues[i] == NULL)
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2018 {
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2019 throw OrthancException(ErrorCode_NullPointer);
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2020 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2021
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2022 client.AddHeader(p.headersKeys[i], p.headersValues[i]);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2023 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2024
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2025 switch (p.method)
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2026 {
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2027 case OrthancPluginHttpMethod_Get:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2028 client.SetMethod(HttpMethod_Get);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2029 break;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2030
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2031 case OrthancPluginHttpMethod_Post:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2032 client.SetMethod(HttpMethod_Post);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2033 client.GetBody().assign(p.body, p.bodySize);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2034 break;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2035
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2036 case OrthancPluginHttpMethod_Put:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2037 client.SetMethod(HttpMethod_Put);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2038 client.GetBody().assign(p.body, p.bodySize);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2039 break;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2040
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2041 case OrthancPluginHttpMethod_Delete:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2042 client.SetMethod(HttpMethod_Delete);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2043 break;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2044
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2045 default:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2046 throw OrthancException(ErrorCode_ParameterOutOfRange);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2047 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2048
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2049 std::string body;
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2050 HttpClient::HttpHeaders headers;
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2051
2787
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
2052 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
2053
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2054 // The HTTP request has succeeded
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2055 *p.httpStatus = static_cast<uint16_t>(client.GetLastStatus());
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2056
2787
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
2057 if (!success)
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
2058 {
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
2059 HttpClient::ThrowException(client.GetLastStatus());
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
2060 }
ad2c32082653 Fix OrthancPluginHttpClient() to return the HTTP status on errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
2061
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2062 // Copy the HTTP headers of the answer, if the plugin requested them
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2063 if (p.answerHeaders != NULL)
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2064 {
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2065 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
2066
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2067 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
2068 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
2069 {
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2070 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
2071 }
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2072
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2073 std::string s = json.toStyledString();
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2074 CopyToMemoryBuffer(*p.answerHeaders, s);
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2075 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2076
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2077 // Copy the body of the answer if it makes sense
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2078 if (p.method != OrthancPluginHttpMethod_Delete)
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2079 {
2041
9f61ca1e3eb3 OrthancPluginHttpClient can return the HTTP headers of the answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2028
diff changeset
2080 CopyToMemoryBuffer(*p.answerBody, body);
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2081 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2082 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2083
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2084
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2085 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
2086 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2087 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
2088 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
2089
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2090 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
2091 client.SetConvertHeadersToLowerCase(false);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2092
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2093 if (p.timeout != 0)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2094 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2095 client.SetTimeout(p.timeout);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2096 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2097
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2098 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
2099 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2100 if (p.additionalHeadersKeys[i] == NULL ||
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2101 p.additionalHeadersValues[i] == NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2102 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2103 throw OrthancException(ErrorCode_NullPointer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2104 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2105
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2106 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
2107 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2108
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2109 switch (p.method)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2110 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2111 case OrthancPluginHttpMethod_Get:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2112 client.SetMethod(HttpMethod_Get);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2113 break;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2114
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2115 case OrthancPluginHttpMethod_Post:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2116 client.SetMethod(HttpMethod_Post);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2117 client.GetBody().assign(p.body, p.bodySize);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2118 break;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2119
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2120 case OrthancPluginHttpMethod_Put:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2121 client.SetMethod(HttpMethod_Put);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2122 client.GetBody().assign(p.body, p.bodySize);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2123 break;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2124
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2125 case OrthancPluginHttpMethod_Delete:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2126 client.SetMethod(HttpMethod_Delete);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2127 break;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2128
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2129 default:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2130 throw OrthancException(ErrorCode_ParameterOutOfRange);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2131 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2132
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2133 std::string body;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2134 HttpClient::HttpHeaders headers;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2135
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2136 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
2137
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2138 // The HTTP request has succeeded
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2139 *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
2140
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2141 if (!success)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2142 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2143 HttpClient::ThrowException(client.GetLastStatus());
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2144 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2145
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2146 // 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
2147 if (p.answerHeaders != NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2148 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2149 Json::Value json = Json::objectValue;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2150
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2151 for (HttpClient::HttpHeaders::const_iterator
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2152 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
2153 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2154 json[it->first] = it->second;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2155 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2156
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2157 std::string s = json.toStyledString();
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2158 CopyToMemoryBuffer(*p.answerHeaders, s);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2159 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2160
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2161 // 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
2162 if (p.method != OrthancPluginHttpMethod_Delete)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2163 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2164 CopyToMemoryBuffer(*p.answerBody, body);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2165 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2166 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2167
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2168
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2169 void OrthancPlugins::ConvertPixelFormat(const void* parameters)
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2170 {
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2171 const _OrthancPluginConvertPixelFormat& p = *reinterpret_cast<const _OrthancPluginConvertPixelFormat*>(parameters);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2172 const ImageAccessor& source = *reinterpret_cast<const ImageAccessor*>(p.source);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2173
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2045
diff changeset
2174 std::auto_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
2175 ImageProcessing::Convert(*target, source);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2176
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2177 *(p.target) = ReturnImage(target);
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2178 }
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2179
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2180
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2181
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2182 void OrthancPlugins::GetFontInfo(const void* parameters)
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2183 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2184 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
2185
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2186 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2187 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2188
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2189 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
2190
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2191 if (p.name != NULL)
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2192 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2193 *(p.name) = font.GetName().c_str();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2194 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2195 else if (p.size != NULL)
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2196 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2197 *(p.size) = font.GetSize();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2198 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2199 else
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2200 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2201 throw OrthancException(ErrorCode_InternalError);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2202 }
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2203 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2204 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2205
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2206
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2207 void OrthancPlugins::DrawText(const void* parameters)
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2208 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2209 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
2210
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2211 ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2212
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2213 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2214 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2215 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
2216 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
2217 }
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2218 }
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2219
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2220
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2221 void OrthancPlugins::ApplyDicomToJson(_OrthancPluginService service,
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2222 const void* parameters)
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2223 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2224 const _OrthancPluginDicomToJson& p =
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2225 *reinterpret_cast<const _OrthancPluginDicomToJson*>(parameters);
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2226
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2227 std::auto_ptr<ParsedDicomFile> dicom;
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2228
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2229 if (service == _OrthancPluginService_DicomBufferToJson)
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2230 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2231 dicom.reset(new ParsedDicomFile(p.buffer, p.size));
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2232 }
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2233 else
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2234 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2235 if (p.instanceId == NULL)
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2236 {
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2237 throw OrthancException(ErrorCode_NullPointer);
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2238 }
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2239
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2240 std::string content;
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2241
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2242 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2243 PImpl::ServerContextLock lock(*pimpl_);
2124
2b1520efa282 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
2244 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
2245 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2246
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2247 dicom.reset(new ParsedDicomFile(content));
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2248 }
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2249
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2250 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
2251 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
2252 static_cast<DicomToJsonFlags>(p.flags), p.maxStringLength);
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2253
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2254 Json::FastWriter writer;
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2255 *p.result = CopyString(writer.write(json));
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2256 }
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2257
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2258
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2259 void OrthancPlugins::ApplyCreateDicom(_OrthancPluginService service,
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2260 const void* parameters)
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2261 {
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2262 const _OrthancPluginCreateDicom& p =
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2263 *reinterpret_cast<const _OrthancPluginCreateDicom*>(parameters);
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2264
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2265 Json::Value json;
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2266
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2267 if (p.json == NULL)
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2268 {
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2269 json = Json::objectValue;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2270 }
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2271 else
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2272 {
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2273 Json::Reader reader;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2274 if (!reader.parse(p.json, json))
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2275 {
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2276 throw OrthancException(ErrorCode_BadJson);
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2277 }
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2278 }
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2279
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2280 std::string dicom;
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2281
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2282 {
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2283 std::auto_ptr<ParsedDicomFile> file
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2284 (ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(p.flags)));
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2285
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2286 if (p.pixelData)
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2287 {
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2288 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
2289 }
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2290
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2291 file->SaveToMemoryBuffer(dicom);
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2292 }
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2293
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2294 CopyToMemoryBuffer(*p.target, dicom);
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2295 }
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2296
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2297
1833
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2298 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
2299 const void* parameters)
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2300 {
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2301 const _OrthancPluginComputeHash& p =
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2302 *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
2303
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2304 std::string hash;
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2305 switch (service)
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2306 {
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2307 case _OrthancPluginService_ComputeMd5:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2308 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
2309 break;
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2310
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2311 case _OrthancPluginService_ComputeSha1:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2312 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
2313 break;
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2314
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2315 default:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2316 throw OrthancException(ErrorCode_ParameterOutOfRange);
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2317 }
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2318
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2319 *p.result = CopyString(hash);
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2320 }
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2321
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2322
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2323 void OrthancPlugins::ApplyCreateImage(_OrthancPluginService service,
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2324 const void* parameters)
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2325 {
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2326 const _OrthancPluginCreateImage& p =
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2327 *reinterpret_cast<const _OrthancPluginCreateImage*>(parameters);
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2328
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2329 std::auto_ptr<ImageAccessor> result;
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2330
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2331 switch (service)
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2332 {
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2333 case _OrthancPluginService_CreateImage:
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2045
diff changeset
2334 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
2335 break;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2336
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2337 case _OrthancPluginService_CreateImageAccessor:
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2338 result.reset(new ImageAccessor);
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2339 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
2340 break;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2341
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2342 case _OrthancPluginService_DecodeDicomImage:
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2343 {
1902
8b0ee8d5e6d0 Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
2344 result.reset(Decode(p.constBuffer, p.bufferSize, p.frameIndex));
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2345 break;
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2346 }
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2347
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2348 default:
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2349 throw OrthancException(ErrorCode_InternalError);
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2350 }
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2351
1843
d10a8164da5f ensure images returned to plugins are writable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1842
diff changeset
2352 *(p.target) = ReturnImage(result);
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2353 }
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2354
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2355
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2356 void OrthancPlugins::ApplySendMultipartItem(const void* parameters)
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2357 {
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2358 // An exception might be raised in this function if the
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2359 // connection was closed by the HTTP client.
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2360 const _OrthancPluginAnswerBuffer& p =
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2361 *reinterpret_cast<const _OrthancPluginAnswerBuffer*>(parameters);
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2362
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2363 HttpOutput& output = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2364
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2365 std::map<std::string, std::string> headers; // No custom headers
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2366 output.SendMultipartItem(p.answer, p.answerSize, headers);
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2367 }
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2368
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2369
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2370 void OrthancPlugins::ApplySendMultipartItem2(const void* parameters)
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2371 {
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2372 // An exception might be raised in this function if the
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2373 // connection was closed by the HTTP client.
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2374 const _OrthancPluginSendMultipartItem2& p =
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2375 *reinterpret_cast<const _OrthancPluginSendMultipartItem2*>(parameters);
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2376 HttpOutput& output = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2377
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2378 std::map<std::string, std::string> headers;
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2379 for (uint32_t i = 0; i < p.headersCount; i++)
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2380 {
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2381 headers[p.headersKeys[i]] = p.headersValues[i];
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2382 }
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2383
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2384 output.SendMultipartItem(p.answer, p.answerSize, headers);
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2385 }
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2386
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2387
1771
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2388 void OrthancPlugins::DatabaseAnswer(const void* parameters)
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2389 {
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2390 const _OrthancPluginDatabaseAnswer& p =
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2391 *reinterpret_cast<const _OrthancPluginDatabaseAnswer*>(parameters);
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2392
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2393 if (pimpl_->database_.get() != NULL)
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2394 {
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2395 pimpl_->database_->AnswerReceived(p);
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2396 }
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2397 else
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2398 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
2399 throw OrthancException(ErrorCode_BadRequest,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
2400 "Cannot invoke this service without a custom database back-end");
1771
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2401 }
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2402 }
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2403
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
2404
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2405 namespace
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2406 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2407 class DictionaryReadLocker
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2408 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2409 private:
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2410 const DcmDataDictionary& dictionary_;
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2411
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2412 public:
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2413 DictionaryReadLocker() : dictionary_(dcmDataDict.rdlock())
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2414 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2415 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2416
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2417 ~DictionaryReadLocker()
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2418 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2419 dcmDataDict.unlock();
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2420 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2421
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2422 const DcmDataDictionary* operator->()
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2423 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2424 return &dictionary_;
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2425 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2426 };
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2427 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2428
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2429
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2430 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
2431 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2432 const _OrthancPluginLookupDictionary& p =
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2433 *reinterpret_cast<const _OrthancPluginLookupDictionary*>(parameters);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2434
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2435 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
2436 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
2437
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2438 DictionaryReadLocker locker;
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2439 const DcmDictEntry* entry = locker->findEntry(tag2, NULL);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2440
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2441 if (entry == NULL)
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2442 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2443 throw OrthancException(ErrorCode_UnknownDicomTag);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2444 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2445 else
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2446 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2447 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
2448 p.target->element = entry->getKey().getElement();
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2000
diff changeset
2449 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
2450 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
2451 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
2452 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2453 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2454
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2455
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2456 bool OrthancPlugins::InvokeSafeService(SharedLibrary& plugin,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2457 _OrthancPluginService service,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2458 const void* parameters)
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2459 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2460 // 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
2461
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2462 switch (service)
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2463 {
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
2464 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
2465 {
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2136
diff changeset
2466 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
2467 *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
2468 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
2469 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
2470
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
2471 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
2472 {
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2136
diff changeset
2473 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
2474 *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
2475 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
2476 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
2477
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
2478 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
2479 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2480 std::string s;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2481
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2482 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2483 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2484 s = lock.GetConfiguration().GetConfigurationAbsolutePath();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2485 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2486
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2487 *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
2488 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
2489 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
2490
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
2491 case _OrthancPluginService_GetConfiguration:
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
2492 {
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
2493 std::string s;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2494
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2495 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2496 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2497 lock.GetConfiguration().Format(s);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2498 }
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
2499
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
2500 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = CopyString(s);
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
2501 return true;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
2502 }
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
2503
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2504 case _OrthancPluginService_BufferCompression:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2505 BufferCompression(parameters);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2506 return true;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
2507
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
2508 case _OrthancPluginService_AnswerBuffer:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2509 AnswerBuffer(parameters);
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2510 return true;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2511
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
2512 case _OrthancPluginService_CompressAndAnswerPngImage:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2513 CompressAndAnswerPngImage(parameters);
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
2514 return true;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
2515
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2516 case _OrthancPluginService_CompressAndAnswerImage:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2517 CompressAndAnswerImage(parameters);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2518 return true;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
2519
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
2520 case _OrthancPluginService_GetDicomForInstance:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2521 GetDicomForInstance(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2522 return true;
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
2523
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
2524 case _OrthancPluginService_RestApiGet:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2525 RestApiGet(parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2526 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2527
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2528 case _OrthancPluginService_RestApiGetAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2529 RestApiGet(parameters, true);
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
2530 return true;
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2531
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2532 case _OrthancPluginService_RestApiGet2:
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2533 RestApiGet2(parameters);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2534 return true;
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
2535
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2536 case _OrthancPluginService_RestApiPost:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2537 RestApiPostPut(true, parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2538 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2539
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2540 case _OrthancPluginService_RestApiPostAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2541 RestApiPostPut(true, parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2542 return true;
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2543
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2544 case _OrthancPluginService_RestApiDelete:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2545 RestApiDelete(parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2546 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2547
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2548 case _OrthancPluginService_RestApiDeleteAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2549 RestApiDelete(parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2550 return true;
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2551
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2552 case _OrthancPluginService_RestApiPut:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2553 RestApiPostPut(false, parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2554 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2555
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2556 case _OrthancPluginService_RestApiPutAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
2557 RestApiPostPut(false, parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
2558 return true;
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
2559
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
2560 case _OrthancPluginService_Redirect:
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
2561 Redirect(parameters);
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
2562 return true;
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
2563
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2564 case _OrthancPluginService_SendUnauthorized:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2565 SendUnauthorized(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2566 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2567
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2568 case _OrthancPluginService_SendMethodNotAllowed:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2569 SendMethodNotAllowed(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2570 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2571
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2572 case _OrthancPluginService_SendHttpStatus:
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2573 SendHttpStatus(parameters);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2574 return true;
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
2575
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2576 case _OrthancPluginService_SendHttpStatusCode:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2577 SendHttpStatusCode(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2578 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2579
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2580 case _OrthancPluginService_SetCookie:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2581 SetCookie(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2582 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
2583
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2584 case _OrthancPluginService_SetHttpHeader:
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2585 SetHttpHeader(parameters);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2586 return true;
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
2587
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2588 case _OrthancPluginService_SetHttpErrorDetails:
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2589 SetHttpErrorDetails(parameters);
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2590 return true;
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2591
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2592 case _OrthancPluginService_LookupPatient:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2593 case _OrthancPluginService_LookupStudy:
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2594 case _OrthancPluginService_LookupStudyWithAccessionNumber:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2595 case _OrthancPluginService_LookupSeries:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2596 case _OrthancPluginService_LookupInstance:
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
2597 LookupResource(service, parameters);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2598 return true;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
2599
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2600 case _OrthancPluginService_GetInstanceRemoteAet:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2601 case _OrthancPluginService_GetInstanceSize:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2602 case _OrthancPluginService_GetInstanceData:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2603 case _OrthancPluginService_GetInstanceJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2604 case _OrthancPluginService_GetInstanceSimplifiedJson:
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2605 case _OrthancPluginService_HasInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
2606 case _OrthancPluginService_GetInstanceMetadata:
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
2607 case _OrthancPluginService_GetInstanceOrigin:
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2608 AccessDicomInstance(service, parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2609 return true;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
2610
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2611 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
2612 {
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2613 const _OrthancPluginGlobalProperty& p =
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2614 *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
2615 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
2616 {
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2617 return false;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2618 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2619 else
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2620 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2621 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2622 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
2623 return true;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2624 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2625 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2626
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2627 case _OrthancPluginService_GetGlobalProperty:
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2628 {
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2629 const _OrthancPluginGlobalProperty& p =
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2630 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2631
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2632 std::string result;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2633
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2634 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2635 PImpl::ServerContextLock lock(*pimpl_);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2636 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
2637 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
2638
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
2639 *(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
2640 return true;
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2641 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2642
1407
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
2643 case _OrthancPluginService_GetExpectedDatabaseVersion:
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
2644 {
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
2645 const _OrthancPluginReturnSingleValue& p =
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
2646 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
2647 *(p.resultUint32) = ORTHANC_DATABASE_VERSION;
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
2648 return true;
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
2649 }
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
2650
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
2651 case _OrthancPluginService_StartMultipartAnswer:
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
2652 {
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
2653 const _OrthancPluginStartMultipartAnswer& p =
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
2654 *reinterpret_cast<const _OrthancPluginStartMultipartAnswer*>(parameters);
2957
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2655 HttpOutput& output = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output)->GetOutput();
ccf61f6e22ef New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
2656 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
2657 return true;
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
2658 }
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
2659
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
2660 case _OrthancPluginService_SendMultipartItem:
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2661 ApplySendMultipartItem(parameters);
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
2662 return true;
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2663
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2664 case _OrthancPluginService_SendMultipartItem2:
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2665 ApplySendMultipartItem2(parameters);
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
2666 return true;
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
2667
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2668 case _OrthancPluginService_ReadFile:
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2669 {
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2670 const _OrthancPluginReadFile& p =
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2671 *reinterpret_cast<const _OrthancPluginReadFile*>(parameters);
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2672
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2673 std::string content;
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2136
diff changeset
2674 SystemToolbox::ReadFile(content, p.path);
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2675 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
2676
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2677 return true;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2678 }
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2679
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2680 case _OrthancPluginService_WriteFile:
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2681 {
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2682 const _OrthancPluginWriteFile& p =
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2683 *reinterpret_cast<const _OrthancPluginWriteFile*>(parameters);
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2136
diff changeset
2684 SystemToolbox::WriteFile(p.data, p.size, p.path);
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2685 return true;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2686 }
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
2687
1593
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
2688 case _OrthancPluginService_GetErrorDescription:
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
2689 {
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
2690 const _OrthancPluginGetErrorDescription& p =
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
2691 *reinterpret_cast<const _OrthancPluginGetErrorDescription*>(parameters);
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
2692 *(p.target) = EnumerationToString(static_cast<ErrorCode>(p.error));
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
2693 return true;
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
2694 }
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
2695
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2696 case _OrthancPluginService_GetImagePixelFormat:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2697 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
2698 const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
2699 *(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
2700 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2701 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2702
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2703 case _OrthancPluginService_GetImageWidth:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2704 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
2705 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
2706 *(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
2707 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2708 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2709
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2710 case _OrthancPluginService_GetImageHeight:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2711 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
2712 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
2713 *(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
2714 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2715 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2716
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2717 case _OrthancPluginService_GetImagePitch:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2718 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
2719 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
2720 *(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
2721 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2722 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2723
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2724 case _OrthancPluginService_GetImageBuffer:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2725 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
2726 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
2727 *(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
2728 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2729 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2730
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2731 case _OrthancPluginService_FreeImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2732 {
1605
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1604
diff changeset
2733 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
2734
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2735 if (p.image != NULL)
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
2736 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
2737 delete reinterpret_cast<ImageAccessor*>(p.image);
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
2738 }
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2739
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2740 return true;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2741 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2742
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2743 case _OrthancPluginService_UncompressImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2744 UncompressImage(parameters);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2745 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2746
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2747 case _OrthancPluginService_CompressImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2748 CompressImage(parameters);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2749 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2750
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2751 case _OrthancPluginService_CallHttpClient:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2752 CallHttpClient(parameters);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2753 return true;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
2754
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2755 case _OrthancPluginService_CallHttpClient2:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2756 CallHttpClient2(parameters);
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2757 return true;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2758
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2759 case _OrthancPluginService_ConvertPixelFormat:
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2760 ConvertPixelFormat(parameters);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2761 return true;
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
2762
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2763 case _OrthancPluginService_GetFontsCount:
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2764 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2765 const _OrthancPluginReturnSingleValue& p =
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2766 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2767
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2768 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2769 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2770 *(p.resultUint32) = lock.GetConfiguration().GetFontRegistry().GetSize();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2771 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2772
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2773 return true;
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2774 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2775
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2776 case _OrthancPluginService_GetFontInfo:
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2777 GetFontInfo(parameters);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2778 return true;
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2779
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2780 case _OrthancPluginService_DrawText:
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2781 DrawText(parameters);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2782 return true;
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
2783
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2784 case _OrthancPluginService_StorageAreaCreate:
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2785 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2786 const _OrthancPluginStorageAreaCreate& p =
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2787 *reinterpret_cast<const _OrthancPluginStorageAreaCreate*>(parameters);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2788 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
2028
d108412411e5 fix msvc warnings
sjodogne
parents: 2022
diff changeset
2789 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
2790 return true;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2791 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2792
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2793 case _OrthancPluginService_StorageAreaRead:
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2794 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2795 const _OrthancPluginStorageAreaRead& p =
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2796 *reinterpret_cast<const _OrthancPluginStorageAreaRead*>(parameters);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2797 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
2798 std::string content;
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
2799 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
2800 CopyToMemoryBuffer(*p.target, content);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2801 return true;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2802 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2803
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2804 case _OrthancPluginService_StorageAreaRemove:
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2805 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2806 const _OrthancPluginStorageAreaRemove& p =
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2807 *reinterpret_cast<const _OrthancPluginStorageAreaRemove*>(parameters);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2808 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
2809 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
2810 return true;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2811 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
2812
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2813 case _OrthancPluginService_DicomBufferToJson:
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2814 case _OrthancPluginService_DicomInstanceToJson:
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2815 ApplyDicomToJson(service, parameters);
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2816 return true;
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2817
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2818 case _OrthancPluginService_CreateDicom:
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2819 ApplyCreateDicom(service, parameters);
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2820 return true;
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2821
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2822 case _OrthancPluginService_WorklistAddAnswer:
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2823 {
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2824 const _OrthancPluginWorklistAnswersOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2825 *reinterpret_cast<const _OrthancPluginWorklistAnswersOperation*>(parameters);
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
2826 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
2827 return true;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2828 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2829
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2830 case _OrthancPluginService_WorklistMarkIncomplete:
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2831 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2832 const _OrthancPluginWorklistAnswersOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2833 *reinterpret_cast<const _OrthancPluginWorklistAnswersOperation*>(parameters);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2834 reinterpret_cast<DicomFindAnswers*>(p.answers)->SetComplete(false);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2835 return true;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2836 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2837
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2838 case _OrthancPluginService_WorklistIsMatch:
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2839 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2840 const _OrthancPluginWorklistQueryOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2841 *reinterpret_cast<const _OrthancPluginWorklistQueryOperation*>(parameters);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2842 *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
2843 return true;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2844 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2845
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2846 case _OrthancPluginService_WorklistGetDicomQuery:
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2847 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2848 const _OrthancPluginWorklistQueryOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2849 *reinterpret_cast<const _OrthancPluginWorklistQueryOperation*>(parameters);
1812
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
2850 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
2851 return true;
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2852 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2853
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2854 case _OrthancPluginService_FindAddAnswer:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2855 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2856 const _OrthancPluginFindOperation& p =
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2857 *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
2858 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
2859 return true;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2860 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2861
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2862 case _OrthancPluginService_FindMarkIncomplete:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2863 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2864 const _OrthancPluginFindOperation& p =
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2865 *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
2866 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
2867 return true;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2868 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2869
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2870 case _OrthancPluginService_GetFindQuerySize:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2871 case _OrthancPluginService_GetFindQueryTag:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2872 case _OrthancPluginService_GetFindQueryTagName:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2873 case _OrthancPluginService_GetFindQueryValue:
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2874 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2875 const _OrthancPluginFindOperation& p =
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2876 *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
2877 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
2878 return true;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2879 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
2880
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2881 case _OrthancPluginService_CreateImage:
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2882 case _OrthancPluginService_CreateImageAccessor:
1829
31df3b48925e OrthancPluginDecodeDicomImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
2883 case _OrthancPluginService_DecodeDicomImage:
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2884 ApplyCreateImage(service, parameters);
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2885 return true;
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2886
1833
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2887 case _OrthancPluginService_ComputeMd5:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2888 case _OrthancPluginService_ComputeSha1:
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2889 ComputeHash(service, parameters);
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2890 return true;
47d032c48818 "OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1829
diff changeset
2891
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2892 case _OrthancPluginService_LookupDictionary:
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2893 ApplyLookupDictionary(parameters);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2894 return true;
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
2895
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2896 case _OrthancPluginService_GenerateUuid:
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2897 {
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2898 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result =
2512
4dcafa8d6633 SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
2899 CopyString(Toolbox::GenerateUuid());
1987
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2900 return true;
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2901 }
ce90d109bb64 new plugin functions: OrthancPluginHttpClient and OrthancPluginGenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1984
diff changeset
2902
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2903 case _OrthancPluginService_CreateFindMatcher:
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2904 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2905 const _OrthancPluginCreateFindMatcher& p =
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2906 *reinterpret_cast<const _OrthancPluginCreateFindMatcher*>(parameters);
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2907 ParsedDicomFile query(p.query, p.size);
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
2908 *(p.target) = reinterpret_cast<OrthancPluginFindMatcher*>(new HierarchicalMatcher(query));
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2909 return true;
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2910 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2911
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2912 case _OrthancPluginService_FreeFindMatcher:
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2913 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2914 const _OrthancPluginFreeFindMatcher& p =
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2915 *reinterpret_cast<const _OrthancPluginFreeFindMatcher*>(parameters);
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2916
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2917 if (p.matcher != NULL)
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2918 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2919 delete reinterpret_cast<HierarchicalMatcher*>(p.matcher);
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2920 }
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2921
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2922 return true;
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2923 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2924
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2925 case _OrthancPluginService_FindMatcherIsMatch:
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2926 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2927 const _OrthancPluginFindMatcherIsMatch& p =
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2928 *reinterpret_cast<const _OrthancPluginFindMatcherIsMatch*>(parameters);
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2929
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2930 if (p.matcher == NULL)
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2931 {
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2932 throw OrthancException(ErrorCode_NullPointer);
2210
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2933 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2934 else
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2935 {
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2936 ParsedDicomFile query(p.dicom, p.size);
2215
028214a95194 refactoring the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2210
diff changeset
2937 *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
2938 return true;
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2939 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2940 }
7bcff7bb7cbf OrthancPluginFindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
2941
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2942 case _OrthancPluginService_GetPeers:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2943 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2944 const _OrthancPluginGetPeers& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2945 *reinterpret_cast<const _OrthancPluginGetPeers*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2946 *(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
2947 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2948 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2949
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2950 case _OrthancPluginService_FreePeers:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2951 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2952 const _OrthancPluginFreePeers& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2953 *reinterpret_cast<const _OrthancPluginFreePeers*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2954
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2955 if (p.peers != NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2956 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2957 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
2958 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2959
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2960 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2961 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2962
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2963 case _OrthancPluginService_GetPeersCount:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2964 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2965 const _OrthancPluginGetPeersCount& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2966 *reinterpret_cast<const _OrthancPluginGetPeersCount*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2967
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2968 if (p.peers == NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2969 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2970 throw OrthancException(ErrorCode_NullPointer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2971 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2972 else
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2973 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2974 *(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
2975 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2976 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2977 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2978
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2979 case _OrthancPluginService_GetPeerName:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2980 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2981 const _OrthancPluginGetPeerProperty& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2982 *reinterpret_cast<const _OrthancPluginGetPeerProperty*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2983
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2984 if (p.peers == NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2985 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2986 throw OrthancException(ErrorCode_NullPointer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2987 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2988 else
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2989 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2990 *(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
2991 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2992 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2993 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2994
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2995 case _OrthancPluginService_GetPeerUrl:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2996 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2997 const _OrthancPluginGetPeerProperty& p =
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2998 *reinterpret_cast<const _OrthancPluginGetPeerProperty*>(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
2999
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3000 if (p.peers == NULL)
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3001 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3002 throw OrthancException(ErrorCode_NullPointer);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3003 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3004 else
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3005 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3006 *(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
3007 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3008 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3009 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3010
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3011 case _OrthancPluginService_GetPeerUserProperty:
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3012 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3013 const _OrthancPluginGetPeerProperty& p =
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3014 *reinterpret_cast<const _OrthancPluginGetPeerProperty*>(parameters);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3015
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3016 if (p.peers == NULL ||
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3017 p.userProperty == NULL)
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3018 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3019 throw OrthancException(ErrorCode_NullPointer);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3020 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3021 else
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3022 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3023 const WebServiceParameters::Dictionary& properties =
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3024 reinterpret_cast<const OrthancPeers*>(p.peers)->GetPeerParameters(p.peerIndex).GetUserProperties();
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3025
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3026 WebServiceParameters::Dictionary::const_iterator found =
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3027 properties.find(p.userProperty);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3028
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3029 if (found == properties.end())
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3030 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3031 *(p.target) = NULL;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3032 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3033 else
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3034 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3035 *(p.target) = found->second.c_str();
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3036 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3037
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3038 return true;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3039 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3040 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2820
diff changeset
3041
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3042 case _OrthancPluginService_CallPeerApi:
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3043 CallPeerApi(parameters);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3044 return true;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2787
diff changeset
3045
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3046 case _OrthancPluginService_CreateJob:
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3047 {
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3048 const _OrthancPluginCreateJob& p =
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3049 *reinterpret_cast<const _OrthancPluginCreateJob*>(parameters);
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3050 *(p.target) = reinterpret_cast<OrthancPluginJob*>(new PluginsJob(p));
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3051 return true;
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3052 }
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3053
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3054 case _OrthancPluginService_FreeJob:
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3055 {
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3056 const _OrthancPluginFreeJob& p =
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3057 *reinterpret_cast<const _OrthancPluginFreeJob*>(parameters);
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3058
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3059 if (p.job != NULL)
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3060 {
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3061 delete reinterpret_cast<PluginsJob*>(p.job);
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3062 }
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3063
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3064 return true;
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3065 }
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3066
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3067 case _OrthancPluginService_SubmitJob:
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3068 {
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3069 const _OrthancPluginSubmitJob& p =
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3070 *reinterpret_cast<const _OrthancPluginSubmitJob*>(parameters);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3071
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3072 std::string uuid;
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3073
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3074 PImpl::ServerContextLock lock(*pimpl_);
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3075 lock.GetContext().GetJobsEngine().GetRegistry().Submit
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3076 (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
3077
2814
7d1d3136f6cf more generic handling of content and serialization in plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2813
diff changeset
3078 *p.resultId = CopyString(uuid);
2813
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
3079
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3080 return true;
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3081 }
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3082
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
3083 default:
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3084 return false;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3085 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3086 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3087
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3088
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3089
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3090 bool OrthancPlugins::InvokeProtectedService(SharedLibrary& plugin,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3091 _OrthancPluginService service,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3092 const void* parameters)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3093 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3094 // 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
3095 // 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
3096 // should be listed here.
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3097
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3098 switch (service)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3099 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3100 case _OrthancPluginService_RegisterRestCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3101 RegisterRestCallback(parameters, true);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3102 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3103
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3104 case _OrthancPluginService_RegisterRestCallbackNoLock:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3105 RegisterRestCallback(parameters, false);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3106 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3107
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3108 case _OrthancPluginService_RegisterOnStoredInstanceCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3109 RegisterOnStoredInstanceCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3110 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3111
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3112 case _OrthancPluginService_RegisterOnChangeCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3113 RegisterOnChangeCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3114 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3115
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3116 case _OrthancPluginService_RegisterWorklistCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3117 RegisterWorklistCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3118 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3119
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3120 case _OrthancPluginService_RegisterFindCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3121 RegisterFindCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3122 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3123
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3124 case _OrthancPluginService_RegisterMoveCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3125 RegisterMoveCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3126 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3127
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3128 case _OrthancPluginService_RegisterDecodeImageCallback:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3129 RegisterDecodeImageCallback(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3130 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3131
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3132 case _OrthancPluginService_RegisterJobsUnserializer:
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3133 RegisterJobsUnserializer(parameters);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3134 return true;
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3135
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3136 case _OrthancPluginService_RegisterIncomingHttpRequestFilter:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3137 RegisterIncomingHttpRequestFilter(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3138 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3139
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3140 case _OrthancPluginService_RegisterIncomingHttpRequestFilter2:
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3141 RegisterIncomingHttpRequestFilter2(parameters);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3142 return true;
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3143
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3144 case _OrthancPluginService_RegisterStorageArea:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3145 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3146 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
3147 const _OrthancPluginRegisterStorageArea& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3148 *reinterpret_cast<const _OrthancPluginRegisterStorageArea*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3149
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3150 if (pimpl_->storageArea_.get() == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3151 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3152 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
3153 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3154 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3155 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3156 throw OrthancException(ErrorCode_StorageAreaAlreadyRegistered);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3157 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3158
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3159 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3160 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3161
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3162 case _OrthancPluginService_SetPluginProperty:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3163 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3164 const _OrthancPluginSetPluginProperty& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3165 *reinterpret_cast<const _OrthancPluginSetPluginProperty*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3166 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
3167 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3168 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3169
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3170 case _OrthancPluginService_GetCommandLineArgumentsCount:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3171 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3172 const _OrthancPluginReturnSingleValue& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3173 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3174 *(p.resultUint32) = pimpl_->argc_ - 1;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3175 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3176 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3177
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3178 case _OrthancPluginService_GetCommandLineArgument:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3179 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3180 const _OrthancPluginGlobalProperty& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3181 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3182
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3183 if (p.property + 1 > pimpl_->argc_)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3184 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3185 return false;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3186 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3187 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3188 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3189 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
3190 *(p.result) = CopyString(arg);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3191 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3192 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3193 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3194
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3195 case _OrthancPluginService_RegisterDatabaseBackend:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3196 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3197 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
3198
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3199 const _OrthancPluginRegisterDatabaseBackend& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3200 *reinterpret_cast<const _OrthancPluginRegisterDatabaseBackend*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3201
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3202 if (pimpl_->database_.get() == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3203 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3204 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
3205 *p.backend, NULL, 0, p.payload));
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3206 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3207 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3208 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3209 throw OrthancException(ErrorCode_DatabaseBackendAlreadyRegistered);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3210 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3211
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3212 *(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
3213
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3214 return true;
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
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3217 case _OrthancPluginService_RegisterDatabaseBackendV2:
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 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
3220
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3221 const _OrthancPluginRegisterDatabaseBackendV2& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3222 *reinterpret_cast<const _OrthancPluginRegisterDatabaseBackendV2*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3223
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3224 if (pimpl_->database_.get() == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3225 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3226 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
3227 *p.backend, p.extensions,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3228 p.extensionsSize, p.payload));
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3229 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3230 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3231 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3232 throw OrthancException(ErrorCode_DatabaseBackendAlreadyRegistered);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3233 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3234
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3235 *(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
3236
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3237 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3238 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3239
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3240 case _OrthancPluginService_DatabaseAnswer:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3241 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
3242
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3243 case _OrthancPluginService_RegisterErrorCode:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3244 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3245 const _OrthancPluginRegisterErrorCode& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3246 *reinterpret_cast<const _OrthancPluginRegisterErrorCode*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3247 *(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
3248 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3249 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3250
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3251 case _OrthancPluginService_RegisterDictionaryTag:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3252 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3253 const _OrthancPluginRegisterDictionaryTag& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3254 *reinterpret_cast<const _OrthancPluginRegisterDictionaryTag*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3255 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
3256 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
3257 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
3258 return true;
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
3259 }
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
3260
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
3261 case _OrthancPluginService_RegisterPrivateDictionaryTag:
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
3262 {
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
3263 const _OrthancPluginRegisterPrivateDictionaryTag& p =
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
3264 *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
3265 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
3266 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
3267 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
3268 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3269 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3270
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3271 case _OrthancPluginService_ReconstructMainDicomTags:
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3272 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3273 const _OrthancPluginReconstructMainDicomTags& p =
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3274 *reinterpret_cast<const _OrthancPluginReconstructMainDicomTags*>(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3275
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3276 if (pimpl_->database_.get() == NULL)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3277 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
3278 throw OrthancException(ErrorCode_DatabasePlugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
3279 "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
3280 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3281
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3282 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
2120
4b02ec79728a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
3283 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
3284
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3285 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3286 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3287
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3288 default:
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3289 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3290 // This service is unknown to the Orthanc plugin engine
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
3291 return false;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
3292 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
3293 }
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
3294 }
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
3295
908
e078ea944089 refactoring HttpOutput
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
3296
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3297
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3298 bool OrthancPlugins::InvokeService(SharedLibrary& plugin,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3299 _OrthancPluginService service,
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3300 const void* parameters)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3301 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3302 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
3303
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3304 if (service == _OrthancPluginService_DatabaseAnswer)
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3305 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3306 // 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
3307 // 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
3308 // 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
3309 // 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
3310 // 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
3311 // "DatabaseAnswer".
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3312 DatabaseAnswer(parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3313 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3314 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3315
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3316 if (InvokeSafeService(plugin, service, parameters))
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3317 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3318 // 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
3319 return true;
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3320 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3321 else
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3322 {
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3323 // The invoked service requires locking
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3324 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
3325 return InvokeProtectedService(plugin, service, parameters);
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3326 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3327 }
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3328
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3329
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
3330 bool OrthancPlugins::HasStorageArea() const
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
3331 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3332 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
3333 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
3334 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3335
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
3336 bool OrthancPlugins::HasDatabaseBackend() const
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3337 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3338 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3339 return pimpl_->database_.get() != NULL;
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3340 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3341
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
3342
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
3343 IStorageArea* OrthancPlugins::CreateStorageArea()
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
3344 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
3345 if (!HasStorageArea())
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
3346 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
3347 throw OrthancException(ErrorCode_BadSequenceOfCalls);
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
3348 }
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
3349 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
3350 {
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
3351 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
3352 }
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
3353 }
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
3354
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
3355
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
3356 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
3357 {
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
3358 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
3359 {
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
3360 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
3361 }
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
3362 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
3363 {
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
3364 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
3365 }
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
3366 }
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3367
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3368
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
3369 IDatabaseWrapper& OrthancPlugins::GetDatabaseBackend()
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3370 {
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
3371 if (!HasDatabaseBackend())
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3372 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3373 throw OrthancException(ErrorCode_BadSequenceOfCalls);
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3374 }
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
3375 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
3376 {
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
3377 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
3378 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3379 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3380
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3381
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
3382 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
3383 {
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
3384 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
3385 {
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
3386 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
3387 }
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
3388 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
3389 {
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
3390 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
3391 }
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
3392 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
3393
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3394
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3395 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
3396 _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
3397 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3398 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
3399 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
3400
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3401 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
3402 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3403 return NULL;
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3404 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3405 else
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3406 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3407 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
3408 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
3409 }
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
3410
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
3411
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
3412 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
3413 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
3414 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
3415 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
3416 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
3417 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
3418
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
3419 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
3420 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
3421 }
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
3422
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
3423
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
3424 PluginsManager& OrthancPlugins::GetManager()
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
3425 {
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
3426 return pimpl_->manager_;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
3427 }
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
3428
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
3429
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
3430 const PluginsManager& OrthancPlugins::GetManager() const
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
3431 {
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
3432 return pimpl_->manager_;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
3433 }
1644
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
3434
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
3435
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
3436 PluginsErrorDictionary& OrthancPlugins::GetErrorDictionary()
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
3437 {
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
3438 return pimpl_->dictionary_;
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
3439 }
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3440
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3441
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3442 IWorklistRequestHandler* OrthancPlugins::ConstructWorklistRequestHandler()
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3443 {
1809
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
3444 if (HasWorklistHandler())
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3445 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3446 return new WorklistHandler(*this);
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3447 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3448 else
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3449 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3450 return NULL;
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3451 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
3452 }
1809
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
3453
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
3454
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
3455 bool OrthancPlugins::HasWorklistHandler()
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
3456 {
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
3457 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
3458 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
3459 }
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
3460
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
3461
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3462 IFindRequestHandler* OrthancPlugins::ConstructFindRequestHandler()
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3463 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3464 if (HasFindHandler())
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3465 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3466 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
3467 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3468 else
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3469 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3470 return NULL;
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3471 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3472 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3473
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3474
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3475 bool OrthancPlugins::HasFindHandler()
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3476 {
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3477 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
3478 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
3479 }
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3480
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1987
diff changeset
3481
1999
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3482 IMoveRequestHandler* OrthancPlugins::ConstructMoveRequestHandler()
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3483 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3484 if (HasMoveHandler())
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3485 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3486 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
3487 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3488 else
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3489 {
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3490 return NULL;
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3491 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3492 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3493
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3494
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3495 bool OrthancPlugins::HasMoveHandler()
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3496 {
2000
39329372b667 Speedup in plugins by removing unnecessary locks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1999
diff changeset
3497 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
3498 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
3499 }
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3500
364cc624eb65 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
3501
1906
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
3502 bool OrthancPlugins::HasCustomImageDecoder()
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
3503 {
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
3504 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
3505 return !pimpl_->decodeImageCallbacks_.empty();
1906
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
3506 }
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
3507
d7c1cb559431 optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
3508
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
3509 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
3510 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
3511 unsigned int frame)
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
3512 {
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
3513 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
3514
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
3515 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
3516 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
3517 decoder != pimpl_->decodeImageCallbacks_.end(); ++decoder)
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
3518 {
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
3519 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
3520 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
3521 pluginImage != NULL)
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
3522 {
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
3523 return reinterpret_cast<ImageAccessor*>(pluginImage);
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
3524 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
3525 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
3526
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
3527 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
3528 }
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
3529
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
3530
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
3531 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
3532 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
3533 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
3534 {
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
3535 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
3536
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
3537 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
3538 {
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
3539 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
3540 }
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
3541 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
3542 {
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
3543 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
3544 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
3545 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
3546 }
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
3547 }
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3548
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3549
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3550 bool OrthancPlugins::IsAllowed(HttpMethod method,
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3551 const char* uri,
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3552 const char* ip,
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3553 const char* username,
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3554 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
3555 const IHttpHandler::GetArguments& getArguments)
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3556 {
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3557 OrthancPluginHttpMethod cMethod = Plugins::Convert(method);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3558
1962
22ddb22fce83 sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1961
diff changeset
3559 std::vector<const char*> httpKeys(httpHeaders.size());
22ddb22fce83 sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1961
diff changeset
3560 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
3561
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3562 size_t pos = 0;
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3563 for (IHttpHandler::Arguments::const_iterator
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3564 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
3565 {
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3566 httpKeys[pos] = it->first.c_str();
1962
22ddb22fce83 sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1961
diff changeset
3567 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
3568 }
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3569
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3570 std::vector<const char*> getKeys(getArguments.size());
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3571 std::vector<const char*> getValues(getArguments.size());
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3572
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3573 for (size_t i = 0; i < getArguments.size(); i++)
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3574 {
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3575 getKeys[i] = getArguments[i].first.c_str();
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3576 getValues[i] = getArguments[i].second.c_str();
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3577 }
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3578
2354
415450f11cc7 rename Orthanc 1.2.1 as 1.3.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2268
diff changeset
3579 // Improved callback with support for GET arguments, since Orthanc 1.3.0
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3580 for (PImpl::IncomingHttpRequestFilters2::const_iterator
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3581 filter = pimpl_->incomingHttpRequestFilters2_.begin();
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3582 filter != pimpl_->incomingHttpRequestFilters2_.end(); ++filter)
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3583 {
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3584 int32_t allowed = (*filter) (cMethod, uri, ip,
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3585 httpKeys.size(),
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3586 httpKeys.empty() ? NULL : &httpKeys[0],
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3587 httpValues.empty() ? NULL : &httpValues[0],
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3588 getKeys.size(),
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3589 getKeys.empty() ? NULL : &getKeys[0],
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3590 getValues.empty() ? NULL : &getValues[0]);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3591
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3592 if (allowed == 0)
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3593 {
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3594 return false;
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3595 }
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3596 else if (allowed != 1)
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3597 {
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3598 // The callback is only allowed to answer 0 or 1
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3599 throw OrthancException(ErrorCode_Plugin);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3600 }
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3601 }
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3602
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3603 for (PImpl::IncomingHttpRequestFilters::const_iterator
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3604 filter = pimpl_->incomingHttpRequestFilters_.begin();
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3605 filter != pimpl_->incomingHttpRequestFilters_.end(); ++filter)
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3606 {
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3607 int32_t allowed = (*filter) (cMethod, uri, ip, httpKeys.size(),
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3608 httpKeys.empty() ? NULL : &httpKeys[0],
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3609 httpValues.empty() ? NULL : &httpValues[0]);
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3610
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3611 if (allowed == 0)
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3612 {
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3613 return false;
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3614 }
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3615 else if (allowed != 1)
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3616 {
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3617 // The callback is only allowed to answer 0 or 1
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3618 throw OrthancException(ErrorCode_Plugin);
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
3619 }
1961
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3620 }
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3621
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3622 return true;
ef1e9856c26f New callback to filter incoming HTTP requests: OrthancPluginRegisterIncomingHttpRequestFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
3623 }
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3624
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3625
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3626 IJob* OrthancPlugins::UnserializeJob(const std::string& type,
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3627 const Json::Value& value)
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3628 {
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3629 const std::string serialized = value.toStyledString();
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3630
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3631 boost::mutex::scoped_lock lock(pimpl_->jobsUnserializersMutex_);
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3632
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3633 for (PImpl::JobsUnserializers::iterator
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3634 unserializer = pimpl_->jobsUnserializers_.begin();
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3635 unserializer != pimpl_->jobsUnserializers_.end(); ++unserializer)
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3636 {
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3637 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
3638 if (job != NULL)
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3639 {
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3640 return reinterpret_cast<PluginsJob*>(job);
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3641 }
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3642 }
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3643
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2814
diff changeset
3644 return NULL;
2808
37583cd183ed primitives to create jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
3645 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3646 }