annotate Plugins/Engine/OrthancPlugins.cpp @ 1827:4b6673e828f4

"OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Nov 2015 16:39:03 +0100
parents ac5b0b4e2434
children a71d74987090
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
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1282
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1282
diff changeset
4 * Department, University Hospital of Liege, Belgium
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * 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
7 * 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
8 * 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
9 * License, or (at your option) any later version.
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * 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
12 * 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
13 * 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
14 * 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
15 * 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
16 * 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
17 * 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
18 * 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
19 * 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
20 * 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
21 * in the program, then also delete it here.
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * 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
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * 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
29 * 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
30 **/
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
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
33 #include "../../OrthancServer/PrecompiledHeadersServer.h"
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
34 #include "OrthancPlugins.h"
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
36 #if ORTHANC_PLUGINS_ENABLED != 1
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
37 #error The plugin support is disabled
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
38 #endif
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
39
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
40
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
41 #include "../../Core/ChunkedBuffer.h"
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
42 #include "../../Core/HttpServer/HttpToolbox.h"
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1466
diff changeset
43 #include "../../Core/Logging.h"
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
44 #include "../../Core/OrthancException.h"
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
45 #include "../../Core/Toolbox.h"
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
46 #include "../../OrthancServer/FromDcmtkBridge.h"
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
47 #include "../../OrthancServer/OrthancInitialization.h"
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
48 #include "../../OrthancServer/ServerContext.h"
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
49 #include "../../OrthancServer/ServerToolbox.h"
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
50 #include "../../OrthancServer/Search/HierarchicalMatcher.h"
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
51 #include "../../OrthancServer/Internals/DicomImageDecoder.h"
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
52 #include "../../Core/Compression/ZlibCompressor.h"
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
53 #include "../../Core/Compression/GzipCompressor.h"
1612
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
54 #include "../../Core/Images/Image.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
55 #include "../../Core/Images/PngReader.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
56 #include "../../Core/Images/PngWriter.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
57 #include "../../Core/Images/JpegReader.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
58 #include "../../Core/Images/JpegWriter.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
59 #include "../../Core/Images/ImageProcessing.h"
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
60 #include "PluginsEnumerations.h"
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 #include <boost/regex.hpp>
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 namespace Orthanc
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
66 static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
67 const void* data,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
68 size_t size)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
69 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
70 target.size = size;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
71
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
72 if (size == 0)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
73 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
74 target.data = NULL;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
75 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
76 else
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
77 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
78 target.data = malloc(size);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
79 if (target.data != NULL)
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 memcpy(target.data, data, size);
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 else
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 throw OrthancException(ErrorCode_NotEnoughMemory);
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 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
88 }
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
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
91 static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
92 const std::string& str)
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 if (str.size() == 0)
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 target.size = 0;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
97 target.data = NULL;
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 else
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
100 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
101 CopyToMemoryBuffer(target, str.c_str(), str.size());
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 }
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
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
106 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
107 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
108 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
109 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
110 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
111 _OrthancPluginRegisterStorageArea callbacks_;
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
112 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
113
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
114 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
115 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
116 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
117 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
118 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
119 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
120 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
121
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
122 public:
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
123 PluginStorageArea(const _OrthancPluginRegisterStorageArea& callbacks,
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
124 PluginsErrorDictionary& errorDictionary) :
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
125 callbacks_(callbacks),
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
126 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
127 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
128 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
129
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
130
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
131 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
132 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
133 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
134 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
135 {
ffd23c0104af "/system" 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 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
137 (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
138
ffd23c0104af "/system" 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 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
140 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
141 errorDictionary_.LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
142 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
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 }
ffd23c0104af "/system" 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
ffd23c0104af "/system" 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 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
148 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
149 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
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 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
152 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
153
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
154 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
155 (&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
156
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
157 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
158 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
159 errorDictionary_.LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
160 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
161 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
162
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
163 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
164 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
165 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
166 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
167 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
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 Free(buffer);
1643
87c77b9b3679 provision for error codes in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
170 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
171 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
172
ffd23c0104af "/system" 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 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
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 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
176 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
177
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
178 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
179 }
ffd23c0104af "/system" 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
ffd23c0104af "/system" 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 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
183 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
184 {
ffd23c0104af "/system" 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 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
186 (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
187
ffd23c0104af "/system" 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 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
189 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
190 errorDictionary_.LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
191 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
192 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
193 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
194 };
ffd23c0104af "/system" 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
ffd23c0104af "/system" 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 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
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 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
200 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
201 _OrthancPluginRegisterStorageArea callbacks_;
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
202 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
203
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
204 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
205 StorageAreaFactory(SharedLibrary& sharedLibrary,
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
206 const _OrthancPluginRegisterStorageArea& callbacks,
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
207 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
208 sharedLibrary_(sharedLibrary),
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
209 callbacks_(callbacks),
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
210 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
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 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
213
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
214 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
215 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
216 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
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
ffd23c0104af "/system" 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 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
220 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
221 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
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
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
227 struct OrthancPlugins::PImpl
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
228 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
229 class RestCallback : public boost::noncopyable
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
230 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
231 private:
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
232 boost::regex regex_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
233 OrthancPluginRestCallback callback_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
234 bool lock_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
235
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
236 OrthancPluginErrorCode InvokeInternal(HttpOutput& output,
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
237 const std::string& flatUri,
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
238 const OrthancPluginHttpRequest& request)
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
239 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
240 return callback_(reinterpret_cast<OrthancPluginRestOutput*>(&output),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
241 flatUri.c_str(),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
242 &request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
243 }
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
244
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
245 public:
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
246 RestCallback(const char* regex,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
247 OrthancPluginRestCallback callback,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
248 bool lockRestCallbacks) :
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
249 regex_(regex),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
250 callback_(callback),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
251 lock_(lockRestCallbacks)
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
252 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
253 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
254
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
255 const boost::regex& GetRegularExpression() const
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
256 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
257 return regex_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
258 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
259
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
260 OrthancPluginErrorCode Invoke(boost::recursive_mutex& restCallbackMutex,
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
261 HttpOutput& output,
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
262 const std::string& flatUri,
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
263 const OrthancPluginHttpRequest& request)
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
264 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
265 if (lock_)
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
266 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
267 boost::recursive_mutex::scoped_lock lock(restCallbackMutex);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
268 return InvokeInternal(output, flatUri, request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
269 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
270 else
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
271 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
272 return InvokeInternal(output, flatUri, request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
273 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
274 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
275 };
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
276
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
277
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
278 typedef std::pair<std::string, _OrthancPluginProperty> Property;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
279 typedef std::list<RestCallback*> RestCallbacks;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
280 typedef std::list<OrthancPluginOnStoredInstanceCallback> OnStoredCallbacks;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
281 typedef std::list<OrthancPluginOnChangeCallback> OnChangeCallbacks;
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
282 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
283
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
284 PluginsManager manager_;
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
285 ServerContext* context_;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
286 RestCallbacks restCallbacks_;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
287 OnStoredCallbacks onStoredCallbacks_;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
288 OnChangeCallbacks onChangeCallbacks_;
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
289 OrthancPluginWorklistCallback worklistCallback_;
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
290 OrthancPluginDecodeImageCallback decodeImageCallback_;
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
291 std::auto_ptr<StorageAreaFactory> storageArea_;
1466
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
292 boost::recursive_mutex restCallbackMutex_;
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
293 boost::recursive_mutex storedCallbackMutex_;
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
294 boost::recursive_mutex changeCallbackMutex_;
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
295 boost::mutex worklistCallbackMutex_;
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
296 boost::mutex decodeImageCallbackMutex_;
1553
7c4b487b3b4a ensure mutual exclusion in InvokeService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
297 boost::recursive_mutex invokeServiceMutex_;
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
298 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
299 int argc_;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
300 char** argv_;
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
301 std::auto_ptr<OrthancPluginDatabase> database_;
1644
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
302 PluginsErrorDictionary dictionary_;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
303
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
304 PImpl() :
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
305 context_(NULL),
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
306 worklistCallback_(NULL),
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
307 decodeImageCallback_(NULL),
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
308 argc_(1),
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
309 argv_(NULL)
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
310 {
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
311 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
312 };
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
313
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
314
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
315
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
316 class OrthancPlugins::WorklistHandler : public IWorklistRequestHandler
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
317 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
318 private:
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
319 OrthancPlugins& that_;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
320 std::auto_ptr<HierarchicalMatcher> matcher_;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
321 ParsedDicomFile* currentQuery_;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
322
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
323 void Reset()
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
324 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
325 matcher_.reset(NULL);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
326 currentQuery_ = NULL;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
327 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
328
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
329 public:
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
330 WorklistHandler(OrthancPlugins& that) : that_(that)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
331 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
332 Reset();
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
333 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
334
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
335 virtual void Handle(DicomFindAnswers& answers,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
336 ParsedDicomFile& query,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
337 const std::string& remoteIp,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
338 const std::string& remoteAet,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
339 const std::string& calledAet)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
340 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
341 bool caseSensitivePN = Configuration::GetGlobalBoolParameter("CaseSensitivePN", false);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
342 matcher_.reset(new HierarchicalMatcher(query, caseSensitivePN));
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
343 currentQuery_ = &query;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
344
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
345 {
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
346 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
347
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
348 if (that_.pimpl_->worklistCallback_)
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
349 {
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
350 OrthancPluginErrorCode error = that_.pimpl_->worklistCallback_
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
351 (reinterpret_cast<OrthancPluginWorklistAnswers*>(&answers),
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
352 reinterpret_cast<const OrthancPluginWorklistQuery*>(this),
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
353 remoteAet.c_str(),
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
354 calledAet.c_str());
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
355
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
356 if (error != OrthancPluginErrorCode_Success)
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
357 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
358 Reset();
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
359 that_.GetErrorDictionary().LogError(error, true);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
360 throw OrthancException(static_cast<ErrorCode>(error));
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
361 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
362 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
363 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
364
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
365 Reset();
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
366 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
367
1812
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
368 void GetDicomQuery(OrthancPluginMemoryBuffer& target) const
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
369 {
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
370 assert(currentQuery_ != NULL);
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
371 std::string dicom;
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
372 currentQuery_->SaveToMemoryBuffer(dicom);
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
373 CopyToMemoryBuffer(target, dicom.c_str(), dicom.size());
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
374 }
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
375
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
376 bool IsMatch(const void* dicom,
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
377 size_t size) const
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
378 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
379 assert(matcher_.get() != NULL);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
380 ParsedDicomFile f(dicom, size);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
381 return matcher_->Match(f);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
382 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
383
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
384 void AddAnswer(OrthancPluginWorklistAnswers* answers,
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
385 const void* dicom,
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
386 size_t size) const
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
387 {
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
388 assert(matcher_.get() != NULL);
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
389 ParsedDicomFile f(dicom, size);
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
390 std::auto_ptr<ParsedDicomFile> summary(matcher_->Extract(f));
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
391 reinterpret_cast<DicomFindAnswers*>(answers)->Add(*summary);
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
392 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
393 };
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
394
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
395
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
396 static char* CopyString(const std::string& str)
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
397 {
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
398 char *result = reinterpret_cast<char*>(malloc(str.size() + 1));
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
399 if (result == NULL)
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
400 {
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
401 throw OrthancException(ErrorCode_NotEnoughMemory);
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
402 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
403
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
404 if (str.size() == 0)
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
405 {
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
406 result[0] = '\0';
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
407 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
408 else
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
409 {
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
410 memcpy(result, &str[0], str.size() + 1);
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
411 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
412
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
413 return result;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
414 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
415
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
416
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
417 OrthancPlugins::OrthancPlugins()
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 {
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
419 /* 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
420 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
421 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
422 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
423 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
424 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
425 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
426 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
427 sizeof(int32_t) != sizeof(OrthancPluginChangeType) ||
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
428 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
429 sizeof(int32_t) != sizeof(OrthancPluginCompressionType) ||
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
430 sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) ||
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
431 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) ||
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
432 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) ||
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
433 sizeof(int32_t) != sizeof(OrthancPluginCreateDicomFlags) ||
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
434 sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType) ||
1760
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1744
diff changeset
435 sizeof(int32_t) != sizeof(OrthancPluginIdentifierConstraint) ||
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
436 sizeof(int32_t) != sizeof(OrthancPluginInstanceOrigin) ||
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
437 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
438 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
439 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
440 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
441 static_cast<int>(OrthancPluginDicomToJsonFlags_ConvertBinaryToNull) != static_cast<int>(DicomToJsonFlags_ConvertBinaryToNull) ||
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
442 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
443 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
444 static_cast<int>(OrthancPluginCreateDicomFlags_GenerateIdentifiers) != static_cast<int>(DicomFromJsonFlags_GenerateIdentifiers))
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
445
1578
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
446 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
447 throw OrthancException(ErrorCode_Plugin);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
448 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
449
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
450 pimpl_.reset(new PImpl());
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
451 pimpl_->manager_.RegisterServiceProvider(*this);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
455 void OrthancPlugins::SetServerContext(ServerContext& context)
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
456 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
457 pimpl_->context_ = &context;
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
458 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
459
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
460
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
461
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
462 OrthancPlugins::~OrthancPlugins()
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
464 for (PImpl::RestCallbacks::iterator it = pimpl_->restCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
465 it != pimpl_->restCallbacks_.end(); ++it)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
467 delete *it;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
472 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
473 std::vector<const char*>& values,
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
474 const IHttpHandler::Arguments& arguments)
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
475 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
476 keys.resize(arguments.size());
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
477 values.resize(arguments.size());
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
478
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
479 size_t pos = 0;
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
480 for (IHttpHandler::Arguments::const_iterator
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
481 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
482 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
483 keys[pos] = it->first.c_str();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
484 values[pos] = it->second.c_str();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
485 pos++;
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
486 }
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
487 }
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
488
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
489
1363
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
490 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
491 std::vector<const char*>& values,
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
492 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
493 {
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
494 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
495 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
496
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
497 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
498 {
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
499 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
500 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
501 }
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
502 }
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
503
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
504
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
505 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
506 RequestOrigin /*origin*/,
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
507 const char* /*remoteIp*/,
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
508 const char* /*username*/,
1329
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
509 HttpMethod method,
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
510 const UriComponents& uri,
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
511 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
512 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
513 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
514 size_t bodySize)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 {
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 std::string flatUri = Toolbox::FlattenUri(uri);
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
517 PImpl::RestCallback* callback = NULL;
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
518
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
519 std::vector<std::string> groups;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
520 std::vector<const char*> cgroups;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
521
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
522 // 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
523 bool found = false;
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
524 for (PImpl::RestCallbacks::const_iterator it = pimpl_->restCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
525 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
526 {
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
527 // 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
528 // callback matches the URI
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
529 boost::cmatch what;
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
530 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
531 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
532 callback = *it;
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
533
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
534 // 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
535 if (what.size() > 1)
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
536 {
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
537 groups.resize(what.size() - 1);
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
538 cgroups.resize(what.size() - 1);
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
539 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
540 {
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
541 groups[i - 1] = what[i];
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
542 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
543 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
544 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
545 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
546 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
547
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
548 if (callback == NULL)
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
549 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
550 // Callback not found
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
551 return false;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
552 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 LOG(INFO) << "Delegating HTTP request to plugin for URI: " << flatUri;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
556 std::vector<const char*> getKeys, getValues, headersKeys, headersValues;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
558 OrthancPluginHttpRequest request;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
559 memset(&request, 0, sizeof(OrthancPluginHttpRequest));
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
560
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
561 ArgumentsToPlugin(headersKeys, headersValues, headers);
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
562
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563 switch (method)
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 {
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 case HttpMethod_Get:
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
566 request.method = OrthancPluginHttpMethod_Get;
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
567 ArgumentsToPlugin(getKeys, getValues, getArguments);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 break;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 case HttpMethod_Post:
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
571 request.method = OrthancPluginHttpMethod_Post;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572 break;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 case HttpMethod_Delete:
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
575 request.method = OrthancPluginHttpMethod_Delete;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 break;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578 case HttpMethod_Put:
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
579 request.method = OrthancPluginHttpMethod_Put;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 break;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582 default:
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 throw OrthancException(ErrorCode_InternalError);
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
586
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
587 request.groups = (cgroups.size() ? &cgroups[0] : NULL);
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
588 request.groupsCount = cgroups.size();
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
589 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
590 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
591 request.bodySize = bodySize;
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
592 request.headersCount = headers.size();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
593
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
594 if (getArguments.size() > 0)
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
595 {
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
596 request.getKeys = &getKeys[0];
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
597 request.getValues = &getValues[0];
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
598 }
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
599
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
600 if (headers.size() > 0)
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
601 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
602 request.headersKeys = &headersKeys[0];
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
603 request.headersValues = &headersValues[0];
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
604 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
605
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
606 assert(callback != NULL);
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
607 OrthancPluginErrorCode error = callback->Invoke(pimpl_->restCallbackMutex_, output, flatUri, request);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
609 if (error == OrthancPluginErrorCode_Success &&
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
610 output.IsWritingMultipart())
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
611 {
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
612 output.CloseMultipart();
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
613 }
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
614
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
615 if (error == OrthancPluginErrorCode_Success)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 {
1628
77c4cc4def0f OrthancPluginErrorCode in REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
617 return true;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 else
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
621 GetErrorDictionary().LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
622 throw OrthancException(static_cast<ErrorCode>(error));
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
624 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
625
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
626
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
627 void OrthancPlugins::SignalStoredInstance(const std::string& instanceId,
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
628 DicomInstanceToStore& instance,
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
629 const Json::Value& simplifiedTags)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
630 {
1466
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
631 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
632
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
633 for (PImpl::OnStoredCallbacks::const_iterator
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
634 callback = pimpl_->onStoredCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
635 callback != pimpl_->onStoredCallbacks_.end(); ++callback)
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
636 {
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
637 OrthancPluginErrorCode error = (*callback)
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
638 (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
639 instanceId.c_str());
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
640
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
641 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
642 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
643 GetErrorDictionary().LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
644 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
645 }
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
646 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
647 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
648
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
649
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
650
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
651 void OrthancPlugins::SignalChangeInternal(OrthancPluginChangeType changeType,
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
652 OrthancPluginResourceType resourceType,
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
653 const char* resource)
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
654 {
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
655 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
656
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
657 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
658 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
659 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
660 {
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
661 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
662
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
663 if (error != OrthancPluginErrorCode_Success)
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
664 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
665 GetErrorDictionary().LogError(error, true);
1646
da799f767e5d simplification in error casting with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1644
diff changeset
666 throw OrthancException(static_cast<ErrorCode>(error));
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
667 }
1178
c71d25e6a63c improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1177
diff changeset
668 }
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
669 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
670
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
671
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
672
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
673 void OrthancPlugins::SignalChange(const ServerIndexChange& change)
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
674 {
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
675 SignalChangeInternal(Plugins::Convert(change.GetChangeType()),
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
676 Plugins::Convert(change.GetResourceType()),
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
677 change.GetPublicId().c_str());
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
678 }
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
679
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
680
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1740
diff changeset
681
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
682 void OrthancPlugins::RegisterRestCallback(const void* parameters,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
683 bool lock)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
684 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
685 const _OrthancPluginRestCallback& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
686 *reinterpret_cast<const _OrthancPluginRestCallback*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
687
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
688 LOG(INFO) << "Plugin has registered a REST callback "
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
689 << (lock ? "with" : "witout")
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
690 << " mutual exclusion on: "
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
691 << p.pathRegularExpression;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
692
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
693 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
694 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
695
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
696
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
697
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
698 void OrthancPlugins::RegisterOnStoredInstanceCallback(const void* parameters)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
699 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
700 const _OrthancPluginOnStoredInstanceCallback& p =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
701 *reinterpret_cast<const _OrthancPluginOnStoredInstanceCallback*>(parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
702
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
703 LOG(INFO) << "Plugin has registered an OnStoredInstance callback";
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
704 pimpl_->onStoredCallbacks_.push_back(p.callback);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
705 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
706
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
707
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
708 void OrthancPlugins::RegisterOnChangeCallback(const void* parameters)
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
709 {
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
710 const _OrthancPluginOnChangeCallback& p =
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
711 *reinterpret_cast<const _OrthancPluginOnChangeCallback*>(parameters);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
712
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
713 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
714 pimpl_->onChangeCallbacks_.push_back(p.callback);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
715 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
716
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
717
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
718 void OrthancPlugins::RegisterWorklistCallback(const void* parameters)
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
719 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
720 const _OrthancPluginWorklistCallback& p =
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
721 *reinterpret_cast<const _OrthancPluginWorklistCallback*>(parameters);
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
722
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
723 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
724
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
725 if (pimpl_->worklistCallback_ != NULL)
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
726 {
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
727 LOG(ERROR) << "Can only register one plugin to handle modality worklists";
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
728 throw OrthancException(ErrorCode_Plugin);
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
729 }
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
730 else
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
731 {
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
732 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
733 pimpl_->worklistCallback_ = p.callback;
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
734 }
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
735 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
736
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
737
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
738 void OrthancPlugins::RegisterDecodeImageCallback(const void* parameters)
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
739 {
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
740 const _OrthancPluginDecodeImageCallback& p =
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
741 *reinterpret_cast<const _OrthancPluginDecodeImageCallback*>(parameters);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
742
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
743 boost::mutex::scoped_lock lock(pimpl_->decodeImageCallbackMutex_);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
744
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
745 if (pimpl_->decodeImageCallback_ != NULL)
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
746 {
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
747 LOG(ERROR) << "Can only register one plugin to handle the decompression of DICOM images";
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
748 throw OrthancException(ErrorCode_Plugin);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
749 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
750 else
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
751 {
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
752 LOG(INFO) << "Plugin has registered a callback to decode DICOM images";
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
753 pimpl_->decodeImageCallback_ = p.callback;
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
754 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
755 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
756
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
757
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
758
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
759
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
760 void OrthancPlugins::AnswerBuffer(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
761 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
762 const _OrthancPluginAnswerBuffer& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
763 *reinterpret_cast<const _OrthancPluginAnswerBuffer*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
764
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
765 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1069
diff changeset
766 translatedOutput->SetContentType(p.mimeType);
1521
3606278d305e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
767 translatedOutput->Answer(p.answer, p.answerSize);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
768 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
769
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
770
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
771 void OrthancPlugins::Redirect(const void* parameters)
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
772 {
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
773 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
774 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
775
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
776 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
777 translatedOutput->Redirect(p.argument);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
778 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
779
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
780
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
781 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
782 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
783 const _OrthancPluginSendHttpStatusCode& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
784 *reinterpret_cast<const _OrthancPluginSendHttpStatusCode*>(parameters);
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
785
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
786 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1069
diff changeset
787 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
788 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
789
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
790
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
791 void OrthancPlugins::SendHttpStatus(const void* parameters)
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
792 {
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
793 const _OrthancPluginSendHttpStatus& p =
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
794 *reinterpret_cast<const _OrthancPluginSendHttpStatus*>(parameters);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
795
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
796 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
797 HttpStatus status = static_cast<HttpStatus>(p.status);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
798
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
799 if (p.bodySize > 0 && p.body != NULL)
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
800 {
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
801 translatedOutput->SendStatus(status, p.body, p.bodySize);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
802 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
803 else
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
804 {
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
805 translatedOutput->SendStatus(status);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
806 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
807 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
808
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
809
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
810 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
811 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
812 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
813 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
814
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
815 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
816 translatedOutput->SendUnauthorized(p.argument);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
817 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
818
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
819
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
820 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
821 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
822 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
823 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
824
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
825 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
826 translatedOutput->SendMethodNotAllowed(p.argument);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
827 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
828
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
829
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
830 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
831 {
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
832 const _OrthancPluginSetHttpHeader& p =
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
833 *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
834
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
835 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
836 translatedOutput->SetCookie(p.key, p.value);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
837 }
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
838
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
839
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
840 void OrthancPlugins::SetHttpHeader(const void* parameters)
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
841 {
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
842 const _OrthancPluginSetHttpHeader& p =
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
843 *reinterpret_cast<const _OrthancPluginSetHttpHeader*>(parameters);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
844
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
845 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
846 translatedOutput->AddHeader(p.key, p.value);
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
847 }
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
848
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
849
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
850 void OrthancPlugins::CompressAndAnswerPngImage(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
851 {
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
852 // Bridge for backward compatibility with Orthanc <= 0.9.3
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
853 const _OrthancPluginCompressAndAnswerPngImage& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
854 *reinterpret_cast<const _OrthancPluginCompressAndAnswerPngImage*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
855
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
856 _OrthancPluginCompressAndAnswerImage p2;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
857 p2.output = p.output;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
858 p2.imageFormat = OrthancPluginImageFormat_Png;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
859 p2.pixelFormat = p.format;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
860 p2.width = p.width;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
861 p2.height = p.height;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
862 p2.pitch = p.height;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
863 p2.buffer = p.buffer;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
864 p2.quality = 0;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
865
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
866 CompressAndAnswerImage(&p2);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
867 }
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
868
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
869
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
870 void OrthancPlugins::CompressAndAnswerImage(const void* parameters)
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
871 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
872 const _OrthancPluginCompressAndAnswerImage& p =
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
873 *reinterpret_cast<const _OrthancPluginCompressAndAnswerImage*>(parameters);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
874
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
875 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
876
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
877 ImageAccessor accessor;
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
878 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
879
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
880 std::string compressed;
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
881
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
882 switch (p.imageFormat)
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
883 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
884 case OrthancPluginImageFormat_Png:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
885 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
886 PngWriter writer;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
887 writer.WriteToMemory(compressed, accessor);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
888 translatedOutput->SetContentType("image/png");
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
889 break;
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
890 }
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
891
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
892 case OrthancPluginImageFormat_Jpeg:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
893 {
1603
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
894 JpegWriter writer;
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
895 writer.SetQuality(p.quality);
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
896 writer.WriteToMemory(compressed, accessor);
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
897 translatedOutput->SetContentType("image/jpeg");
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
898 break;
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
899 }
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
900
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
901 default:
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
902 throw OrthancException(ErrorCode_ParameterOutOfRange);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
903 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
904
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
905 translatedOutput->Answer(compressed);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
906 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
907
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
908
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
909 void OrthancPlugins::CheckContextAvailable()
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
910 {
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
911 if (!pimpl_->context_)
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
912 {
1643
87c77b9b3679 provision for error codes in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
913 throw OrthancException(ErrorCode_DatabaseNotInitialized);
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
914 }
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
915 }
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
916
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
917
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
918 void OrthancPlugins::GetDicomForInstance(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
919 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
920 const _OrthancPluginGetDicomForInstance& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
921 *reinterpret_cast<const _OrthancPluginGetDicomForInstance*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
922
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
923 std::string dicom;
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
924
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
925 CheckContextAvailable();
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
926 pimpl_->context_->ReadFile(dicom, p.instanceId, FileContentType_Dicom);
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
927
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
928 CopyToMemoryBuffer(*p.target, dicom);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
929 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
930
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
931
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
932 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
933 bool afterPlugins)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
934 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
935 const _OrthancPluginRestApiGet& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
936 *reinterpret_cast<const _OrthancPluginRestApiGet*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
937
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
938 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
939 << (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
940
1445
d26c8a93d05a refactoring: SimpleGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
941 CheckContextAvailable();
d26c8a93d05a refactoring: SimpleGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
942 IHttpHandler& handler = pimpl_->context_->GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
943
1445
d26c8a93d05a refactoring: SimpleGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
944 std::string result;
1571
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
945 if (HttpToolbox::SimpleGet(result, handler, RequestOrigin_Plugins, p.uri))
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
946 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
947 CopyToMemoryBuffer(*p.target, result);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
948 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
949 else
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
950 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
951 throw OrthancException(ErrorCode_BadRequest);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
952 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
953 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
954
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
955
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
956 void OrthancPlugins::RestApiGet2(const void* parameters)
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
957 {
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
958 const _OrthancPluginRestApiGet2& p =
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
959 *reinterpret_cast<const _OrthancPluginRestApiGet2*>(parameters);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
960
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
961 LOG(INFO) << "Plugin making REST GET call on URI " << p.uri
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
962 << (p.afterPlugins ? " (after plugins)" : " (built-in API)");
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
963
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
964 IHttpHandler::Arguments headers;
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
965
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
966 for (uint32_t i = 0; i < p.headersCount; i++)
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
967 {
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
968 headers[p.headersKeys[i]] = p.headersValues[i];
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
969 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
970
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
971 CheckContextAvailable();
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
972 IHttpHandler& handler = pimpl_->context_->GetHttpHandler().RestrictToOrthancRestApi(!p.afterPlugins);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
973
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
974 std::string result;
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
975 if (HttpToolbox::SimpleGet(result, handler, RequestOrigin_Plugins, p.uri, headers))
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
976 {
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
977 CopyToMemoryBuffer(*p.target, result);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
978 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
979 else
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
980 {
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
981 throw OrthancException(ErrorCode_BadRequest);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
982 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
983 }
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
984
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
985
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
986 void OrthancPlugins::RestApiPostPut(bool isPost,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
987 const void* parameters,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
988 bool afterPlugins)
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
989 {
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
990 const _OrthancPluginRestApiPostPut& p =
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
991 *reinterpret_cast<const _OrthancPluginRestApiPostPut*>(parameters);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
992
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
993 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
994 << " 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
995
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
996 CheckContextAvailable();
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
997 IHttpHandler& handler = pimpl_->context_->GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
998
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
999 std::string result;
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
1000 if (isPost ?
1571
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
1001 HttpToolbox::SimplePost(result, handler, RequestOrigin_Plugins, p.uri, p.body, p.bodySize) :
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
1002 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
1003 {
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1004 CopyToMemoryBuffer(*p.target, result);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1005 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1006 else
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1007 {
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1008 throw OrthancException(ErrorCode_BadRequest);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1009 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1010 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1011
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1012
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1013 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
1014 bool afterPlugins)
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1015 {
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
1016 const char* uri = reinterpret_cast<const char*>(parameters);
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
1017 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
1018 << (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
1019
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
1020 CheckContextAvailable();
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
1021 IHttpHandler& handler = pimpl_->context_->GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1022
1571
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
1023 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
1024 {
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1025 throw OrthancException(ErrorCode_BadRequest);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1026 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1027 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1028
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1029
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1030 void OrthancPlugins::LookupResource(_OrthancPluginService service,
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1031 const void* parameters)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1032 {
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1033 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
1034 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1035
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1036 /**
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1037 * 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
1038 * the Orthanc database. It reflects the
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1039 * "CandidateResources::ApplyFilter()" method of the
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1040 * "OrthancFindRequestHandler" class.
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1041 **/
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1042
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1043 DicomTag tag(0, 0);
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1044 ResourceType level;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1045 switch (service)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1046 {
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1047 case _OrthancPluginService_LookupPatient:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1048 tag = DICOM_TAG_PATIENT_ID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1049 level = ResourceType_Patient;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1050 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1051
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1052 case _OrthancPluginService_LookupStudy:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1053 tag = DICOM_TAG_STUDY_INSTANCE_UID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1054 level = ResourceType_Study;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1055 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1056
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1057 case _OrthancPluginService_LookupStudyWithAccessionNumber:
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1058 tag = DICOM_TAG_ACCESSION_NUMBER;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1059 level = ResourceType_Study;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1060 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1061
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1062 case _OrthancPluginService_LookupSeries:
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1063 tag = DICOM_TAG_SERIES_INSTANCE_UID;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1064 level = ResourceType_Series;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1065 break;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1066
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1067 case _OrthancPluginService_LookupInstance:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1068 tag = DICOM_TAG_SOP_INSTANCE_UID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1069 level = ResourceType_Instance;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1070 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1071
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1072 default:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1073 throw OrthancException(ErrorCode_InternalError);
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1074 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1075
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
1076 CheckContextAvailable();
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1077
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1078 std::list<std::string> result;
1728
4941494b5dd8 rename LookupIdentifier as LookupIdentifierExact
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1727
diff changeset
1079 pimpl_->context_->GetIndex().LookupIdentifierExact(result, level, tag, p.argument);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1080
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1081 if (result.size() == 1)
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1082 {
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1083 *p.result = CopyString(result.front());
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1084 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1085 else
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1086 {
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1087 throw OrthancException(ErrorCode_UnknownResource);
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1088 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1089 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1090
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1091
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1092 static void AccessInstanceMetadataInternal(bool checkExistence,
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1093 const _OrthancPluginAccessDicomInstance& params,
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1094 const DicomInstanceToStore& instance)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1095 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1096 MetadataType metadata;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1097
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1098 try
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1099 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1100 metadata = StringToMetadata(params.key);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1101 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1102 catch (OrthancException&)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1103 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1104 // Unknown metadata
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1105 if (checkExistence)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1106 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1107 *params.resultInt64 = -1;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1108 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1109 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1110 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1111 *params.resultString = NULL;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1112 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1113
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1114 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1115 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1116
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1117 ServerIndex::MetadataMap::const_iterator it =
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1118 instance.GetMetadata().find(std::make_pair(ResourceType_Instance, metadata));
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1119
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1120 if (checkExistence)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1121 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1122 if (it != instance.GetMetadata().end())
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1123 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1124 *params.resultInt64 = 1;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1125 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1126 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1127 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1128 *params.resultInt64 = 0;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1129 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1130 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1131 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1132 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1133 if (it != instance.GetMetadata().end())
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1134 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1135 *params.resultString = it->second.c_str();
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1136 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1137 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1138 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1139 // Error: Missing metadata
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1140 *params.resultString = NULL;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1141 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1142 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1143 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1144
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1145
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1146 static void AccessDicomInstance(_OrthancPluginService service,
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1147 const void* parameters)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1148 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1149 const _OrthancPluginAccessDicomInstance& p =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1150 *reinterpret_cast<const _OrthancPluginAccessDicomInstance*>(parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1151
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1152 DicomInstanceToStore& instance =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1153 *reinterpret_cast<DicomInstanceToStore*>(p.instance);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1154
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1155 switch (service)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1156 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1157 case _OrthancPluginService_GetInstanceRemoteAet:
1572
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
diff changeset
1158 *p.resultString = instance.GetRemoteAet();
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1159 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1160
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1161 case _OrthancPluginService_GetInstanceSize:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1162 *p.resultInt64 = instance.GetBufferSize();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1163 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1164
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1165 case _OrthancPluginService_GetInstanceData:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1166 *p.resultString = instance.GetBufferData();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1167 return;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1168
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1169 case _OrthancPluginService_HasInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1170 AccessInstanceMetadataInternal(true, p, instance);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1171 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1172
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1173 case _OrthancPluginService_GetInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1174 AccessInstanceMetadataInternal(false, p, instance);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1175 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1176
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1177 case _OrthancPluginService_GetInstanceJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1178 case _OrthancPluginService_GetInstanceSimplifiedJson:
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 Json::StyledWriter writer;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1181 std::string s;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1182
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1183 if (service == _OrthancPluginService_GetInstanceJson)
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 s = writer.write(instance.GetJson());
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1186 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1187 else
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1188 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1189 Json::Value simplified;
1668
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
1190 Toolbox::SimplifyTags(simplified, instance.GetJson());
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1191 s = writer.write(simplified);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1192 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1193
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1194 *p.resultStringToFree = CopyString(s);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1195 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1196 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1197
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
1198 case _OrthancPluginService_GetInstanceOrigin: // New in Orthanc 0.9.5
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
1199 *p.resultOrigin = Plugins::Convert(instance.GetRequestOrigin());
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
1200 return;
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
1201
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1202 default:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1203 throw OrthancException(ErrorCode_InternalError);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1204 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1205 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1206
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1207
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1208 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
1209 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1210 const _OrthancPluginBufferCompression& p =
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1211 *reinterpret_cast<const _OrthancPluginBufferCompression*>(parameters);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1212
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1213 std::string result;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1214
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1215 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1216 std::auto_ptr<DeflateBaseCompressor> compressor;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1217
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1218 switch (p.compression)
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1219 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1220 case OrthancPluginCompressionType_Zlib:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1221 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1222 compressor.reset(new ZlibCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1223 compressor->SetPrefixWithUncompressedSize(false);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1224 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1225 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1226
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1227 case OrthancPluginCompressionType_ZlibWithSize:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1228 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1229 compressor.reset(new ZlibCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1230 compressor->SetPrefixWithUncompressedSize(true);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1231 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1232 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1233
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1234 case OrthancPluginCompressionType_Gzip:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1235 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1236 compressor.reset(new GzipCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1237 compressor->SetPrefixWithUncompressedSize(false);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1238 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1239 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1240
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1241 case OrthancPluginCompressionType_GzipWithSize:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1242 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1243 compressor.reset(new GzipCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1244 compressor->SetPrefixWithUncompressedSize(true);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1245 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1246 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1247
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1248 default:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1249 throw OrthancException(ErrorCode_ParameterOutOfRange);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1250 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1251
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1252 if (p.uncompress)
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1253 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1254 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
1255 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1256 else
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1257 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1258 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
1259 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1260 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1261
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1262 CopyToMemoryBuffer(*p.target, result);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1263 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1264
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1265
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1266 void OrthancPlugins::UncompressImage(const void* parameters)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1267 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1268 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
1269
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1270 std::auto_ptr<ImageAccessor> image;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1271
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1272 switch (p.format)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1273 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1274 case OrthancPluginImageFormat_Png:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1275 {
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1276 image.reset(new PngReader);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1277 reinterpret_cast<PngReader&>(*image).ReadFromMemory(p.data, p.size);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1278 break;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1279 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1280
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1281 case OrthancPluginImageFormat_Jpeg:
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1282 {
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1283 image.reset(new JpegReader);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1284 reinterpret_cast<JpegReader&>(*image).ReadFromMemory(p.data, p.size);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1285 break;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1286 }
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1287
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1288 default:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1289 throw OrthancException(ErrorCode_ParameterOutOfRange);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1290 }
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1291
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1292 *(p.target) = reinterpret_cast<OrthancPluginImage*>(image.release());
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1293 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1294
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1295
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1296 void OrthancPlugins::CompressImage(const void* parameters)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1297 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1298 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
1299
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1300 std::string compressed;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1301
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1302 switch (p.imageFormat)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1303 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1304 case OrthancPluginImageFormat_Png:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1305 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1306 PngWriter writer;
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
1307 writer.WriteToMemory(compressed, p.width, p.height, p.pitch, Plugins::Convert(p.pixelFormat), p.buffer);
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1308 break;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1309 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1310
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1311 case OrthancPluginImageFormat_Jpeg:
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1312 {
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1313 JpegWriter writer;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1314 writer.SetQuality(p.quality);
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
1315 writer.WriteToMemory(compressed, p.width, p.height, p.pitch, Plugins::Convert(p.pixelFormat), p.buffer);
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1316 break;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1317 }
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1318
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1319 default:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1320 throw OrthancException(ErrorCode_ParameterOutOfRange);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1321 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1322
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1323 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
1324 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1325
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1326
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1327 void OrthancPlugins::CallHttpClient(const void* parameters)
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1328 {
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1329 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
1330
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1331 HttpClient client;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1332 client.SetUrl(p.url);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1333
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1334 if (p.username != NULL &&
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1335 p.password != NULL)
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1336 {
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1337 client.SetCredentials(p.username, p.password);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1338 }
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1339
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1340 switch (p.method)
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1341 {
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1342 case OrthancPluginHttpMethod_Get:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1343 client.SetMethod(HttpMethod_Get);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1344 break;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1345
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1346 case OrthancPluginHttpMethod_Post:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1347 client.SetMethod(HttpMethod_Post);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1348 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
1349 break;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1350
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1351 case OrthancPluginHttpMethod_Put:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1352 client.SetMethod(HttpMethod_Put);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1353 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
1354 break;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1355
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1356 case OrthancPluginHttpMethod_Delete:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1357 client.SetMethod(HttpMethod_Delete);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1358 break;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1359
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1360 default:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1361 throw OrthancException(ErrorCode_ParameterOutOfRange);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1362 }
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1363
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1364 std::string s;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1365 client.ApplyAndThrowException(s);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1366
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1367 if (p.method != OrthancPluginHttpMethod_Delete)
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1368 {
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1369 CopyToMemoryBuffer(*p.target, s);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1370 }
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1371 }
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1372
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1373
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1374 void OrthancPlugins::ConvertPixelFormat(const void* parameters)
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1375 {
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1376 const _OrthancPluginConvertPixelFormat& p = *reinterpret_cast<const _OrthancPluginConvertPixelFormat*>(parameters);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1377 const ImageAccessor& source = *reinterpret_cast<const ImageAccessor*>(p.source);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1378
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
1379 std::auto_ptr<ImageAccessor> target(new Image(Plugins::Convert(p.targetFormat), source.GetWidth(), source.GetHeight()));
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1380 ImageProcessing::Convert(*target, source);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1381
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1382 *(p.target) = reinterpret_cast<OrthancPluginImage*>(target.release());
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1383 }
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1384
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1385
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1386
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1387 void OrthancPlugins::GetFontInfo(const void* parameters)
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1388 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1389 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
1390
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1391 const Font& font = Configuration::GetFontRegistry().GetFont(p.fontIndex);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1392
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1393 if (p.name != NULL)
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1394 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1395 *(p.name) = font.GetName().c_str();
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1396 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1397 else if (p.size != NULL)
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1398 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1399 *(p.size) = font.GetSize();
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1400 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1401 else
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1402 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1403 throw OrthancException(ErrorCode_InternalError);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1404 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1405 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1406
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1407
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1408 void OrthancPlugins::DrawText(const void* parameters)
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1409 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1410 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
1411
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1412 ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1413 const Font& font = Configuration::GetFontRegistry().GetFont(p.fontIndex);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1414
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1415 font.Draw(target, p.utf8Text, p.x, p.y, p.r, p.g, p.b);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1416 }
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1417
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1418
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1419 void OrthancPlugins::ApplyDicomToJson(_OrthancPluginService service,
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1420 const void* parameters)
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1421 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1422 const _OrthancPluginDicomToJson& p =
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1423 *reinterpret_cast<const _OrthancPluginDicomToJson*>(parameters);
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1424
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1425 std::auto_ptr<ParsedDicomFile> dicom;
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1426
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1427 if (service == _OrthancPluginService_DicomBufferToJson)
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1428 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1429 dicom.reset(new ParsedDicomFile(p.buffer, p.size));
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1430 }
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1431 else
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1432 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1433 if (p.instanceId == NULL)
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1434 {
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1435 throw OrthancException(ErrorCode_ParameterOutOfRange);
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1436 }
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1437
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1438 std::string content;
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1439 pimpl_->context_->ReadFile(content, p.instanceId, FileContentType_Dicom);
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1440 dicom.reset(new ParsedDicomFile(content));
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1441 }
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1442
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1443 Json::Value json;
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1444 dicom->ToJson(json, Plugins::Convert(p.format),
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1445 static_cast<DicomToJsonFlags>(p.flags), p.maxStringLength);
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1446
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1447 Json::FastWriter writer;
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1448 *p.result = CopyString(writer.write(json));
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
1449 }
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1450
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1451
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1452 void OrthancPlugins::ApplyCreateDicom(_OrthancPluginService service,
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1453 const void* parameters)
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1454 {
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1455 const _OrthancPluginCreateDicom& p =
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1456 *reinterpret_cast<const _OrthancPluginCreateDicom*>(parameters);
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1457
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1458 Json::Value json;
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1459 Json::Reader reader;
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1460 if (!reader.parse(p.json, json))
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1461 {
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1462 throw OrthancException(ErrorCode_BadJson);
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1463 }
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1464
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1465 std::string dicom;
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1466
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1467 {
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1468 std::auto_ptr<ParsedDicomFile> file
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1469 (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
1470
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1471 if (p.pixelData)
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1472 {
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1473 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
1474 }
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1475
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1476 file->SaveToMemoryBuffer(dicom);
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1477 }
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1478
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1479 CopyToMemoryBuffer(*p.target, dicom);
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1480 }
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1481
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1482
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1483 void OrthancPlugins::ApplyCreateImage(_OrthancPluginService service,
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1484 const void* parameters)
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1485 {
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1486 const _OrthancPluginCreateImage& p =
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1487 *reinterpret_cast<const _OrthancPluginCreateImage*>(parameters);
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1488
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1489 std::auto_ptr<ImageAccessor> result;
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1490
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1491 if (service == _OrthancPluginService_CreateImage)
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1492 {
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1493 result.reset(new Image(Plugins::Convert(p.format), p.width, p.height));
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1494 }
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1495 else
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1496 {
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1497 result.reset(new ImageAccessor);
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1498 result->AssignWritable(Plugins::Convert(p.format), p.width, p.height, p.pitch, p.buffer);
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1499 }
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1500
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1501 *(p.target) = reinterpret_cast<OrthancPluginImage*>(result.release());
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
1502 }
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1503
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
1504
1771
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1505 void OrthancPlugins::DatabaseAnswer(const void* parameters)
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1506 {
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1507 const _OrthancPluginDatabaseAnswer& p =
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1508 *reinterpret_cast<const _OrthancPluginDatabaseAnswer*>(parameters);
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1509
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1510 if (pimpl_->database_.get() != NULL)
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1511 {
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1512 pimpl_->database_->AnswerReceived(p);
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1513 }
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1514 else
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1515 {
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1516 LOG(ERROR) << "Cannot invoke this service without a custom database back-end";
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1517 throw OrthancException(ErrorCode_BadRequest);
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1518 }
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1519 }
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1520
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1521
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
1522 bool OrthancPlugins::InvokeService(SharedLibrary& plugin,
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1523 _OrthancPluginService service,
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1524 const void* parameters)
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1525 {
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
1526 VLOG(1) << "Calling service " << service << " from plugin " << plugin.GetPath();
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1527
1768
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1528 if (service == _OrthancPluginService_DatabaseAnswer)
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1529 {
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1530 // This case solves a deadlock at (*) reported by James Webster
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1531 // on 2015-10-27 that was present in versions of Orthanc <=
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1532 // 0.9.4 and related to database plugins implementing a custom
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1533 // index. The problem was that locking the database is already
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1534 // ensured by the "ServerIndex" class if the invoked service is
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1535 // "DatabaseAnswer".
1771
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1536 DatabaseAnswer(parameters);
8790488ae98b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
1537 return true;
1768
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1538 }
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1539
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1540
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1541 std::auto_ptr<boost::recursive_mutex::scoped_lock> lock; // (*)
1553
7c4b487b3b4a ensure mutual exclusion in InvokeService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1542
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1543 switch (service)
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1544 {
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1545 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
1546 {
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1547 std::string s = Toolbox::GetPathToExecutable();
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1548 *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
1549 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
1550 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1551
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1552 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
1553 {
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1554 std::string s = Toolbox::GetDirectoryOfExecutable();
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1555 *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
1556 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
1557 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1558
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1559 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
1560 {
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1561 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result =
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1562 CopyString(Configuration::GetConfigurationAbsolutePath());
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1563 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
1564 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1565
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1566 case _OrthancPluginService_GetConfiguration:
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1567 {
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1568 std::string s;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1569 Configuration::FormatConfiguration(s);
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1570
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1571 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = CopyString(s);
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1572 return true;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1573 }
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1574
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1575 case _OrthancPluginService_BufferCompression:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1576 BufferCompression(parameters);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1577 return true;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1578
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
1579 case _OrthancPluginService_RegisterRestCallback:
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1580 RegisterRestCallback(parameters, true);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1581 return true;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1582
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1583 case _OrthancPluginService_RegisterRestCallbackNoLock:
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1584 RegisterRestCallback(parameters, false);
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1585 return true;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1586
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1587 case _OrthancPluginService_RegisterOnStoredInstanceCallback:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1588 RegisterOnStoredInstanceCallback(parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1589 return true;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1590
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1591 case _OrthancPluginService_RegisterOnChangeCallback:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1592 RegisterOnChangeCallback(parameters);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1593 return true;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1594
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1595 case _OrthancPluginService_RegisterWorklistCallback:
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1596 RegisterWorklistCallback(parameters);
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1597 return true;
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
1598
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1599 case _OrthancPluginService_RegisterDecodeImageCallback:
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1600 RegisterDecodeImageCallback(parameters);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1601 return true;
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
1602
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
1603 case _OrthancPluginService_AnswerBuffer:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1604 AnswerBuffer(parameters);
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1605 return true;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1606
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
1607 case _OrthancPluginService_CompressAndAnswerPngImage:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1608 CompressAndAnswerPngImage(parameters);
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1609 return true;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1610
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1611 case _OrthancPluginService_CompressAndAnswerImage:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1612 CompressAndAnswerImage(parameters);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1613 return true;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1614
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
1615 case _OrthancPluginService_GetDicomForInstance:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1616 GetDicomForInstance(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1617 return true;
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
1618
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1619 case _OrthancPluginService_RestApiGet:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1620 RestApiGet(parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1621 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1622
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1623 case _OrthancPluginService_RestApiGetAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1624 RestApiGet(parameters, true);
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
1625 return true;
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1626
1780
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1627 case _OrthancPluginService_RestApiGet2:
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1628 RestApiGet2(parameters);
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1629 return true;
94990da8710e OrthancPluginRestApiGet2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1771
diff changeset
1630
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1631 case _OrthancPluginService_RestApiPost:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1632 RestApiPostPut(true, parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1633 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1634
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1635 case _OrthancPluginService_RestApiPostAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1636 RestApiPostPut(true, parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1637 return true;
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1638
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1639 case _OrthancPluginService_RestApiDelete:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1640 RestApiDelete(parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1641 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1642
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1643 case _OrthancPluginService_RestApiDeleteAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1644 RestApiDelete(parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1645 return true;
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1646
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1647 case _OrthancPluginService_RestApiPut:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1648 RestApiPostPut(false, parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1649 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1650
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1651 case _OrthancPluginService_RestApiPutAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1652 RestApiPostPut(false, parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1653 return true;
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
1654
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1655 case _OrthancPluginService_Redirect:
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1656 Redirect(parameters);
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1657 return true;
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1658
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1659 case _OrthancPluginService_SendUnauthorized:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1660 SendUnauthorized(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1661 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1662
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1663 case _OrthancPluginService_SendMethodNotAllowed:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1664 SendMethodNotAllowed(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1665 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1666
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1667 case _OrthancPluginService_SendHttpStatus:
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1668 SendHttpStatus(parameters);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1669 return true;
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1670
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1671 case _OrthancPluginService_SendHttpStatusCode:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1672 SendHttpStatusCode(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1673 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1674
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1675 case _OrthancPluginService_SetCookie:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1676 SetCookie(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1677 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1678
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1679 case _OrthancPluginService_SetHttpHeader:
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1680 SetHttpHeader(parameters);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1681 return true;
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1682
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1683 case _OrthancPluginService_LookupPatient:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1684 case _OrthancPluginService_LookupStudy:
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1685 case _OrthancPluginService_LookupStudyWithAccessionNumber:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1686 case _OrthancPluginService_LookupSeries:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1687 case _OrthancPluginService_LookupInstance:
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1688 LookupResource(service, parameters);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1689 return true;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1690
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1691 case _OrthancPluginService_GetInstanceRemoteAet:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1692 case _OrthancPluginService_GetInstanceSize:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1693 case _OrthancPluginService_GetInstanceData:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1694 case _OrthancPluginService_GetInstanceJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1695 case _OrthancPluginService_GetInstanceSimplifiedJson:
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1696 case _OrthancPluginService_HasInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1697 case _OrthancPluginService_GetInstanceMetadata:
1815
2abfdca9b915 OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
1698 case _OrthancPluginService_GetInstanceOrigin:
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1699 AccessDicomInstance(service, parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1700 return true;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1701
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1702 case _OrthancPluginService_RegisterStorageArea:
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1703 {
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1704 LOG(INFO) << "Plugin has registered a custom storage area";
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1705 const _OrthancPluginRegisterStorageArea& p =
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1706 *reinterpret_cast<const _OrthancPluginRegisterStorageArea*>(parameters);
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1707
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
1708 if (pimpl_->storageArea_.get() == 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
1709 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
1710 pimpl_->storageArea_.reset(new StorageAreaFactory(plugin, p, GetErrorDictionary()));
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
1711 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1712 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
1713 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1714 throw OrthancException(ErrorCode_StorageAreaAlreadyRegistered);
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1715 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1716
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1717 return true;
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1718 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1719
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1720 case _OrthancPluginService_SetPluginProperty:
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1721 {
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1722 const _OrthancPluginSetPluginProperty& p =
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1723 *reinterpret_cast<const _OrthancPluginSetPluginProperty*>(parameters);
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1724 pimpl_->properties_[std::make_pair(p.plugin, p.property)] = p.value;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1725 return true;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1726 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1727
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1728 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
1729 {
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1730 const _OrthancPluginGlobalProperty& p =
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1731 *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
1732 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
1733 {
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1734 return false;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1735 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1736 else
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1737 {
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
1738 CheckContextAvailable();
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1739 pimpl_->context_->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
1740 return true;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1741 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1742 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1743
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1744 case _OrthancPluginService_GetGlobalProperty:
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1745 {
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
1746 CheckContextAvailable();
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1747
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1748 const _OrthancPluginGlobalProperty& p =
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1749 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1750 std::string result = pimpl_->context_->GetIndex().GetGlobalProperty(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
1751 *(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
1752 return true;
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1753 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1754
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1755 case _OrthancPluginService_GetCommandLineArgumentsCount:
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1756 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1757 const _OrthancPluginReturnSingleValue& p =
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1758 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1759 *(p.resultUint32) = pimpl_->argc_ - 1;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1760 return true;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1761 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1762
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1763 case _OrthancPluginService_GetCommandLineArgument:
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1764 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1765 const _OrthancPluginGlobalProperty& p =
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1766 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1767
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1768 if (p.property + 1 > pimpl_->argc_)
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1769 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1770 return false;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1771 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1772 else
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1773 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1774 std::string arg = std::string(pimpl_->argv_[p.property + 1]);
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1775 *(p.result) = CopyString(arg);
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1776 return true;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1777 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1778 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1779
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1780 case _OrthancPluginService_RegisterDatabaseBackend:
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1781 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1782 LOG(INFO) << "Plugin has registered a custom database back-end";
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1783
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1784 const _OrthancPluginRegisterDatabaseBackend& p =
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1785 *reinterpret_cast<const _OrthancPluginRegisterDatabaseBackend*>(parameters);
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
1786
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1787 if (pimpl_->database_.get() == 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
1788 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
1789 pimpl_->database_.reset(new OrthancPluginDatabase(plugin, GetErrorDictionary(),
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
1790 *p.backend, NULL, 0, p.payload));
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
1791 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1792 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
1793 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1794 throw OrthancException(ErrorCode_DatabaseBackendAlreadyRegistered);
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1795 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1796
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1797 *(p.result) = reinterpret_cast<OrthancPluginDatabaseContext*>(pimpl_->database_.get());
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1798
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1799 return true;
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1800 }
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1801
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1802 case _OrthancPluginService_RegisterDatabaseBackendV2:
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1803 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1804 LOG(INFO) << "Plugin has registered a custom database back-end";
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1805
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1806 const _OrthancPluginRegisterDatabaseBackendV2& p =
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1807 *reinterpret_cast<const _OrthancPluginRegisterDatabaseBackendV2*>(parameters);
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
1808
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1809 if (pimpl_->database_.get() == 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
1810 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
1811 pimpl_->database_.reset(new OrthancPluginDatabase(plugin, GetErrorDictionary(),
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1649
diff changeset
1812 *p.backend, p.extensions,
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
1813 p.extensionsSize, p.payload));
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1814 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1815 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
1816 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1817 throw OrthancException(ErrorCode_DatabaseBackendAlreadyRegistered);
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
1818 }
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1819
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1820 *(p.result) = reinterpret_cast<OrthancPluginDatabaseContext*>(pimpl_->database_.get());
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1821
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1822 return true;
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1823 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1824
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1825 case _OrthancPluginService_DatabaseAnswer:
1768
70f544f9c38f fix possible deadlock in custom database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
1826 throw OrthancException(ErrorCode_InternalError); // Implemented before locking (*)
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1827
1407
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1828 case _OrthancPluginService_GetExpectedDatabaseVersion:
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1829 {
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1830 const _OrthancPluginReturnSingleValue& p =
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1831 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1832 *(p.resultUint32) = ORTHANC_DATABASE_VERSION;
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1833 return true;
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1834 }
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1835
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1836 case _OrthancPluginService_StartMultipartAnswer:
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1837 {
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1838 const _OrthancPluginStartMultipartAnswer& p =
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1839 *reinterpret_cast<const _OrthancPluginStartMultipartAnswer*>(parameters);
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1840 HttpOutput* output = reinterpret_cast<HttpOutput*>(p.output);
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1841 output->StartMultipart(p.subType, p.contentType);
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1842 return true;
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1843 }
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1844
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1845 case _OrthancPluginService_SendMultipartItem:
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1846 {
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1847 // An exception might be raised in this function if the
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1848 // connection was closed by the HTTP client.
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1849 const _OrthancPluginAnswerBuffer& p =
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1850 *reinterpret_cast<const _OrthancPluginAnswerBuffer*>(parameters);
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1851 HttpOutput* output = reinterpret_cast<HttpOutput*>(p.output);
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1852 output->SendMultipartItem(p.answer, p.answerSize);
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1853 return true;
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1854 }
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1855
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1856 case _OrthancPluginService_ReadFile:
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1857 {
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1858 const _OrthancPluginReadFile& p =
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1859 *reinterpret_cast<const _OrthancPluginReadFile*>(parameters);
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1860
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1861 std::string content;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1862 Toolbox::ReadFile(content, p.path);
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1863 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
1864
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1865 return true;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1866 }
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1867
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1868 case _OrthancPluginService_WriteFile:
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1869 {
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1870 const _OrthancPluginWriteFile& p =
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1871 *reinterpret_cast<const _OrthancPluginWriteFile*>(parameters);
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1872 Toolbox::WriteFile(p.data, p.size, p.path);
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1873 return true;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1874 }
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1875
1593
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1876 case _OrthancPluginService_GetErrorDescription:
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1877 {
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1878 const _OrthancPluginGetErrorDescription& p =
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1879 *reinterpret_cast<const _OrthancPluginGetErrorDescription*>(parameters);
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1880 *(p.target) = EnumerationToString(static_cast<ErrorCode>(p.error));
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1881 return true;
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1882 }
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1883
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1884 case _OrthancPluginService_GetImagePixelFormat:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1885 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1886 const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
1887 *(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
1888 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1889 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1890
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1891 case _OrthancPluginService_GetImageWidth:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1892 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1893 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
1894 *(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
1895 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1896 }
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 case _OrthancPluginService_GetImageHeight:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1899 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1900 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
1901 *(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
1902 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1903 }
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 _OrthancPluginService_GetImagePitch:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1906 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1907 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
1908 *(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
1909 return true;
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 _OrthancPluginService_GetImageBuffer:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1913 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1914 const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1915 *(p.resultBuffer) = reinterpret_cast<const ImageAccessor*>(p.image)->GetConstBuffer();
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1916 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1917 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1918
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1919 case _OrthancPluginService_FreeImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1920 {
1605
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1604
diff changeset
1921 const _OrthancPluginFreeImage& p = *reinterpret_cast<const _OrthancPluginFreeImage*>(parameters);
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1922 if (p.image == NULL)
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1923 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1924 throw OrthancException(ErrorCode_ParameterOutOfRange);
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1925 }
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1926 else
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1927 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1928 delete reinterpret_cast<ImageAccessor*>(p.image);
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1929 return true;
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1608
diff changeset
1930 }
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1931 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1932
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1933 case _OrthancPluginService_UncompressImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1934 UncompressImage(parameters);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1935 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1936
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1937 case _OrthancPluginService_CompressImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1938 CompressImage(parameters);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1939 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1940
1606
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1941 case _OrthancPluginService_CallHttpClient:
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1942 CallHttpClient(parameters);
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1943 return true;
31f4adefb88f issuing HTTP requests from the plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1605
diff changeset
1944
1608
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1945 case _OrthancPluginService_ConvertPixelFormat:
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1946 ConvertPixelFormat(parameters);
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1947 return true;
adc6a5704cdb OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
1948
1613
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1949 case _OrthancPluginService_GetFontsCount:
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1950 {
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1951 const _OrthancPluginReturnSingleValue& p =
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1952 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1953 *(p.resultUint32) = Configuration::GetFontRegistry().GetSize();
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1954 return true;
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1955 }
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1956
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1957 case _OrthancPluginService_GetFontInfo:
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1958 GetFontInfo(parameters);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1959 return true;
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1960
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1961 case _OrthancPluginService_DrawText:
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1962 DrawText(parameters);
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1963 return true;
1ec254a7c645 drawing texts on image from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1964
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1965 case _OrthancPluginService_StorageAreaCreate:
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1966 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1967 const _OrthancPluginStorageAreaCreate& p =
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1968 *reinterpret_cast<const _OrthancPluginStorageAreaCreate*>(parameters);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1969 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
1970 storage.Create(p.uuid, p.content, 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
1971 return true;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1972 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1973
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1974 case _OrthancPluginService_StorageAreaRead:
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1975 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1976 const _OrthancPluginStorageAreaRead& p =
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1977 *reinterpret_cast<const _OrthancPluginStorageAreaRead*>(parameters);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1978 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
1979 std::string content;
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
1980 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
1981 CopyToMemoryBuffer(*p.target, content);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1982 return true;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1983 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1984
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1985 case _OrthancPluginService_StorageAreaRemove:
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1986 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1987 const _OrthancPluginStorageAreaRemove& p =
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1988 *reinterpret_cast<const _OrthancPluginStorageAreaRemove*>(parameters);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1989 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
1990 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
1991 return true;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1992 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1613
diff changeset
1993
1649
8040d56cb0b3 New function "OrthancPluginRegisterErrorCode()" to declare custom error codes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
1994 case _OrthancPluginService_RegisterErrorCode:
8040d56cb0b3 New function "OrthancPluginRegisterErrorCode()" to declare custom error codes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
1995 {
8040d56cb0b3 New function "OrthancPluginRegisterErrorCode()" to declare custom error codes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
1996 const _OrthancPluginRegisterErrorCode& p =
8040d56cb0b3 New function "OrthancPluginRegisterErrorCode()" to declare custom error codes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
1997 *reinterpret_cast<const _OrthancPluginRegisterErrorCode*>(parameters);
8040d56cb0b3 New function "OrthancPluginRegisterErrorCode()" to declare custom error codes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
1998 *(p.target) = pimpl_->dictionary_.Register(plugin, p.code, p.httpStatus, p.message);
8040d56cb0b3 New function "OrthancPluginRegisterErrorCode()" to declare custom error codes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
1999 return true;
8040d56cb0b3 New function "OrthancPluginRegisterErrorCode()" to declare custom error codes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2000 }
8040d56cb0b3 New function "OrthancPluginRegisterErrorCode()" to declare custom error codes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
2001
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
2002 case _OrthancPluginService_RegisterDictionaryTag:
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
2003 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
2004 const _OrthancPluginRegisterDictionaryTag& p =
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
2005 *reinterpret_cast<const _OrthancPluginRegisterDictionaryTag*>(parameters);
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
2006 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(p.group, p.element),
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
2007 Plugins::Convert(p.vr), p.name,
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
2008 p.minMultiplicity, p.maxMultiplicity);
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
2009 return true;
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
2010 }
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
2011
1669
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2012 case _OrthancPluginService_ReconstructMainDicomTags:
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2013 {
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2014 const _OrthancPluginReconstructMainDicomTags& p =
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2015 *reinterpret_cast<const _OrthancPluginReconstructMainDicomTags*>(parameters);
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2016
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2017 if (pimpl_->database_.get() == NULL)
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2018 {
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2019 LOG(ERROR) << "The service ReconstructMainDicomTags can only be invoked by custom database plugins";
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2020 throw OrthancException(ErrorCode_DatabasePlugin);
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2021 }
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2022
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2023 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea);
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2024 Toolbox::ReconstructMainDicomTags(*pimpl_->database_, storage, Plugins::Convert(p.level));
1673
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1669
diff changeset
2025
1669
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2026 return true;
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2027 }
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
2028
1740
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2029 case _OrthancPluginService_DicomBufferToJson:
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2030 case _OrthancPluginService_DicomInstanceToJson:
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2031 ApplyDicomToJson(service, parameters);
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2032 return true;
5e99a70b0635 DicomToJson callable from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1673
diff changeset
2033
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2034 case _OrthancPluginService_CreateDicom:
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2035 ApplyCreateDicom(service, parameters);
1821
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2036 return true;
580951a33583 OrthancPluginDicomFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1817
diff changeset
2037
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2038 case _OrthancPluginService_WorklistAddAnswer:
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2039 {
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2040 const _OrthancPluginWorklistAnswersOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2041 *reinterpret_cast<const _OrthancPluginWorklistAnswersOperation*>(parameters);
1802
138664eb59de sample worklist plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1801
diff changeset
2042 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
2043 return true;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2044 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2045
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2046 case _OrthancPluginService_WorklistMarkIncomplete:
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2047 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2048 const _OrthancPluginWorklistAnswersOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2049 *reinterpret_cast<const _OrthancPluginWorklistAnswersOperation*>(parameters);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2050 reinterpret_cast<DicomFindAnswers*>(p.answers)->SetComplete(false);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2051 return true;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2052 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2053
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2054 case _OrthancPluginService_WorklistIsMatch:
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2055 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2056 const _OrthancPluginWorklistQueryOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2057 *reinterpret_cast<const _OrthancPluginWorklistQueryOperation*>(parameters);
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2058 *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
2059 return true;
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2060 }
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2061
1810
796d0b087fb8 more consistent naming in worklist primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1809
diff changeset
2062 case _OrthancPluginService_WorklistGetDicomQuery:
1801
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2063 {
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2064 const _OrthancPluginWorklistQueryOperation& p =
2c60c357ee3e sdk primitives to handle worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
2065 *reinterpret_cast<const _OrthancPluginWorklistQueryOperation*>(parameters);
1812
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1810
diff changeset
2066 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
2067 return true;
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2068 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2069
1827
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2070 case _OrthancPluginService_CreateImage:
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2071 case _OrthancPluginService_CreateImageAccessor:
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2072 ApplyCreateImage(service, parameters);
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2073 return true;
4b6673e828f4 "OrthancPluginCreateImage()" and "OrthancPluginCreateImageAccessor()" to create images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1826
diff changeset
2074
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2075 default:
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2076 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2077 // This service is unknown to the Orthanc plugin engine
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2078 return false;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
2079 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2080 }
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2081 }
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
2082
908
e078ea944089 refactoring HttpOutput
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
2083
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
2084 bool OrthancPlugins::HasStorageArea() const
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
2085 {
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
2086 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
2087 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2088
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
2089 bool OrthancPlugins::HasDatabaseBackend() const
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2090 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2091 return pimpl_->database_.get() != NULL;
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2092 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2093
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
2094
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
2095 IStorageArea* OrthancPlugins::CreateStorageArea()
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
2096 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
2097 if (!HasStorageArea())
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
2098 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
2099 throw OrthancException(ErrorCode_BadSequenceOfCalls);
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
2100 }
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
2101 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
2102 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2103 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
2104 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2105 }
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
2106
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
2107
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2108 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
2109 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2110 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
2111 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2112 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
2113 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2114 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
2115 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2116 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
2117 }
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
2118 }
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2119
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2120
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
2121 IDatabaseWrapper& OrthancPlugins::GetDatabaseBackend()
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2122 {
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
2123 if (!HasDatabaseBackend())
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2124 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2125 throw OrthancException(ErrorCode_BadSequenceOfCalls);
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2126 }
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
2127 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
2128 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2129 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
2130 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2131 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2132
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2133
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
2134 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
2135 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2136 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
2137 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2138 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
2139 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2140 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
2141 {
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2142 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
2143 }
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1628
diff changeset
2144 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
2145
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2146
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2147 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
2148 _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
2149 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2150 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
2151 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
2152
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2153 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
2154 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2155 return NULL;
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2156 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2157 else
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2158 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2159 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
2160 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
2161 }
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
2162
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
2163
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
2164 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
2165 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
2166 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
2167 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
2168 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
2169 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
2170
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
2171 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
2172 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
2173 }
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2174
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2175
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2176 PluginsManager& OrthancPlugins::GetManager()
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2177 {
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2178 return pimpl_->manager_;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2179 }
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2180
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2181
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2182 const PluginsManager& OrthancPlugins::GetManager() const
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2183 {
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2184 return pimpl_->manager_;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
2185 }
1644
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
2186
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
2187
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
2188 PluginsErrorDictionary& OrthancPlugins::GetErrorDictionary()
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
2189 {
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
2190 return pimpl_->dictionary_;
939b921b2c81 plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1643
diff changeset
2191 }
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2192
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2193
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2194 IWorklistRequestHandler* OrthancPlugins::ConstructWorklistRequestHandler()
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2195 {
1809
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
2196 if (HasWorklistHandler())
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2197 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2198 return new WorklistHandler(*this);
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2199 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2200 else
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2201 {
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2202 return NULL;
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2203 }
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1780
diff changeset
2204 }
1809
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
2205
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
2206
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
2207 bool OrthancPlugins::HasWorklistHandler()
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
2208 {
1825
f0f8a94c0858 only one modality worklist handler at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1821
diff changeset
2209 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
2210 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
2211 }
5ed8769b17f9 disable worklist support if no plugin has registered callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1802
diff changeset
2212
1826
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2213
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2214 ImageAccessor* OrthancPlugins::Decode(ParsedDicomFile& dicom,
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2215 unsigned int frame)
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2216 {
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2217 {
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2218 boost::mutex::scoped_lock lock(pimpl_->decodeImageCallbackMutex_);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2219 if (pimpl_->decodeImageCallback_ != NULL)
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2220 {
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2221 std::string s;
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2222 dicom.SaveToMemoryBuffer(s);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2223
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2224 OrthancPluginImage* pluginImage = NULL;
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2225 if (pimpl_->decodeImageCallback_(&pluginImage, s.c_str(), s.size(), frame) == OrthancPluginErrorCode_Success &&
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2226 pluginImage != NULL)
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2227 {
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2228 return reinterpret_cast<ImageAccessor*>(pluginImage);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2229 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2230 else
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2231 {
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2232 LOG(WARNING) << "The custom image decoder cannot handle an image, trying with the built-in decoder";
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2233 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2234 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2235 }
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2236
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2237 DicomImageDecoder defaultDecoder;
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2238 return defaultDecoder.Decode(dicom, frame);
ac5b0b4e2434 refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1825
diff changeset
2239 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2240 }