annotate Plugins/Engine/OrthancPlugins.cpp @ 1604:1f5d6a2f9638

JpegReader
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 01 Sep 2015 14:57:13 +0200
parents 905b4db3092b
children fd0464ce1962
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
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
33 #include "OrthancPlugins.h"
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
35 #include "../../Core/ChunkedBuffer.h"
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
36 #include "../../Core/HttpServer/HttpToolbox.h"
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1466
diff changeset
37 #include "../../Core/Logging.h"
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
38 #include "../../Core/OrthancException.h"
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
39 #include "../../Core/Toolbox.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
40 #include "../../OrthancServer/OrthancInitialization.h"
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
41 #include "../../OrthancServer/ServerContext.h"
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
42 #include "../../OrthancServer/ServerToolbox.h"
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
43 #include "../../Core/Compression/ZlibCompressor.h"
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
44 #include "../../Core/Compression/GzipCompressor.h"
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
45 #include "../../Core/ImageFormats/PngReader.h"
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
46 #include "../../Core/ImageFormats/PngWriter.h"
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
47 #include "../../Core/ImageFormats/JpegReader.h"
1603
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
48 #include "../../Core/ImageFormats/JpegWriter.h"
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 #include <boost/regex.hpp>
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 namespace Orthanc
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
54 static OrthancPluginResourceType Convert(ResourceType type)
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
55 {
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
56 switch (type)
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
57 {
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
58 case ResourceType_Patient:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
59 return OrthancPluginResourceType_Patient;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
60
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
61 case ResourceType_Study:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
62 return OrthancPluginResourceType_Study;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
63
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
64 case ResourceType_Series:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
65 return OrthancPluginResourceType_Series;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
66
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
67 case ResourceType_Instance:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
68 return OrthancPluginResourceType_Instance;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
69
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
70 default:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
71 throw OrthancException(ErrorCode_ParameterOutOfRange);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
72 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
73 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
74
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
75
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
76 static OrthancPluginChangeType Convert(ChangeType type)
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
77 {
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
78 switch (type)
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
79 {
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
80 case ChangeType_CompletedSeries:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
81 return OrthancPluginChangeType_CompletedSeries;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
82
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
83 case ChangeType_Deleted:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
84 return OrthancPluginChangeType_Deleted;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
85
1189
6b9b02a16e99 NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1185
diff changeset
86 case ChangeType_NewChildInstance:
6b9b02a16e99 NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1185
diff changeset
87 return OrthancPluginChangeType_NewChildInstance;
6b9b02a16e99 NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1185
diff changeset
88
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
89 case ChangeType_NewInstance:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
90 return OrthancPluginChangeType_NewInstance;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
91
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
92 case ChangeType_NewPatient:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
93 return OrthancPluginChangeType_NewPatient;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
94
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
95 case ChangeType_NewSeries:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
96 return OrthancPluginChangeType_NewSeries;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
97
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
98 case ChangeType_NewStudy:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
99 return OrthancPluginChangeType_NewStudy;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
100
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
101 case ChangeType_StablePatient:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
102 return OrthancPluginChangeType_StablePatient;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
103
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
104 case ChangeType_StableSeries:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
105 return OrthancPluginChangeType_StableSeries;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
106
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
107 case ChangeType_StableStudy:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
108 return OrthancPluginChangeType_StableStudy;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
109
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
110 default:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
111 throw OrthancException(ErrorCode_ParameterOutOfRange);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
112 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
113 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
114
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
115
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
116 static OrthancPluginPixelFormat Convert(PixelFormat format)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
117 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
118 switch (format)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
119 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
120 case PixelFormat_Grayscale16:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
121 return OrthancPluginPixelFormat_Grayscale16;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
122
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
123 case PixelFormat_Grayscale8:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
124 return OrthancPluginPixelFormat_Grayscale8;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
125
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
126 case PixelFormat_RGB24:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
127 return OrthancPluginPixelFormat_RGB24;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
128
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
129 case PixelFormat_RGBA32:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
130 return OrthancPluginPixelFormat_RGBA32;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
131
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
132 case PixelFormat_SignedGrayscale16:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
133 return OrthancPluginPixelFormat_SignedGrayscale16;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
134
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
135 default:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
136 throw OrthancException(ErrorCode_ParameterOutOfRange);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
137 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
138 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
139
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
140
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
141 static PixelFormat Convert(OrthancPluginPixelFormat format)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
142 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
143 switch (format)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
144 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
145 case OrthancPluginPixelFormat_Grayscale16:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
146 return PixelFormat_Grayscale16;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
147
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
148 case OrthancPluginPixelFormat_Grayscale8:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
149 return PixelFormat_Grayscale8;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
150
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
151 case OrthancPluginPixelFormat_RGB24:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
152 return PixelFormat_RGB24;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
153
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
154 case OrthancPluginPixelFormat_RGBA32:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
155 return PixelFormat_RGBA32;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
156
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
157 case OrthancPluginPixelFormat_SignedGrayscale16:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
158 return PixelFormat_SignedGrayscale16;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
159
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
160 default:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
161 throw OrthancException(ErrorCode_ParameterOutOfRange);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
162 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
163 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
164
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
165
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
166
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
167 struct OrthancPlugins::PImpl
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
168 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
169 class RestCallback : public boost::noncopyable
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
170 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
171 private:
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
172 boost::regex regex_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
173 OrthancPluginRestCallback callback_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
174 bool lock_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
175
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
176 int32_t InvokeInternal(HttpOutput& output,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
177 const std::string& flatUri,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
178 const OrthancPluginHttpRequest& request)
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
179 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
180 return callback_(reinterpret_cast<OrthancPluginRestOutput*>(&output),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
181 flatUri.c_str(),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
182 &request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
183 }
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
184
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
185 public:
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
186 RestCallback(const char* regex,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
187 OrthancPluginRestCallback callback,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
188 bool lockRestCallbacks) :
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
189 regex_(regex),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
190 callback_(callback),
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
191 lock_(lockRestCallbacks)
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
192 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
193 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
194
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
195 const boost::regex& GetRegularExpression() const
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
196 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
197 return regex_;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
198 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
199
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
200 int32_t Invoke(boost::recursive_mutex& restCallbackMutex,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
201 HttpOutput& output,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
202 const std::string& flatUri,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
203 const OrthancPluginHttpRequest& request)
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
204 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
205 if (lock_)
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
206 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
207 boost::recursive_mutex::scoped_lock lock(restCallbackMutex);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
208 return InvokeInternal(output, flatUri, request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
209 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
210 else
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
211 {
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
212 return InvokeInternal(output, flatUri, request);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
213 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
214 }
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
215 };
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
216
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
217 typedef std::pair<std::string, _OrthancPluginProperty> Property;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
218 typedef std::list<RestCallback*> RestCallbacks;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
219 typedef std::list<OrthancPluginOnStoredInstanceCallback> OnStoredCallbacks;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
220 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
221 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
222
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
223 PluginsManager manager_;
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
224 ServerContext* context_;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
225 RestCallbacks restCallbacks_;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
226 OnStoredCallbacks onStoredCallbacks_;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
227 OnChangeCallbacks onChangeCallbacks_;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
228 bool hasStorageArea_;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
229 _OrthancPluginRegisterStorageArea storageArea_;
1466
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
230 boost::recursive_mutex restCallbackMutex_;
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
231 boost::recursive_mutex storedCallbackMutex_;
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
232 boost::recursive_mutex changeCallbackMutex_;
1553
7c4b487b3b4a ensure mutual exclusion in InvokeService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
233 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
234 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
235 int argc_;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
236 char** argv_;
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
237 std::auto_ptr<OrthancPluginDatabase> database_;
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
238
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
239 PImpl() :
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
240 context_(NULL),
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
241 hasStorageArea_(false),
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
242 argc_(1),
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
243 argv_(NULL)
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
244 {
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
245 memset(&storageArea_, 0, sizeof(storageArea_));
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
246 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
247 };
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
248
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
249
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
250
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
251 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
252 {
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
253 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
254 if (result == NULL)
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
255 {
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
256 throw OrthancException(ErrorCode_NotEnoughMemory);
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
257 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
258
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
259 if (str.size() == 0)
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
260 {
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
261 result[0] = '\0';
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
262 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
263 else
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
264 {
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
265 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
266 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
267
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
268 return result;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
269 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
270
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
271
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
272 OrthancPlugins::OrthancPlugins()
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 {
1579
b93c398f934d check the size of the enumerations in the plugin engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
274 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
275 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
276 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
277 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
278 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
279 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
280 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
281 sizeof(int32_t) != sizeof(OrthancPluginChangeType) ||
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
282 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
283 sizeof(int32_t) != sizeof(OrthancPluginCompressionType) ||
b93c398f934d check the size of the enumerations in the plugin engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1578
diff changeset
284 sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType))
1578
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
285 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
286 /* Sanity check of the compiler */
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
287 throw OrthancException(ErrorCode_Plugin);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
288 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1572
diff changeset
289
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
290 pimpl_.reset(new PImpl());
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
291 pimpl_->manager_.RegisterServiceProvider(*this);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
295 void OrthancPlugins::SetServerContext(ServerContext& context)
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
296 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
297 pimpl_->context_ = &context;
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
298 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
299
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
300
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
301
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
302 OrthancPlugins::~OrthancPlugins()
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
304 for (PImpl::RestCallbacks::iterator it = pimpl_->restCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
305 it != pimpl_->restCallbacks_.end(); ++it)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
307 delete *it;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
312 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
313 std::vector<const char*>& values,
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
314 const IHttpHandler::Arguments& arguments)
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
315 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
316 keys.resize(arguments.size());
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
317 values.resize(arguments.size());
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
318
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
319 size_t pos = 0;
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
320 for (IHttpHandler::Arguments::const_iterator
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
321 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
322 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
323 keys[pos] = it->first.c_str();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
324 values[pos] = it->second.c_str();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
325 pos++;
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
326 }
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
327 }
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
328
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
329
1363
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
330 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
331 std::vector<const char*>& values,
1441
f3672356c121 refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1437
diff changeset
332 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
333 {
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
334 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
335 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
336
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
337 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
338 {
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
339 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
340 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
341 }
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
342 }
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
343
feaf2840917c Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1330
diff changeset
344
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
345 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
346 RequestOrigin /*origin*/,
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
347 const char* /*remoteIp*/,
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
348 const char* /*username*/,
1329
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
349 HttpMethod method,
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
350 const UriComponents& uri,
272cb2019a4c fix recovery tool
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1328
diff changeset
351 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
352 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
353 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
354 size_t bodySize)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 {
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 std::string flatUri = Toolbox::FlattenUri(uri);
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
357 PImpl::RestCallback* callback = NULL;
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
358
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
359 std::vector<std::string> groups;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
360 std::vector<const char*> cgroups;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
361
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
362 // 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
363 bool found = false;
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
364 for (PImpl::RestCallbacks::const_iterator it = pimpl_->restCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
365 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
366 {
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
367 // 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
368 // callback matches the URI
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
369 boost::cmatch what;
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
370 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
371 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
372 callback = *it;
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
373
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
374 // 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
375 if (what.size() > 1)
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
376 {
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
377 groups.resize(what.size() - 1);
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
378 cgroups.resize(what.size() - 1);
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
379 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
380 {
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
381 groups[i - 1] = what[i];
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
382 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
383 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
384 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
385 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
386 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
387
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
388 if (callback == NULL)
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
389 {
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
390 // Callback not found
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
391 return false;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
392 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 LOG(INFO) << "Delegating HTTP request to plugin for URI: " << flatUri;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
396 std::vector<const char*> getKeys, getValues, headersKeys, headersValues;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
398 OrthancPluginHttpRequest request;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
399 memset(&request, 0, sizeof(OrthancPluginHttpRequest));
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
400
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
401 ArgumentsToPlugin(headersKeys, headersValues, headers);
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
402
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 switch (method)
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 {
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 case HttpMethod_Get:
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
406 request.method = OrthancPluginHttpMethod_Get;
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
407 ArgumentsToPlugin(getKeys, getValues, getArguments);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 break;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 case HttpMethod_Post:
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
411 request.method = OrthancPluginHttpMethod_Post;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 break;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 case HttpMethod_Delete:
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
415 request.method = OrthancPluginHttpMethod_Delete;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 break;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 case HttpMethod_Put:
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
419 request.method = OrthancPluginHttpMethod_Put;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 break;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 default:
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 throw OrthancException(ErrorCode_InternalError);
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
426
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
427 request.groups = (cgroups.size() ? &cgroups[0] : NULL);
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
428 request.groupsCount = cgroups.size();
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
429 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
430 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
431 request.bodySize = bodySize;
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
432 request.headersCount = headers.size();
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
433
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
434 if (getArguments.size() > 0)
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
435 {
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
436 request.getKeys = &getKeys[0];
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
437 request.getValues = &getValues[0];
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
438 }
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
439
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
440 if (headers.size() > 0)
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
441 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
442 request.headersKeys = &headersKeys[0];
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
443 request.headersValues = &headersValues[0];
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1037
diff changeset
444 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
445
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
446 assert(callback != NULL);
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
447 int32_t error = callback->Invoke(pimpl_->restCallbackMutex_, output, flatUri, request);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
449 if (error == 0 &&
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
450 output.IsWritingMultipart())
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
451 {
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
452 output.CloseMultipart();
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
453 }
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
454
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 if (error < 0)
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 {
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
457 LOG(ERROR) << "Plugin callback failed with error code " << error;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 return false;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 else
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 {
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 if (error > 0)
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 {
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
464 LOG(WARNING) << "Plugin callback finished with warning code " << error;
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 return true;
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 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
470
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
471
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
472 void OrthancPlugins::SignalStoredInstance(const std::string& instanceId,
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
473 DicomInstanceToStore& instance,
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1430
diff changeset
474 const Json::Value& simplifiedTags)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
475 {
1466
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
476 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
477
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
478 for (PImpl::OnStoredCallbacks::const_iterator
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
479 callback = pimpl_->onStoredCallbacks_.begin();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
480 callback != pimpl_->onStoredCallbacks_.end(); ++callback)
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
481 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
482 (*callback) (reinterpret_cast<OrthancPluginDicomInstance*>(&instance),
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
483 instanceId.c_str());
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
484 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
485 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
486
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
487
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
488
1198
1169528a9a5f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1189
diff changeset
489 void OrthancPlugins::SignalChange(const ServerIndexChange& change)
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
490 {
1178
c71d25e6a63c improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1177
diff changeset
491 try
c71d25e6a63c improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1177
diff changeset
492 {
1466
0cd0f2ad3599 Fix potential deadlock in the callbacks of plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1452
diff changeset
493 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
494
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
495 for (std::list<OrthancPluginOnChangeCallback>::const_iterator
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
496 callback = pimpl_->onChangeCallbacks_.begin();
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
497 callback != pimpl_->onChangeCallbacks_.end(); ++callback)
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
498 {
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
499 (*callback) (Convert(change.GetChangeType()),
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
500 Convert(change.GetResourceType()),
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
501 change.GetPublicId().c_str());
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
502 }
1178
c71d25e6a63c improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1177
diff changeset
503 }
c71d25e6a63c improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1177
diff changeset
504 catch (OrthancException&)
c71d25e6a63c improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1177
diff changeset
505 {
c71d25e6a63c improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1177
diff changeset
506 // This change type or resource type is not supported by the plugin SDK
c71d25e6a63c improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1177
diff changeset
507 return;
c71d25e6a63c improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1177
diff changeset
508 }
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
509 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
510
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
511
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
512
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
513 static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target,
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
514 const void* data,
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
515 size_t size)
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
516 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
517 target.size = size;
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
518
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
519 if (size == 0)
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
520 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
521 target.data = NULL;
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
522 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
523 else
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
524 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
525 target.data = malloc(size);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
526 if (target.data != NULL)
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
527 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
528 memcpy(target.data, data, size);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
529 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
530 else
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
531 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
532 throw OrthancException(ErrorCode_NotEnoughMemory);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
533 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
534 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
535 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
536
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
537
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
538 static void CopyToMemoryBuffer(OrthancPluginMemoryBuffer& target,
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
539 const std::string& str)
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
540 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
541 if (str.size() == 0)
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
542 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
543 target.size = 0;
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
544 target.data = NULL;
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
545 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
546 else
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
547 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
548 CopyToMemoryBuffer(target, str.c_str(), str.size());
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
549 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
550 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
551
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
552
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
553 void OrthancPlugins::RegisterRestCallback(const void* parameters,
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
554 bool lock)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
555 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
556 const _OrthancPluginRestCallback& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
557 *reinterpret_cast<const _OrthancPluginRestCallback*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
558
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
559 LOG(INFO) << "Plugin has registered a REST callback "
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
560 << (lock ? "with" : "witout")
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
561 << " mutual exclusion on: "
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
562 << p.pathRegularExpression;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
563
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
564 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
565 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
566
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
567
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
568
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
569 void OrthancPlugins::RegisterOnStoredInstanceCallback(const void* parameters)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
570 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
571 const _OrthancPluginOnStoredInstanceCallback& p =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
572 *reinterpret_cast<const _OrthancPluginOnStoredInstanceCallback*>(parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
573
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
574 LOG(INFO) << "Plugin has registered an OnStoredInstance callback";
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
575 pimpl_->onStoredCallbacks_.push_back(p.callback);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
576 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
577
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
578
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
579 void OrthancPlugins::RegisterOnChangeCallback(const void* parameters)
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
580 {
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
581 const _OrthancPluginOnChangeCallback& p =
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
582 *reinterpret_cast<const _OrthancPluginOnChangeCallback*>(parameters);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
583
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
584 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
585 pimpl_->onChangeCallbacks_.push_back(p.callback);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
586 }
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
587
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
588
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
589
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
590 void OrthancPlugins::AnswerBuffer(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
591 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
592 const _OrthancPluginAnswerBuffer& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
593 *reinterpret_cast<const _OrthancPluginAnswerBuffer*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
594
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
595 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
596 translatedOutput->SetContentType(p.mimeType);
1521
3606278d305e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
597 translatedOutput->Answer(p.answer, p.answerSize);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
598 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
599
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
600
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
601 void OrthancPlugins::Redirect(const void* parameters)
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
602 {
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
603 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
604 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
605
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
606 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
607 translatedOutput->Redirect(p.argument);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
608 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
609
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
610
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
611 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
612 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
613 const _OrthancPluginSendHttpStatusCode& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
614 *reinterpret_cast<const _OrthancPluginSendHttpStatusCode*>(parameters);
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
615
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
616 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
617 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
618 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
619
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
620
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
621 void OrthancPlugins::SendHttpStatus(const void* parameters)
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
622 {
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
623 const _OrthancPluginSendHttpStatus& p =
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
624 *reinterpret_cast<const _OrthancPluginSendHttpStatus*>(parameters);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
625
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
626 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
627 HttpStatus status = static_cast<HttpStatus>(p.status);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
628
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
629 if (p.bodySize > 0 && p.body != NULL)
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
630 {
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
631 translatedOutput->SendStatus(status, p.body, p.bodySize);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
632 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
633 else
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
634 {
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
635 translatedOutput->SendStatus(status);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
636 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
637 }
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
638
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
639
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
640 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
641 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
642 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
643 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
644
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
645 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
646 translatedOutput->SendUnauthorized(p.argument);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
647 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
648
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
649
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
650 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
651 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
652 const _OrthancPluginOutputPlusArgument& p =
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
653 *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
654
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
655 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
656 translatedOutput->SendMethodNotAllowed(p.argument);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
657 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
658
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
659
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
660 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
661 {
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
662 const _OrthancPluginSetHttpHeader& p =
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
663 *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
664
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
665 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
666 translatedOutput->SetCookie(p.key, p.value);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
667 }
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
668
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
669
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
670 void OrthancPlugins::SetHttpHeader(const void* parameters)
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
671 {
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
672 const _OrthancPluginSetHttpHeader& p =
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
673 *reinterpret_cast<const _OrthancPluginSetHttpHeader*>(parameters);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
674
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
675 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
676 translatedOutput->AddHeader(p.key, p.value);
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
677 }
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
678
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
679
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
680 void OrthancPlugins::CompressAndAnswerPngImage(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
681 {
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
682 // Bridge for backward compatibility with Orthanc <= 0.9.3
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
683 const _OrthancPluginCompressAndAnswerPngImage& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
684 *reinterpret_cast<const _OrthancPluginCompressAndAnswerPngImage*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
685
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
686 _OrthancPluginCompressAndAnswerImage p2;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
687 p2.output = p.output;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
688 p2.imageFormat = OrthancPluginImageFormat_Png;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
689 p2.pixelFormat = p.format;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
690 p2.width = p.width;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
691 p2.height = p.height;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
692 p2.pitch = p.height;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
693 p2.buffer = p.buffer;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
694 p2.quality = 0;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
695
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
696 CompressAndAnswerImage(&p2);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
697 }
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
698
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
699
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
700 void OrthancPlugins::CompressAndAnswerImage(const void* parameters)
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
701 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
702 const _OrthancPluginCompressAndAnswerImage& p =
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
703 *reinterpret_cast<const _OrthancPluginCompressAndAnswerImage*>(parameters);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
704
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
705 HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
706
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
707 ImageAccessor accessor;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
708 accessor.AssignReadOnly(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
709
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
710 std::string compressed;
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
711
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
712 switch (p.imageFormat)
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
713 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
714 case OrthancPluginImageFormat_Png:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
715 {
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
716 PngWriter writer;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
717 writer.WriteToMemory(compressed, accessor);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
718 translatedOutput->SetContentType("image/png");
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
719 break;
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
720 }
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
721
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
722 case OrthancPluginImageFormat_Jpeg:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
723 {
1603
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
724 JpegWriter writer;
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
725 writer.SetQuality(p.quality);
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
726 writer.WriteToMemory(compressed, accessor);
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
727 translatedOutput->SetContentType("image/jpeg");
905b4db3092b CompressAndAnswerJpegImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1600
diff changeset
728 break;
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
729 }
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
730
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
731 default:
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
732 throw OrthancException(ErrorCode_ParameterOutOfRange);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
733 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
734
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
735 translatedOutput->Answer(compressed);
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
736 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
737
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
738
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
739 void OrthancPlugins::CheckContextAvailable()
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
740 {
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
741 if (!pimpl_->context_)
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
742 {
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
743 LOG(ERROR) << "Plugin trying to call the database during its initialization";
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
744 throw OrthancException(ErrorCode_Plugin);
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
745 }
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
746 }
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
747
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
748
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
749 void OrthancPlugins::GetDicomForInstance(const void* parameters)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
750 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
751 const _OrthancPluginGetDicomForInstance& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
752 *reinterpret_cast<const _OrthancPluginGetDicomForInstance*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
753
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
754 std::string dicom;
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
755
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
756 CheckContextAvailable();
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
757 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
758
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
759 CopyToMemoryBuffer(*p.target, dicom);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
760 }
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
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
763 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
764 bool afterPlugins)
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
765 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
766 const _OrthancPluginRestApiGet& p =
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
767 *reinterpret_cast<const _OrthancPluginRestApiGet*>(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
768
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
769 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
770 << (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
771
1445
d26c8a93d05a refactoring: SimpleGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
772 CheckContextAvailable();
d26c8a93d05a refactoring: SimpleGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
773 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
774
1445
d26c8a93d05a refactoring: SimpleGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1441
diff changeset
775 std::string result;
1571
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
776 if (HttpToolbox::SimpleGet(result, handler, RequestOrigin_Plugins, p.uri))
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
777 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
778 CopyToMemoryBuffer(*p.target, result);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
779 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
780 else
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
781 {
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
782 throw OrthancException(ErrorCode_BadRequest);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
783 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
784 }
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
785
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
786
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
787 void OrthancPlugins::RestApiPostPut(bool isPost,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
788 const void* parameters,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
789 bool afterPlugins)
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
790 {
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
791 const _OrthancPluginRestApiPostPut& p =
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
792 *reinterpret_cast<const _OrthancPluginRestApiPostPut*>(parameters);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
793
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
794 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
795 << " 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
796
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
797 CheckContextAvailable();
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
798 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
799
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
800 std::string result;
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
801 if (isPost ?
1571
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
802 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
803 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
804 {
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
805 CopyToMemoryBuffer(*p.target, result);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
806 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
807 else
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
808 {
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
809 throw OrthancException(ErrorCode_BadRequest);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
810 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
811 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
812
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
813
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
814 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
815 bool afterPlugins)
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
816 {
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
817 const char* uri = reinterpret_cast<const char*>(parameters);
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
818 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
819 << (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
820
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
821 CheckContextAvailable();
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
822 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
823
1571
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
824 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
825 {
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
826 throw OrthancException(ErrorCode_BadRequest);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
827 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
828 }
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
829
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
830
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
831 void OrthancPlugins::LookupResource(_OrthancPluginService service,
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
832 const void* parameters)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
833 {
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
834 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
835 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
836
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
837 /**
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
838 * 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
839 * the Orthanc database. It reflects the
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
840 * "CandidateResources::ApplyFilter()" method of the
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
841 * "OrthancFindRequestHandler" class.
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
842 **/
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
843
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
844 DicomTag tag(0, 0);
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
845 ResourceType level;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
846 switch (service)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
847 {
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
848 case _OrthancPluginService_LookupPatient:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
849 tag = DICOM_TAG_PATIENT_ID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
850 level = ResourceType_Patient;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
851 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
852
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
853 case _OrthancPluginService_LookupStudy:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
854 tag = DICOM_TAG_STUDY_INSTANCE_UID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
855 level = ResourceType_Study;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
856 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
857
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
858 case _OrthancPluginService_LookupStudyWithAccessionNumber:
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
859 tag = DICOM_TAG_ACCESSION_NUMBER;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
860 level = ResourceType_Study;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
861 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
862
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
863 case _OrthancPluginService_LookupSeries:
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
864 tag = DICOM_TAG_SERIES_INSTANCE_UID;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
865 level = ResourceType_Series;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
866 break;
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
867
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
868 case _OrthancPluginService_LookupInstance:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
869 tag = DICOM_TAG_SOP_INSTANCE_UID;
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
870 level = ResourceType_Instance;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
871 break;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
872
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
873 default:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
874 throw OrthancException(ErrorCode_InternalError);
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
875 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
876
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
877 CheckContextAvailable();
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
878
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
879 std::list<std::string> result;
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
880 pimpl_->context_->GetIndex().LookupIdentifier(result, tag, p.argument, level);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
881
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
882 if (result.size() == 1)
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
883 {
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
884 *p.result = CopyString(result.front());
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
885 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
886 else
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
887 {
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
888 throw OrthancException(ErrorCode_UnknownResource);
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
889 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
890 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
891
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
892
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
893 static void AccessInstanceMetadataInternal(bool checkExistence,
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
894 const _OrthancPluginAccessDicomInstance& params,
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
895 const DicomInstanceToStore& instance)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
896 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
897 MetadataType metadata;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
898
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
899 try
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
900 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
901 metadata = StringToMetadata(params.key);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
902 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
903 catch (OrthancException&)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
904 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
905 // Unknown metadata
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
906 if (checkExistence)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
907 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
908 *params.resultInt64 = -1;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
909 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
910 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
911 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
912 *params.resultString = NULL;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
913 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
914
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
915 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
916 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
917
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
918 ServerIndex::MetadataMap::const_iterator it =
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
919 instance.GetMetadata().find(std::make_pair(ResourceType_Instance, metadata));
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
920
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
921 if (checkExistence)
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
922 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
923 if (it != instance.GetMetadata().end())
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
924 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
925 *params.resultInt64 = 1;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
926 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
927 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
928 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
929 *params.resultInt64 = 0;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
930 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
931 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
932 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
933 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
934 if (it != instance.GetMetadata().end())
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
935 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
936 *params.resultString = it->second.c_str();
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
937 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
938 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
939 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
940 // Error: Missing metadata
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
941 *params.resultString = NULL;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
942 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
943 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
944 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
945
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
946
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
947 static void AccessDicomInstance(_OrthancPluginService service,
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
948 const void* parameters)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
949 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
950 const _OrthancPluginAccessDicomInstance& p =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
951 *reinterpret_cast<const _OrthancPluginAccessDicomInstance*>(parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
952
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
953 DicomInstanceToStore& instance =
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
954 *reinterpret_cast<DicomInstanceToStore*>(p.instance);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
955
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
956 switch (service)
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
957 {
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
958 case _OrthancPluginService_GetInstanceRemoteAet:
1572
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
diff changeset
959 *p.resultString = instance.GetRemoteAet();
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
960 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
961
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
962 case _OrthancPluginService_GetInstanceSize:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
963 *p.resultInt64 = instance.GetBufferSize();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
964 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
965
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
966 case _OrthancPluginService_GetInstanceData:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
967 *p.resultString = instance.GetBufferData();
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
968 return;
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
969
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
970 case _OrthancPluginService_HasInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
971 AccessInstanceMetadataInternal(true, p, instance);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
972 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
973
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
974 case _OrthancPluginService_GetInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
975 AccessInstanceMetadataInternal(false, p, instance);
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
976 return;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
977
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
978 case _OrthancPluginService_GetInstanceJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
979 case _OrthancPluginService_GetInstanceSimplifiedJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
980 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
981 Json::StyledWriter writer;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
982 std::string s;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
983
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
984 if (service == _OrthancPluginService_GetInstanceJson)
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
985 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
986 s = writer.write(instance.GetJson());
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
987 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
988 else
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
989 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
990 Json::Value simplified;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
991 SimplifyTags(simplified, instance.GetJson());
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
992 s = writer.write(simplified);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
993 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
994
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
995 *p.resultStringToFree = CopyString(s);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
996 return;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
997 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
998
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
999 default:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1000 throw OrthancException(ErrorCode_InternalError);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1001 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1002 }
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1003
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1004
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1005 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
1006 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1007 const _OrthancPluginBufferCompression& p =
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1008 *reinterpret_cast<const _OrthancPluginBufferCompression*>(parameters);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1009
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1010 std::string result;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1011
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1012 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1013 std::auto_ptr<DeflateBaseCompressor> compressor;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1014
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1015 switch (p.compression)
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1016 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1017 case OrthancPluginCompressionType_Zlib:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1018 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1019 compressor.reset(new ZlibCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1020 compressor->SetPrefixWithUncompressedSize(false);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1021 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1022 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1023
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1024 case OrthancPluginCompressionType_ZlibWithSize:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1025 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1026 compressor.reset(new ZlibCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1027 compressor->SetPrefixWithUncompressedSize(true);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1028 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1029 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1030
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1031 case OrthancPluginCompressionType_Gzip:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1032 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1033 compressor.reset(new GzipCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1034 compressor->SetPrefixWithUncompressedSize(false);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1035 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1036 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1037
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1038 case OrthancPluginCompressionType_GzipWithSize:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1039 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1040 compressor.reset(new GzipCompressor);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1041 compressor->SetPrefixWithUncompressedSize(true);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1042 break;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1043 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1044
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1045 default:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1046 throw OrthancException(ErrorCode_ParameterOutOfRange);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1047 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1048
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1049 if (p.uncompress)
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1050 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1051 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
1052 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1053 else
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1054 {
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1055 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
1056 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1057 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1058
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1059 CopyToMemoryBuffer(*p.target, result);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1060 }
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1061
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1062
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1063 void OrthancPlugins::UncompressImage(const void* parameters)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1064 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1065 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
1066
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1067 std::auto_ptr<ImageAccessor> image;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1068
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1069 switch (p.format)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1070 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1071 case OrthancPluginImageFormat_Png:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1072 {
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1073 image.reset(new PngReader);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1074 reinterpret_cast<PngReader&>(*image).ReadFromMemory(p.data, p.size);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1075 break;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1076 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1077
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1078 case OrthancPluginImageFormat_Jpeg:
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1079 {
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1080 image.reset(new JpegReader);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1081 reinterpret_cast<JpegReader&>(*image).ReadFromMemory(p.data, p.size);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1082 break;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1083 }
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1084
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1085 default:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1086 throw OrthancException(ErrorCode_ParameterOutOfRange);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1087 }
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1088
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1089 *(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
1090 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1091
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1092
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1093 void OrthancPlugins::CompressImage(const void* parameters)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1094 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1095 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
1096
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1097 std::string compressed;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1098
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1099 switch (p.imageFormat)
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1100 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1101 case OrthancPluginImageFormat_Png:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1102 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1103 PngWriter writer;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1104 writer.WriteToMemory(compressed, p.width, p.height, p.pitch, Convert(p.pixelFormat), p.buffer);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1105 break;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1106 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1107
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1108 case OrthancPluginImageFormat_Jpeg:
1604
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1109 {
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1110 JpegWriter writer;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1111 writer.SetQuality(p.quality);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1112 writer.WriteToMemory(compressed, p.width, p.height, p.pitch, Convert(p.pixelFormat), p.buffer);
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1113 break;
1f5d6a2f9638 JpegReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1603
diff changeset
1114 }
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1115
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1116 default:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1117 throw OrthancException(ErrorCode_ParameterOutOfRange);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1118 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1119
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1120 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
1121 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1122
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1123
1133
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1132
diff changeset
1124 bool OrthancPlugins::InvokeService(_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
1125 const void* parameters)
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1126 {
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1127 VLOG(1) << "Calling plugin service: " << service;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1128
1553
7c4b487b3b4a ensure mutual exclusion in InvokeService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1129 boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_);
7c4b487b3b4a ensure mutual exclusion in InvokeService
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1130
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1131 switch (service)
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1132 {
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1133 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
1134 {
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1135 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
1136 *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
1137 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
1138 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1139
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1140 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
1141 {
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1142 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
1143 *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
1144 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
1145 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1146
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1147 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
1148 {
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1149 *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
1150 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
1151 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
1152 }
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
1153
1424
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1154 case _OrthancPluginService_GetConfiguration:
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1155 {
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1156 std::string s;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1157 Configuration::FormatConfiguration(s);
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1158
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1159 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = CopyString(s);
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1160 return true;
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1161 }
fe384a9d3b51 OrthancPluginGetConfiguration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
1162
1554
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1163 case _OrthancPluginService_BufferCompression:
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1164 BufferCompression(parameters);
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1165 return true;
89ab71a68fcf New function OrthancPluginBufferCompression() to (un)compress memory buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1553
diff changeset
1166
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
1167 case _OrthancPluginService_RegisterRestCallback:
1595
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1168 RegisterRestCallback(parameters, true);
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1169 return true;
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1170
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1171 case _OrthancPluginService_RegisterRestCallbackNoLock:
e1e54a73ba8b OrthancPluginRegisterRestCallbackNoLock, documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
1172 RegisterRestCallback(parameters, false);
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1173 return true;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1174
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1175 case _OrthancPluginService_RegisterOnStoredInstanceCallback:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1176 RegisterOnStoredInstanceCallback(parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1177 return true;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1178
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1179 case _OrthancPluginService_RegisterOnChangeCallback:
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1180 RegisterOnChangeCallback(parameters);
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1181 return true;
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
1182
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
1183 case _OrthancPluginService_AnswerBuffer:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1184 AnswerBuffer(parameters);
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1185 return true;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1186
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
1187 case _OrthancPluginService_CompressAndAnswerPngImage:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1188 CompressAndAnswerPngImage(parameters);
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1189 return true;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 900
diff changeset
1190
1600
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1191 case _OrthancPluginService_CompressAndAnswerImage:
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1192 CompressAndAnswerImage(parameters);
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1193 return true;
7151d63e6d81 documentation, primitives for jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1599
diff changeset
1194
907
9b8298234254 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
1195 case _OrthancPluginService_GetDicomForInstance:
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1196 GetDicomForInstance(parameters);
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1197 return true;
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
1198
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 909
diff changeset
1199 case _OrthancPluginService_RestApiGet:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1200 RestApiGet(parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1201 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1202
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1203 case _OrthancPluginService_RestApiGetAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1204 RestApiGet(parameters, true);
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
1205 return true;
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1206
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1207 case _OrthancPluginService_RestApiPost:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1208 RestApiPostPut(true, parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1209 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1210
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1211 case _OrthancPluginService_RestApiPostAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1212 RestApiPostPut(true, parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1213 return true;
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1214
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1215 case _OrthancPluginService_RestApiDelete:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1216 RestApiDelete(parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1217 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1218
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1219 case _OrthancPluginService_RestApiDeleteAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1220 RestApiDelete(parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1221 return true;
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1222
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1223 case _OrthancPluginService_RestApiPut:
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1224 RestApiPostPut(false, parameters, false);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1225 return true;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1226
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1227 case _OrthancPluginService_RestApiPutAfterPlugins:
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
1228 RestApiPostPut(false, parameters, true);
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
1229 return true;
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
1230
993
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1231 case _OrthancPluginService_Redirect:
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1232 Redirect(parameters);
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1233 return true;
501880d76474 improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 944
diff changeset
1234
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1235 case _OrthancPluginService_SendUnauthorized:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1236 SendUnauthorized(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1237 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1238
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1239 case _OrthancPluginService_SendMethodNotAllowed:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1240 SendMethodNotAllowed(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1241 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1242
1594
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1243 case _OrthancPluginService_SendHttpStatus:
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1244 SendHttpStatus(parameters);
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1245 return true;
2bac60a4f584 OrthancPluginSendHttpStatus
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1593
diff changeset
1246
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1247 case _OrthancPluginService_SendHttpStatusCode:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1248 SendHttpStatusCode(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1249 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1250
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1251 case _OrthancPluginService_SetCookie:
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1252 SetCookie(parameters);
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1253 return true;
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
1254
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1255 case _OrthancPluginService_SetHttpHeader:
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1256 SetHttpHeader(parameters);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1257 return true;
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1136
diff changeset
1258
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1259 case _OrthancPluginService_LookupPatient:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1260 case _OrthancPluginService_LookupStudy:
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1261 case _OrthancPluginService_LookupStudyWithAccessionNumber:
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1262 case _OrthancPluginService_LookupSeries:
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1263 case _OrthancPluginService_LookupInstance:
1069
a91b4900f06a plugin lookup using accession number
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
1264 LookupResource(service, parameters);
1037
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1265 return true;
6208ab500ffd LookupResource service in plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 993
diff changeset
1266
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1267 case _OrthancPluginService_GetInstanceRemoteAet:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1268 case _OrthancPluginService_GetInstanceSize:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1269 case _OrthancPluginService_GetInstanceData:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1270 case _OrthancPluginService_GetInstanceJson:
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1271 case _OrthancPluginService_GetInstanceSimplifiedJson:
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1272 case _OrthancPluginService_HasInstanceMetadata:
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
1273 case _OrthancPluginService_GetInstanceMetadata:
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1274 AccessDicomInstance(service, parameters);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1275 return true;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
1276
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1277 case _OrthancPluginService_RegisterStorageArea:
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1278 {
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1279 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
1280 const _OrthancPluginRegisterStorageArea& p =
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1281 *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
1282
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1283 pimpl_->storageArea_ = p;
1136
208dc67b9bab sample custom storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1135
diff changeset
1284 pimpl_->hasStorageArea_ = true;
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1285 return true;
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1286 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1287
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1288 case _OrthancPluginService_SetPluginProperty:
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1289 {
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1290 const _OrthancPluginSetPluginProperty& p =
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1291 *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
1292 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
1293 return true;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1294 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1295
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1296 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
1297 {
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1298 const _OrthancPluginGlobalProperty& p =
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1299 *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
1300 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
1301 {
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1302 return false;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1303 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1304 else
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1305 {
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
1306 CheckContextAvailable();
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1307 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
1308 return true;
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1309 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1310 }
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1311
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1312 case _OrthancPluginService_GetGlobalProperty:
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1313 {
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1424
diff changeset
1314 CheckContextAvailable();
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1315
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1316 const _OrthancPluginGlobalProperty& p =
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
1317 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1318 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
1319 *(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
1320 return true;
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1321 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1322
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1323 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
1324 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1325 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
1326 *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
1327 *(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
1328 return true;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1329 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1330
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1331 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
1332 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1333 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
1334 *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
1335
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1336 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
1337 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1338 return false;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1339 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1340 else
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1341 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1342 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
1343 *(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
1344 return true;
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1345 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1346 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1347
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1348 case _OrthancPluginService_RegisterDatabaseBackend:
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1349 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1350 LOG(INFO) << "Plugin has registered a custom database back-end";
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1351 const _OrthancPluginRegisterDatabaseBackend& p =
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1352 *reinterpret_cast<const _OrthancPluginRegisterDatabaseBackend*>(parameters);
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1353
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1354 pimpl_->database_.reset(new OrthancPluginDatabase(*p.backend, p.payload));
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1355 *(p.result) = reinterpret_cast<OrthancPluginDatabaseContext*>(pimpl_->database_.get());
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1356
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1357 return true;
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1358 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1359
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1360 case _OrthancPluginService_DatabaseAnswer:
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1361 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1362 const _OrthancPluginDatabaseAnswer& p =
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1363 *reinterpret_cast<const _OrthancPluginDatabaseAnswer*>(parameters);
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1364 if (pimpl_->database_.get() != NULL)
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1365 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1366 pimpl_->database_->AnswerReceived(p);
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1367 return true;
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1368 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1369 else
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1370 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1371 LOG(ERROR) << "Cannot invoke this service without a custom database back-end";
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1372 throw OrthancException(ErrorCode_BadRequest);
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1373 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1374 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1375
1407
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1376 case _OrthancPluginService_GetExpectedDatabaseVersion:
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1377 {
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1378 const _OrthancPluginReturnSingleValue& p =
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1379 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters);
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1380 *(p.resultUint32) = ORTHANC_DATABASE_VERSION;
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1381 return true;
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1382 }
d371a66972a4 OrthancPluginGetExpectedDatabaseVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1363
diff changeset
1383
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1384 case _OrthancPluginService_StartMultipartAnswer:
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1385 {
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1386 const _OrthancPluginStartMultipartAnswer& p =
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1387 *reinterpret_cast<const _OrthancPluginStartMultipartAnswer*>(parameters);
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1388 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
1389 output->StartMultipart(p.subType, p.contentType);
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1390 return true;
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1391 }
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1392
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1393 case _OrthancPluginService_SendMultipartItem:
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1394 {
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1395 // 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
1396 // 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
1397 const _OrthancPluginAnswerBuffer& p =
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1398 *reinterpret_cast<const _OrthancPluginAnswerBuffer*>(parameters);
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1399 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
1400 output->SendMultipartItem(p.answer, p.answerSize);
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1401 return true;
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1402 }
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
1403
1588
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1404 case _OrthancPluginService_ReadFile:
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1405 {
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1406 const _OrthancPluginReadFile& p =
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1407 *reinterpret_cast<const _OrthancPluginReadFile*>(parameters);
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1408
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1409 std::string content;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1410 Toolbox::ReadFile(content, p.path);
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1411 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
1412
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1413 return true;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1414 }
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1415
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1416 case _OrthancPluginService_WriteFile:
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1417 {
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1418 const _OrthancPluginWriteFile& p =
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1419 *reinterpret_cast<const _OrthancPluginWriteFile*>(parameters);
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1420 Toolbox::WriteFile(p.data, p.size, p.path);
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1421 return true;
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1422 }
b5bc87a7212d OrthancPluginReadFile, OrthancPluginWriteFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1581
diff changeset
1423
1593
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1424 case _OrthancPluginService_GetErrorDescription:
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1425 {
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1426 const _OrthancPluginGetErrorDescription& p =
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1427 *reinterpret_cast<const _OrthancPluginGetErrorDescription*>(parameters);
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1428 *(p.target) = EnumerationToString(static_cast<ErrorCode>(p.error));
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1429 return true;
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1430 }
235d89817b89 OrthancPluginGetErrorDescription
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1588
diff changeset
1431
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1432 case _OrthancPluginService_GetImagePixelFormat:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1433 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1434 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
1435 *(p.resultPixelFormat) = Convert(reinterpret_cast<const ImageAccessor*>(p.image)->GetFormat());
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1436 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1437 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1438
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1439 case _OrthancPluginService_GetImageWidth:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1440 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1441 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
1442 *(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
1443 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1444 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1445
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1446 case _OrthancPluginService_GetImageHeight:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1447 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1448 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
1449 *(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
1450 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1451 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1452
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1453 case _OrthancPluginService_GetImagePitch:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1454 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1455 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
1456 *(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
1457 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1458 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1459
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1460 case _OrthancPluginService_GetImageBuffer:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1461 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1462 const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1463 *(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
1464 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1465 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1466
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1467 case _OrthancPluginService_FreeImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1468 {
1599
dd1f9e81f891 fixes to image primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
1469 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
1470 delete reinterpret_cast<const ImageAccessor*>(p.image);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1471 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1472 }
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1473
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1474 case _OrthancPluginService_UncompressImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1475 UncompressImage(parameters);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1476 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1477
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1478 case _OrthancPluginService_CompressImage:
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1479 CompressImage(parameters);
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1480 return true;
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1481
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1482 default:
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1483 {
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1484 // This service is unknown to the Orthanc plugin engine
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1485 return false;
1598
c6b50b803387 primitives for image encoding/decoding in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1595
diff changeset
1486 }
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1487 }
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1488 }
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
1489
908
e078ea944089 refactoring HttpOutput
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 907
diff changeset
1490
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1491 bool OrthancPlugins::HasStorageArea() const
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1492 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1493 return pimpl_->hasStorageArea_;
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1494 }
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1495
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1496 bool OrthancPlugins::HasDatabase() const
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1497 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1498 return pimpl_->database_.get() != NULL;
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1499 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1500
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1501
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1502
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1503 namespace
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1504 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1505 class PluginStorageArea : public IStorageArea
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1506 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1507 private:
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1508 _OrthancPluginRegisterStorageArea params_;
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1509
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1510 void Free(void* buffer) const
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1511 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1512 if (buffer != NULL)
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1513 {
1296
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1514 params_.free(buffer);
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1515 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1516 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1517
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1518 OrthancPluginContentType Convert(FileContentType type) const
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1519 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1520 switch (type)
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1521 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1522 case FileContentType_Dicom:
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1523 return OrthancPluginContentType_Dicom;
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1524
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1525 case FileContentType_DicomAsJson:
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1526 return OrthancPluginContentType_DicomAsJson;
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1527
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1528 default:
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1529 return OrthancPluginContentType_Unknown;
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1530 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1531 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1532
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1533 public:
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1534 PluginStorageArea(const _OrthancPluginRegisterStorageArea& params) : params_(params)
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1535 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1536 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1537
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1538 virtual void Create(const std::string& uuid,
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1539 const void* content,
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1540 size_t size,
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1541 FileContentType type)
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1542 {
1296
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1543 if (params_.create(uuid.c_str(), content, size, Convert(type)) != 0)
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1544 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1545 throw OrthancException(ErrorCode_Plugin);
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1546 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1547 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1548
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1549 virtual void Read(std::string& content,
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1550 const std::string& uuid,
1250
2ffe07abd9d8 removal of const on IStorageArea::Read()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1249
diff changeset
1551 FileContentType type)
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1552 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1553 void* buffer = NULL;
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1554 int64_t size = 0;
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1555
1296
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1556 if (params_.read(&buffer, &size, uuid.c_str(), Convert(type)) != 0)
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1557 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1558 throw OrthancException(ErrorCode_Plugin);
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1559 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1560
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1561 try
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1562 {
1545
33d34bc4ac15 fix msvc warnings
jodogne
parents: 1521
diff changeset
1563 content.resize(static_cast<size_t>(size));
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1564 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1565 catch (OrthancException&)
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1566 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1567 Free(buffer);
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1568 throw;
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1569 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1570
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1571 if (size > 0)
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1572 {
1545
33d34bc4ac15 fix msvc warnings
jodogne
parents: 1521
diff changeset
1573 memcpy(&content[0], buffer, static_cast<size_t>(size));
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1574 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1575
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1576 Free(buffer);
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1577 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1578
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1579 virtual void Remove(const std::string& uuid,
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1580 FileContentType type)
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1581 {
1296
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1582 if (params_.remove(uuid.c_str(), Convert(type)) != 0)
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1583 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1584 throw OrthancException(ErrorCode_Plugin);
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1585 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1586 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1587 };
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1588 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1589
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1590
1452
b737acb13da5 refactoring of the main function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
1591 IStorageArea* OrthancPlugins::CreateStorageArea()
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1592 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1593 if (!HasStorageArea())
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1594 {
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1595 throw OrthancException(ErrorCode_BadSequenceOfCalls);
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1596 }
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1597
1250
2ffe07abd9d8 removal of const on IStorageArea::Read()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1249
diff changeset
1598 return new PluginStorageArea(pimpl_->storageArea_);
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1133
diff changeset
1599 }
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1600
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1601
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1602 IDatabaseWrapper& OrthancPlugins::GetDatabase()
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1603 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1604 if (!HasDatabase())
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1605 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1606 throw OrthancException(ErrorCode_BadSequenceOfCalls);
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1607 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1608
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1609 return *pimpl_->database_;
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1610 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1611
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1612
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1613
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1296
diff changeset
1614
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1615
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1616 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
1617 _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
1618 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1619 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
1620 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
1621
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1622 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
1623 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1624 return NULL;
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1625 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1626 else
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1627 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1628 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
1629 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
1630 }
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1631
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1632
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1633 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
1634 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1635 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
1636 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1637 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
1638 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1639
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1250
diff changeset
1640 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
1641 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
1642 }
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1643
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1644
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1645 PluginsManager& OrthancPlugins::GetManager()
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1646 {
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1647 return pimpl_->manager_;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1648 }
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1649
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1650
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1651 const PluginsManager& OrthancPlugins::GetManager() const
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1652 {
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1653 return pimpl_->manager_;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1654 }
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1655 }