405
|
1 /**
|
|
2 * \mainpage
|
|
3 *
|
|
4 * This C/C++ SDK allows external developers to create plugins that
|
|
5 * can be loaded into Orthanc to extend its functionality. Each
|
|
6 * Orthanc plugin must expose 4 public functions with the following
|
|
7 * signatures:
|
|
8 *
|
|
9 * -# <tt>int32_t OrthancPluginInitialize(const OrthancPluginContext* context)</tt>:
|
|
10 * This function is invoked by Orthanc when it loads the plugin on startup.
|
|
11 * The plugin must:
|
|
12 * - Check its compatibility with the Orthanc version using
|
|
13 * ::OrthancPluginCheckVersion().
|
|
14 * - Store the context pointer so that it can use the plugin
|
|
15 * services of Orthanc.
|
|
16 * - Register all its REST callbacks using ::OrthancPluginRegisterRestCallback().
|
|
17 * - Possibly register its callback for received DICOM instances using ::OrthancPluginRegisterOnStoredInstanceCallback().
|
|
18 * - Possibly register its callback for changes to the DICOM store using ::OrthancPluginRegisterOnChangeCallback().
|
|
19 * - Possibly register a custom storage area using ::OrthancPluginRegisterStorageArea2().
|
|
20 * - Possibly register a custom database back-end area using OrthancPluginRegisterDatabaseBackendV4().
|
|
21 * - Possibly register a handler for C-Find SCP using OrthancPluginRegisterFindCallback().
|
|
22 * - Possibly register a handler for C-Find SCP against DICOM worklists using OrthancPluginRegisterWorklistCallback().
|
|
23 * - Possibly register a handler for C-Move SCP using OrthancPluginRegisterMoveCallback().
|
|
24 * - Possibly register a custom decoder for DICOM images using OrthancPluginRegisterDecodeImageCallback().
|
|
25 * - Possibly register a callback to filter incoming HTTP requests using OrthancPluginRegisterIncomingHttpRequestFilter2().
|
|
26 * - Possibly register a callback to unserialize jobs using OrthancPluginRegisterJobsUnserializer().
|
|
27 * - Possibly register a callback to refresh its metrics using OrthancPluginRegisterRefreshMetricsCallback().
|
|
28 * - Possibly register a callback to answer chunked HTTP transfers using ::OrthancPluginRegisterChunkedRestCallback().
|
|
29 * - Possibly register a callback for Storage Commitment SCP using ::OrthancPluginRegisterStorageCommitmentScpCallback().
|
|
30 * - Possibly register a callback to keep/discard/modify incoming DICOM instances using OrthancPluginRegisterReceivedInstanceCallback().
|
|
31 * - Possibly register a custom transcoder for DICOM images using OrthancPluginRegisterTranscoderCallback().
|
|
32 * - Possibly register a callback to discard instances received through DICOM C-STORE using OrthancPluginRegisterIncomingCStoreInstanceFilter().
|
|
33 * - Possibly register a callback to branch a WebDAV virtual filesystem using OrthancPluginRegisterWebDavCollection().
|
|
34 * -# <tt>void OrthancPluginFinalize()</tt>:
|
|
35 * This function is invoked by Orthanc during its shutdown. The plugin
|
|
36 * must free all its memory.
|
|
37 * -# <tt>const char* OrthancPluginGetName()</tt>:
|
|
38 * The plugin must return a short string to identify itself.
|
|
39 * -# <tt>const char* OrthancPluginGetVersion()</tt>:
|
|
40 * The plugin must return a string containing its version number.
|
|
41 *
|
|
42 * The name and the version of a plugin is only used to prevent it
|
|
43 * from being loaded twice. Note that, in C++, it is mandatory to
|
|
44 * declare these functions within an <tt>extern "C"</tt> section.
|
|
45 *
|
|
46 * To ensure multi-threading safety, the various REST callbacks are
|
|
47 * guaranteed to be executed in mutual exclusion since Orthanc
|
|
48 * 0.8.5. If this feature is undesired (notably when developing
|
|
49 * high-performance plugins handling simultaneous requests), use
|
|
50 * ::OrthancPluginRegisterRestCallbackNoLock().
|
|
51 **/
|
|
52
|
|
53
|
|
54
|
|
55 /**
|
|
56 * @defgroup Images Images and compression
|
|
57 * @brief Functions to deal with images and compressed buffers.
|
|
58 *
|
|
59 * @defgroup REST REST
|
|
60 * @brief Functions to answer REST requests in a callback.
|
|
61 *
|
|
62 * @defgroup Callbacks Callbacks
|
|
63 * @brief Functions to register and manage callbacks by the plugins.
|
|
64 *
|
|
65 * @defgroup DicomCallbacks DicomCallbacks
|
|
66 * @brief Functions to register and manage DICOM callbacks (worklists, C-FIND, C-MOVE, storage commitment).
|
|
67 *
|
|
68 * @defgroup Orthanc Orthanc
|
|
69 * @brief Functions to access the content of the Orthanc server.
|
|
70 *
|
|
71 * @defgroup DicomInstance DicomInstance
|
|
72 * @brief Functions to access DICOM images that are managed by the Orthanc core.
|
|
73 **/
|
|
74
|
|
75
|
|
76
|
|
77 /**
|
|
78 * @defgroup Toolbox Toolbox
|
|
79 * @brief Generic functions to help with the creation of plugins.
|
|
80 **/
|
|
81
|
|
82
|
|
83
|
|
84 /**
|
|
85 * Orthanc - A Lightweight, RESTful DICOM Store
|
|
86 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
|
|
87 * Department, University Hospital of Liege, Belgium
|
|
88 * Copyright (C) 2017-2023 Osimis S.A., Belgium
|
|
89 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
|
|
90 *
|
|
91 * This program is free software: you can redistribute it and/or
|
|
92 * modify it under the terms of the GNU General Public License as
|
|
93 * published by the Free Software Foundation, either version 3 of the
|
|
94 * License, or (at your option) any later version.
|
|
95 *
|
|
96 * This program is distributed in the hope that it will be useful, but
|
|
97 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
98 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
99 * General Public License for more details.
|
|
100 *
|
|
101 * You should have received a copy of the GNU General Public License
|
|
102 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
103 **/
|
|
104
|
|
105
|
|
106
|
|
107 #pragma once
|
|
108
|
|
109
|
|
110 #include <stdio.h>
|
|
111 #include <string.h>
|
|
112
|
|
113 #ifdef WIN32
|
|
114 # define ORTHANC_PLUGINS_API __declspec(dllexport)
|
|
115 #elif __GNUC__ >= 4
|
|
116 # define ORTHANC_PLUGINS_API __attribute__ ((visibility ("default")))
|
|
117 #else
|
|
118 # define ORTHANC_PLUGINS_API
|
|
119 #endif
|
|
120
|
|
121 #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 1
|
|
122 #define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 12
|
|
123 #define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 0
|
|
124
|
|
125
|
|
126 #if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)
|
|
127 #define ORTHANC_PLUGINS_VERSION_IS_ABOVE(major, minor, revision) \
|
|
128 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER > major || \
|
|
129 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == major && \
|
|
130 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER > minor || \
|
|
131 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor && \
|
|
132 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision))))
|
|
133 #endif
|
|
134
|
|
135
|
|
136
|
|
137 /********************************************************************
|
|
138 ** Check that function inlining is properly supported. The use of
|
|
139 ** inlining is required, to avoid the duplication of object code
|
|
140 ** between two compilation modules that would use the Orthanc Plugin
|
|
141 ** API.
|
|
142 ********************************************************************/
|
|
143
|
|
144 /* If the auto-detection of the "inline" keyword below does not work
|
|
145 automatically and that your compiler is known to properly support
|
|
146 inlining, uncomment the following #define and adapt the definition
|
|
147 of "static inline". */
|
|
148
|
|
149 /* #define ORTHANC_PLUGIN_INLINE static inline */
|
|
150
|
|
151 #ifndef ORTHANC_PLUGIN_INLINE
|
|
152 # if __STDC_VERSION__ >= 199901L
|
|
153 /* This is C99 or above: http://predef.sourceforge.net/prestd.html */
|
|
154 # define ORTHANC_PLUGIN_INLINE static inline
|
|
155 # elif defined(__cplusplus)
|
|
156 /* This is C++ */
|
|
157 # define ORTHANC_PLUGIN_INLINE static inline
|
|
158 # elif defined(__GNUC__)
|
|
159 /* This is GCC running in C89 mode */
|
|
160 # define ORTHANC_PLUGIN_INLINE static __inline
|
|
161 # elif defined(_MSC_VER)
|
|
162 /* This is Visual Studio running in C89 mode */
|
|
163 # define ORTHANC_PLUGIN_INLINE static __inline
|
|
164 # else
|
|
165 # error Your compiler is not known to support the "inline" keyword
|
|
166 # endif
|
|
167 #endif
|
|
168
|
|
169
|
|
170
|
|
171 /********************************************************************
|
|
172 ** Inclusion of standard libraries.
|
|
173 ********************************************************************/
|
|
174
|
|
175 /**
|
|
176 * For Microsoft Visual Studio, a compatibility "stdint.h" can be
|
|
177 * downloaded at the following URL:
|
|
178 * https://hg.orthanc-server.com/orthanc/raw-file/tip/Resources/ThirdParty/VisualStudio/stdint.h
|
|
179 **/
|
|
180 #include <stdint.h>
|
|
181
|
|
182 #include <stdlib.h>
|
|
183
|
|
184
|
|
185
|
|
186 /********************************************************************
|
|
187 ** Definition of the Orthanc Plugin API.
|
|
188 ********************************************************************/
|
|
189
|
|
190 /** @{ */
|
|
191
|
|
192 #ifdef __cplusplus
|
|
193 extern "C"
|
|
194 {
|
|
195 #endif
|
|
196
|
|
197 /**
|
|
198 * The various error codes that can be returned by the Orthanc core.
|
|
199 **/
|
|
200 typedef enum
|
|
201 {
|
|
202 OrthancPluginErrorCode_InternalError = -1 /*!< Internal error */,
|
|
203 OrthancPluginErrorCode_Success = 0 /*!< Success */,
|
|
204 OrthancPluginErrorCode_Plugin = 1 /*!< Error encountered within the plugin engine */,
|
|
205 OrthancPluginErrorCode_NotImplemented = 2 /*!< Not implemented yet */,
|
|
206 OrthancPluginErrorCode_ParameterOutOfRange = 3 /*!< Parameter out of range */,
|
|
207 OrthancPluginErrorCode_NotEnoughMemory = 4 /*!< The server hosting Orthanc is running out of memory */,
|
|
208 OrthancPluginErrorCode_BadParameterType = 5 /*!< Bad type for a parameter */,
|
|
209 OrthancPluginErrorCode_BadSequenceOfCalls = 6 /*!< Bad sequence of calls */,
|
|
210 OrthancPluginErrorCode_InexistentItem = 7 /*!< Accessing an inexistent item */,
|
|
211 OrthancPluginErrorCode_BadRequest = 8 /*!< Bad request */,
|
|
212 OrthancPluginErrorCode_NetworkProtocol = 9 /*!< Error in the network protocol */,
|
|
213 OrthancPluginErrorCode_SystemCommand = 10 /*!< Error while calling a system command */,
|
|
214 OrthancPluginErrorCode_Database = 11 /*!< Error with the database engine */,
|
|
215 OrthancPluginErrorCode_UriSyntax = 12 /*!< Badly formatted URI */,
|
|
216 OrthancPluginErrorCode_InexistentFile = 13 /*!< Inexistent file */,
|
|
217 OrthancPluginErrorCode_CannotWriteFile = 14 /*!< Cannot write to file */,
|
|
218 OrthancPluginErrorCode_BadFileFormat = 15 /*!< Bad file format */,
|
|
219 OrthancPluginErrorCode_Timeout = 16 /*!< Timeout */,
|
|
220 OrthancPluginErrorCode_UnknownResource = 17 /*!< Unknown resource */,
|
|
221 OrthancPluginErrorCode_IncompatibleDatabaseVersion = 18 /*!< Incompatible version of the database */,
|
|
222 OrthancPluginErrorCode_FullStorage = 19 /*!< The file storage is full */,
|
|
223 OrthancPluginErrorCode_CorruptedFile = 20 /*!< Corrupted file (e.g. inconsistent MD5 hash) */,
|
|
224 OrthancPluginErrorCode_InexistentTag = 21 /*!< Inexistent tag */,
|
|
225 OrthancPluginErrorCode_ReadOnly = 22 /*!< Cannot modify a read-only data structure */,
|
|
226 OrthancPluginErrorCode_IncompatibleImageFormat = 23 /*!< Incompatible format of the images */,
|
|
227 OrthancPluginErrorCode_IncompatibleImageSize = 24 /*!< Incompatible size of the images */,
|
|
228 OrthancPluginErrorCode_SharedLibrary = 25 /*!< Error while using a shared library (plugin) */,
|
|
229 OrthancPluginErrorCode_UnknownPluginService = 26 /*!< Plugin invoking an unknown service */,
|
|
230 OrthancPluginErrorCode_UnknownDicomTag = 27 /*!< Unknown DICOM tag */,
|
|
231 OrthancPluginErrorCode_BadJson = 28 /*!< Cannot parse a JSON document */,
|
|
232 OrthancPluginErrorCode_Unauthorized = 29 /*!< Bad credentials were provided to an HTTP request */,
|
|
233 OrthancPluginErrorCode_BadFont = 30 /*!< Badly formatted font file */,
|
|
234 OrthancPluginErrorCode_DatabasePlugin = 31 /*!< The plugin implementing a custom database back-end does not fulfill the proper interface */,
|
|
235 OrthancPluginErrorCode_StorageAreaPlugin = 32 /*!< Error in the plugin implementing a custom storage area */,
|
|
236 OrthancPluginErrorCode_EmptyRequest = 33 /*!< The request is empty */,
|
|
237 OrthancPluginErrorCode_NotAcceptable = 34 /*!< Cannot send a response which is acceptable according to the Accept HTTP header */,
|
|
238 OrthancPluginErrorCode_NullPointer = 35 /*!< Cannot handle a NULL pointer */,
|
|
239 OrthancPluginErrorCode_DatabaseUnavailable = 36 /*!< The database is currently not available (probably a transient situation) */,
|
|
240 OrthancPluginErrorCode_CanceledJob = 37 /*!< This job was canceled */,
|
|
241 OrthancPluginErrorCode_BadGeometry = 38 /*!< Geometry error encountered in Stone */,
|
|
242 OrthancPluginErrorCode_SslInitialization = 39 /*!< Cannot initialize SSL encryption, check out your certificates */,
|
|
243 OrthancPluginErrorCode_DiscontinuedAbi = 40 /*!< Calling a function that has been removed from the Orthanc Framework */,
|
|
244 OrthancPluginErrorCode_BadRange = 41 /*!< Incorrect range request */,
|
|
245 OrthancPluginErrorCode_DatabaseCannotSerialize = 42 /*!< Database could not serialize access due to concurrent update, the transaction should be retried */,
|
|
246 OrthancPluginErrorCode_Revision = 43 /*!< A bad revision number was provided, which might indicate conflict between multiple writers */,
|
|
247 OrthancPluginErrorCode_MainDicomTagsMultiplyDefined = 44 /*!< A main DICOM Tag has been defined multiple times for the same resource level */,
|
|
248 OrthancPluginErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */,
|
|
249 OrthancPluginErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */,
|
|
250 OrthancPluginErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */,
|
|
251 OrthancPluginErrorCode_SQLiteStatementAlreadyUsed = 1003 /*!< SQLite: This cached statement is already being referred to */,
|
|
252 OrthancPluginErrorCode_SQLiteExecute = 1004 /*!< SQLite: Cannot execute a command */,
|
|
253 OrthancPluginErrorCode_SQLiteRollbackWithoutTransaction = 1005 /*!< SQLite: Rolling back a nonexistent transaction (have you called Begin()?) */,
|
|
254 OrthancPluginErrorCode_SQLiteCommitWithoutTransaction = 1006 /*!< SQLite: Committing a nonexistent transaction */,
|
|
255 OrthancPluginErrorCode_SQLiteRegisterFunction = 1007 /*!< SQLite: Unable to register a function */,
|
|
256 OrthancPluginErrorCode_SQLiteFlush = 1008 /*!< SQLite: Unable to flush the database */,
|
|
257 OrthancPluginErrorCode_SQLiteCannotRun = 1009 /*!< SQLite: Cannot run a cached statement */,
|
|
258 OrthancPluginErrorCode_SQLiteCannotStep = 1010 /*!< SQLite: Cannot step over a cached statement */,
|
|
259 OrthancPluginErrorCode_SQLiteBindOutOfRange = 1011 /*!< SQLite: Bing a value while out of range (serious error) */,
|
|
260 OrthancPluginErrorCode_SQLitePrepareStatement = 1012 /*!< SQLite: Cannot prepare a cached statement */,
|
|
261 OrthancPluginErrorCode_SQLiteTransactionAlreadyStarted = 1013 /*!< SQLite: Beginning the same transaction twice */,
|
|
262 OrthancPluginErrorCode_SQLiteTransactionCommit = 1014 /*!< SQLite: Failure when committing the transaction */,
|
|
263 OrthancPluginErrorCode_SQLiteTransactionBegin = 1015 /*!< SQLite: Cannot start a transaction */,
|
|
264 OrthancPluginErrorCode_DirectoryOverFile = 2000 /*!< The directory to be created is already occupied by a regular file */,
|
|
265 OrthancPluginErrorCode_FileStorageCannotWrite = 2001 /*!< Unable to create a subdirectory or a file in the file storage */,
|
|
266 OrthancPluginErrorCode_DirectoryExpected = 2002 /*!< The specified path does not point to a directory */,
|
|
267 OrthancPluginErrorCode_HttpPortInUse = 2003 /*!< The TCP port of the HTTP server is privileged or already in use */,
|
|
268 OrthancPluginErrorCode_DicomPortInUse = 2004 /*!< The TCP port of the DICOM server is privileged or already in use */,
|
|
269 OrthancPluginErrorCode_BadHttpStatusInRest = 2005 /*!< This HTTP status is not allowed in a REST API */,
|
|
270 OrthancPluginErrorCode_RegularFileExpected = 2006 /*!< The specified path does not point to a regular file */,
|
|
271 OrthancPluginErrorCode_PathToExecutable = 2007 /*!< Unable to get the path to the executable */,
|
|
272 OrthancPluginErrorCode_MakeDirectory = 2008 /*!< Cannot create a directory */,
|
|
273 OrthancPluginErrorCode_BadApplicationEntityTitle = 2009 /*!< An application entity title (AET) cannot be empty or be longer than 16 characters */,
|
|
274 OrthancPluginErrorCode_NoCFindHandler = 2010 /*!< No request handler factory for DICOM C-FIND SCP */,
|
|
275 OrthancPluginErrorCode_NoCMoveHandler = 2011 /*!< No request handler factory for DICOM C-MOVE SCP */,
|
|
276 OrthancPluginErrorCode_NoCStoreHandler = 2012 /*!< No request handler factory for DICOM C-STORE SCP */,
|
|
277 OrthancPluginErrorCode_NoApplicationEntityFilter = 2013 /*!< No application entity filter */,
|
|
278 OrthancPluginErrorCode_NoSopClassOrInstance = 2014 /*!< DicomUserConnection: Unable to find the SOP class and instance */,
|
|
279 OrthancPluginErrorCode_NoPresentationContext = 2015 /*!< DicomUserConnection: No acceptable presentation context for modality */,
|
|
280 OrthancPluginErrorCode_DicomFindUnavailable = 2016 /*!< DicomUserConnection: The C-FIND command is not supported by the remote SCP */,
|
|
281 OrthancPluginErrorCode_DicomMoveUnavailable = 2017 /*!< DicomUserConnection: The C-MOVE command is not supported by the remote SCP */,
|
|
282 OrthancPluginErrorCode_CannotStoreInstance = 2018 /*!< Cannot store an instance */,
|
|
283 OrthancPluginErrorCode_CreateDicomNotString = 2019 /*!< Only string values are supported when creating DICOM instances */,
|
|
284 OrthancPluginErrorCode_CreateDicomOverrideTag = 2020 /*!< Trying to override a value inherited from a parent module */,
|
|
285 OrthancPluginErrorCode_CreateDicomUseContent = 2021 /*!< Use \"Content\" to inject an image into a new DICOM instance */,
|
|
286 OrthancPluginErrorCode_CreateDicomNoPayload = 2022 /*!< No payload is present for one instance in the series */,
|
|
287 OrthancPluginErrorCode_CreateDicomUseDataUriScheme = 2023 /*!< The payload of the DICOM instance must be specified according to Data URI scheme */,
|
|
288 OrthancPluginErrorCode_CreateDicomBadParent = 2024 /*!< Trying to attach a new DICOM instance to an inexistent resource */,
|
|
289 OrthancPluginErrorCode_CreateDicomParentIsInstance = 2025 /*!< Trying to attach a new DICOM instance to an instance (must be a series, study or patient) */,
|
|
290 OrthancPluginErrorCode_CreateDicomParentEncoding = 2026 /*!< Unable to get the encoding of the parent resource */,
|
|
291 OrthancPluginErrorCode_UnknownModality = 2027 /*!< Unknown modality */,
|
|
292 OrthancPluginErrorCode_BadJobOrdering = 2028 /*!< Bad ordering of filters in a job */,
|
|
293 OrthancPluginErrorCode_JsonToLuaTable = 2029 /*!< Cannot convert the given JSON object to a Lua table */,
|
|
294 OrthancPluginErrorCode_CannotCreateLua = 2030 /*!< Cannot create the Lua context */,
|
|
295 OrthancPluginErrorCode_CannotExecuteLua = 2031 /*!< Cannot execute a Lua command */,
|
|
296 OrthancPluginErrorCode_LuaAlreadyExecuted = 2032 /*!< Arguments cannot be pushed after the Lua function is executed */,
|
|
297 OrthancPluginErrorCode_LuaBadOutput = 2033 /*!< The Lua function does not give the expected number of outputs */,
|
|
298 OrthancPluginErrorCode_NotLuaPredicate = 2034 /*!< The Lua function is not a predicate (only true/false outputs allowed) */,
|
|
299 OrthancPluginErrorCode_LuaReturnsNoString = 2035 /*!< The Lua function does not return a string */,
|
|
300 OrthancPluginErrorCode_StorageAreaAlreadyRegistered = 2036 /*!< Another plugin has already registered a custom storage area */,
|
|
301 OrthancPluginErrorCode_DatabaseBackendAlreadyRegistered = 2037 /*!< Another plugin has already registered a custom database back-end */,
|
|
302 OrthancPluginErrorCode_DatabaseNotInitialized = 2038 /*!< Plugin trying to call the database during its initialization */,
|
|
303 OrthancPluginErrorCode_SslDisabled = 2039 /*!< Orthanc has been built without SSL support */,
|
|
304 OrthancPluginErrorCode_CannotOrderSlices = 2040 /*!< Unable to order the slices of the series */,
|
|
305 OrthancPluginErrorCode_NoWorklistHandler = 2041 /*!< No request handler factory for DICOM C-Find Modality SCP */,
|
|
306 OrthancPluginErrorCode_AlreadyExistingTag = 2042 /*!< Cannot override the value of a tag that already exists */,
|
|
307 OrthancPluginErrorCode_NoStorageCommitmentHandler = 2043 /*!< No request handler factory for DICOM N-ACTION SCP (storage commitment) */,
|
|
308 OrthancPluginErrorCode_NoCGetHandler = 2044 /*!< No request handler factory for DICOM C-GET SCP */,
|
|
309 OrthancPluginErrorCode_UnsupportedMediaType = 3000 /*!< Unsupported media type */,
|
|
310
|
|
311 _OrthancPluginErrorCode_INTERNAL = 0x7fffffff
|
|
312 } OrthancPluginErrorCode;
|
|
313
|
|
314
|
|
315 /**
|
|
316 * Forward declaration of one of the mandatory functions for Orthanc
|
|
317 * plugins.
|
|
318 **/
|
|
319 ORTHANC_PLUGINS_API const char* OrthancPluginGetName();
|
|
320
|
|
321
|
|
322 /**
|
|
323 * The various HTTP methods for a REST call.
|
|
324 **/
|
|
325 typedef enum
|
|
326 {
|
|
327 OrthancPluginHttpMethod_Get = 1, /*!< GET request */
|
|
328 OrthancPluginHttpMethod_Post = 2, /*!< POST request */
|
|
329 OrthancPluginHttpMethod_Put = 3, /*!< PUT request */
|
|
330 OrthancPluginHttpMethod_Delete = 4, /*!< DELETE request */
|
|
331
|
|
332 _OrthancPluginHttpMethod_INTERNAL = 0x7fffffff
|
|
333 } OrthancPluginHttpMethod;
|
|
334
|
|
335
|
|
336 /**
|
|
337 * @brief The parameters of a REST request.
|
|
338 * @ingroup Callbacks
|
|
339 **/
|
|
340 typedef struct
|
|
341 {
|
|
342 /**
|
|
343 * @brief The HTTP method.
|
|
344 **/
|
|
345 OrthancPluginHttpMethod method;
|
|
346
|
|
347 /**
|
|
348 * @brief The number of groups of the regular expression.
|
|
349 **/
|
|
350 uint32_t groupsCount;
|
|
351
|
|
352 /**
|
|
353 * @brief The matched values for the groups of the regular expression.
|
|
354 **/
|
|
355 const char* const* groups;
|
|
356
|
|
357 /**
|
|
358 * @brief For a GET request, the number of GET parameters.
|
|
359 **/
|
|
360 uint32_t getCount;
|
|
361
|
|
362 /**
|
|
363 * @brief For a GET request, the keys of the GET parameters.
|
|
364 **/
|
|
365 const char* const* getKeys;
|
|
366
|
|
367 /**
|
|
368 * @brief For a GET request, the values of the GET parameters.
|
|
369 **/
|
|
370 const char* const* getValues;
|
|
371
|
|
372 /**
|
|
373 * @brief For a PUT or POST request, the content of the body.
|
|
374 **/
|
|
375 const void* body;
|
|
376
|
|
377 /**
|
|
378 * @brief For a PUT or POST request, the number of bytes of the body.
|
|
379 **/
|
|
380 uint32_t bodySize;
|
|
381
|
|
382
|
|
383 /* --------------------------------------------------
|
|
384 New in version 0.8.1
|
|
385 -------------------------------------------------- */
|
|
386
|
|
387 /**
|
|
388 * @brief The number of HTTP headers.
|
|
389 **/
|
|
390 uint32_t headersCount;
|
|
391
|
|
392 /**
|
|
393 * @brief The keys of the HTTP headers (always converted to low-case).
|
|
394 **/
|
|
395 const char* const* headersKeys;
|
|
396
|
|
397 /**
|
|
398 * @brief The values of the HTTP headers.
|
|
399 **/
|
|
400 const char* const* headersValues;
|
|
401
|
|
402 } OrthancPluginHttpRequest;
|
|
403
|
|
404
|
|
405 typedef enum
|
|
406 {
|
|
407 /* Generic services */
|
|
408 _OrthancPluginService_LogInfo = 1,
|
|
409 _OrthancPluginService_LogWarning = 2,
|
|
410 _OrthancPluginService_LogError = 3,
|
|
411 _OrthancPluginService_GetOrthancPath = 4,
|
|
412 _OrthancPluginService_GetOrthancDirectory = 5,
|
|
413 _OrthancPluginService_GetConfigurationPath = 6,
|
|
414 _OrthancPluginService_SetPluginProperty = 7,
|
|
415 _OrthancPluginService_GetGlobalProperty = 8,
|
|
416 _OrthancPluginService_SetGlobalProperty = 9,
|
|
417 _OrthancPluginService_GetCommandLineArgumentsCount = 10,
|
|
418 _OrthancPluginService_GetCommandLineArgument = 11,
|
|
419 _OrthancPluginService_GetExpectedDatabaseVersion = 12,
|
|
420 _OrthancPluginService_GetConfiguration = 13,
|
|
421 _OrthancPluginService_BufferCompression = 14,
|
|
422 _OrthancPluginService_ReadFile = 15,
|
|
423 _OrthancPluginService_WriteFile = 16,
|
|
424 _OrthancPluginService_GetErrorDescription = 17,
|
|
425 _OrthancPluginService_CallHttpClient = 18,
|
|
426 _OrthancPluginService_RegisterErrorCode = 19,
|
|
427 _OrthancPluginService_RegisterDictionaryTag = 20,
|
|
428 _OrthancPluginService_DicomBufferToJson = 21,
|
|
429 _OrthancPluginService_DicomInstanceToJson = 22,
|
|
430 _OrthancPluginService_CreateDicom = 23,
|
|
431 _OrthancPluginService_ComputeMd5 = 24,
|
|
432 _OrthancPluginService_ComputeSha1 = 25,
|
|
433 _OrthancPluginService_LookupDictionary = 26,
|
|
434 _OrthancPluginService_CallHttpClient2 = 27,
|
|
435 _OrthancPluginService_GenerateUuid = 28,
|
|
436 _OrthancPluginService_RegisterPrivateDictionaryTag = 29,
|
|
437 _OrthancPluginService_AutodetectMimeType = 30,
|
|
438 _OrthancPluginService_SetMetricsValue = 31,
|
|
439 _OrthancPluginService_EncodeDicomWebJson = 32,
|
|
440 _OrthancPluginService_EncodeDicomWebXml = 33,
|
|
441 _OrthancPluginService_ChunkedHttpClient = 34, /* New in Orthanc 1.5.7 */
|
|
442 _OrthancPluginService_GetTagName = 35, /* New in Orthanc 1.5.7 */
|
|
443 _OrthancPluginService_EncodeDicomWebJson2 = 36, /* New in Orthanc 1.7.0 */
|
|
444 _OrthancPluginService_EncodeDicomWebXml2 = 37, /* New in Orthanc 1.7.0 */
|
|
445 _OrthancPluginService_CreateMemoryBuffer = 38, /* New in Orthanc 1.7.0 */
|
|
446 _OrthancPluginService_GenerateRestApiAuthorizationToken = 39, /* New in Orthanc 1.8.1 */
|
|
447 _OrthancPluginService_CreateMemoryBuffer64 = 40, /* New in Orthanc 1.9.0 */
|
|
448 _OrthancPluginService_CreateDicom2 = 41, /* New in Orthanc 1.9.0 */
|
|
449 _OrthancPluginService_GetDatabaseServerIdentifier = 42, /* New in Orthanc 1.11.1 */
|
|
450
|
|
451 /* Registration of callbacks */
|
|
452 _OrthancPluginService_RegisterRestCallback = 1000,
|
|
453 _OrthancPluginService_RegisterOnStoredInstanceCallback = 1001,
|
|
454 _OrthancPluginService_RegisterStorageArea = 1002,
|
|
455 _OrthancPluginService_RegisterOnChangeCallback = 1003,
|
|
456 _OrthancPluginService_RegisterRestCallbackNoLock = 1004,
|
|
457 _OrthancPluginService_RegisterWorklistCallback = 1005,
|
|
458 _OrthancPluginService_RegisterDecodeImageCallback = 1006,
|
|
459 _OrthancPluginService_RegisterIncomingHttpRequestFilter = 1007,
|
|
460 _OrthancPluginService_RegisterFindCallback = 1008,
|
|
461 _OrthancPluginService_RegisterMoveCallback = 1009,
|
|
462 _OrthancPluginService_RegisterIncomingHttpRequestFilter2 = 1010,
|
|
463 _OrthancPluginService_RegisterRefreshMetricsCallback = 1011,
|
|
464 _OrthancPluginService_RegisterChunkedRestCallback = 1012, /* New in Orthanc 1.5.7 */
|
|
465 _OrthancPluginService_RegisterStorageCommitmentScpCallback = 1013,
|
|
466 _OrthancPluginService_RegisterIncomingDicomInstanceFilter = 1014,
|
|
467 _OrthancPluginService_RegisterTranscoderCallback = 1015, /* New in Orthanc 1.7.0 */
|
|
468 _OrthancPluginService_RegisterStorageArea2 = 1016, /* New in Orthanc 1.9.0 */
|
|
469 _OrthancPluginService_RegisterIncomingCStoreInstanceFilter = 1017, /* New in Orthanc 1.10.0 */
|
|
470 _OrthancPluginService_RegisterReceivedInstanceCallback = 1018, /* New in Orthanc 1.10.0 */
|
|
471 _OrthancPluginService_RegisterWebDavCollection = 1019, /* New in Orthanc 1.10.1 */
|
|
472
|
|
473 /* Sending answers to REST calls */
|
|
474 _OrthancPluginService_AnswerBuffer = 2000,
|
|
475 _OrthancPluginService_CompressAndAnswerPngImage = 2001, /* Unused as of Orthanc 0.9.4 */
|
|
476 _OrthancPluginService_Redirect = 2002,
|
|
477 _OrthancPluginService_SendHttpStatusCode = 2003,
|
|
478 _OrthancPluginService_SendUnauthorized = 2004,
|
|
479 _OrthancPluginService_SendMethodNotAllowed = 2005,
|
|
480 _OrthancPluginService_SetCookie = 2006,
|
|
481 _OrthancPluginService_SetHttpHeader = 2007,
|
|
482 _OrthancPluginService_StartMultipartAnswer = 2008,
|
|
483 _OrthancPluginService_SendMultipartItem = 2009,
|
|
484 _OrthancPluginService_SendHttpStatus = 2010,
|
|
485 _OrthancPluginService_CompressAndAnswerImage = 2011,
|
|
486 _OrthancPluginService_SendMultipartItem2 = 2012,
|
|
487 _OrthancPluginService_SetHttpErrorDetails = 2013,
|
|
488
|
|
489 /* Access to the Orthanc database and API */
|
|
490 _OrthancPluginService_GetDicomForInstance = 3000,
|
|
491 _OrthancPluginService_RestApiGet = 3001,
|
|
492 _OrthancPluginService_RestApiPost = 3002,
|
|
493 _OrthancPluginService_RestApiDelete = 3003,
|
|
494 _OrthancPluginService_RestApiPut = 3004,
|
|
495 _OrthancPluginService_LookupPatient = 3005,
|
|
496 _OrthancPluginService_LookupStudy = 3006,
|
|
497 _OrthancPluginService_LookupSeries = 3007,
|
|
498 _OrthancPluginService_LookupInstance = 3008,
|
|
499 _OrthancPluginService_LookupStudyWithAccessionNumber = 3009,
|
|
500 _OrthancPluginService_RestApiGetAfterPlugins = 3010,
|
|
501 _OrthancPluginService_RestApiPostAfterPlugins = 3011,
|
|
502 _OrthancPluginService_RestApiDeleteAfterPlugins = 3012,
|
|
503 _OrthancPluginService_RestApiPutAfterPlugins = 3013,
|
|
504 _OrthancPluginService_ReconstructMainDicomTags = 3014,
|
|
505 _OrthancPluginService_RestApiGet2 = 3015,
|
|
506 _OrthancPluginService_CallRestApi = 3016, /* New in Orthanc 1.9.2 */
|
|
507
|
|
508 /* Access to DICOM instances */
|
|
509 _OrthancPluginService_GetInstanceRemoteAet = 4000,
|
|
510 _OrthancPluginService_GetInstanceSize = 4001,
|
|
511 _OrthancPluginService_GetInstanceData = 4002,
|
|
512 _OrthancPluginService_GetInstanceJson = 4003,
|
|
513 _OrthancPluginService_GetInstanceSimplifiedJson = 4004,
|
|
514 _OrthancPluginService_HasInstanceMetadata = 4005,
|
|
515 _OrthancPluginService_GetInstanceMetadata = 4006,
|
|
516 _OrthancPluginService_GetInstanceOrigin = 4007,
|
|
517 _OrthancPluginService_GetInstanceTransferSyntaxUid = 4008,
|
|
518 _OrthancPluginService_HasInstancePixelData = 4009,
|
|
519 _OrthancPluginService_CreateDicomInstance = 4010, /* New in Orthanc 1.7.0 */
|
|
520 _OrthancPluginService_FreeDicomInstance = 4011, /* New in Orthanc 1.7.0 */
|
|
521 _OrthancPluginService_GetInstanceFramesCount = 4012, /* New in Orthanc 1.7.0 */
|
|
522 _OrthancPluginService_GetInstanceRawFrame = 4013, /* New in Orthanc 1.7.0 */
|
|
523 _OrthancPluginService_GetInstanceDecodedFrame = 4014, /* New in Orthanc 1.7.0 */
|
|
524 _OrthancPluginService_TranscodeDicomInstance = 4015, /* New in Orthanc 1.7.0 */
|
|
525 _OrthancPluginService_SerializeDicomInstance = 4016, /* New in Orthanc 1.7.0 */
|
|
526 _OrthancPluginService_GetInstanceAdvancedJson = 4017, /* New in Orthanc 1.7.0 */
|
|
527 _OrthancPluginService_GetInstanceDicomWebJson = 4018, /* New in Orthanc 1.7.0 */
|
|
528 _OrthancPluginService_GetInstanceDicomWebXml = 4019, /* New in Orthanc 1.7.0 */
|
|
529
|
|
530 /* Services for plugins implementing a database back-end */
|
|
531 _OrthancPluginService_RegisterDatabaseBackend = 5000, /* New in Orthanc 0.8.6 */
|
|
532 _OrthancPluginService_DatabaseAnswer = 5001,
|
|
533 _OrthancPluginService_RegisterDatabaseBackendV2 = 5002, /* New in Orthanc 0.9.4 */
|
|
534 _OrthancPluginService_StorageAreaCreate = 5003,
|
|
535 _OrthancPluginService_StorageAreaRead = 5004,
|
|
536 _OrthancPluginService_StorageAreaRemove = 5005,
|
|
537 _OrthancPluginService_RegisterDatabaseBackendV3 = 5006, /* New in Orthanc 1.9.2 */
|
|
538 _OrthancPluginService_RegisterDatabaseBackendV4 = 5007, /* New in Orthanc 1.12.0 */
|
|
539
|
|
540 /* Primitives for handling images */
|
|
541 _OrthancPluginService_GetImagePixelFormat = 6000,
|
|
542 _OrthancPluginService_GetImageWidth = 6001,
|
|
543 _OrthancPluginService_GetImageHeight = 6002,
|
|
544 _OrthancPluginService_GetImagePitch = 6003,
|
|
545 _OrthancPluginService_GetImageBuffer = 6004,
|
|
546 _OrthancPluginService_UncompressImage = 6005,
|
|
547 _OrthancPluginService_FreeImage = 6006,
|
|
548 _OrthancPluginService_CompressImage = 6007,
|
|
549 _OrthancPluginService_ConvertPixelFormat = 6008,
|
|
550 _OrthancPluginService_GetFontsCount = 6009,
|
|
551 _OrthancPluginService_GetFontInfo = 6010,
|
|
552 _OrthancPluginService_DrawText = 6011,
|
|
553 _OrthancPluginService_CreateImage = 6012,
|
|
554 _OrthancPluginService_CreateImageAccessor = 6013,
|
|
555 _OrthancPluginService_DecodeDicomImage = 6014,
|
|
556
|
|
557 /* Primitives for handling C-Find, C-Move and worklists */
|
|
558 _OrthancPluginService_WorklistAddAnswer = 7000,
|
|
559 _OrthancPluginService_WorklistMarkIncomplete = 7001,
|
|
560 _OrthancPluginService_WorklistIsMatch = 7002,
|
|
561 _OrthancPluginService_WorklistGetDicomQuery = 7003,
|
|
562 _OrthancPluginService_FindAddAnswer = 7004,
|
|
563 _OrthancPluginService_FindMarkIncomplete = 7005,
|
|
564 _OrthancPluginService_GetFindQuerySize = 7006,
|
|
565 _OrthancPluginService_GetFindQueryTag = 7007,
|
|
566 _OrthancPluginService_GetFindQueryTagName = 7008,
|
|
567 _OrthancPluginService_GetFindQueryValue = 7009,
|
|
568 _OrthancPluginService_CreateFindMatcher = 7010,
|
|
569 _OrthancPluginService_FreeFindMatcher = 7011,
|
|
570 _OrthancPluginService_FindMatcherIsMatch = 7012,
|
|
571
|
|
572 /* Primitives for accessing Orthanc Peers (new in 1.4.2) */
|
|
573 _OrthancPluginService_GetPeers = 8000,
|
|
574 _OrthancPluginService_FreePeers = 8001,
|
|
575 _OrthancPluginService_GetPeersCount = 8003,
|
|
576 _OrthancPluginService_GetPeerName = 8004,
|
|
577 _OrthancPluginService_GetPeerUrl = 8005,
|
|
578 _OrthancPluginService_CallPeerApi = 8006,
|
|
579 _OrthancPluginService_GetPeerUserProperty = 8007,
|
|
580
|
|
581 /* Primitives for handling jobs (new in 1.4.2) */
|
|
582 _OrthancPluginService_CreateJob = 9000, /* Deprecated since SDK 1.11.3 */
|
|
583 _OrthancPluginService_FreeJob = 9001,
|
|
584 _OrthancPluginService_SubmitJob = 9002,
|
|
585 _OrthancPluginService_RegisterJobsUnserializer = 9003,
|
|
586 _OrthancPluginService_CreateJob2 = 9004, /* New in SDK 1.11.3 */
|
|
587
|
|
588 _OrthancPluginService_INTERNAL = 0x7fffffff
|
|
589 } _OrthancPluginService;
|
|
590
|
|
591
|
|
592 typedef enum
|
|
593 {
|
|
594 _OrthancPluginProperty_Description = 1,
|
|
595 _OrthancPluginProperty_RootUri = 2,
|
|
596 _OrthancPluginProperty_OrthancExplorer = 3,
|
|
597
|
|
598 _OrthancPluginProperty_INTERNAL = 0x7fffffff
|
|
599 } _OrthancPluginProperty;
|
|
600
|
|
601
|
|
602
|
|
603 /**
|
|
604 * The memory layout of the pixels of an image.
|
|
605 * @ingroup Images
|
|
606 **/
|
|
607 typedef enum
|
|
608 {
|
|
609 /**
|
|
610 * @brief Graylevel 8bpp image.
|
|
611 *
|
|
612 * The image is graylevel. Each pixel is unsigned and stored in
|
|
613 * one byte.
|
|
614 **/
|
|
615 OrthancPluginPixelFormat_Grayscale8 = 1,
|
|
616
|
|
617 /**
|
|
618 * @brief Graylevel, unsigned 16bpp image.
|
|
619 *
|
|
620 * The image is graylevel. Each pixel is unsigned and stored in
|
|
621 * two bytes.
|
|
622 **/
|
|
623 OrthancPluginPixelFormat_Grayscale16 = 2,
|
|
624
|
|
625 /**
|
|
626 * @brief Graylevel, signed 16bpp image.
|
|
627 *
|
|
628 * The image is graylevel. Each pixel is signed and stored in two
|
|
629 * bytes.
|
|
630 **/
|
|
631 OrthancPluginPixelFormat_SignedGrayscale16 = 3,
|
|
632
|
|
633 /**
|
|
634 * @brief Color image in RGB24 format.
|
|
635 *
|
|
636 * This format describes a color image. The pixels are stored in 3
|
|
637 * consecutive bytes. The memory layout is RGB.
|
|
638 **/
|
|
639 OrthancPluginPixelFormat_RGB24 = 4,
|
|
640
|
|
641 /**
|
|
642 * @brief Color image in RGBA32 format.
|
|
643 *
|
|
644 * This format describes a color image. The pixels are stored in 4
|
|
645 * consecutive bytes. The memory layout is RGBA.
|
|
646 **/
|
|
647 OrthancPluginPixelFormat_RGBA32 = 5,
|
|
648
|
|
649 OrthancPluginPixelFormat_Unknown = 6, /*!< Unknown pixel format */
|
|
650
|
|
651 /**
|
|
652 * @brief Color image in RGB48 format.
|
|
653 *
|
|
654 * This format describes a color image. The pixels are stored in 6
|
|
655 * consecutive bytes. The memory layout is RRGGBB.
|
|
656 **/
|
|
657 OrthancPluginPixelFormat_RGB48 = 7,
|
|
658
|
|
659 /**
|
|
660 * @brief Graylevel, unsigned 32bpp image.
|
|
661 *
|
|
662 * The image is graylevel. Each pixel is unsigned and stored in
|
|
663 * four bytes.
|
|
664 **/
|
|
665 OrthancPluginPixelFormat_Grayscale32 = 8,
|
|
666
|
|
667 /**
|
|
668 * @brief Graylevel, floating-point 32bpp image.
|
|
669 *
|
|
670 * The image is graylevel. Each pixel is floating-point and stored
|
|
671 * in four bytes.
|
|
672 **/
|
|
673 OrthancPluginPixelFormat_Float32 = 9,
|
|
674
|
|
675 /**
|
|
676 * @brief Color image in BGRA32 format.
|
|
677 *
|
|
678 * This format describes a color image. The pixels are stored in 4
|
|
679 * consecutive bytes. The memory layout is BGRA.
|
|
680 **/
|
|
681 OrthancPluginPixelFormat_BGRA32 = 10,
|
|
682
|
|
683 /**
|
|
684 * @brief Graylevel, unsigned 64bpp image.
|
|
685 *
|
|
686 * The image is graylevel. Each pixel is unsigned and stored in
|
|
687 * eight bytes.
|
|
688 **/
|
|
689 OrthancPluginPixelFormat_Grayscale64 = 11,
|
|
690
|
|
691 _OrthancPluginPixelFormat_INTERNAL = 0x7fffffff
|
|
692 } OrthancPluginPixelFormat;
|
|
693
|
|
694
|
|
695
|
|
696 /**
|
|
697 * The content types that are supported by Orthanc plugins.
|
|
698 **/
|
|
699 typedef enum
|
|
700 {
|
|
701 OrthancPluginContentType_Unknown = 0, /*!< Unknown content type */
|
|
702 OrthancPluginContentType_Dicom = 1, /*!< DICOM */
|
|
703 OrthancPluginContentType_DicomAsJson = 2, /*!< JSON summary of a DICOM file */
|
|
704 OrthancPluginContentType_DicomUntilPixelData = 3, /*!< DICOM Header till pixel data */
|
|
705
|
|
706 _OrthancPluginContentType_INTERNAL = 0x7fffffff
|
|
707 } OrthancPluginContentType;
|
|
708
|
|
709
|
|
710
|
|
711 /**
|
|
712 * The supported types of DICOM resources.
|
|
713 **/
|
|
714 typedef enum
|
|
715 {
|
|
716 OrthancPluginResourceType_Patient = 0, /*!< Patient */
|
|
717 OrthancPluginResourceType_Study = 1, /*!< Study */
|
|
718 OrthancPluginResourceType_Series = 2, /*!< Series */
|
|
719 OrthancPluginResourceType_Instance = 3, /*!< Instance */
|
|
720 OrthancPluginResourceType_None = 4, /*!< Unavailable resource type */
|
|
721
|
|
722 _OrthancPluginResourceType_INTERNAL = 0x7fffffff
|
|
723 } OrthancPluginResourceType;
|
|
724
|
|
725
|
|
726
|
|
727 /**
|
|
728 * The supported types of changes that can be signaled to the change callback.
|
|
729 * @ingroup Callbacks
|
|
730 **/
|
|
731 typedef enum
|
|
732 {
|
|
733 OrthancPluginChangeType_CompletedSeries = 0, /*!< Series is now complete */
|
|
734 OrthancPluginChangeType_Deleted = 1, /*!< Deleted resource */
|
|
735 OrthancPluginChangeType_NewChildInstance = 2, /*!< A new instance was added to this resource */
|
|
736 OrthancPluginChangeType_NewInstance = 3, /*!< New instance received */
|
|
737 OrthancPluginChangeType_NewPatient = 4, /*!< New patient created */
|
|
738 OrthancPluginChangeType_NewSeries = 5, /*!< New series created */
|
|
739 OrthancPluginChangeType_NewStudy = 6, /*!< New study created */
|
|
740 OrthancPluginChangeType_StablePatient = 7, /*!< Timeout: No new instance in this patient */
|
|
741 OrthancPluginChangeType_StableSeries = 8, /*!< Timeout: No new instance in this series */
|
|
742 OrthancPluginChangeType_StableStudy = 9, /*!< Timeout: No new instance in this study */
|
|
743 OrthancPluginChangeType_OrthancStarted = 10, /*!< Orthanc has started */
|
|
744 OrthancPluginChangeType_OrthancStopped = 11, /*!< Orthanc is stopping */
|
|
745 OrthancPluginChangeType_UpdatedAttachment = 12, /*!< Some user-defined attachment has changed for this resource */
|
|
746 OrthancPluginChangeType_UpdatedMetadata = 13, /*!< Some user-defined metadata has changed for this resource */
|
|
747 OrthancPluginChangeType_UpdatedPeers = 14, /*!< The list of Orthanc peers has changed */
|
|
748 OrthancPluginChangeType_UpdatedModalities = 15, /*!< The list of DICOM modalities has changed */
|
|
749 OrthancPluginChangeType_JobSubmitted = 16, /*!< New Job submitted */
|
|
750 OrthancPluginChangeType_JobSuccess = 17, /*!< A Job has completed successfully */
|
|
751 OrthancPluginChangeType_JobFailure = 18, /*!< A Job has failed */
|
|
752
|
|
753 _OrthancPluginChangeType_INTERNAL = 0x7fffffff
|
|
754 } OrthancPluginChangeType;
|
|
755
|
|
756
|
|
757 /**
|
|
758 * The compression algorithms that are supported by the Orthanc core.
|
|
759 * @ingroup Images
|
|
760 **/
|
|
761 typedef enum
|
|
762 {
|
|
763 OrthancPluginCompressionType_Zlib = 0, /*!< Standard zlib compression */
|
|
764 OrthancPluginCompressionType_ZlibWithSize = 1, /*!< zlib, prefixed with uncompressed size (uint64_t) */
|
|
765 OrthancPluginCompressionType_Gzip = 2, /*!< Standard gzip compression */
|
|
766 OrthancPluginCompressionType_GzipWithSize = 3, /*!< gzip, prefixed with uncompressed size (uint64_t) */
|
|
767
|
|
768 _OrthancPluginCompressionType_INTERNAL = 0x7fffffff
|
|
769 } OrthancPluginCompressionType;
|
|
770
|
|
771
|
|
772 /**
|
|
773 * The image formats that are supported by the Orthanc core.
|
|
774 * @ingroup Images
|
|
775 **/
|
|
776 typedef enum
|
|
777 {
|
|
778 OrthancPluginImageFormat_Png = 0, /*!< Image compressed using PNG */
|
|
779 OrthancPluginImageFormat_Jpeg = 1, /*!< Image compressed using JPEG */
|
|
780 OrthancPluginImageFormat_Dicom = 2, /*!< Image compressed using DICOM */
|
|
781
|
|
782 _OrthancPluginImageFormat_INTERNAL = 0x7fffffff
|
|
783 } OrthancPluginImageFormat;
|
|
784
|
|
785
|
|
786 /**
|
|
787 * The value representations present in the DICOM standard (version 2013).
|
|
788 * @ingroup Toolbox
|
|
789 **/
|
|
790 typedef enum
|
|
791 {
|
|
792 OrthancPluginValueRepresentation_AE = 1, /*!< Application Entity */
|
|
793 OrthancPluginValueRepresentation_AS = 2, /*!< Age String */
|
|
794 OrthancPluginValueRepresentation_AT = 3, /*!< Attribute Tag */
|
|
795 OrthancPluginValueRepresentation_CS = 4, /*!< Code String */
|
|
796 OrthancPluginValueRepresentation_DA = 5, /*!< Date */
|
|
797 OrthancPluginValueRepresentation_DS = 6, /*!< Decimal String */
|
|
798 OrthancPluginValueRepresentation_DT = 7, /*!< Date Time */
|
|
799 OrthancPluginValueRepresentation_FD = 8, /*!< Floating Point Double */
|
|
800 OrthancPluginValueRepresentation_FL = 9, /*!< Floating Point Single */
|
|
801 OrthancPluginValueRepresentation_IS = 10, /*!< Integer String */
|
|
802 OrthancPluginValueRepresentation_LO = 11, /*!< Long String */
|
|
803 OrthancPluginValueRepresentation_LT = 12, /*!< Long Text */
|
|
804 OrthancPluginValueRepresentation_OB = 13, /*!< Other Byte String */
|
|
805 OrthancPluginValueRepresentation_OF = 14, /*!< Other Float String */
|
|
806 OrthancPluginValueRepresentation_OW = 15, /*!< Other Word String */
|
|
807 OrthancPluginValueRepresentation_PN = 16, /*!< Person Name */
|
|
808 OrthancPluginValueRepresentation_SH = 17, /*!< Short String */
|
|
809 OrthancPluginValueRepresentation_SL = 18, /*!< Signed Long */
|
|
810 OrthancPluginValueRepresentation_SQ = 19, /*!< Sequence of Items */
|
|
811 OrthancPluginValueRepresentation_SS = 20, /*!< Signed Short */
|
|
812 OrthancPluginValueRepresentation_ST = 21, /*!< Short Text */
|
|
813 OrthancPluginValueRepresentation_TM = 22, /*!< Time */
|
|
814 OrthancPluginValueRepresentation_UI = 23, /*!< Unique Identifier (UID) */
|
|
815 OrthancPluginValueRepresentation_UL = 24, /*!< Unsigned Long */
|
|
816 OrthancPluginValueRepresentation_UN = 25, /*!< Unknown */
|
|
817 OrthancPluginValueRepresentation_US = 26, /*!< Unsigned Short */
|
|
818 OrthancPluginValueRepresentation_UT = 27, /*!< Unlimited Text */
|
|
819
|
|
820 _OrthancPluginValueRepresentation_INTERNAL = 0x7fffffff
|
|
821 } OrthancPluginValueRepresentation;
|
|
822
|
|
823
|
|
824 /**
|
|
825 * The possible output formats for a DICOM-to-JSON conversion.
|
|
826 * @ingroup Toolbox
|
|
827 * @see OrthancPluginDicomToJson()
|
|
828 **/
|
|
829 typedef enum
|
|
830 {
|
|
831 OrthancPluginDicomToJsonFormat_Full = 1, /*!< Full output, with most details */
|
|
832 OrthancPluginDicomToJsonFormat_Short = 2, /*!< Tags output as hexadecimal numbers */
|
|
833 OrthancPluginDicomToJsonFormat_Human = 3, /*!< Human-readable JSON */
|
|
834
|
|
835 _OrthancPluginDicomToJsonFormat_INTERNAL = 0x7fffffff
|
|
836 } OrthancPluginDicomToJsonFormat;
|
|
837
|
|
838
|
|
839 /**
|
|
840 * Flags to customize a DICOM-to-JSON conversion. By default, binary
|
|
841 * tags are formatted using Data URI scheme.
|
|
842 * @ingroup Toolbox
|
|
843 **/
|
|
844 typedef enum
|
|
845 {
|
|
846 OrthancPluginDicomToJsonFlags_None = 0,
|
|
847 OrthancPluginDicomToJsonFlags_IncludeBinary = (1 << 0), /*!< Include the binary tags */
|
|
848 OrthancPluginDicomToJsonFlags_IncludePrivateTags = (1 << 1), /*!< Include the private tags */
|
|
849 OrthancPluginDicomToJsonFlags_IncludeUnknownTags = (1 << 2), /*!< Include the tags unknown by the dictionary */
|
|
850 OrthancPluginDicomToJsonFlags_IncludePixelData = (1 << 3), /*!< Include the pixel data */
|
|
851 OrthancPluginDicomToJsonFlags_ConvertBinaryToAscii = (1 << 4), /*!< Output binary tags as-is, dropping non-ASCII */
|
|
852 OrthancPluginDicomToJsonFlags_ConvertBinaryToNull = (1 << 5), /*!< Signal binary tags as null values */
|
|
853 OrthancPluginDicomToJsonFlags_StopAfterPixelData = (1 << 6), /*!< Stop processing after pixel data (new in 1.9.1) */
|
|
854 OrthancPluginDicomToJsonFlags_SkipGroupLengths = (1 << 7), /*!< Skip tags whose element is zero (new in 1.9.1) */
|
|
855
|
|
856 _OrthancPluginDicomToJsonFlags_INTERNAL = 0x7fffffff
|
|
857 } OrthancPluginDicomToJsonFlags;
|
|
858
|
|
859
|
|
860 /**
|
|
861 * Flags to the creation of a DICOM file.
|
|
862 * @ingroup Toolbox
|
|
863 * @see OrthancPluginCreateDicom()
|
|
864 **/
|
|
865 typedef enum
|
|
866 {
|
|
867 OrthancPluginCreateDicomFlags_None = 0,
|
|
868 OrthancPluginCreateDicomFlags_DecodeDataUriScheme = (1 << 0), /*!< Decode fields encoded using data URI scheme */
|
|
869 OrthancPluginCreateDicomFlags_GenerateIdentifiers = (1 << 1), /*!< Automatically generate DICOM identifiers */
|
|
870
|
|
871 _OrthancPluginCreateDicomFlags_INTERNAL = 0x7fffffff
|
|
872 } OrthancPluginCreateDicomFlags;
|
|
873
|
|
874
|
|
875 /**
|
|
876 * The constraints on the DICOM identifiers that must be supported
|
|
877 * by the database plugins.
|
|
878 * @deprecated Plugins using OrthancPluginConstraintType will be faster
|
|
879 **/
|
|
880 typedef enum
|
|
881 {
|
|
882 OrthancPluginIdentifierConstraint_Equal = 1, /*!< Equal */
|
|
883 OrthancPluginIdentifierConstraint_SmallerOrEqual = 2, /*!< Less or equal */
|
|
884 OrthancPluginIdentifierConstraint_GreaterOrEqual = 3, /*!< More or equal */
|
|
885 OrthancPluginIdentifierConstraint_Wildcard = 4, /*!< Case-sensitive wildcard matching (with * and ?) */
|
|
886
|
|
887 _OrthancPluginIdentifierConstraint_INTERNAL = 0x7fffffff
|
|
888 } OrthancPluginIdentifierConstraint;
|
|
889
|
|
890
|
|
891 /**
|
|
892 * The constraints on the tags (main DICOM tags and identifier tags)
|
|
893 * that must be supported by the database plugins.
|
|
894 **/
|
|
895 typedef enum
|
|
896 {
|
|
897 OrthancPluginConstraintType_Equal = 1, /*!< Equal */
|
|
898 OrthancPluginConstraintType_SmallerOrEqual = 2, /*!< Less or equal */
|
|
899 OrthancPluginConstraintType_GreaterOrEqual = 3, /*!< More or equal */
|
|
900 OrthancPluginConstraintType_Wildcard = 4, /*!< Wildcard matching */
|
|
901 OrthancPluginConstraintType_List = 5, /*!< List of values */
|
|
902
|
|
903 _OrthancPluginConstraintType_INTERNAL = 0x7fffffff
|
|
904 } OrthancPluginConstraintType;
|
|
905
|
|
906
|
|
907 /**
|
|
908 * The origin of a DICOM instance that has been received by Orthanc.
|
|
909 **/
|
|
910 typedef enum
|
|
911 {
|
|
912 OrthancPluginInstanceOrigin_Unknown = 1, /*!< Unknown origin */
|
|
913 OrthancPluginInstanceOrigin_DicomProtocol = 2, /*!< Instance received through DICOM protocol */
|
|
914 OrthancPluginInstanceOrigin_RestApi = 3, /*!< Instance received through REST API of Orthanc */
|
|
915 OrthancPluginInstanceOrigin_Plugin = 4, /*!< Instance added to Orthanc by a plugin */
|
|
916 OrthancPluginInstanceOrigin_Lua = 5, /*!< Instance added to Orthanc by a Lua script */
|
|
917 OrthancPluginInstanceOrigin_WebDav = 6, /*!< Instance received through WebDAV (new in 1.8.0) */
|
|
918
|
|
919 _OrthancPluginInstanceOrigin_INTERNAL = 0x7fffffff
|
|
920 } OrthancPluginInstanceOrigin;
|
|
921
|
|
922
|
|
923 /**
|
|
924 * The possible status for one single step of a job.
|
|
925 **/
|
|
926 typedef enum
|
|
927 {
|
|
928 OrthancPluginJobStepStatus_Success = 1, /*!< The job has successfully executed all its steps */
|
|
929 OrthancPluginJobStepStatus_Failure = 2, /*!< The job has failed while executing this step */
|
|
930 OrthancPluginJobStepStatus_Continue = 3 /*!< The job has still data to process after this step */
|
|
931 } OrthancPluginJobStepStatus;
|
|
932
|
|
933
|
|
934 /**
|
|
935 * Explains why the job should stop and release the resources it has
|
|
936 * allocated. This is especially important to disambiguate between
|
|
937 * the "paused" condition and the "final" conditions (success,
|
|
938 * failure, or canceled).
|
|
939 **/
|
|
940 typedef enum
|
|
941 {
|
|
942 OrthancPluginJobStopReason_Success = 1, /*!< The job has succeeded */
|
|
943 OrthancPluginJobStopReason_Paused = 2, /*!< The job was paused, and will be resumed later */
|
|
944 OrthancPluginJobStopReason_Failure = 3, /*!< The job has failed, and might be resubmitted later */
|
|
945 OrthancPluginJobStopReason_Canceled = 4 /*!< The job was canceled, and might be resubmitted later */
|
|
946 } OrthancPluginJobStopReason;
|
|
947
|
|
948
|
|
949 /**
|
|
950 * The available types of metrics.
|
|
951 **/
|
|
952 typedef enum
|
|
953 {
|
|
954 OrthancPluginMetricsType_Default = 0, /*!< Default metrics */
|
|
955
|
|
956 /**
|
|
957 * This metrics represents a time duration. Orthanc will keep the
|
|
958 * maximum value of the metrics over a sliding window of ten
|
|
959 * seconds, which is useful if the metrics is sampled frequently.
|
|
960 **/
|
|
961 OrthancPluginMetricsType_Timer = 1
|
|
962 } OrthancPluginMetricsType;
|
|
963
|
|
964
|
|
965 /**
|
|
966 * The available modes to export a binary DICOM tag into a DICOMweb
|
|
967 * JSON or XML document.
|
|
968 **/
|
|
969 typedef enum
|
|
970 {
|
|
971 OrthancPluginDicomWebBinaryMode_Ignore = 0, /*!< Don't include binary tags */
|
|
972 OrthancPluginDicomWebBinaryMode_InlineBinary = 1, /*!< Inline encoding using Base64 */
|
|
973 OrthancPluginDicomWebBinaryMode_BulkDataUri = 2 /*!< Use a bulk data URI field */
|
|
974 } OrthancPluginDicomWebBinaryMode;
|
|
975
|
|
976
|
|
977 /**
|
|
978 * The available values for the Failure Reason (0008,1197) during
|
|
979 * storage commitment.
|
|
980 * http://dicom.nema.org/medical/dicom/2019e/output/chtml/part03/sect_C.14.html#sect_C.14.1.1
|
|
981 **/
|
|
982 typedef enum
|
|
983 {
|
|
984 OrthancPluginStorageCommitmentFailureReason_Success = 0,
|
|
985 /*!< Success: The DICOM instance is properly stored in the SCP */
|
|
986
|
|
987 OrthancPluginStorageCommitmentFailureReason_ProcessingFailure = 1,
|
|
988 /*!< 0110H: A general failure in processing the operation was encountered */
|
|
989
|
|
990 OrthancPluginStorageCommitmentFailureReason_NoSuchObjectInstance = 2,
|
|
991 /*!< 0112H: One or more of the elements in the Referenced SOP
|
|
992 Instance Sequence was not available */
|
|
993
|
|
994 OrthancPluginStorageCommitmentFailureReason_ResourceLimitation = 3,
|
|
995 /*!< 0213H: The SCP does not currently have enough resources to
|
|
996 store the requested SOP Instance(s) */
|
|
997
|
|
998 OrthancPluginStorageCommitmentFailureReason_ReferencedSOPClassNotSupported = 4,
|
|
999 /*!< 0122H: Storage Commitment has been requested for a SOP
|
|
1000 Instance with a SOP Class that is not supported by the SCP */
|
|
1001
|
|
1002 OrthancPluginStorageCommitmentFailureReason_ClassInstanceConflict = 5,
|
|
1003 /*!< 0119H: The SOP Class of an element in the Referenced SOP
|
|
1004 Instance Sequence did not correspond to the SOP class registered
|
|
1005 for this SOP Instance at the SCP */
|
|
1006
|
|
1007 OrthancPluginStorageCommitmentFailureReason_DuplicateTransactionUID = 6
|
|
1008 /*!< 0131H: The Transaction UID of the Storage Commitment Request
|
|
1009 is already in use */
|
|
1010 } OrthancPluginStorageCommitmentFailureReason;
|
|
1011
|
|
1012
|
|
1013 /**
|
|
1014 * The action to be taken after ReceivedInstanceCallback is triggered
|
|
1015 **/
|
|
1016 typedef enum
|
|
1017 {
|
|
1018 OrthancPluginReceivedInstanceAction_KeepAsIs = 1, /*!< Keep the instance as is */
|
|
1019 OrthancPluginReceivedInstanceAction_Modify = 2, /*!< Modify the instance */
|
|
1020 OrthancPluginReceivedInstanceAction_Discard = 3, /*!< Discard the instance */
|
|
1021
|
|
1022 _OrthancPluginReceivedInstanceAction_INTERNAL = 0x7fffffff
|
|
1023 } OrthancPluginReceivedInstanceAction;
|
|
1024
|
|
1025
|
|
1026 /**
|
|
1027 * @brief A 32-bit memory buffer allocated by the core system of Orthanc.
|
|
1028 *
|
|
1029 * A memory buffer allocated by the core system of Orthanc. When the
|
|
1030 * content of the buffer is not useful anymore, it must be free by a
|
|
1031 * call to ::OrthancPluginFreeMemoryBuffer().
|
|
1032 **/
|
|
1033 typedef struct
|
|
1034 {
|
|
1035 /**
|
|
1036 * @brief The content of the buffer.
|
|
1037 **/
|
|
1038 void* data;
|
|
1039
|
|
1040 /**
|
|
1041 * @brief The number of bytes in the buffer.
|
|
1042 **/
|
|
1043 uint32_t size;
|
|
1044 } OrthancPluginMemoryBuffer;
|
|
1045
|
|
1046
|
|
1047
|
|
1048 /**
|
|
1049 * @brief A 64-bit memory buffer allocated by the core system of Orthanc.
|
|
1050 *
|
|
1051 * A memory buffer allocated by the core system of Orthanc. When the
|
|
1052 * content of the buffer is not useful anymore, it must be free by a
|
|
1053 * call to ::OrthancPluginFreeMemoryBuffer64().
|
|
1054 **/
|
|
1055 typedef struct
|
|
1056 {
|
|
1057 /**
|
|
1058 * @brief The content of the buffer.
|
|
1059 **/
|
|
1060 void* data;
|
|
1061
|
|
1062 /**
|
|
1063 * @brief The number of bytes in the buffer.
|
|
1064 **/
|
|
1065 uint64_t size;
|
|
1066 } OrthancPluginMemoryBuffer64;
|
|
1067
|
|
1068
|
|
1069
|
|
1070
|
|
1071 /**
|
|
1072 * @brief Opaque structure that represents the HTTP connection to the client application.
|
|
1073 * @ingroup Callbacks
|
|
1074 **/
|
|
1075 typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput;
|
|
1076
|
|
1077
|
|
1078
|
|
1079 /**
|
|
1080 * @brief Opaque structure that represents a DICOM instance that is managed by the Orthanc core.
|
|
1081 * @ingroup DicomInstance
|
|
1082 **/
|
|
1083 typedef struct _OrthancPluginDicomInstance_t OrthancPluginDicomInstance;
|
|
1084
|
|
1085
|
|
1086
|
|
1087 /**
|
|
1088 * @brief Opaque structure that represents an image that is uncompressed in memory.
|
|
1089 * @ingroup Images
|
|
1090 **/
|
|
1091 typedef struct _OrthancPluginImage_t OrthancPluginImage;
|
|
1092
|
|
1093
|
|
1094
|
|
1095 /**
|
|
1096 * @brief Opaque structure that represents the storage area that is actually used by Orthanc.
|
|
1097 * @ingroup Images
|
|
1098 **/
|
|
1099 typedef struct _OrthancPluginStorageArea_t OrthancPluginStorageArea;
|
|
1100
|
|
1101
|
|
1102
|
|
1103 /**
|
|
1104 * @brief Opaque structure to an object that represents a C-Find query for worklists.
|
|
1105 * @ingroup DicomCallbacks
|
|
1106 **/
|
|
1107 typedef struct _OrthancPluginWorklistQuery_t OrthancPluginWorklistQuery;
|
|
1108
|
|
1109
|
|
1110
|
|
1111 /**
|
|
1112 * @brief Opaque structure to an object that represents the answers to a C-Find query for worklists.
|
|
1113 * @ingroup DicomCallbacks
|
|
1114 **/
|
|
1115 typedef struct _OrthancPluginWorklistAnswers_t OrthancPluginWorklistAnswers;
|
|
1116
|
|
1117
|
|
1118
|
|
1119 /**
|
|
1120 * @brief Opaque structure to an object that represents a C-Find query.
|
|
1121 * @ingroup DicomCallbacks
|
|
1122 **/
|
|
1123 typedef struct _OrthancPluginFindQuery_t OrthancPluginFindQuery;
|
|
1124
|
|
1125
|
|
1126
|
|
1127 /**
|
|
1128 * @brief Opaque structure to an object that represents the answers to a C-Find query for worklists.
|
|
1129 * @ingroup DicomCallbacks
|
|
1130 **/
|
|
1131 typedef struct _OrthancPluginFindAnswers_t OrthancPluginFindAnswers;
|
|
1132
|
|
1133
|
|
1134
|
|
1135 /**
|
|
1136 * @brief Opaque structure to an object that can be used to check whether a DICOM instance matches a C-Find query.
|
|
1137 * @ingroup Toolbox
|
|
1138 **/
|
|
1139 typedef struct _OrthancPluginFindMatcher_t OrthancPluginFindMatcher;
|
|
1140
|
|
1141
|
|
1142
|
|
1143 /**
|
|
1144 * @brief Opaque structure to the set of remote Orthanc Peers that are known to the local Orthanc server.
|
|
1145 * @ingroup Toolbox
|
|
1146 **/
|
|
1147 typedef struct _OrthancPluginPeers_t OrthancPluginPeers;
|
|
1148
|
|
1149
|
|
1150
|
|
1151 /**
|
|
1152 * @brief Opaque structure to a job to be executed by Orthanc.
|
|
1153 * @ingroup Toolbox
|
|
1154 **/
|
|
1155 typedef struct _OrthancPluginJob_t OrthancPluginJob;
|
|
1156
|
|
1157
|
|
1158
|
|
1159 /**
|
|
1160 * @brief Opaque structure that represents a node in a JSON or XML
|
|
1161 * document used in DICOMweb.
|
|
1162 * @ingroup Toolbox
|
|
1163 **/
|
|
1164 typedef struct _OrthancPluginDicomWebNode_t OrthancPluginDicomWebNode;
|
|
1165
|
|
1166
|
|
1167
|
|
1168 /**
|
|
1169 * @brief Signature of a callback function that answers to a REST request.
|
|
1170 * @ingroup Callbacks
|
|
1171 **/
|
|
1172 typedef OrthancPluginErrorCode (*OrthancPluginRestCallback) (
|
|
1173 OrthancPluginRestOutput* output,
|
|
1174 const char* url,
|
|
1175 const OrthancPluginHttpRequest* request);
|
|
1176
|
|
1177
|
|
1178
|
|
1179 /**
|
|
1180 * @brief Signature of a callback function that is triggered when Orthanc stores a new DICOM instance.
|
|
1181 * @ingroup Callbacks
|
|
1182 **/
|
|
1183 typedef OrthancPluginErrorCode (*OrthancPluginOnStoredInstanceCallback) (
|
|
1184 const OrthancPluginDicomInstance* instance,
|
|
1185 const char* instanceId);
|
|
1186
|
|
1187
|
|
1188
|
|
1189 /**
|
|
1190 * @brief Signature of a callback function that is triggered when a change happens to some DICOM resource.
|
|
1191 * @ingroup Callbacks
|
|
1192 **/
|
|
1193 typedef OrthancPluginErrorCode (*OrthancPluginOnChangeCallback) (
|
|
1194 OrthancPluginChangeType changeType,
|
|
1195 OrthancPluginResourceType resourceType,
|
|
1196 const char* resourceId);
|
|
1197
|
|
1198
|
|
1199
|
|
1200 /**
|
|
1201 * @brief Signature of a callback function to decode a DICOM instance as an image.
|
|
1202 * @ingroup Callbacks
|
|
1203 **/
|
|
1204 typedef OrthancPluginErrorCode (*OrthancPluginDecodeImageCallback) (
|
|
1205 OrthancPluginImage** target,
|
|
1206 const void* dicom,
|
|
1207 const uint32_t size,
|
|
1208 uint32_t frameIndex);
|
|
1209
|
|
1210
|
|
1211
|
|
1212 /**
|
|
1213 * @brief Signature of a function to free dynamic memory.
|
|
1214 * @ingroup Callbacks
|
|
1215 **/
|
|
1216 typedef void (*OrthancPluginFree) (void* buffer);
|
|
1217
|
|
1218
|
|
1219
|
|
1220 /**
|
|
1221 * @brief Signature of a function to set the content of a node
|
|
1222 * encoding a binary DICOM tag, into a JSON or XML document
|
|
1223 * generated for DICOMweb.
|
|
1224 * @ingroup Callbacks
|
|
1225 **/
|
|
1226 typedef void (*OrthancPluginDicomWebSetBinaryNode) (
|
|
1227 OrthancPluginDicomWebNode* node,
|
|
1228 OrthancPluginDicomWebBinaryMode mode,
|
|
1229 const char* bulkDataUri);
|
|
1230
|
|
1231
|
|
1232
|
|
1233 /**
|
|
1234 * @brief Callback for writing to the storage area.
|
|
1235 *
|
|
1236 * Signature of a callback function that is triggered when Orthanc writes a file to the storage area.
|
|
1237 *
|
|
1238 * @param uuid The UUID of the file.
|
|
1239 * @param content The content of the file.
|
|
1240 * @param size The size of the file.
|
|
1241 * @param type The content type corresponding to this file.
|
|
1242 * @return 0 if success, other value if error.
|
|
1243 * @ingroup Callbacks
|
|
1244 **/
|
|
1245 typedef OrthancPluginErrorCode (*OrthancPluginStorageCreate) (
|
|
1246 const char* uuid,
|
|
1247 const void* content,
|
|
1248 int64_t size,
|
|
1249 OrthancPluginContentType type);
|
|
1250
|
|
1251
|
|
1252
|
|
1253 /**
|
|
1254 * @brief Callback for reading from the storage area.
|
|
1255 *
|
|
1256 * Signature of a callback function that is triggered when Orthanc reads a file from the storage area.
|
|
1257 *
|
|
1258 * @param content The content of the file (output).
|
|
1259 * @param size The size of the file (output).
|
|
1260 * @param uuid The UUID of the file of interest.
|
|
1261 * @param type The content type corresponding to this file.
|
|
1262 * @return 0 if success, other value if error.
|
|
1263 * @ingroup Callbacks
|
|
1264 * @deprecated New plugins should use OrthancPluginStorageRead2
|
|
1265 *
|
|
1266 * @warning The "content" buffer *must* have been allocated using
|
|
1267 * the "malloc()" function of your C standard library (i.e. nor
|
|
1268 * "new[]", neither a pointer to a buffer). The "free()" function of
|
|
1269 * your C standard library will automatically be invoked on the
|
|
1270 * "content" pointer.
|
|
1271 **/
|
|
1272 typedef OrthancPluginErrorCode (*OrthancPluginStorageRead) (
|
|
1273 void** content,
|
|
1274 int64_t* size,
|
|
1275 const char* uuid,
|
|
1276 OrthancPluginContentType type);
|
|
1277
|
|
1278
|
|
1279
|
|
1280 /**
|
|
1281 * @brief Callback for reading a whole file from the storage area.
|
|
1282 *
|
|
1283 * Signature of a callback function that is triggered when Orthanc
|
|
1284 * reads a whole file from the storage area.
|
|
1285 *
|
|
1286 * @param target Memory buffer where to store the content of the file. It must be allocated by the
|
|
1287 * plugin using OrthancPluginCreateMemoryBuffer64(). The core of Orthanc will free it.
|
|
1288 * @param uuid The UUID of the file of interest.
|
|
1289 * @param type The content type corresponding to this file.
|
|
1290 * @ingroup Callbacks
|
|
1291 **/
|
|
1292 typedef OrthancPluginErrorCode (*OrthancPluginStorageReadWhole) (
|
|
1293 OrthancPluginMemoryBuffer64* target,
|
|
1294 const char* uuid,
|
|
1295 OrthancPluginContentType type);
|
|
1296
|
|
1297
|
|
1298
|
|
1299 /**
|
|
1300 * @brief Callback for reading a range of a file from the storage area.
|
|
1301 *
|
|
1302 * Signature of a callback function that is triggered when Orthanc
|
|
1303 * reads a portion of a file from the storage area. Orthanc
|
|
1304 * indicates the start position and the length of the range.
|
|
1305 *
|
|
1306 * @param target Memory buffer where to store the content of the range.
|
|
1307 * The memory buffer is allocated and freed by Orthanc. The length of the range
|
|
1308 * of interest corresponds to the size of this buffer.
|
|
1309 * @param uuid The UUID of the file of interest.
|
|
1310 * @param type The content type corresponding to this file.
|
|
1311 * @param rangeStart Start position of the requested range in the file.
|
|
1312 * @return 0 if success, other value if error.
|
|
1313 * @ingroup Callbacks
|
|
1314 **/
|
|
1315 typedef OrthancPluginErrorCode (*OrthancPluginStorageReadRange) (
|
|
1316 OrthancPluginMemoryBuffer64* target,
|
|
1317 const char* uuid,
|
|
1318 OrthancPluginContentType type,
|
|
1319 uint64_t rangeStart);
|
|
1320
|
|
1321
|
|
1322
|
|
1323 /**
|
|
1324 * @brief Callback for removing a file from the storage area.
|
|
1325 *
|
|
1326 * Signature of a callback function that is triggered when Orthanc deletes a file from the storage area.
|
|
1327 *
|
|
1328 * @param uuid The UUID of the file to be removed.
|
|
1329 * @param type The content type corresponding to this file.
|
|
1330 * @return 0 if success, other value if error.
|
|
1331 * @ingroup Callbacks
|
|
1332 **/
|
|
1333 typedef OrthancPluginErrorCode (*OrthancPluginStorageRemove) (
|
|
1334 const char* uuid,
|
|
1335 OrthancPluginContentType type);
|
|
1336
|
|
1337
|
|
1338
|
|
1339 /**
|
|
1340 * @brief Callback to handle the C-Find SCP requests for worklists.
|
|
1341 *
|
|
1342 * Signature of a callback function that is triggered when Orthanc
|
|
1343 * receives a C-Find SCP request against modality worklists.
|
|
1344 *
|
|
1345 * @param answers The target structure where answers must be stored.
|
|
1346 * @param query The worklist query.
|
|
1347 * @param issuerAet The Application Entity Title (AET) of the modality from which the request originates.
|
|
1348 * @param calledAet The Application Entity Title (AET) of the modality that is called by the request.
|
|
1349 * @return 0 if success, other value if error.
|
|
1350 * @ingroup DicomCallbacks
|
|
1351 **/
|
|
1352 typedef OrthancPluginErrorCode (*OrthancPluginWorklistCallback) (
|
|
1353 OrthancPluginWorklistAnswers* answers,
|
|
1354 const OrthancPluginWorklistQuery* query,
|
|
1355 const char* issuerAet,
|
|
1356 const char* calledAet);
|
|
1357
|
|
1358
|
|
1359
|
|
1360 /**
|
|
1361 * @brief Callback to filter incoming HTTP requests received by Orthanc.
|
|
1362 *
|
|
1363 * Signature of a callback function that is triggered whenever
|
|
1364 * Orthanc receives an HTTP/REST request, and that answers whether
|
|
1365 * this request should be allowed. If the callback returns "0"
|
|
1366 * ("false"), the server answers with HTTP status code 403
|
|
1367 * (Forbidden).
|
|
1368 *
|
|
1369 * Pay attention to the fact that this function may be invoked
|
|
1370 * concurrently by different threads of the Web server of
|
|
1371 * Orthanc. You must implement proper locking if applicable.
|
|
1372 *
|
|
1373 * @param method The HTTP method used by the request.
|
|
1374 * @param uri The URI of interest.
|
|
1375 * @param ip The IP address of the HTTP client.
|
|
1376 * @param headersCount The number of HTTP headers.
|
|
1377 * @param headersKeys The keys of the HTTP headers (always converted to low-case).
|
|
1378 * @param headersValues The values of the HTTP headers.
|
|
1379 * @return 0 if forbidden access, 1 if allowed access, -1 if error.
|
|
1380 * @ingroup Callbacks
|
|
1381 * @deprecated Please instead use OrthancPluginIncomingHttpRequestFilter2()
|
|
1382 **/
|
|
1383 typedef int32_t (*OrthancPluginIncomingHttpRequestFilter) (
|
|
1384 OrthancPluginHttpMethod method,
|
|
1385 const char* uri,
|
|
1386 const char* ip,
|
|
1387 uint32_t headersCount,
|
|
1388 const char* const* headersKeys,
|
|
1389 const char* const* headersValues);
|
|
1390
|
|
1391
|
|
1392
|
|
1393 /**
|
|
1394 * @brief Callback to filter incoming HTTP requests received by Orthanc.
|
|
1395 *
|
|
1396 * Signature of a callback function that is triggered whenever
|
|
1397 * Orthanc receives an HTTP/REST request, and that answers whether
|
|
1398 * this request should be allowed. If the callback returns "0"
|
|
1399 * ("false"), the server answers with HTTP status code 403
|
|
1400 * (Forbidden).
|
|
1401 *
|
|
1402 * Pay attention to the fact that this function may be invoked
|
|
1403 * concurrently by different threads of the Web server of
|
|
1404 * Orthanc. You must implement proper locking if applicable.
|
|
1405 *
|
|
1406 * @param method The HTTP method used by the request.
|
|
1407 * @param uri The URI of interest.
|
|
1408 * @param ip The IP address of the HTTP client.
|
|
1409 * @param headersCount The number of HTTP headers.
|
|
1410 * @param headersKeys The keys of the HTTP headers (always converted to low-case).
|
|
1411 * @param headersValues The values of the HTTP headers.
|
|
1412 * @param getArgumentsCount The number of GET arguments (only for the GET HTTP method).
|
|
1413 * @param getArgumentsKeys The keys of the GET arguments (only for the GET HTTP method).
|
|
1414 * @param getArgumentsValues The values of the GET arguments (only for the GET HTTP method).
|
|
1415 * @return 0 if forbidden access, 1 if allowed access, -1 if error.
|
|
1416 * @ingroup Callbacks
|
|
1417 **/
|
|
1418 typedef int32_t (*OrthancPluginIncomingHttpRequestFilter2) (
|
|
1419 OrthancPluginHttpMethod method,
|
|
1420 const char* uri,
|
|
1421 const char* ip,
|
|
1422 uint32_t headersCount,
|
|
1423 const char* const* headersKeys,
|
|
1424 const char* const* headersValues,
|
|
1425 uint32_t getArgumentsCount,
|
|
1426 const char* const* getArgumentsKeys,
|
|
1427 const char* const* getArgumentsValues);
|
|
1428
|
|
1429
|
|
1430
|
|
1431 /**
|
|
1432 * @brief Callback to handle incoming C-Find SCP requests.
|
|
1433 *
|
|
1434 * Signature of a callback function that is triggered whenever
|
|
1435 * Orthanc receives a C-Find SCP request not concerning modality
|
|
1436 * worklists.
|
|
1437 *
|
|
1438 * @param answers The target structure where answers must be stored.
|
|
1439 * @param query The worklist query.
|
|
1440 * @param issuerAet The Application Entity Title (AET) of the modality from which the request originates.
|
|
1441 * @param calledAet The Application Entity Title (AET) of the modality that is called by the request.
|
|
1442 * @return 0 if success, other value if error.
|
|
1443 * @ingroup DicomCallbacks
|
|
1444 **/
|
|
1445 typedef OrthancPluginErrorCode (*OrthancPluginFindCallback) (
|
|
1446 OrthancPluginFindAnswers* answers,
|
|
1447 const OrthancPluginFindQuery* query,
|
|
1448 const char* issuerAet,
|
|
1449 const char* calledAet);
|
|
1450
|
|
1451
|
|
1452
|
|
1453 /**
|
|
1454 * @brief Callback to handle incoming C-Move SCP requests.
|
|
1455 *
|
|
1456 * Signature of a callback function that is triggered whenever
|
|
1457 * Orthanc receives a C-Move SCP request. The callback receives the
|
|
1458 * type of the resource of interest (study, series, instance...)
|
|
1459 * together with the DICOM tags containing its identifiers. In turn,
|
|
1460 * the plugin must create a driver object that will be responsible
|
|
1461 * for driving the successive move suboperations.
|
|
1462 *
|
|
1463 * @param resourceType The type of the resource of interest. Note
|
|
1464 * that this might be set to ResourceType_None if the
|
|
1465 * QueryRetrieveLevel (0008,0052) tag was not provided by the
|
|
1466 * issuer (i.e. the originator modality).
|
|
1467 * @param patientId Content of the PatientID (0x0010, 0x0020) tag of the resource of interest. Might be NULL.
|
|
1468 * @param accessionNumber Content of the AccessionNumber (0x0008, 0x0050) tag. Might be NULL.
|
|
1469 * @param studyInstanceUid Content of the StudyInstanceUID (0x0020, 0x000d) tag. Might be NULL.
|
|
1470 * @param seriesInstanceUid Content of the SeriesInstanceUID (0x0020, 0x000e) tag. Might be NULL.
|
|
1471 * @param sopInstanceUid Content of the SOPInstanceUID (0x0008, 0x0018) tag. Might be NULL.
|
|
1472 * @param originatorAet The Application Entity Title (AET) of the
|
|
1473 * modality from which the request originates.
|
|
1474 * @param sourceAet The Application Entity Title (AET) of the
|
|
1475 * modality that should send its DICOM files to another modality.
|
|
1476 * @param targetAet The Application Entity Title (AET) of the
|
|
1477 * modality that should receive the DICOM files.
|
|
1478 * @param originatorId The Message ID issued by the originator modality,
|
|
1479 * as found in tag (0000,0110) of the DICOM query emitted by the issuer.
|
|
1480 *
|
|
1481 * @return The NULL value if the plugin cannot deal with this query,
|
|
1482 * or a pointer to the driver object that is responsible for
|
|
1483 * handling the successive move suboperations.
|
|
1484 *
|
|
1485 * @note If targetAet equals sourceAet, this is actually a query/retrieve operation.
|
|
1486 * @ingroup DicomCallbacks
|
|
1487 **/
|
|
1488 typedef void* (*OrthancPluginMoveCallback) (
|
|
1489 OrthancPluginResourceType resourceType,
|
|
1490 const char* patientId,
|
|
1491 const char* accessionNumber,
|
|
1492 const char* studyInstanceUid,
|
|
1493 const char* seriesInstanceUid,
|
|
1494 const char* sopInstanceUid,
|
|
1495 const char* originatorAet,
|
|
1496 const char* sourceAet,
|
|
1497 const char* targetAet,
|
|
1498 uint16_t originatorId);
|
|
1499
|
|
1500
|
|
1501 /**
|
|
1502 * @brief Callback to read the size of a C-Move driver.
|
|
1503 *
|
|
1504 * Signature of a callback function that returns the number of
|
|
1505 * C-Move suboperations that are to be achieved by the given C-Move
|
|
1506 * driver. This driver is the return value of a previous call to the
|
|
1507 * OrthancPluginMoveCallback() callback.
|
|
1508 *
|
|
1509 * @param moveDriver The C-Move driver of interest.
|
|
1510 * @return The number of suboperations.
|
|
1511 * @ingroup DicomCallbacks
|
|
1512 **/
|
|
1513 typedef uint32_t (*OrthancPluginGetMoveSize) (void* moveDriver);
|
|
1514
|
|
1515
|
|
1516 /**
|
|
1517 * @brief Callback to apply one C-Move suboperation.
|
|
1518 *
|
|
1519 * Signature of a callback function that applies the next C-Move
|
|
1520 * suboperation that os to be achieved by the given C-Move
|
|
1521 * driver. This driver is the return value of a previous call to the
|
|
1522 * OrthancPluginMoveCallback() callback.
|
|
1523 *
|
|
1524 * @param moveDriver The C-Move driver of interest.
|
|
1525 * @return 0 if success, or the error code if failure.
|
|
1526 * @ingroup DicomCallbacks
|
|
1527 **/
|
|
1528 typedef OrthancPluginErrorCode (*OrthancPluginApplyMove) (void* moveDriver);
|
|
1529
|
|
1530
|
|
1531 /**
|
|
1532 * @brief Callback to free one C-Move driver.
|
|
1533 *
|
|
1534 * Signature of a callback function that releases the resources
|
|
1535 * allocated by the given C-Move driver. This driver is the return
|
|
1536 * value of a previous call to the OrthancPluginMoveCallback()
|
|
1537 * callback.
|
|
1538 *
|
|
1539 * @param moveDriver The C-Move driver of interest.
|
|
1540 * @ingroup DicomCallbacks
|
|
1541 **/
|
|
1542 typedef void (*OrthancPluginFreeMove) (void* moveDriver);
|
|
1543
|
|
1544
|
|
1545 /**
|
|
1546 * @brief Callback to finalize one custom job.
|
|
1547 *
|
|
1548 * Signature of a callback function that releases all the resources
|
|
1549 * allocated by the given job. This job is the argument provided to
|
|
1550 * OrthancPluginCreateJob().
|
|
1551 *
|
|
1552 * @param job The job of interest.
|
|
1553 * @ingroup Toolbox
|
|
1554 **/
|
|
1555 typedef void (*OrthancPluginJobFinalize) (void* job);
|
|
1556
|
|
1557
|
|
1558 /**
|
|
1559 * @brief Callback to check the progress of one custom job.
|
|
1560 *
|
|
1561 * Signature of a callback function that returns the progress of the
|
|
1562 * job.
|
|
1563 *
|
|
1564 * @param job The job of interest.
|
|
1565 * @return The progress, as a floating-point number ranging from 0 to 1.
|
|
1566 * @ingroup Toolbox
|
|
1567 **/
|
|
1568 typedef float (*OrthancPluginJobGetProgress) (void* job);
|
|
1569
|
|
1570
|
|
1571 /**
|
|
1572 * @brief Callback to retrieve the content of one custom job.
|
|
1573 *
|
|
1574 * Signature of a callback function that returns human-readable
|
|
1575 * statistics about the job. This statistics must be formatted as a
|
|
1576 * JSON object. This information is notably displayed in the "Jobs"
|
|
1577 * tab of "Orthanc Explorer".
|
|
1578 *
|
|
1579 * @param job The job of interest.
|
|
1580 * @return The statistics, as a JSON object encoded as a string.
|
|
1581 * @ingroup Toolbox
|
|
1582 * @deprecated This signature should not be used anymore since Orthanc SDK 1.11.3.
|
|
1583 **/
|
|
1584 typedef const char* (*OrthancPluginJobGetContent) (void* job);
|
|
1585
|
|
1586
|
|
1587 /**
|
|
1588 * @brief Callback to retrieve the content of one custom job.
|
|
1589 *
|
|
1590 * Signature of a callback function that returns human-readable
|
|
1591 * statistics about the job. This statistics must be formatted as a
|
|
1592 * JSON object. This information is notably displayed in the "Jobs"
|
|
1593 * tab of "Orthanc Explorer".
|
|
1594 *
|
|
1595 * @param target The target memory buffer where to store the JSON string.
|
|
1596 * This buffer must be allocated using OrthancPluginCreateMemoryBuffer()
|
|
1597 * and will be freed by the Orthanc core.
|
|
1598 * @param job The job of interest.
|
|
1599 * @return 0 if success, other value if error.
|
|
1600 * @ingroup Toolbox
|
|
1601 **/
|
|
1602 typedef OrthancPluginErrorCode (*OrthancPluginJobGetContent2) (OrthancPluginMemoryBuffer* target,
|
|
1603 void* job);
|
|
1604
|
|
1605
|
|
1606 /**
|
|
1607 * @brief Callback to serialize one custom job.
|
|
1608 *
|
|
1609 * Signature of a callback function that returns a serialized
|
|
1610 * version of the job, formatted as a JSON object. This
|
|
1611 * serialization is stored in the Orthanc database, and is used to
|
|
1612 * reload the job on the restart of Orthanc. The "unserialization"
|
|
1613 * callback (with OrthancPluginJobsUnserializer signature) will
|
|
1614 * receive this serialized object.
|
|
1615 *
|
|
1616 * @param job The job of interest.
|
|
1617 * @return The serialized job, as a JSON object encoded as a string.
|
|
1618 * @see OrthancPluginRegisterJobsUnserializer()
|
|
1619 * @ingroup Toolbox
|
|
1620 * @deprecated This signature should not be used anymore since Orthanc SDK 1.11.3.
|
|
1621 **/
|
|
1622 typedef const char* (*OrthancPluginJobGetSerialized) (void* job);
|
|
1623
|
|
1624
|
|
1625 /**
|
|
1626 * @brief Callback to serialize one custom job.
|
|
1627 *
|
|
1628 * Signature of a callback function that returns a serialized
|
|
1629 * version of the job, formatted as a JSON object. This
|
|
1630 * serialization is stored in the Orthanc database, and is used to
|
|
1631 * reload the job on the restart of Orthanc. The "unserialization"
|
|
1632 * callback (with OrthancPluginJobsUnserializer signature) will
|
|
1633 * receive this serialized object.
|
|
1634 *
|
|
1635 * @param target The target memory buffer where to store the JSON string.
|
|
1636 * This buffer must be allocated using OrthancPluginCreateMemoryBuffer()
|
|
1637 * and will be freed by the Orthanc core.
|
|
1638 * @param job The job of interest.
|
|
1639 * @return 1 if the serialization has succeeded, 0 if serialization is
|
|
1640 * not implemented for this type of job, or -1 in case of error.
|
|
1641 **/
|
|
1642 typedef int32_t (*OrthancPluginJobGetSerialized2) (OrthancPluginMemoryBuffer* target,
|
|
1643 void* job);
|
|
1644
|
|
1645
|
|
1646 /**
|
|
1647 * @brief Callback to execute one step of a custom job.
|
|
1648 *
|
|
1649 * Signature of a callback function that executes one step in the
|
|
1650 * job. The jobs engine of Orthanc will make successive calls to
|
|
1651 * this method, as long as it returns
|
|
1652 * OrthancPluginJobStepStatus_Continue.
|
|
1653 *
|
|
1654 * @param job The job of interest.
|
|
1655 * @return The status of execution.
|
|
1656 * @ingroup Toolbox
|
|
1657 **/
|
|
1658 typedef OrthancPluginJobStepStatus (*OrthancPluginJobStep) (void* job);
|
|
1659
|
|
1660
|
|
1661 /**
|
|
1662 * @brief Callback executed once one custom job leaves the "running" state.
|
|
1663 *
|
|
1664 * Signature of a callback function that is invoked once a job
|
|
1665 * leaves the "running" state. This can happen if the previous call
|
|
1666 * to OrthancPluginJobStep has failed/succeeded, if the host Orthanc
|
|
1667 * server is being stopped, or if the user manually tags the job as
|
|
1668 * paused/canceled. This callback allows the plugin to free
|
|
1669 * resources allocated for running this custom job (e.g. to stop
|
|
1670 * threads, or to remove temporary files).
|
|
1671 *
|
|
1672 * Note that handling pauses might involves a specific treatment
|
|
1673 * (such a stopping threads, but keeping temporary files on the
|
|
1674 * disk). This "paused" situation can be checked by looking at the
|
|
1675 * "reason" parameter.
|
|
1676 *
|
|
1677 * @param job The job of interest.
|
|
1678 * @param reason The reason for leaving the "running" state.
|
|
1679 * @return 0 if success, or the error code if failure.
|
|
1680 * @ingroup Toolbox
|
|
1681 **/
|
|
1682 typedef OrthancPluginErrorCode (*OrthancPluginJobStop) (void* job,
|
|
1683 OrthancPluginJobStopReason reason);
|
|
1684
|
|
1685
|
|
1686 /**
|
|
1687 * @brief Callback executed once one stopped custom job is started again.
|
|
1688 *
|
|
1689 * Signature of a callback function that is invoked once a job
|
|
1690 * leaves the "failure/canceled" state, to be started again. This
|
|
1691 * function will typically reset the progress to zero. Note that
|
|
1692 * before being actually executed, the job would first be tagged as
|
|
1693 * "pending" in the Orthanc jobs engine.
|
|
1694 *
|
|
1695 * @param job The job of interest.
|
|
1696 * @return 0 if success, or the error code if failure.
|
|
1697 * @ingroup Toolbox
|
|
1698 **/
|
|
1699 typedef OrthancPluginErrorCode (*OrthancPluginJobReset) (void* job);
|
|
1700
|
|
1701
|
|
1702 /**
|
|
1703 * @brief Callback executed to unserialize a custom job.
|
|
1704 *
|
|
1705 * Signature of a callback function that unserializes a job that was
|
|
1706 * saved in the Orthanc database.
|
|
1707 *
|
|
1708 * @param jobType The type of the job, as provided to OrthancPluginCreateJob().
|
|
1709 * @param serialized The serialization of the job, as provided by OrthancPluginJobGetSerialized.
|
|
1710 * @return The unserialized job (as created by OrthancPluginCreateJob()), or NULL
|
|
1711 * if this unserializer cannot handle this job type.
|
|
1712 * @see OrthancPluginRegisterJobsUnserializer()
|
|
1713 * @ingroup Callbacks
|
|
1714 **/
|
|
1715 typedef OrthancPluginJob* (*OrthancPluginJobsUnserializer) (const char* jobType,
|
|
1716 const char* serialized);
|
|
1717
|
|
1718
|
|
1719
|
|
1720 /**
|
|
1721 * @brief Callback executed to update the metrics of the plugin.
|
|
1722 *
|
|
1723 * Signature of a callback function that is called by Orthanc
|
|
1724 * whenever a monitoring tool (such as Prometheus) asks the current
|
|
1725 * values of the metrics. This callback gives the plugin a chance to
|
|
1726 * update its metrics, by calling OrthancPluginSetMetricsValue().
|
|
1727 * This is typically useful for metrics that are expensive to
|
|
1728 * acquire.
|
|
1729 *
|
|
1730 * @see OrthancPluginRegisterRefreshMetrics()
|
|
1731 * @ingroup Callbacks
|
|
1732 **/
|
|
1733 typedef void (*OrthancPluginRefreshMetricsCallback) ();
|
|
1734
|
|
1735
|
|
1736
|
|
1737 /**
|
|
1738 * @brief Callback executed to encode a binary tag in DICOMweb.
|
|
1739 *
|
|
1740 * Signature of a callback function that is called by Orthanc
|
|
1741 * whenever a DICOM tag that contains a binary value must be written
|
|
1742 * to a JSON or XML node, while a DICOMweb document is being
|
|
1743 * generated. The value representation (VR) of the DICOM tag can be
|
|
1744 * OB, OD, OF, OL, OW, or UN.
|
|
1745 *
|
|
1746 * @see OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
|
|
1747 * @param node The node being generated, as provided by Orthanc.
|
|
1748 * @param setter The setter to be used to encode the content of the node. If
|
|
1749 * the setter is not called, the binary tag is not written to the output document.
|
|
1750 * @param levelDepth The depth of the node in the DICOM hierarchy of sequences.
|
|
1751 * This parameter gives the number of elements in the "levelTagGroup",
|
|
1752 * "levelTagElement", and "levelIndex" arrays.
|
|
1753 * @param levelTagGroup The group of the parent DICOM tags in the hierarchy.
|
|
1754 * @param levelTagElement The element of the parent DICOM tags in the hierarchy.
|
|
1755 * @param levelIndex The index of the node in the parent sequences of the hierarchy.
|
|
1756 * @param tagGroup The group of the DICOM tag of interest.
|
|
1757 * @param tagElement The element of the DICOM tag of interest.
|
|
1758 * @param vr The value representation of the binary DICOM node.
|
|
1759 * @ingroup Callbacks
|
|
1760 **/
|
|
1761 typedef void (*OrthancPluginDicomWebBinaryCallback) (
|
|
1762 OrthancPluginDicomWebNode* node,
|
|
1763 OrthancPluginDicomWebSetBinaryNode setter,
|
|
1764 uint32_t levelDepth,
|
|
1765 const uint16_t* levelTagGroup,
|
|
1766 const uint16_t* levelTagElement,
|
|
1767 const uint32_t* levelIndex,
|
|
1768 uint16_t tagGroup,
|
|
1769 uint16_t tagElement,
|
|
1770 OrthancPluginValueRepresentation vr);
|
|
1771
|
|
1772
|
|
1773
|
|
1774 /**
|
|
1775 * @brief Callback executed to encode a binary tag in DICOMweb.
|
|
1776 *
|
|
1777 * Signature of a callback function that is called by Orthanc
|
|
1778 * whenever a DICOM tag that contains a binary value must be written
|
|
1779 * to a JSON or XML node, while a DICOMweb document is being
|
|
1780 * generated. The value representation (VR) of the DICOM tag can be
|
|
1781 * OB, OD, OF, OL, OW, or UN.
|
|
1782 *
|
|
1783 * @see OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
|
|
1784 * @param node The node being generated, as provided by Orthanc.
|
|
1785 * @param setter The setter to be used to encode the content of the node. If
|
|
1786 * the setter is not called, the binary tag is not written to the output document.
|
|
1787 * @param levelDepth The depth of the node in the DICOM hierarchy of sequences.
|
|
1788 * This parameter gives the number of elements in the "levelTagGroup",
|
|
1789 * "levelTagElement", and "levelIndex" arrays.
|
|
1790 * @param levelTagGroup The group of the parent DICOM tags in the hierarchy.
|
|
1791 * @param levelTagElement The element of the parent DICOM tags in the hierarchy.
|
|
1792 * @param levelIndex The index of the node in the parent sequences of the hierarchy.
|
|
1793 * @param tagGroup The group of the DICOM tag of interest.
|
|
1794 * @param tagElement The element of the DICOM tag of interest.
|
|
1795 * @param vr The value representation of the binary DICOM node.
|
|
1796 * @param payload The user payload.
|
|
1797 * @ingroup Callbacks
|
|
1798 **/
|
|
1799 typedef void (*OrthancPluginDicomWebBinaryCallback2) (
|
|
1800 OrthancPluginDicomWebNode* node,
|
|
1801 OrthancPluginDicomWebSetBinaryNode setter,
|
|
1802 uint32_t levelDepth,
|
|
1803 const uint16_t* levelTagGroup,
|
|
1804 const uint16_t* levelTagElement,
|
|
1805 const uint32_t* levelIndex,
|
|
1806 uint16_t tagGroup,
|
|
1807 uint16_t tagElement,
|
|
1808 OrthancPluginValueRepresentation vr,
|
|
1809 void* payload);
|
|
1810
|
|
1811
|
|
1812
|
|
1813 /**
|
|
1814 * @brief Data structure that contains information about the Orthanc core.
|
|
1815 **/
|
|
1816 typedef struct _OrthancPluginContext_t
|
|
1817 {
|
|
1818 void* pluginsManager;
|
|
1819 const char* orthancVersion;
|
|
1820 OrthancPluginFree Free;
|
|
1821 OrthancPluginErrorCode (*InvokeService) (struct _OrthancPluginContext_t* context,
|
|
1822 _OrthancPluginService service,
|
|
1823 const void* params);
|
|
1824 } OrthancPluginContext;
|
|
1825
|
|
1826
|
|
1827
|
|
1828 /**
|
|
1829 * @brief An entry in the dictionary of DICOM tags.
|
|
1830 **/
|
|
1831 typedef struct
|
|
1832 {
|
|
1833 uint16_t group; /*!< The group of the tag */
|
|
1834 uint16_t element; /*!< The element of the tag */
|
|
1835 OrthancPluginValueRepresentation vr; /*!< The value representation of the tag */
|
|
1836 uint32_t minMultiplicity; /*!< The minimum multiplicity of the tag */
|
|
1837 uint32_t maxMultiplicity; /*!< The maximum multiplicity of the tag (0 means arbitrary) */
|
|
1838 } OrthancPluginDictionaryEntry;
|
|
1839
|
|
1840
|
|
1841
|
|
1842 /**
|
|
1843 * @brief Free a string.
|
|
1844 *
|
|
1845 * Free a string that was allocated by the core system of Orthanc.
|
|
1846 *
|
|
1847 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1848 * @param str The string to be freed.
|
|
1849 **/
|
|
1850 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeString(
|
|
1851 OrthancPluginContext* context,
|
|
1852 char* str)
|
|
1853 {
|
|
1854 if (str != NULL)
|
|
1855 {
|
|
1856 context->Free(str);
|
|
1857 }
|
|
1858 }
|
|
1859
|
|
1860
|
|
1861 /**
|
|
1862 * @brief Check that the version of the hosting Orthanc is above a given version.
|
|
1863 *
|
|
1864 * This function checks whether the version of the Orthanc server
|
|
1865 * running this plugin, is above the given version. Contrarily to
|
|
1866 * OrthancPluginCheckVersion(), it is up to the developer of the
|
|
1867 * plugin to make sure that all the Orthanc SDK services called by
|
|
1868 * the plugin are actually implemented in the given version of
|
|
1869 * Orthanc.
|
|
1870 *
|
|
1871 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1872 * @param expectedMajor Expected major version.
|
|
1873 * @param expectedMinor Expected minor version.
|
|
1874 * @param expectedRevision Expected revision.
|
|
1875 * @return 1 if and only if the versions are compatible. If the
|
|
1876 * result is 0, the initialization of the plugin should fail.
|
|
1877 * @see OrthancPluginCheckVersion
|
|
1878 * @ingroup Callbacks
|
|
1879 **/
|
|
1880 ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersionAdvanced(
|
|
1881 OrthancPluginContext* context,
|
|
1882 int expectedMajor,
|
|
1883 int expectedMinor,
|
|
1884 int expectedRevision)
|
|
1885 {
|
|
1886 int major, minor, revision;
|
|
1887
|
|
1888 if (sizeof(int32_t) != sizeof(OrthancPluginErrorCode) ||
|
|
1889 sizeof(int32_t) != sizeof(OrthancPluginHttpMethod) ||
|
|
1890 sizeof(int32_t) != sizeof(_OrthancPluginService) ||
|
|
1891 sizeof(int32_t) != sizeof(_OrthancPluginProperty) ||
|
|
1892 sizeof(int32_t) != sizeof(OrthancPluginPixelFormat) ||
|
|
1893 sizeof(int32_t) != sizeof(OrthancPluginContentType) ||
|
|
1894 sizeof(int32_t) != sizeof(OrthancPluginResourceType) ||
|
|
1895 sizeof(int32_t) != sizeof(OrthancPluginChangeType) ||
|
|
1896 sizeof(int32_t) != sizeof(OrthancPluginCompressionType) ||
|
|
1897 sizeof(int32_t) != sizeof(OrthancPluginImageFormat) ||
|
|
1898 sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) ||
|
|
1899 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) ||
|
|
1900 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) ||
|
|
1901 sizeof(int32_t) != sizeof(OrthancPluginCreateDicomFlags) ||
|
|
1902 sizeof(int32_t) != sizeof(OrthancPluginIdentifierConstraint) ||
|
|
1903 sizeof(int32_t) != sizeof(OrthancPluginInstanceOrigin) ||
|
|
1904 sizeof(int32_t) != sizeof(OrthancPluginJobStepStatus) ||
|
|
1905 sizeof(int32_t) != sizeof(OrthancPluginConstraintType) ||
|
|
1906 sizeof(int32_t) != sizeof(OrthancPluginMetricsType) ||
|
|
1907 sizeof(int32_t) != sizeof(OrthancPluginDicomWebBinaryMode) ||
|
|
1908 sizeof(int32_t) != sizeof(OrthancPluginStorageCommitmentFailureReason) ||
|
|
1909 sizeof(int32_t) != sizeof(OrthancPluginReceivedInstanceAction))
|
|
1910 {
|
|
1911 /* Mismatch in the size of the enumerations */
|
|
1912 return 0;
|
|
1913 }
|
|
1914
|
|
1915 /* Assume compatibility with the mainline */
|
|
1916 if (!strcmp(context->orthancVersion, "mainline"))
|
|
1917 {
|
|
1918 return 1;
|
|
1919 }
|
|
1920
|
|
1921 /* Parse the version of the Orthanc core */
|
|
1922 if (
|
|
1923 #ifdef _MSC_VER
|
|
1924 sscanf_s
|
|
1925 #else
|
|
1926 sscanf
|
|
1927 #endif
|
|
1928 (context->orthancVersion, "%4d.%4d.%4d", &major, &minor, &revision) != 3)
|
|
1929 {
|
|
1930 return 0;
|
|
1931 }
|
|
1932
|
|
1933 /* Check the major number of the version */
|
|
1934
|
|
1935 if (major > expectedMajor)
|
|
1936 {
|
|
1937 return 1;
|
|
1938 }
|
|
1939
|
|
1940 if (major < expectedMajor)
|
|
1941 {
|
|
1942 return 0;
|
|
1943 }
|
|
1944
|
|
1945 /* Check the minor number of the version */
|
|
1946
|
|
1947 if (minor > expectedMinor)
|
|
1948 {
|
|
1949 return 1;
|
|
1950 }
|
|
1951
|
|
1952 if (minor < expectedMinor)
|
|
1953 {
|
|
1954 return 0;
|
|
1955 }
|
|
1956
|
|
1957 /* Check the revision number of the version */
|
|
1958
|
|
1959 if (revision >= expectedRevision)
|
|
1960 {
|
|
1961 return 1;
|
|
1962 }
|
|
1963 else
|
|
1964 {
|
|
1965 return 0;
|
|
1966 }
|
|
1967 }
|
|
1968
|
|
1969
|
|
1970 /**
|
|
1971 * @brief Check the compatibility of the plugin wrt. the version of its hosting Orthanc.
|
|
1972 *
|
|
1973 * This function checks whether the version of the Orthanc server
|
|
1974 * running this plugin, is above the version of the current Orthanc
|
|
1975 * SDK header. This guarantees that the plugin is compatible with
|
|
1976 * the hosting Orthanc (i.e. it will not call unavailable services).
|
|
1977 * The result of this function should always be checked in the
|
|
1978 * OrthancPluginInitialize() entry point of the plugin.
|
|
1979 *
|
|
1980 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1981 * @return 1 if and only if the versions are compatible. If the
|
|
1982 * result is 0, the initialization of the plugin should fail.
|
|
1983 * @see OrthancPluginCheckVersionAdvanced
|
|
1984 * @ingroup Callbacks
|
|
1985 **/
|
|
1986 ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersion(
|
|
1987 OrthancPluginContext* context)
|
|
1988 {
|
|
1989 return OrthancPluginCheckVersionAdvanced(
|
|
1990 context,
|
|
1991 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
|
|
1992 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
|
|
1993 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
|
|
1994 }
|
|
1995
|
|
1996
|
|
1997 /**
|
|
1998 * @brief Free a memory buffer.
|
|
1999 *
|
|
2000 * Free a memory buffer that was allocated by the core system of Orthanc.
|
|
2001 *
|
|
2002 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2003 * @param buffer The memory buffer to release.
|
|
2004 **/
|
|
2005 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeMemoryBuffer(
|
|
2006 OrthancPluginContext* context,
|
|
2007 OrthancPluginMemoryBuffer* buffer)
|
|
2008 {
|
|
2009 context->Free(buffer->data);
|
|
2010 }
|
|
2011
|
|
2012
|
|
2013 /**
|
|
2014 * @brief Free a memory buffer.
|
|
2015 *
|
|
2016 * Free a memory buffer that was allocated by the core system of Orthanc.
|
|
2017 *
|
|
2018 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2019 * @param buffer The memory buffer to release.
|
|
2020 **/
|
|
2021 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeMemoryBuffer64(
|
|
2022 OrthancPluginContext* context,
|
|
2023 OrthancPluginMemoryBuffer64* buffer)
|
|
2024 {
|
|
2025 context->Free(buffer->data);
|
|
2026 }
|
|
2027
|
|
2028
|
|
2029 /**
|
|
2030 * @brief Log an error.
|
|
2031 *
|
|
2032 * Log an error message using the Orthanc logging system.
|
|
2033 *
|
|
2034 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2035 * @param message The message to be logged.
|
|
2036 **/
|
|
2037 ORTHANC_PLUGIN_INLINE void OrthancPluginLogError(
|
|
2038 OrthancPluginContext* context,
|
|
2039 const char* message)
|
|
2040 {
|
|
2041 context->InvokeService(context, _OrthancPluginService_LogError, message);
|
|
2042 }
|
|
2043
|
|
2044
|
|
2045 /**
|
|
2046 * @brief Log a warning.
|
|
2047 *
|
|
2048 * Log a warning message using the Orthanc logging system.
|
|
2049 *
|
|
2050 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2051 * @param message The message to be logged.
|
|
2052 **/
|
|
2053 ORTHANC_PLUGIN_INLINE void OrthancPluginLogWarning(
|
|
2054 OrthancPluginContext* context,
|
|
2055 const char* message)
|
|
2056 {
|
|
2057 context->InvokeService(context, _OrthancPluginService_LogWarning, message);
|
|
2058 }
|
|
2059
|
|
2060
|
|
2061 /**
|
|
2062 * @brief Log an information.
|
|
2063 *
|
|
2064 * Log an information message using the Orthanc logging system.
|
|
2065 *
|
|
2066 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2067 * @param message The message to be logged.
|
|
2068 **/
|
|
2069 ORTHANC_PLUGIN_INLINE void OrthancPluginLogInfo(
|
|
2070 OrthancPluginContext* context,
|
|
2071 const char* message)
|
|
2072 {
|
|
2073 context->InvokeService(context, _OrthancPluginService_LogInfo, message);
|
|
2074 }
|
|
2075
|
|
2076
|
|
2077
|
|
2078 typedef struct
|
|
2079 {
|
|
2080 const char* pathRegularExpression;
|
|
2081 OrthancPluginRestCallback callback;
|
|
2082 } _OrthancPluginRestCallback;
|
|
2083
|
|
2084 /**
|
|
2085 * @brief Register a REST callback.
|
|
2086 *
|
|
2087 * This function registers a REST callback against a regular
|
|
2088 * expression for a URI. This function must be called during the
|
|
2089 * initialization of the plugin, i.e. inside the
|
|
2090 * OrthancPluginInitialize() public function.
|
|
2091 *
|
|
2092 * Each REST callback is guaranteed to run in mutual exclusion.
|
|
2093 *
|
|
2094 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2095 * @param pathRegularExpression Regular expression for the URI. May contain groups.
|
|
2096 * @param callback The callback function to handle the REST call.
|
|
2097 * @see OrthancPluginRegisterRestCallbackNoLock()
|
|
2098 *
|
|
2099 * @note
|
|
2100 * The regular expression is case sensitive and must follow the
|
|
2101 * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html).
|
|
2102 *
|
|
2103 * @ingroup Callbacks
|
|
2104 **/
|
|
2105 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback(
|
|
2106 OrthancPluginContext* context,
|
|
2107 const char* pathRegularExpression,
|
|
2108 OrthancPluginRestCallback callback)
|
|
2109 {
|
|
2110 _OrthancPluginRestCallback params;
|
|
2111 params.pathRegularExpression = pathRegularExpression;
|
|
2112 params.callback = callback;
|
|
2113 context->InvokeService(context, _OrthancPluginService_RegisterRestCallback, ¶ms);
|
|
2114 }
|
|
2115
|
|
2116
|
|
2117
|
|
2118 /**
|
|
2119 * @brief Register a REST callback, without locking.
|
|
2120 *
|
|
2121 * This function registers a REST callback against a regular
|
|
2122 * expression for a URI. This function must be called during the
|
|
2123 * initialization of the plugin, i.e. inside the
|
|
2124 * OrthancPluginInitialize() public function.
|
|
2125 *
|
|
2126 * Contrarily to OrthancPluginRegisterRestCallback(), the callback
|
|
2127 * will NOT be invoked in mutual exclusion. This can be useful for
|
|
2128 * high-performance plugins that must handle concurrent requests
|
|
2129 * (Orthanc uses a pool of threads, one thread being assigned to
|
|
2130 * each incoming HTTP request). Of course, if using this function,
|
|
2131 * it is up to the plugin to implement the required locking
|
|
2132 * mechanisms.
|
|
2133 *
|
|
2134 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2135 * @param pathRegularExpression Regular expression for the URI. May contain groups.
|
|
2136 * @param callback The callback function to handle the REST call.
|
|
2137 * @see OrthancPluginRegisterRestCallback()
|
|
2138 *
|
|
2139 * @note
|
|
2140 * The regular expression is case sensitive and must follow the
|
|
2141 * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html).
|
|
2142 *
|
|
2143 * @ingroup Callbacks
|
|
2144 **/
|
|
2145 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallbackNoLock(
|
|
2146 OrthancPluginContext* context,
|
|
2147 const char* pathRegularExpression,
|
|
2148 OrthancPluginRestCallback callback)
|
|
2149 {
|
|
2150 _OrthancPluginRestCallback params;
|
|
2151 params.pathRegularExpression = pathRegularExpression;
|
|
2152 params.callback = callback;
|
|
2153 context->InvokeService(context, _OrthancPluginService_RegisterRestCallbackNoLock, ¶ms);
|
|
2154 }
|
|
2155
|
|
2156
|
|
2157
|
|
2158 typedef struct
|
|
2159 {
|
|
2160 OrthancPluginOnStoredInstanceCallback callback;
|
|
2161 } _OrthancPluginOnStoredInstanceCallback;
|
|
2162
|
|
2163 /**
|
|
2164 * @brief Register a callback for received instances.
|
|
2165 *
|
|
2166 * This function registers a callback function that is called
|
|
2167 * whenever a new DICOM instance is stored into the Orthanc core.
|
|
2168 *
|
|
2169 * @warning Your callback function will be called synchronously with
|
|
2170 * the core of Orthanc. This implies that deadlocks might emerge if
|
|
2171 * you call other core primitives of Orthanc in your callback (such
|
|
2172 * deadlocks are particularly visible in the presence of other plugins
|
|
2173 * or Lua scripts). It is thus strongly advised to avoid any call to
|
|
2174 * the REST API of Orthanc in the callback. If you have to call
|
|
2175 * other primitives of Orthanc, you should make these calls in a
|
|
2176 * separate thread, passing the pending events to be processed
|
|
2177 * through a message queue.
|
|
2178 *
|
|
2179 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2180 * @param callback The callback function.
|
|
2181 * @ingroup Callbacks
|
|
2182 **/
|
|
2183 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnStoredInstanceCallback(
|
|
2184 OrthancPluginContext* context,
|
|
2185 OrthancPluginOnStoredInstanceCallback callback)
|
|
2186 {
|
|
2187 _OrthancPluginOnStoredInstanceCallback params;
|
|
2188 params.callback = callback;
|
|
2189
|
|
2190 context->InvokeService(context, _OrthancPluginService_RegisterOnStoredInstanceCallback, ¶ms);
|
|
2191 }
|
|
2192
|
|
2193
|
|
2194
|
|
2195 typedef struct
|
|
2196 {
|
|
2197 OrthancPluginRestOutput* output;
|
|
2198 const void* answer;
|
|
2199 uint32_t answerSize;
|
|
2200 const char* mimeType;
|
|
2201 } _OrthancPluginAnswerBuffer;
|
|
2202
|
|
2203 /**
|
|
2204 * @brief Answer to a REST request.
|
|
2205 *
|
|
2206 * This function answers to a REST request with the content of a memory buffer.
|
|
2207 *
|
|
2208 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2209 * @param output The HTTP connection to the client application.
|
|
2210 * @param answer Pointer to the memory buffer containing the answer.
|
|
2211 * @param answerSize Number of bytes of the answer.
|
|
2212 * @param mimeType The MIME type of the answer.
|
|
2213 * @ingroup REST
|
|
2214 **/
|
|
2215 ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer(
|
|
2216 OrthancPluginContext* context,
|
|
2217 OrthancPluginRestOutput* output,
|
|
2218 const void* answer,
|
|
2219 uint32_t answerSize,
|
|
2220 const char* mimeType)
|
|
2221 {
|
|
2222 _OrthancPluginAnswerBuffer params;
|
|
2223 params.output = output;
|
|
2224 params.answer = answer;
|
|
2225 params.answerSize = answerSize;
|
|
2226 params.mimeType = mimeType;
|
|
2227 context->InvokeService(context, _OrthancPluginService_AnswerBuffer, ¶ms);
|
|
2228 }
|
|
2229
|
|
2230
|
|
2231 typedef struct
|
|
2232 {
|
|
2233 OrthancPluginRestOutput* output;
|
|
2234 OrthancPluginPixelFormat format;
|
|
2235 uint32_t width;
|
|
2236 uint32_t height;
|
|
2237 uint32_t pitch;
|
|
2238 const void* buffer;
|
|
2239 } _OrthancPluginCompressAndAnswerPngImage;
|
|
2240
|
|
2241 typedef struct
|
|
2242 {
|
|
2243 OrthancPluginRestOutput* output;
|
|
2244 OrthancPluginImageFormat imageFormat;
|
|
2245 OrthancPluginPixelFormat pixelFormat;
|
|
2246 uint32_t width;
|
|
2247 uint32_t height;
|
|
2248 uint32_t pitch;
|
|
2249 const void* buffer;
|
|
2250 uint8_t quality;
|
|
2251 } _OrthancPluginCompressAndAnswerImage;
|
|
2252
|
|
2253
|
|
2254 /**
|
|
2255 * @brief Answer to a REST request with a PNG image.
|
|
2256 *
|
|
2257 * This function answers to a REST request with a PNG image. The
|
|
2258 * parameters of this function describe a memory buffer that
|
|
2259 * contains an uncompressed image. The image will be automatically compressed
|
|
2260 * as a PNG image by the core system of Orthanc.
|
|
2261 *
|
|
2262 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2263 * @param output The HTTP connection to the client application.
|
|
2264 * @param format The memory layout of the uncompressed image.
|
|
2265 * @param width The width of the image.
|
|
2266 * @param height The height of the image.
|
|
2267 * @param pitch The pitch of the image (i.e. the number of bytes
|
|
2268 * between 2 successive lines of the image in the memory buffer).
|
|
2269 * @param buffer The memory buffer containing the uncompressed image.
|
|
2270 * @ingroup REST
|
|
2271 **/
|
|
2272 ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerPngImage(
|
|
2273 OrthancPluginContext* context,
|
|
2274 OrthancPluginRestOutput* output,
|
|
2275 OrthancPluginPixelFormat format,
|
|
2276 uint32_t width,
|
|
2277 uint32_t height,
|
|
2278 uint32_t pitch,
|
|
2279 const void* buffer)
|
|
2280 {
|
|
2281 _OrthancPluginCompressAndAnswerImage params;
|
|
2282 params.output = output;
|
|
2283 params.imageFormat = OrthancPluginImageFormat_Png;
|
|
2284 params.pixelFormat = format;
|
|
2285 params.width = width;
|
|
2286 params.height = height;
|
|
2287 params.pitch = pitch;
|
|
2288 params.buffer = buffer;
|
|
2289 params.quality = 0; /* No quality for PNG */
|
|
2290 context->InvokeService(context, _OrthancPluginService_CompressAndAnswerImage, ¶ms);
|
|
2291 }
|
|
2292
|
|
2293
|
|
2294
|
|
2295 typedef struct
|
|
2296 {
|
|
2297 OrthancPluginMemoryBuffer* target;
|
|
2298 const char* instanceId;
|
|
2299 } _OrthancPluginGetDicomForInstance;
|
|
2300
|
|
2301 /**
|
|
2302 * @brief Retrieve a DICOM instance using its Orthanc identifier.
|
|
2303 *
|
|
2304 * Retrieve a DICOM instance using its Orthanc identifier. The DICOM
|
|
2305 * file is stored into a newly allocated memory buffer.
|
|
2306 *
|
|
2307 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2308 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
2309 * @param instanceId The Orthanc identifier of the DICOM instance of interest.
|
|
2310 * @return 0 if success, or the error code if failure.
|
|
2311 * @ingroup Orthanc
|
|
2312 **/
|
|
2313 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetDicomForInstance(
|
|
2314 OrthancPluginContext* context,
|
|
2315 OrthancPluginMemoryBuffer* target,
|
|
2316 const char* instanceId)
|
|
2317 {
|
|
2318 _OrthancPluginGetDicomForInstance params;
|
|
2319 params.target = target;
|
|
2320 params.instanceId = instanceId;
|
|
2321 return context->InvokeService(context, _OrthancPluginService_GetDicomForInstance, ¶ms);
|
|
2322 }
|
|
2323
|
|
2324
|
|
2325
|
|
2326 typedef struct
|
|
2327 {
|
|
2328 OrthancPluginMemoryBuffer* target;
|
|
2329 const char* uri;
|
|
2330 } _OrthancPluginRestApiGet;
|
|
2331
|
|
2332 /**
|
|
2333 * @brief Make a GET call to the built-in Orthanc REST API.
|
|
2334 *
|
|
2335 * Make a GET call to the built-in Orthanc REST API. The result to
|
|
2336 * the query is stored into a newly allocated memory buffer.
|
|
2337 *
|
|
2338 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2339 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
2340 * @param uri The URI in the built-in Orthanc API.
|
|
2341 * @return 0 if success, or the error code if failure.
|
|
2342 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
|
|
2343 * @see OrthancPluginRestApiGetAfterPlugins
|
|
2344 * @ingroup Orthanc
|
|
2345 **/
|
|
2346 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet(
|
|
2347 OrthancPluginContext* context,
|
|
2348 OrthancPluginMemoryBuffer* target,
|
|
2349 const char* uri)
|
|
2350 {
|
|
2351 _OrthancPluginRestApiGet params;
|
|
2352 params.target = target;
|
|
2353 params.uri = uri;
|
|
2354 return context->InvokeService(context, _OrthancPluginService_RestApiGet, ¶ms);
|
|
2355 }
|
|
2356
|
|
2357
|
|
2358
|
|
2359 /**
|
|
2360 * @brief Make a GET call to the REST API, as tainted by the plugins.
|
|
2361 *
|
|
2362 * Make a GET call to the Orthanc REST API, after all the plugins
|
|
2363 * are applied. In other words, if some plugin overrides or adds the
|
|
2364 * called URI to the built-in Orthanc REST API, this call will
|
|
2365 * return the result provided by this plugin. The result to the
|
|
2366 * query is stored into a newly allocated memory buffer.
|
|
2367 *
|
|
2368 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2369 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
2370 * @param uri The URI in the built-in Orthanc API.
|
|
2371 * @return 0 if success, or the error code if failure.
|
|
2372 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
|
|
2373 * @see OrthancPluginRestApiGet
|
|
2374 * @ingroup Orthanc
|
|
2375 **/
|
|
2376 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGetAfterPlugins(
|
|
2377 OrthancPluginContext* context,
|
|
2378 OrthancPluginMemoryBuffer* target,
|
|
2379 const char* uri)
|
|
2380 {
|
|
2381 _OrthancPluginRestApiGet params;
|
|
2382 params.target = target;
|
|
2383 params.uri = uri;
|
|
2384 return context->InvokeService(context, _OrthancPluginService_RestApiGetAfterPlugins, ¶ms);
|
|
2385 }
|
|
2386
|
|
2387
|
|
2388
|
|
2389 typedef struct
|
|
2390 {
|
|
2391 OrthancPluginMemoryBuffer* target;
|
|
2392 const char* uri;
|
|
2393 const void* body;
|
|
2394 uint32_t bodySize;
|
|
2395 } _OrthancPluginRestApiPostPut;
|
|
2396
|
|
2397 /**
|
|
2398 * @brief Make a POST call to the built-in Orthanc REST API.
|
|
2399 *
|
|
2400 * Make a POST call to the built-in Orthanc REST API. The result to
|
|
2401 * the query is stored into a newly allocated memory buffer.
|
|
2402 *
|
|
2403 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2404 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
2405 * @param uri The URI in the built-in Orthanc API.
|
|
2406 * @param body The body of the POST request.
|
|
2407 * @param bodySize The size of the body.
|
|
2408 * @return 0 if success, or the error code if failure.
|
|
2409 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
|
|
2410 * @see OrthancPluginRestApiPostAfterPlugins
|
|
2411 * @ingroup Orthanc
|
|
2412 **/
|
|
2413 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPost(
|
|
2414 OrthancPluginContext* context,
|
|
2415 OrthancPluginMemoryBuffer* target,
|
|
2416 const char* uri,
|
|
2417 const void* body,
|
|
2418 uint32_t bodySize)
|
|
2419 {
|
|
2420 _OrthancPluginRestApiPostPut params;
|
|
2421 params.target = target;
|
|
2422 params.uri = uri;
|
|
2423 params.body = body;
|
|
2424 params.bodySize = bodySize;
|
|
2425 return context->InvokeService(context, _OrthancPluginService_RestApiPost, ¶ms);
|
|
2426 }
|
|
2427
|
|
2428
|
|
2429 /**
|
|
2430 * @brief Make a POST call to the REST API, as tainted by the plugins.
|
|
2431 *
|
|
2432 * Make a POST call to the Orthanc REST API, after all the plugins
|
|
2433 * are applied. In other words, if some plugin overrides or adds the
|
|
2434 * called URI to the built-in Orthanc REST API, this call will
|
|
2435 * return the result provided by this plugin. The result to the
|
|
2436 * query is stored into a newly allocated memory buffer.
|
|
2437 *
|
|
2438 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2439 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
2440 * @param uri The URI in the built-in Orthanc API.
|
|
2441 * @param body The body of the POST request.
|
|
2442 * @param bodySize The size of the body.
|
|
2443 * @return 0 if success, or the error code if failure.
|
|
2444 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
|
|
2445 * @see OrthancPluginRestApiPost
|
|
2446 * @ingroup Orthanc
|
|
2447 **/
|
|
2448 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPostAfterPlugins(
|
|
2449 OrthancPluginContext* context,
|
|
2450 OrthancPluginMemoryBuffer* target,
|
|
2451 const char* uri,
|
|
2452 const void* body,
|
|
2453 uint32_t bodySize)
|
|
2454 {
|
|
2455 _OrthancPluginRestApiPostPut params;
|
|
2456 params.target = target;
|
|
2457 params.uri = uri;
|
|
2458 params.body = body;
|
|
2459 params.bodySize = bodySize;
|
|
2460 return context->InvokeService(context, _OrthancPluginService_RestApiPostAfterPlugins, ¶ms);
|
|
2461 }
|
|
2462
|
|
2463
|
|
2464
|
|
2465 /**
|
|
2466 * @brief Make a DELETE call to the built-in Orthanc REST API.
|
|
2467 *
|
|
2468 * Make a DELETE call to the built-in Orthanc REST API.
|
|
2469 *
|
|
2470 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2471 * @param uri The URI to delete in the built-in Orthanc API.
|
|
2472 * @return 0 if success, or the error code if failure.
|
|
2473 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
|
|
2474 * @see OrthancPluginRestApiDeleteAfterPlugins
|
|
2475 * @ingroup Orthanc
|
|
2476 **/
|
|
2477 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiDelete(
|
|
2478 OrthancPluginContext* context,
|
|
2479 const char* uri)
|
|
2480 {
|
|
2481 return context->InvokeService(context, _OrthancPluginService_RestApiDelete, uri);
|
|
2482 }
|
|
2483
|
|
2484
|
|
2485 /**
|
|
2486 * @brief Make a DELETE call to the REST API, as tainted by the plugins.
|
|
2487 *
|
|
2488 * Make a DELETE call to the Orthanc REST API, after all the plugins
|
|
2489 * are applied. In other words, if some plugin overrides or adds the
|
|
2490 * called URI to the built-in Orthanc REST API, this call will
|
|
2491 * return the result provided by this plugin.
|
|
2492 *
|
|
2493 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2494 * @param uri The URI to delete in the built-in Orthanc API.
|
|
2495 * @return 0 if success, or the error code if failure.
|
|
2496 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
|
|
2497 * @see OrthancPluginRestApiDelete
|
|
2498 * @ingroup Orthanc
|
|
2499 **/
|
|
2500 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiDeleteAfterPlugins(
|
|
2501 OrthancPluginContext* context,
|
|
2502 const char* uri)
|
|
2503 {
|
|
2504 return context->InvokeService(context, _OrthancPluginService_RestApiDeleteAfterPlugins, uri);
|
|
2505 }
|
|
2506
|
|
2507
|
|
2508
|
|
2509 /**
|
|
2510 * @brief Make a PUT call to the built-in Orthanc REST API.
|
|
2511 *
|
|
2512 * Make a PUT call to the built-in Orthanc REST API. The result to
|
|
2513 * the query is stored into a newly allocated memory buffer.
|
|
2514 *
|
|
2515 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2516 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
2517 * @param uri The URI in the built-in Orthanc API.
|
|
2518 * @param body The body of the PUT request.
|
|
2519 * @param bodySize The size of the body.
|
|
2520 * @return 0 if success, or the error code if failure.
|
|
2521 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
|
|
2522 * @see OrthancPluginRestApiPutAfterPlugins
|
|
2523 * @ingroup Orthanc
|
|
2524 **/
|
|
2525 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPut(
|
|
2526 OrthancPluginContext* context,
|
|
2527 OrthancPluginMemoryBuffer* target,
|
|
2528 const char* uri,
|
|
2529 const void* body,
|
|
2530 uint32_t bodySize)
|
|
2531 {
|
|
2532 _OrthancPluginRestApiPostPut params;
|
|
2533 params.target = target;
|
|
2534 params.uri = uri;
|
|
2535 params.body = body;
|
|
2536 params.bodySize = bodySize;
|
|
2537 return context->InvokeService(context, _OrthancPluginService_RestApiPut, ¶ms);
|
|
2538 }
|
|
2539
|
|
2540
|
|
2541
|
|
2542 /**
|
|
2543 * @brief Make a PUT call to the REST API, as tainted by the plugins.
|
|
2544 *
|
|
2545 * Make a PUT call to the Orthanc REST API, after all the plugins
|
|
2546 * are applied. In other words, if some plugin overrides or adds the
|
|
2547 * called URI to the built-in Orthanc REST API, this call will
|
|
2548 * return the result provided by this plugin. The result to the
|
|
2549 * query is stored into a newly allocated memory buffer.
|
|
2550 *
|
|
2551 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2552 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
2553 * @param uri The URI in the built-in Orthanc API.
|
|
2554 * @param body The body of the PUT request.
|
|
2555 * @param bodySize The size of the body.
|
|
2556 * @return 0 if success, or the error code if failure.
|
|
2557 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
|
|
2558 * @see OrthancPluginRestApiPut
|
|
2559 * @ingroup Orthanc
|
|
2560 **/
|
|
2561 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPutAfterPlugins(
|
|
2562 OrthancPluginContext* context,
|
|
2563 OrthancPluginMemoryBuffer* target,
|
|
2564 const char* uri,
|
|
2565 const void* body,
|
|
2566 uint32_t bodySize)
|
|
2567 {
|
|
2568 _OrthancPluginRestApiPostPut params;
|
|
2569 params.target = target;
|
|
2570 params.uri = uri;
|
|
2571 params.body = body;
|
|
2572 params.bodySize = bodySize;
|
|
2573 return context->InvokeService(context, _OrthancPluginService_RestApiPutAfterPlugins, ¶ms);
|
|
2574 }
|
|
2575
|
|
2576
|
|
2577
|
|
2578 typedef struct
|
|
2579 {
|
|
2580 OrthancPluginRestOutput* output;
|
|
2581 const char* argument;
|
|
2582 } _OrthancPluginOutputPlusArgument;
|
|
2583
|
|
2584 /**
|
|
2585 * @brief Redirect a REST request.
|
|
2586 *
|
|
2587 * This function answers to a REST request by redirecting the user
|
|
2588 * to another URI using HTTP status 301.
|
|
2589 *
|
|
2590 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2591 * @param output The HTTP connection to the client application.
|
|
2592 * @param redirection Where to redirect.
|
|
2593 * @ingroup REST
|
|
2594 **/
|
|
2595 ORTHANC_PLUGIN_INLINE void OrthancPluginRedirect(
|
|
2596 OrthancPluginContext* context,
|
|
2597 OrthancPluginRestOutput* output,
|
|
2598 const char* redirection)
|
|
2599 {
|
|
2600 _OrthancPluginOutputPlusArgument params;
|
|
2601 params.output = output;
|
|
2602 params.argument = redirection;
|
|
2603 context->InvokeService(context, _OrthancPluginService_Redirect, ¶ms);
|
|
2604 }
|
|
2605
|
|
2606
|
|
2607
|
|
2608 typedef struct
|
|
2609 {
|
|
2610 char** result;
|
|
2611 const char* argument;
|
|
2612 } _OrthancPluginRetrieveDynamicString;
|
|
2613
|
|
2614 /**
|
|
2615 * @brief Look for a patient.
|
|
2616 *
|
|
2617 * Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020).
|
|
2618 * This function uses the database index to run as fast as possible (it does not loop
|
|
2619 * over all the stored patients).
|
|
2620 *
|
|
2621 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2622 * @param patientID The Patient ID of interest.
|
|
2623 * @return The NULL value if the patient is non-existent, or a string containing the
|
|
2624 * Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString().
|
|
2625 * @ingroup Orthanc
|
|
2626 **/
|
|
2627 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupPatient(
|
|
2628 OrthancPluginContext* context,
|
|
2629 const char* patientID)
|
|
2630 {
|
|
2631 char* result;
|
|
2632
|
|
2633 _OrthancPluginRetrieveDynamicString params;
|
|
2634 params.result = &result;
|
|
2635 params.argument = patientID;
|
|
2636
|
|
2637 if (context->InvokeService(context, _OrthancPluginService_LookupPatient, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2638 {
|
|
2639 /* Error */
|
|
2640 return NULL;
|
|
2641 }
|
|
2642 else
|
|
2643 {
|
|
2644 return result;
|
|
2645 }
|
|
2646 }
|
|
2647
|
|
2648
|
|
2649 /**
|
|
2650 * @brief Look for a study.
|
|
2651 *
|
|
2652 * Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d).
|
|
2653 * This function uses the database index to run as fast as possible (it does not loop
|
|
2654 * over all the stored studies).
|
|
2655 *
|
|
2656 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2657 * @param studyUID The Study Instance UID of interest.
|
|
2658 * @return The NULL value if the study is non-existent, or a string containing the
|
|
2659 * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString().
|
|
2660 * @ingroup Orthanc
|
|
2661 **/
|
|
2662 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudy(
|
|
2663 OrthancPluginContext* context,
|
|
2664 const char* studyUID)
|
|
2665 {
|
|
2666 char* result;
|
|
2667
|
|
2668 _OrthancPluginRetrieveDynamicString params;
|
|
2669 params.result = &result;
|
|
2670 params.argument = studyUID;
|
|
2671
|
|
2672 if (context->InvokeService(context, _OrthancPluginService_LookupStudy, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2673 {
|
|
2674 /* Error */
|
|
2675 return NULL;
|
|
2676 }
|
|
2677 else
|
|
2678 {
|
|
2679 return result;
|
|
2680 }
|
|
2681 }
|
|
2682
|
|
2683
|
|
2684 /**
|
|
2685 * @brief Look for a study, using the accession number.
|
|
2686 *
|
|
2687 * Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050).
|
|
2688 * This function uses the database index to run as fast as possible (it does not loop
|
|
2689 * over all the stored studies).
|
|
2690 *
|
|
2691 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2692 * @param accessionNumber The Accession Number of interest.
|
|
2693 * @return The NULL value if the study is non-existent, or a string containing the
|
|
2694 * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString().
|
|
2695 * @ingroup Orthanc
|
|
2696 **/
|
|
2697 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudyWithAccessionNumber(
|
|
2698 OrthancPluginContext* context,
|
|
2699 const char* accessionNumber)
|
|
2700 {
|
|
2701 char* result;
|
|
2702
|
|
2703 _OrthancPluginRetrieveDynamicString params;
|
|
2704 params.result = &result;
|
|
2705 params.argument = accessionNumber;
|
|
2706
|
|
2707 if (context->InvokeService(context, _OrthancPluginService_LookupStudyWithAccessionNumber, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2708 {
|
|
2709 /* Error */
|
|
2710 return NULL;
|
|
2711 }
|
|
2712 else
|
|
2713 {
|
|
2714 return result;
|
|
2715 }
|
|
2716 }
|
|
2717
|
|
2718
|
|
2719 /**
|
|
2720 * @brief Look for a series.
|
|
2721 *
|
|
2722 * Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e).
|
|
2723 * This function uses the database index to run as fast as possible (it does not loop
|
|
2724 * over all the stored series).
|
|
2725 *
|
|
2726 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2727 * @param seriesUID The Series Instance UID of interest.
|
|
2728 * @return The NULL value if the series is non-existent, or a string containing the
|
|
2729 * Orthanc ID of the series. This string must be freed by OrthancPluginFreeString().
|
|
2730 * @ingroup Orthanc
|
|
2731 **/
|
|
2732 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupSeries(
|
|
2733 OrthancPluginContext* context,
|
|
2734 const char* seriesUID)
|
|
2735 {
|
|
2736 char* result;
|
|
2737
|
|
2738 _OrthancPluginRetrieveDynamicString params;
|
|
2739 params.result = &result;
|
|
2740 params.argument = seriesUID;
|
|
2741
|
|
2742 if (context->InvokeService(context, _OrthancPluginService_LookupSeries, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2743 {
|
|
2744 /* Error */
|
|
2745 return NULL;
|
|
2746 }
|
|
2747 else
|
|
2748 {
|
|
2749 return result;
|
|
2750 }
|
|
2751 }
|
|
2752
|
|
2753
|
|
2754 /**
|
|
2755 * @brief Look for an instance.
|
|
2756 *
|
|
2757 * Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018).
|
|
2758 * This function uses the database index to run as fast as possible (it does not loop
|
|
2759 * over all the stored instances).
|
|
2760 *
|
|
2761 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2762 * @param sopInstanceUID The SOP Instance UID of interest.
|
|
2763 * @return The NULL value if the instance is non-existent, or a string containing the
|
|
2764 * Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString().
|
|
2765 * @ingroup Orthanc
|
|
2766 **/
|
|
2767 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupInstance(
|
|
2768 OrthancPluginContext* context,
|
|
2769 const char* sopInstanceUID)
|
|
2770 {
|
|
2771 char* result;
|
|
2772
|
|
2773 _OrthancPluginRetrieveDynamicString params;
|
|
2774 params.result = &result;
|
|
2775 params.argument = sopInstanceUID;
|
|
2776
|
|
2777 if (context->InvokeService(context, _OrthancPluginService_LookupInstance, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2778 {
|
|
2779 /* Error */
|
|
2780 return NULL;
|
|
2781 }
|
|
2782 else
|
|
2783 {
|
|
2784 return result;
|
|
2785 }
|
|
2786 }
|
|
2787
|
|
2788
|
|
2789
|
|
2790 typedef struct
|
|
2791 {
|
|
2792 OrthancPluginRestOutput* output;
|
|
2793 uint16_t status;
|
|
2794 } _OrthancPluginSendHttpStatusCode;
|
|
2795
|
|
2796 /**
|
|
2797 * @brief Send a HTTP status code.
|
|
2798 *
|
|
2799 * This function answers to a REST request by sending a HTTP status
|
|
2800 * code (such as "400 - Bad Request"). Note that:
|
|
2801 * - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer().
|
|
2802 * - Redirections (status 301) must use ::OrthancPluginRedirect().
|
|
2803 * - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized().
|
|
2804 * - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed().
|
|
2805 *
|
|
2806 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2807 * @param output The HTTP connection to the client application.
|
|
2808 * @param status The HTTP status code to be sent.
|
|
2809 * @ingroup REST
|
|
2810 * @see OrthancPluginSendHttpStatus()
|
|
2811 **/
|
|
2812 ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatusCode(
|
|
2813 OrthancPluginContext* context,
|
|
2814 OrthancPluginRestOutput* output,
|
|
2815 uint16_t status)
|
|
2816 {
|
|
2817 _OrthancPluginSendHttpStatusCode params;
|
|
2818 params.output = output;
|
|
2819 params.status = status;
|
|
2820 context->InvokeService(context, _OrthancPluginService_SendHttpStatusCode, ¶ms);
|
|
2821 }
|
|
2822
|
|
2823
|
|
2824 /**
|
|
2825 * @brief Signal that a REST request is not authorized.
|
|
2826 *
|
|
2827 * This function answers to a REST request by signaling that it is
|
|
2828 * not authorized.
|
|
2829 *
|
|
2830 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2831 * @param output The HTTP connection to the client application.
|
|
2832 * @param realm The realm for the authorization process.
|
|
2833 * @ingroup REST
|
|
2834 **/
|
|
2835 ORTHANC_PLUGIN_INLINE void OrthancPluginSendUnauthorized(
|
|
2836 OrthancPluginContext* context,
|
|
2837 OrthancPluginRestOutput* output,
|
|
2838 const char* realm)
|
|
2839 {
|
|
2840 _OrthancPluginOutputPlusArgument params;
|
|
2841 params.output = output;
|
|
2842 params.argument = realm;
|
|
2843 context->InvokeService(context, _OrthancPluginService_SendUnauthorized, ¶ms);
|
|
2844 }
|
|
2845
|
|
2846
|
|
2847 /**
|
|
2848 * @brief Signal that this URI does not support this HTTP method.
|
|
2849 *
|
|
2850 * This function answers to a REST request by signaling that the
|
|
2851 * queried URI does not support this method.
|
|
2852 *
|
|
2853 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2854 * @param output The HTTP connection to the client application.
|
|
2855 * @param allowedMethods The allowed methods for this URI (e.g. "GET,POST" after a PUT or a POST request).
|
|
2856 * @ingroup REST
|
|
2857 **/
|
|
2858 ORTHANC_PLUGIN_INLINE void OrthancPluginSendMethodNotAllowed(
|
|
2859 OrthancPluginContext* context,
|
|
2860 OrthancPluginRestOutput* output,
|
|
2861 const char* allowedMethods)
|
|
2862 {
|
|
2863 _OrthancPluginOutputPlusArgument params;
|
|
2864 params.output = output;
|
|
2865 params.argument = allowedMethods;
|
|
2866 context->InvokeService(context, _OrthancPluginService_SendMethodNotAllowed, ¶ms);
|
|
2867 }
|
|
2868
|
|
2869
|
|
2870 typedef struct
|
|
2871 {
|
|
2872 OrthancPluginRestOutput* output;
|
|
2873 const char* key;
|
|
2874 const char* value;
|
|
2875 } _OrthancPluginSetHttpHeader;
|
|
2876
|
|
2877 /**
|
|
2878 * @brief Set a cookie.
|
|
2879 *
|
|
2880 * This function sets a cookie in the HTTP client.
|
|
2881 *
|
|
2882 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2883 * @param output The HTTP connection to the client application.
|
|
2884 * @param cookie The cookie to be set.
|
|
2885 * @param value The value of the cookie.
|
|
2886 * @ingroup REST
|
|
2887 **/
|
|
2888 ORTHANC_PLUGIN_INLINE void OrthancPluginSetCookie(
|
|
2889 OrthancPluginContext* context,
|
|
2890 OrthancPluginRestOutput* output,
|
|
2891 const char* cookie,
|
|
2892 const char* value)
|
|
2893 {
|
|
2894 _OrthancPluginSetHttpHeader params;
|
|
2895 params.output = output;
|
|
2896 params.key = cookie;
|
|
2897 params.value = value;
|
|
2898 context->InvokeService(context, _OrthancPluginService_SetCookie, ¶ms);
|
|
2899 }
|
|
2900
|
|
2901
|
|
2902 /**
|
|
2903 * @brief Set some HTTP header.
|
|
2904 *
|
|
2905 * This function sets a HTTP header in the HTTP answer.
|
|
2906 *
|
|
2907 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2908 * @param output The HTTP connection to the client application.
|
|
2909 * @param key The HTTP header to be set.
|
|
2910 * @param value The value of the HTTP header.
|
|
2911 * @ingroup REST
|
|
2912 **/
|
|
2913 ORTHANC_PLUGIN_INLINE void OrthancPluginSetHttpHeader(
|
|
2914 OrthancPluginContext* context,
|
|
2915 OrthancPluginRestOutput* output,
|
|
2916 const char* key,
|
|
2917 const char* value)
|
|
2918 {
|
|
2919 _OrthancPluginSetHttpHeader params;
|
|
2920 params.output = output;
|
|
2921 params.key = key;
|
|
2922 params.value = value;
|
|
2923 context->InvokeService(context, _OrthancPluginService_SetHttpHeader, ¶ms);
|
|
2924 }
|
|
2925
|
|
2926
|
|
2927 typedef struct
|
|
2928 {
|
|
2929 char** resultStringToFree;
|
|
2930 const char** resultString;
|
|
2931 int64_t* resultInt64;
|
|
2932 const char* key;
|
|
2933 const OrthancPluginDicomInstance* instance;
|
|
2934 OrthancPluginInstanceOrigin* resultOrigin; /* New in Orthanc 0.9.5 SDK */
|
|
2935 } _OrthancPluginAccessDicomInstance;
|
|
2936
|
|
2937
|
|
2938 /**
|
|
2939 * @brief Get the AET of a DICOM instance.
|
|
2940 *
|
|
2941 * This function returns the Application Entity Title (AET) of the
|
|
2942 * DICOM modality from which a DICOM instance originates.
|
|
2943 *
|
|
2944 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2945 * @param instance The instance of interest.
|
|
2946 * @return The AET if success, NULL if error.
|
|
2947 * @ingroup DicomInstance
|
|
2948 **/
|
|
2949 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceRemoteAet(
|
|
2950 OrthancPluginContext* context,
|
|
2951 const OrthancPluginDicomInstance* instance)
|
|
2952 {
|
|
2953 const char* result;
|
|
2954
|
|
2955 _OrthancPluginAccessDicomInstance params;
|
|
2956 memset(¶ms, 0, sizeof(params));
|
|
2957 params.resultString = &result;
|
|
2958 params.instance = instance;
|
|
2959
|
|
2960 if (context->InvokeService(context, _OrthancPluginService_GetInstanceRemoteAet, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2961 {
|
|
2962 /* Error */
|
|
2963 return NULL;
|
|
2964 }
|
|
2965 else
|
|
2966 {
|
|
2967 return result;
|
|
2968 }
|
|
2969 }
|
|
2970
|
|
2971
|
|
2972 /**
|
|
2973 * @brief Get the size of a DICOM file.
|
|
2974 *
|
|
2975 * This function returns the number of bytes of the given DICOM instance.
|
|
2976 *
|
|
2977 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2978 * @param instance The instance of interest.
|
|
2979 * @return The size of the file, -1 in case of error.
|
|
2980 * @ingroup DicomInstance
|
|
2981 **/
|
|
2982 ORTHANC_PLUGIN_INLINE int64_t OrthancPluginGetInstanceSize(
|
|
2983 OrthancPluginContext* context,
|
|
2984 const OrthancPluginDicomInstance* instance)
|
|
2985 {
|
|
2986 int64_t size;
|
|
2987
|
|
2988 _OrthancPluginAccessDicomInstance params;
|
|
2989 memset(¶ms, 0, sizeof(params));
|
|
2990 params.resultInt64 = &size;
|
|
2991 params.instance = instance;
|
|
2992
|
|
2993 if (context->InvokeService(context, _OrthancPluginService_GetInstanceSize, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2994 {
|
|
2995 /* Error */
|
|
2996 return -1;
|
|
2997 }
|
|
2998 else
|
|
2999 {
|
|
3000 return size;
|
|
3001 }
|
|
3002 }
|
|
3003
|
|
3004
|
|
3005 /**
|
|
3006 * @brief Get the data of a DICOM file.
|
|
3007 *
|
|
3008 * This function returns a pointer to the content of the given DICOM instance.
|
|
3009 *
|
|
3010 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3011 * @param instance The instance of interest.
|
|
3012 * @return The pointer to the DICOM data, NULL in case of error.
|
|
3013 * @ingroup DicomInstance
|
|
3014 **/
|
|
3015 ORTHANC_PLUGIN_INLINE const void* OrthancPluginGetInstanceData(
|
|
3016 OrthancPluginContext* context,
|
|
3017 const OrthancPluginDicomInstance* instance)
|
|
3018 {
|
|
3019 const char* result;
|
|
3020
|
|
3021 _OrthancPluginAccessDicomInstance params;
|
|
3022 memset(¶ms, 0, sizeof(params));
|
|
3023 params.resultString = &result;
|
|
3024 params.instance = instance;
|
|
3025
|
|
3026 if (context->InvokeService(context, _OrthancPluginService_GetInstanceData, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3027 {
|
|
3028 /* Error */
|
|
3029 return NULL;
|
|
3030 }
|
|
3031 else
|
|
3032 {
|
|
3033 return result;
|
|
3034 }
|
|
3035 }
|
|
3036
|
|
3037
|
|
3038 /**
|
|
3039 * @brief Get the DICOM tag hierarchy as a JSON file.
|
|
3040 *
|
|
3041 * This function returns a pointer to a newly created string
|
|
3042 * containing a JSON file. This JSON file encodes the tag hierarchy
|
|
3043 * of the given DICOM instance.
|
|
3044 *
|
|
3045 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3046 * @param instance The instance of interest.
|
|
3047 * @return The NULL value in case of error, or a string containing the JSON file.
|
|
3048 * This string must be freed by OrthancPluginFreeString().
|
|
3049 * @ingroup DicomInstance
|
|
3050 **/
|
|
3051 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceJson(
|
|
3052 OrthancPluginContext* context,
|
|
3053 const OrthancPluginDicomInstance* instance)
|
|
3054 {
|
|
3055 char* result;
|
|
3056
|
|
3057 _OrthancPluginAccessDicomInstance params;
|
|
3058 memset(¶ms, 0, sizeof(params));
|
|
3059 params.resultStringToFree = &result;
|
|
3060 params.instance = instance;
|
|
3061
|
|
3062 if (context->InvokeService(context, _OrthancPluginService_GetInstanceJson, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3063 {
|
|
3064 /* Error */
|
|
3065 return NULL;
|
|
3066 }
|
|
3067 else
|
|
3068 {
|
|
3069 return result;
|
|
3070 }
|
|
3071 }
|
|
3072
|
|
3073
|
|
3074 /**
|
|
3075 * @brief Get the DICOM tag hierarchy as a JSON file (with simplification).
|
|
3076 *
|
|
3077 * This function returns a pointer to a newly created string
|
|
3078 * containing a JSON file. This JSON file encodes the tag hierarchy
|
|
3079 * of the given DICOM instance. In contrast with
|
|
3080 * ::OrthancPluginGetInstanceJson(), the returned JSON file is in
|
|
3081 * its simplified version.
|
|
3082 *
|
|
3083 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3084 * @param instance The instance of interest.
|
|
3085 * @return The NULL value in case of error, or a string containing the JSON file.
|
|
3086 * This string must be freed by OrthancPluginFreeString().
|
|
3087 * @ingroup DicomInstance
|
|
3088 **/
|
|
3089 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceSimplifiedJson(
|
|
3090 OrthancPluginContext* context,
|
|
3091 const OrthancPluginDicomInstance* instance)
|
|
3092 {
|
|
3093 char* result;
|
|
3094
|
|
3095 _OrthancPluginAccessDicomInstance params;
|
|
3096 memset(¶ms, 0, sizeof(params));
|
|
3097 params.resultStringToFree = &result;
|
|
3098 params.instance = instance;
|
|
3099
|
|
3100 if (context->InvokeService(context, _OrthancPluginService_GetInstanceSimplifiedJson, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3101 {
|
|
3102 /* Error */
|
|
3103 return NULL;
|
|
3104 }
|
|
3105 else
|
|
3106 {
|
|
3107 return result;
|
|
3108 }
|
|
3109 }
|
|
3110
|
|
3111
|
|
3112 /**
|
|
3113 * @brief Check whether a DICOM instance is associated with some metadata.
|
|
3114 *
|
|
3115 * This function checks whether the DICOM instance of interest is
|
|
3116 * associated with some metadata. As of Orthanc 0.8.1, in the
|
|
3117 * callbacks registered by
|
|
3118 * ::OrthancPluginRegisterOnStoredInstanceCallback(), the only
|
|
3119 * possibly available metadata are "ReceptionDate", "RemoteAET" and
|
|
3120 * "IndexInSeries".
|
|
3121 *
|
|
3122 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3123 * @param instance The instance of interest.
|
|
3124 * @param metadata The metadata of interest.
|
|
3125 * @return 1 if the metadata is present, 0 if it is absent, -1 in case of error.
|
|
3126 * @ingroup DicomInstance
|
|
3127 **/
|
|
3128 ORTHANC_PLUGIN_INLINE int OrthancPluginHasInstanceMetadata(
|
|
3129 OrthancPluginContext* context,
|
|
3130 const OrthancPluginDicomInstance* instance,
|
|
3131 const char* metadata)
|
|
3132 {
|
|
3133 int64_t result;
|
|
3134
|
|
3135 _OrthancPluginAccessDicomInstance params;
|
|
3136 memset(¶ms, 0, sizeof(params));
|
|
3137 params.resultInt64 = &result;
|
|
3138 params.instance = instance;
|
|
3139 params.key = metadata;
|
|
3140
|
|
3141 if (context->InvokeService(context, _OrthancPluginService_HasInstanceMetadata, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3142 {
|
|
3143 /* Error */
|
|
3144 return -1;
|
|
3145 }
|
|
3146 else
|
|
3147 {
|
|
3148 return (result != 0);
|
|
3149 }
|
|
3150 }
|
|
3151
|
|
3152
|
|
3153 /**
|
|
3154 * @brief Get the value of some metadata associated with a given DICOM instance.
|
|
3155 *
|
|
3156 * This functions returns the value of some metadata that is associated with the DICOM instance of interest.
|
|
3157 * Before calling this function, the existence of the metadata must have been checked with
|
|
3158 * ::OrthancPluginHasInstanceMetadata().
|
|
3159 *
|
|
3160 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3161 * @param instance The instance of interest.
|
|
3162 * @param metadata The metadata of interest.
|
|
3163 * @return The metadata value if success, NULL if error. Please note that the
|
|
3164 * returned string belongs to the instance object and must NOT be
|
|
3165 * deallocated. Please make a copy of the string if you wish to access
|
|
3166 * it later.
|
|
3167 * @ingroup DicomInstance
|
|
3168 **/
|
|
3169 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceMetadata(
|
|
3170 OrthancPluginContext* context,
|
|
3171 const OrthancPluginDicomInstance* instance,
|
|
3172 const char* metadata)
|
|
3173 {
|
|
3174 const char* result;
|
|
3175
|
|
3176 _OrthancPluginAccessDicomInstance params;
|
|
3177 memset(¶ms, 0, sizeof(params));
|
|
3178 params.resultString = &result;
|
|
3179 params.instance = instance;
|
|
3180 params.key = metadata;
|
|
3181
|
|
3182 if (context->InvokeService(context, _OrthancPluginService_GetInstanceMetadata, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3183 {
|
|
3184 /* Error */
|
|
3185 return NULL;
|
|
3186 }
|
|
3187 else
|
|
3188 {
|
|
3189 return result;
|
|
3190 }
|
|
3191 }
|
|
3192
|
|
3193
|
|
3194
|
|
3195 typedef struct
|
|
3196 {
|
|
3197 OrthancPluginStorageCreate create;
|
|
3198 OrthancPluginStorageRead read;
|
|
3199 OrthancPluginStorageRemove remove;
|
|
3200 OrthancPluginFree free;
|
|
3201 } _OrthancPluginRegisterStorageArea;
|
|
3202
|
|
3203 /**
|
|
3204 * @brief Register a custom storage area.
|
|
3205 *
|
|
3206 * This function registers a custom storage area, to replace the
|
|
3207 * built-in way Orthanc stores its files on the filesystem. This
|
|
3208 * function must be called during the initialization of the plugin,
|
|
3209 * i.e. inside the OrthancPluginInitialize() public function.
|
|
3210 *
|
|
3211 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3212 * @param create The callback function to store a file on the custom storage area.
|
|
3213 * @param read The callback function to read a file from the custom storage area.
|
|
3214 * @param remove The callback function to remove a file from the custom storage area.
|
|
3215 * @ingroup Callbacks
|
|
3216 * @deprecated Please use OrthancPluginRegisterStorageArea2()
|
|
3217 **/
|
|
3218 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea(
|
|
3219 OrthancPluginContext* context,
|
|
3220 OrthancPluginStorageCreate create,
|
|
3221 OrthancPluginStorageRead read,
|
|
3222 OrthancPluginStorageRemove remove)
|
|
3223 {
|
|
3224 _OrthancPluginRegisterStorageArea params;
|
|
3225 params.create = create;
|
|
3226 params.read = read;
|
|
3227 params.remove = remove;
|
|
3228
|
|
3229 #ifdef __cplusplus
|
|
3230 params.free = ::free;
|
|
3231 #else
|
|
3232 params.free = free;
|
|
3233 #endif
|
|
3234
|
|
3235 context->InvokeService(context, _OrthancPluginService_RegisterStorageArea, ¶ms);
|
|
3236 }
|
|
3237
|
|
3238
|
|
3239
|
|
3240 /**
|
|
3241 * @brief Return the path to the Orthanc executable.
|
|
3242 *
|
|
3243 * This function returns the path to the Orthanc executable.
|
|
3244 *
|
|
3245 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3246 * @return NULL in the case of an error, or a newly allocated string
|
|
3247 * containing the path. This string must be freed by
|
|
3248 * OrthancPluginFreeString().
|
|
3249 **/
|
|
3250 ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancPath(OrthancPluginContext* context)
|
|
3251 {
|
|
3252 char* result;
|
|
3253
|
|
3254 _OrthancPluginRetrieveDynamicString params;
|
|
3255 params.result = &result;
|
|
3256 params.argument = NULL;
|
|
3257
|
|
3258 if (context->InvokeService(context, _OrthancPluginService_GetOrthancPath, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3259 {
|
|
3260 /* Error */
|
|
3261 return NULL;
|
|
3262 }
|
|
3263 else
|
|
3264 {
|
|
3265 return result;
|
|
3266 }
|
|
3267 }
|
|
3268
|
|
3269
|
|
3270 /**
|
|
3271 * @brief Return the directory containing the Orthanc.
|
|
3272 *
|
|
3273 * This function returns the path to the directory containing the Orthanc executable.
|
|
3274 *
|
|
3275 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3276 * @return NULL in the case of an error, or a newly allocated string
|
|
3277 * containing the path. This string must be freed by
|
|
3278 * OrthancPluginFreeString().
|
|
3279 **/
|
|
3280 ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancDirectory(OrthancPluginContext* context)
|
|
3281 {
|
|
3282 char* result;
|
|
3283
|
|
3284 _OrthancPluginRetrieveDynamicString params;
|
|
3285 params.result = &result;
|
|
3286 params.argument = NULL;
|
|
3287
|
|
3288 if (context->InvokeService(context, _OrthancPluginService_GetOrthancDirectory, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3289 {
|
|
3290 /* Error */
|
|
3291 return NULL;
|
|
3292 }
|
|
3293 else
|
|
3294 {
|
|
3295 return result;
|
|
3296 }
|
|
3297 }
|
|
3298
|
|
3299
|
|
3300 /**
|
|
3301 * @brief Return the path to the configuration file(s).
|
|
3302 *
|
|
3303 * This function returns the path to the configuration file(s) that
|
|
3304 * was specified when starting Orthanc. Since version 0.9.1, this
|
|
3305 * path can refer to a folder that stores a set of configuration
|
|
3306 * files. This function is deprecated in favor of
|
|
3307 * OrthancPluginGetConfiguration().
|
|
3308 *
|
|
3309 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3310 * @return NULL in the case of an error, or a newly allocated string
|
|
3311 * containing the path. This string must be freed by
|
|
3312 * OrthancPluginFreeString().
|
|
3313 * @see OrthancPluginGetConfiguration()
|
|
3314 **/
|
|
3315 ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfigurationPath(OrthancPluginContext* context)
|
|
3316 {
|
|
3317 char* result;
|
|
3318
|
|
3319 _OrthancPluginRetrieveDynamicString params;
|
|
3320 params.result = &result;
|
|
3321 params.argument = NULL;
|
|
3322
|
|
3323 if (context->InvokeService(context, _OrthancPluginService_GetConfigurationPath, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3324 {
|
|
3325 /* Error */
|
|
3326 return NULL;
|
|
3327 }
|
|
3328 else
|
|
3329 {
|
|
3330 return result;
|
|
3331 }
|
|
3332 }
|
|
3333
|
|
3334
|
|
3335
|
|
3336 typedef struct
|
|
3337 {
|
|
3338 OrthancPluginOnChangeCallback callback;
|
|
3339 } _OrthancPluginOnChangeCallback;
|
|
3340
|
|
3341 /**
|
|
3342 * @brief Register a callback to monitor changes.
|
|
3343 *
|
|
3344 * This function registers a callback function that is called
|
|
3345 * whenever a change happens to some DICOM resource.
|
|
3346 *
|
|
3347 * @warning Your callback function will be called synchronously with
|
|
3348 * the core of Orthanc. This implies that deadlocks might emerge if
|
|
3349 * you call other core primitives of Orthanc in your callback (such
|
|
3350 * deadlocks are particularly visible in the presence of other plugins
|
|
3351 * or Lua scripts). It is thus strongly advised to avoid any call to
|
|
3352 * the REST API of Orthanc in the callback. If you have to call
|
|
3353 * other primitives of Orthanc, you should make these calls in a
|
|
3354 * separate thread, passing the pending events to be processed
|
|
3355 * through a message queue.
|
|
3356 *
|
|
3357 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3358 * @param callback The callback function.
|
|
3359 * @ingroup Callbacks
|
|
3360 **/
|
|
3361 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnChangeCallback(
|
|
3362 OrthancPluginContext* context,
|
|
3363 OrthancPluginOnChangeCallback callback)
|
|
3364 {
|
|
3365 _OrthancPluginOnChangeCallback params;
|
|
3366 params.callback = callback;
|
|
3367
|
|
3368 context->InvokeService(context, _OrthancPluginService_RegisterOnChangeCallback, ¶ms);
|
|
3369 }
|
|
3370
|
|
3371
|
|
3372
|
|
3373 typedef struct
|
|
3374 {
|
|
3375 const char* plugin;
|
|
3376 _OrthancPluginProperty property;
|
|
3377 const char* value;
|
|
3378 } _OrthancPluginSetPluginProperty;
|
|
3379
|
|
3380
|
|
3381 /**
|
|
3382 * @brief Set the URI where the plugin provides its Web interface.
|
|
3383 *
|
|
3384 * For plugins that come with a Web interface, this function
|
|
3385 * declares the entry path where to find this interface. This
|
|
3386 * information is notably used in the "Plugins" page of Orthanc
|
|
3387 * Explorer.
|
|
3388 *
|
|
3389 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3390 * @param uri The root URI for this plugin.
|
|
3391 **/
|
|
3392 ORTHANC_PLUGIN_INLINE void OrthancPluginSetRootUri(
|
|
3393 OrthancPluginContext* context,
|
|
3394 const char* uri)
|
|
3395 {
|
|
3396 _OrthancPluginSetPluginProperty params;
|
|
3397 params.plugin = OrthancPluginGetName();
|
|
3398 params.property = _OrthancPluginProperty_RootUri;
|
|
3399 params.value = uri;
|
|
3400
|
|
3401 context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms);
|
|
3402 }
|
|
3403
|
|
3404
|
|
3405 /**
|
|
3406 * @brief Set a description for this plugin.
|
|
3407 *
|
|
3408 * Set a description for this plugin. It is displayed in the
|
|
3409 * "Plugins" page of Orthanc Explorer.
|
|
3410 *
|
|
3411 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3412 * @param description The description.
|
|
3413 **/
|
|
3414 ORTHANC_PLUGIN_INLINE void OrthancPluginSetDescription(
|
|
3415 OrthancPluginContext* context,
|
|
3416 const char* description)
|
|
3417 {
|
|
3418 _OrthancPluginSetPluginProperty params;
|
|
3419 params.plugin = OrthancPluginGetName();
|
|
3420 params.property = _OrthancPluginProperty_Description;
|
|
3421 params.value = description;
|
|
3422
|
|
3423 context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms);
|
|
3424 }
|
|
3425
|
|
3426
|
|
3427 /**
|
|
3428 * @brief Extend the JavaScript code of Orthanc Explorer.
|
|
3429 *
|
|
3430 * Add JavaScript code to customize the default behavior of Orthanc
|
|
3431 * Explorer. This can for instance be used to add new buttons.
|
|
3432 *
|
|
3433 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3434 * @param javascript The custom JavaScript code.
|
|
3435 **/
|
|
3436 ORTHANC_PLUGIN_INLINE void OrthancPluginExtendOrthancExplorer(
|
|
3437 OrthancPluginContext* context,
|
|
3438 const char* javascript)
|
|
3439 {
|
|
3440 _OrthancPluginSetPluginProperty params;
|
|
3441 params.plugin = OrthancPluginGetName();
|
|
3442 params.property = _OrthancPluginProperty_OrthancExplorer;
|
|
3443 params.value = javascript;
|
|
3444
|
|
3445 context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms);
|
|
3446 }
|
|
3447
|
|
3448
|
|
3449 typedef struct
|
|
3450 {
|
|
3451 char** result;
|
|
3452 int32_t property;
|
|
3453 const char* value;
|
|
3454 } _OrthancPluginGlobalProperty;
|
|
3455
|
|
3456
|
|
3457 /**
|
|
3458 * @brief Get the value of a global property.
|
|
3459 *
|
|
3460 * Get the value of a global property that is stored in the Orthanc database. Global
|
|
3461 * properties whose index is below 1024 are reserved by Orthanc.
|
|
3462 *
|
|
3463 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3464 * @param property The global property of interest.
|
|
3465 * @param defaultValue The value to return, if the global property is unset.
|
|
3466 * @return The value of the global property, or NULL in the case of an error. This
|
|
3467 * string must be freed by OrthancPluginFreeString().
|
|
3468 * @ingroup Orthanc
|
|
3469 **/
|
|
3470 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetGlobalProperty(
|
|
3471 OrthancPluginContext* context,
|
|
3472 int32_t property,
|
|
3473 const char* defaultValue)
|
|
3474 {
|
|
3475 char* result;
|
|
3476
|
|
3477 _OrthancPluginGlobalProperty params;
|
|
3478 params.result = &result;
|
|
3479 params.property = property;
|
|
3480 params.value = defaultValue;
|
|
3481
|
|
3482 if (context->InvokeService(context, _OrthancPluginService_GetGlobalProperty, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3483 {
|
|
3484 /* Error */
|
|
3485 return NULL;
|
|
3486 }
|
|
3487 else
|
|
3488 {
|
|
3489 return result;
|
|
3490 }
|
|
3491 }
|
|
3492
|
|
3493
|
|
3494 /**
|
|
3495 * @brief Set the value of a global property.
|
|
3496 *
|
|
3497 * Set the value of a global property into the Orthanc
|
|
3498 * database. Setting a global property can be used by plugins to
|
|
3499 * save their internal parameters. Plugins are only allowed to set
|
|
3500 * properties whose index are above or equal to 1024 (properties
|
|
3501 * below 1024 are read-only and reserved by Orthanc).
|
|
3502 *
|
|
3503 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3504 * @param property The global property of interest.
|
|
3505 * @param value The value to be set in the global property.
|
|
3506 * @return 0 if success, or the error code if failure.
|
|
3507 * @ingroup Orthanc
|
|
3508 **/
|
|
3509 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSetGlobalProperty(
|
|
3510 OrthancPluginContext* context,
|
|
3511 int32_t property,
|
|
3512 const char* value)
|
|
3513 {
|
|
3514 _OrthancPluginGlobalProperty params;
|
|
3515 params.result = NULL;
|
|
3516 params.property = property;
|
|
3517 params.value = value;
|
|
3518
|
|
3519 return context->InvokeService(context, _OrthancPluginService_SetGlobalProperty, ¶ms);
|
|
3520 }
|
|
3521
|
|
3522
|
|
3523
|
|
3524 typedef struct
|
|
3525 {
|
|
3526 int32_t *resultInt32;
|
|
3527 uint32_t *resultUint32;
|
|
3528 int64_t *resultInt64;
|
|
3529 uint64_t *resultUint64;
|
|
3530 } _OrthancPluginReturnSingleValue;
|
|
3531
|
|
3532 /**
|
|
3533 * @brief Get the number of command-line arguments.
|
|
3534 *
|
|
3535 * Retrieve the number of command-line arguments that were used to launch Orthanc.
|
|
3536 *
|
|
3537 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3538 * @return The number of arguments.
|
|
3539 **/
|
|
3540 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetCommandLineArgumentsCount(
|
|
3541 OrthancPluginContext* context)
|
|
3542 {
|
|
3543 uint32_t count = 0;
|
|
3544
|
|
3545 _OrthancPluginReturnSingleValue params;
|
|
3546 memset(¶ms, 0, sizeof(params));
|
|
3547 params.resultUint32 = &count;
|
|
3548
|
|
3549 if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgumentsCount, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3550 {
|
|
3551 /* Error */
|
|
3552 return 0;
|
|
3553 }
|
|
3554 else
|
|
3555 {
|
|
3556 return count;
|
|
3557 }
|
|
3558 }
|
|
3559
|
|
3560
|
|
3561
|
|
3562 /**
|
|
3563 * @brief Get the value of a command-line argument.
|
|
3564 *
|
|
3565 * Get the value of one of the command-line arguments that were used
|
|
3566 * to launch Orthanc. The number of available arguments can be
|
|
3567 * retrieved by OrthancPluginGetCommandLineArgumentsCount().
|
|
3568 *
|
|
3569 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3570 * @param argument The index of the argument.
|
|
3571 * @return The value of the argument, or NULL in the case of an error. This
|
|
3572 * string must be freed by OrthancPluginFreeString().
|
|
3573 **/
|
|
3574 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetCommandLineArgument(
|
|
3575 OrthancPluginContext* context,
|
|
3576 uint32_t argument)
|
|
3577 {
|
|
3578 char* result;
|
|
3579
|
|
3580 _OrthancPluginGlobalProperty params;
|
|
3581 params.result = &result;
|
|
3582 params.property = (int32_t) argument;
|
|
3583 params.value = NULL;
|
|
3584
|
|
3585 if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgument, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3586 {
|
|
3587 /* Error */
|
|
3588 return NULL;
|
|
3589 }
|
|
3590 else
|
|
3591 {
|
|
3592 return result;
|
|
3593 }
|
|
3594 }
|
|
3595
|
|
3596
|
|
3597 /**
|
|
3598 * @brief Get the expected version of the database schema.
|
|
3599 *
|
|
3600 * Retrieve the expected version of the database schema.
|
|
3601 *
|
|
3602 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3603 * @return The version.
|
|
3604 * @ingroup Callbacks
|
|
3605 **/
|
|
3606 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetExpectedDatabaseVersion(
|
|
3607 OrthancPluginContext* context)
|
|
3608 {
|
|
3609 uint32_t count = 0;
|
|
3610
|
|
3611 _OrthancPluginReturnSingleValue params;
|
|
3612 memset(¶ms, 0, sizeof(params));
|
|
3613 params.resultUint32 = &count;
|
|
3614
|
|
3615 if (context->InvokeService(context, _OrthancPluginService_GetExpectedDatabaseVersion, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3616 {
|
|
3617 /* Error */
|
|
3618 return 0;
|
|
3619 }
|
|
3620 else
|
|
3621 {
|
|
3622 return count;
|
|
3623 }
|
|
3624 }
|
|
3625
|
|
3626
|
|
3627
|
|
3628 /**
|
|
3629 * @brief Return the content of the configuration file(s).
|
|
3630 *
|
|
3631 * This function returns the content of the configuration that is
|
|
3632 * used by Orthanc, formatted as a JSON string.
|
|
3633 *
|
|
3634 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3635 * @return NULL in the case of an error, or a newly allocated string
|
|
3636 * containing the configuration. This string must be freed by
|
|
3637 * OrthancPluginFreeString().
|
|
3638 **/
|
|
3639 ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfiguration(OrthancPluginContext* context)
|
|
3640 {
|
|
3641 char* result;
|
|
3642
|
|
3643 _OrthancPluginRetrieveDynamicString params;
|
|
3644 params.result = &result;
|
|
3645 params.argument = NULL;
|
|
3646
|
|
3647 if (context->InvokeService(context, _OrthancPluginService_GetConfiguration, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3648 {
|
|
3649 /* Error */
|
|
3650 return NULL;
|
|
3651 }
|
|
3652 else
|
|
3653 {
|
|
3654 return result;
|
|
3655 }
|
|
3656 }
|
|
3657
|
|
3658
|
|
3659
|
|
3660 typedef struct
|
|
3661 {
|
|
3662 OrthancPluginRestOutput* output;
|
|
3663 const char* subType;
|
|
3664 const char* contentType;
|
|
3665 } _OrthancPluginStartMultipartAnswer;
|
|
3666
|
|
3667 /**
|
|
3668 * @brief Start an HTTP multipart answer.
|
|
3669 *
|
|
3670 * Initiates a HTTP multipart answer, as the result of a REST request.
|
|
3671 *
|
|
3672 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3673 * @param output The HTTP connection to the client application.
|
|
3674 * @param subType The sub-type of the multipart answer ("mixed" or "related").
|
|
3675 * @param contentType The MIME type of the items in the multipart answer.
|
|
3676 * @return 0 if success, or the error code if failure.
|
|
3677 * @see OrthancPluginSendMultipartItem(), OrthancPluginSendMultipartItem2()
|
|
3678 * @ingroup REST
|
|
3679 **/
|
|
3680 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStartMultipartAnswer(
|
|
3681 OrthancPluginContext* context,
|
|
3682 OrthancPluginRestOutput* output,
|
|
3683 const char* subType,
|
|
3684 const char* contentType)
|
|
3685 {
|
|
3686 _OrthancPluginStartMultipartAnswer params;
|
|
3687 params.output = output;
|
|
3688 params.subType = subType;
|
|
3689 params.contentType = contentType;
|
|
3690 return context->InvokeService(context, _OrthancPluginService_StartMultipartAnswer, ¶ms);
|
|
3691 }
|
|
3692
|
|
3693
|
|
3694 /**
|
|
3695 * @brief Send an item as a part of some HTTP multipart answer.
|
|
3696 *
|
|
3697 * This function sends an item as a part of some HTTP multipart
|
|
3698 * answer that was initiated by OrthancPluginStartMultipartAnswer().
|
|
3699 *
|
|
3700 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3701 * @param output The HTTP connection to the client application.
|
|
3702 * @param answer Pointer to the memory buffer containing the item.
|
|
3703 * @param answerSize Number of bytes of the item.
|
|
3704 * @return 0 if success, or the error code if failure (this notably happens
|
|
3705 * if the connection is closed by the client).
|
|
3706 * @see OrthancPluginSendMultipartItem2()
|
|
3707 * @ingroup REST
|
|
3708 **/
|
|
3709 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendMultipartItem(
|
|
3710 OrthancPluginContext* context,
|
|
3711 OrthancPluginRestOutput* output,
|
|
3712 const void* answer,
|
|
3713 uint32_t answerSize)
|
|
3714 {
|
|
3715 _OrthancPluginAnswerBuffer params;
|
|
3716 params.output = output;
|
|
3717 params.answer = answer;
|
|
3718 params.answerSize = answerSize;
|
|
3719 params.mimeType = NULL;
|
|
3720 return context->InvokeService(context, _OrthancPluginService_SendMultipartItem, ¶ms);
|
|
3721 }
|
|
3722
|
|
3723
|
|
3724
|
|
3725 typedef struct
|
|
3726 {
|
|
3727 OrthancPluginMemoryBuffer* target;
|
|
3728 const void* source;
|
|
3729 uint32_t size;
|
|
3730 OrthancPluginCompressionType compression;
|
|
3731 uint8_t uncompress;
|
|
3732 } _OrthancPluginBufferCompression;
|
|
3733
|
|
3734
|
|
3735 /**
|
|
3736 * @brief Compress or decompress a buffer.
|
|
3737 *
|
|
3738 * This function compresses or decompresses a buffer, using the
|
|
3739 * version of the zlib library that is used by the Orthanc core.
|
|
3740 *
|
|
3741 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3742 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
3743 * @param source The source buffer.
|
|
3744 * @param size The size in bytes of the source buffer.
|
|
3745 * @param compression The compression algorithm.
|
|
3746 * @param uncompress If set to "0", the buffer must be compressed.
|
|
3747 * If set to "1", the buffer must be uncompressed.
|
|
3748 * @return 0 if success, or the error code if failure.
|
|
3749 * @ingroup Images
|
|
3750 **/
|
|
3751 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginBufferCompression(
|
|
3752 OrthancPluginContext* context,
|
|
3753 OrthancPluginMemoryBuffer* target,
|
|
3754 const void* source,
|
|
3755 uint32_t size,
|
|
3756 OrthancPluginCompressionType compression,
|
|
3757 uint8_t uncompress)
|
|
3758 {
|
|
3759 _OrthancPluginBufferCompression params;
|
|
3760 params.target = target;
|
|
3761 params.source = source;
|
|
3762 params.size = size;
|
|
3763 params.compression = compression;
|
|
3764 params.uncompress = uncompress;
|
|
3765
|
|
3766 return context->InvokeService(context, _OrthancPluginService_BufferCompression, ¶ms);
|
|
3767 }
|
|
3768
|
|
3769
|
|
3770
|
|
3771 typedef struct
|
|
3772 {
|
|
3773 OrthancPluginMemoryBuffer* target;
|
|
3774 const char* path;
|
|
3775 } _OrthancPluginReadFile;
|
|
3776
|
|
3777 /**
|
|
3778 * @brief Read a file.
|
|
3779 *
|
|
3780 * Read the content of a file on the filesystem, and returns it into
|
|
3781 * a newly allocated memory buffer.
|
|
3782 *
|
|
3783 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3784 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
3785 * @param path The path of the file to be read.
|
|
3786 * @return 0 if success, or the error code if failure.
|
|
3787 **/
|
|
3788 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReadFile(
|
|
3789 OrthancPluginContext* context,
|
|
3790 OrthancPluginMemoryBuffer* target,
|
|
3791 const char* path)
|
|
3792 {
|
|
3793 _OrthancPluginReadFile params;
|
|
3794 params.target = target;
|
|
3795 params.path = path;
|
|
3796 return context->InvokeService(context, _OrthancPluginService_ReadFile, ¶ms);
|
|
3797 }
|
|
3798
|
|
3799
|
|
3800
|
|
3801 typedef struct
|
|
3802 {
|
|
3803 const char* path;
|
|
3804 const void* data;
|
|
3805 uint32_t size;
|
|
3806 } _OrthancPluginWriteFile;
|
|
3807
|
|
3808 /**
|
|
3809 * @brief Write a file.
|
|
3810 *
|
|
3811 * Write the content of a memory buffer to the filesystem.
|
|
3812 *
|
|
3813 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3814 * @param path The path of the file to be written.
|
|
3815 * @param data The content of the memory buffer.
|
|
3816 * @param size The size of the memory buffer.
|
|
3817 * @return 0 if success, or the error code if failure.
|
|
3818 **/
|
|
3819 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWriteFile(
|
|
3820 OrthancPluginContext* context,
|
|
3821 const char* path,
|
|
3822 const void* data,
|
|
3823 uint32_t size)
|
|
3824 {
|
|
3825 _OrthancPluginWriteFile params;
|
|
3826 params.path = path;
|
|
3827 params.data = data;
|
|
3828 params.size = size;
|
|
3829 return context->InvokeService(context, _OrthancPluginService_WriteFile, ¶ms);
|
|
3830 }
|
|
3831
|
|
3832
|
|
3833
|
|
3834 typedef struct
|
|
3835 {
|
|
3836 const char** target;
|
|
3837 OrthancPluginErrorCode error;
|
|
3838 } _OrthancPluginGetErrorDescription;
|
|
3839
|
|
3840 /**
|
|
3841 * @brief Get the description of a given error code.
|
|
3842 *
|
|
3843 * This function returns the description of a given error code.
|
|
3844 *
|
|
3845 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3846 * @param error The error code of interest.
|
|
3847 * @return The error description. This is a statically-allocated
|
|
3848 * string, do not free it.
|
|
3849 **/
|
|
3850 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetErrorDescription(
|
|
3851 OrthancPluginContext* context,
|
|
3852 OrthancPluginErrorCode error)
|
|
3853 {
|
|
3854 const char* result = NULL;
|
|
3855
|
|
3856 _OrthancPluginGetErrorDescription params;
|
|
3857 params.target = &result;
|
|
3858 params.error = error;
|
|
3859
|
|
3860 if (context->InvokeService(context, _OrthancPluginService_GetErrorDescription, ¶ms) != OrthancPluginErrorCode_Success ||
|
|
3861 result == NULL)
|
|
3862 {
|
|
3863 return "Unknown error code";
|
|
3864 }
|
|
3865 else
|
|
3866 {
|
|
3867 return result;
|
|
3868 }
|
|
3869 }
|
|
3870
|
|
3871
|
|
3872
|
|
3873 typedef struct
|
|
3874 {
|
|
3875 OrthancPluginRestOutput* output;
|
|
3876 uint16_t status;
|
|
3877 const void* body;
|
|
3878 uint32_t bodySize;
|
|
3879 } _OrthancPluginSendHttpStatus;
|
|
3880
|
|
3881 /**
|
|
3882 * @brief Send a HTTP status, with a custom body.
|
|
3883 *
|
|
3884 * This function answers to a HTTP request by sending a HTTP status
|
|
3885 * code (such as "400 - Bad Request"), together with a body
|
|
3886 * describing the error. The body will only be returned if the
|
|
3887 * configuration option "HttpDescribeErrors" of Orthanc is set to "true".
|
|
3888 *
|
|
3889 * Note that:
|
|
3890 * - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer().
|
|
3891 * - Redirections (status 301) must use ::OrthancPluginRedirect().
|
|
3892 * - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized().
|
|
3893 * - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed().
|
|
3894 *
|
|
3895 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3896 * @param output The HTTP connection to the client application.
|
|
3897 * @param status The HTTP status code to be sent.
|
|
3898 * @param body The body of the answer.
|
|
3899 * @param bodySize The size of the body.
|
|
3900 * @see OrthancPluginSendHttpStatusCode()
|
|
3901 * @ingroup REST
|
|
3902 **/
|
|
3903 ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatus(
|
|
3904 OrthancPluginContext* context,
|
|
3905 OrthancPluginRestOutput* output,
|
|
3906 uint16_t status,
|
|
3907 const void* body,
|
|
3908 uint32_t bodySize)
|
|
3909 {
|
|
3910 _OrthancPluginSendHttpStatus params;
|
|
3911 params.output = output;
|
|
3912 params.status = status;
|
|
3913 params.body = body;
|
|
3914 params.bodySize = bodySize;
|
|
3915 context->InvokeService(context, _OrthancPluginService_SendHttpStatus, ¶ms);
|
|
3916 }
|
|
3917
|
|
3918
|
|
3919
|
|
3920 typedef struct
|
|
3921 {
|
|
3922 const OrthancPluginImage* image;
|
|
3923 uint32_t* resultUint32;
|
|
3924 OrthancPluginPixelFormat* resultPixelFormat;
|
|
3925 void** resultBuffer;
|
|
3926 } _OrthancPluginGetImageInfo;
|
|
3927
|
|
3928
|
|
3929 /**
|
|
3930 * @brief Return the pixel format of an image.
|
|
3931 *
|
|
3932 * This function returns the type of memory layout for the pixels of the given image.
|
|
3933 *
|
|
3934 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3935 * @param image The image of interest.
|
|
3936 * @return The pixel format.
|
|
3937 * @ingroup Images
|
|
3938 **/
|
|
3939 ORTHANC_PLUGIN_INLINE OrthancPluginPixelFormat OrthancPluginGetImagePixelFormat(
|
|
3940 OrthancPluginContext* context,
|
|
3941 const OrthancPluginImage* image)
|
|
3942 {
|
|
3943 OrthancPluginPixelFormat target;
|
|
3944
|
|
3945 _OrthancPluginGetImageInfo params;
|
|
3946 memset(¶ms, 0, sizeof(params));
|
|
3947 params.image = image;
|
|
3948 params.resultPixelFormat = ⌖
|
|
3949
|
|
3950 if (context->InvokeService(context, _OrthancPluginService_GetImagePixelFormat, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3951 {
|
|
3952 return OrthancPluginPixelFormat_Unknown;
|
|
3953 }
|
|
3954 else
|
|
3955 {
|
|
3956 return (OrthancPluginPixelFormat) target;
|
|
3957 }
|
|
3958 }
|
|
3959
|
|
3960
|
|
3961
|
|
3962 /**
|
|
3963 * @brief Return the width of an image.
|
|
3964 *
|
|
3965 * This function returns the width of the given image.
|
|
3966 *
|
|
3967 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3968 * @param image The image of interest.
|
|
3969 * @return The width.
|
|
3970 * @ingroup Images
|
|
3971 **/
|
|
3972 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImageWidth(
|
|
3973 OrthancPluginContext* context,
|
|
3974 const OrthancPluginImage* image)
|
|
3975 {
|
|
3976 uint32_t width;
|
|
3977
|
|
3978 _OrthancPluginGetImageInfo params;
|
|
3979 memset(¶ms, 0, sizeof(params));
|
|
3980 params.image = image;
|
|
3981 params.resultUint32 = &width;
|
|
3982
|
|
3983 if (context->InvokeService(context, _OrthancPluginService_GetImageWidth, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3984 {
|
|
3985 return 0;
|
|
3986 }
|
|
3987 else
|
|
3988 {
|
|
3989 return width;
|
|
3990 }
|
|
3991 }
|
|
3992
|
|
3993
|
|
3994
|
|
3995 /**
|
|
3996 * @brief Return the height of an image.
|
|
3997 *
|
|
3998 * This function returns the height of the given image.
|
|
3999 *
|
|
4000 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4001 * @param image The image of interest.
|
|
4002 * @return The height.
|
|
4003 * @ingroup Images
|
|
4004 **/
|
|
4005 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImageHeight(
|
|
4006 OrthancPluginContext* context,
|
|
4007 const OrthancPluginImage* image)
|
|
4008 {
|
|
4009 uint32_t height;
|
|
4010
|
|
4011 _OrthancPluginGetImageInfo params;
|
|
4012 memset(¶ms, 0, sizeof(params));
|
|
4013 params.image = image;
|
|
4014 params.resultUint32 = &height;
|
|
4015
|
|
4016 if (context->InvokeService(context, _OrthancPluginService_GetImageHeight, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4017 {
|
|
4018 return 0;
|
|
4019 }
|
|
4020 else
|
|
4021 {
|
|
4022 return height;
|
|
4023 }
|
|
4024 }
|
|
4025
|
|
4026
|
|
4027
|
|
4028 /**
|
|
4029 * @brief Return the pitch of an image.
|
|
4030 *
|
|
4031 * This function returns the pitch of the given image. The pitch is
|
|
4032 * defined as the number of bytes between 2 successive lines of the
|
|
4033 * image in the memory buffer.
|
|
4034 *
|
|
4035 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4036 * @param image The image of interest.
|
|
4037 * @return The pitch.
|
|
4038 * @ingroup Images
|
|
4039 **/
|
|
4040 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImagePitch(
|
|
4041 OrthancPluginContext* context,
|
|
4042 const OrthancPluginImage* image)
|
|
4043 {
|
|
4044 uint32_t pitch;
|
|
4045
|
|
4046 _OrthancPluginGetImageInfo params;
|
|
4047 memset(¶ms, 0, sizeof(params));
|
|
4048 params.image = image;
|
|
4049 params.resultUint32 = &pitch;
|
|
4050
|
|
4051 if (context->InvokeService(context, _OrthancPluginService_GetImagePitch, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4052 {
|
|
4053 return 0;
|
|
4054 }
|
|
4055 else
|
|
4056 {
|
|
4057 return pitch;
|
|
4058 }
|
|
4059 }
|
|
4060
|
|
4061
|
|
4062
|
|
4063 /**
|
|
4064 * @brief Return a pointer to the content of an image.
|
|
4065 *
|
|
4066 * This function returns a pointer to the memory buffer that
|
|
4067 * contains the pixels of the image.
|
|
4068 *
|
|
4069 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4070 * @param image The image of interest.
|
|
4071 * @return The pointer.
|
|
4072 * @ingroup Images
|
|
4073 **/
|
|
4074 ORTHANC_PLUGIN_INLINE void* OrthancPluginGetImageBuffer(
|
|
4075 OrthancPluginContext* context,
|
|
4076 const OrthancPluginImage* image)
|
|
4077 {
|
|
4078 void* target = NULL;
|
|
4079
|
|
4080 _OrthancPluginGetImageInfo params;
|
|
4081 memset(¶ms, 0, sizeof(params));
|
|
4082 params.resultBuffer = ⌖
|
|
4083 params.image = image;
|
|
4084
|
|
4085 if (context->InvokeService(context, _OrthancPluginService_GetImageBuffer, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4086 {
|
|
4087 return NULL;
|
|
4088 }
|
|
4089 else
|
|
4090 {
|
|
4091 return target;
|
|
4092 }
|
|
4093 }
|
|
4094
|
|
4095
|
|
4096 typedef struct
|
|
4097 {
|
|
4098 OrthancPluginImage** target;
|
|
4099 const void* data;
|
|
4100 uint32_t size;
|
|
4101 OrthancPluginImageFormat format;
|
|
4102 } _OrthancPluginUncompressImage;
|
|
4103
|
|
4104
|
|
4105 /**
|
|
4106 * @brief Decode a compressed image.
|
|
4107 *
|
|
4108 * This function decodes a compressed image from a memory buffer.
|
|
4109 *
|
|
4110 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4111 * @param data Pointer to a memory buffer containing the compressed image.
|
|
4112 * @param size Size of the memory buffer containing the compressed image.
|
|
4113 * @param format The file format of the compressed image.
|
|
4114 * @return The uncompressed image. It must be freed with OrthancPluginFreeImage().
|
|
4115 * @ingroup Images
|
|
4116 **/
|
|
4117 ORTHANC_PLUGIN_INLINE OrthancPluginImage *OrthancPluginUncompressImage(
|
|
4118 OrthancPluginContext* context,
|
|
4119 const void* data,
|
|
4120 uint32_t size,
|
|
4121 OrthancPluginImageFormat format)
|
|
4122 {
|
|
4123 OrthancPluginImage* target = NULL;
|
|
4124
|
|
4125 _OrthancPluginUncompressImage params;
|
|
4126 memset(¶ms, 0, sizeof(params));
|
|
4127 params.target = ⌖
|
|
4128 params.data = data;
|
|
4129 params.size = size;
|
|
4130 params.format = format;
|
|
4131
|
|
4132 if (context->InvokeService(context, _OrthancPluginService_UncompressImage, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4133 {
|
|
4134 return NULL;
|
|
4135 }
|
|
4136 else
|
|
4137 {
|
|
4138 return target;
|
|
4139 }
|
|
4140 }
|
|
4141
|
|
4142
|
|
4143
|
|
4144
|
|
4145 typedef struct
|
|
4146 {
|
|
4147 OrthancPluginImage* image;
|
|
4148 } _OrthancPluginFreeImage;
|
|
4149
|
|
4150 /**
|
|
4151 * @brief Free an image.
|
|
4152 *
|
|
4153 * This function frees an image that was decoded with OrthancPluginUncompressImage().
|
|
4154 *
|
|
4155 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4156 * @param image The image.
|
|
4157 * @ingroup Images
|
|
4158 **/
|
|
4159 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeImage(
|
|
4160 OrthancPluginContext* context,
|
|
4161 OrthancPluginImage* image)
|
|
4162 {
|
|
4163 _OrthancPluginFreeImage params;
|
|
4164 params.image = image;
|
|
4165
|
|
4166 context->InvokeService(context, _OrthancPluginService_FreeImage, ¶ms);
|
|
4167 }
|
|
4168
|
|
4169
|
|
4170
|
|
4171
|
|
4172 typedef struct
|
|
4173 {
|
|
4174 OrthancPluginMemoryBuffer* target;
|
|
4175 OrthancPluginImageFormat imageFormat;
|
|
4176 OrthancPluginPixelFormat pixelFormat;
|
|
4177 uint32_t width;
|
|
4178 uint32_t height;
|
|
4179 uint32_t pitch;
|
|
4180 const void* buffer;
|
|
4181 uint8_t quality;
|
|
4182 } _OrthancPluginCompressImage;
|
|
4183
|
|
4184
|
|
4185 /**
|
|
4186 * @brief Encode a PNG image.
|
|
4187 *
|
|
4188 * This function compresses the given memory buffer containing an
|
|
4189 * image using the PNG specification, and stores the result of the
|
|
4190 * compression into a newly allocated memory buffer.
|
|
4191 *
|
|
4192 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4193 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
4194 * @param format The memory layout of the uncompressed image.
|
|
4195 * @param width The width of the image.
|
|
4196 * @param height The height of the image.
|
|
4197 * @param pitch The pitch of the image (i.e. the number of bytes
|
|
4198 * between 2 successive lines of the image in the memory buffer).
|
|
4199 * @param buffer The memory buffer containing the uncompressed image.
|
|
4200 * @return 0 if success, or the error code if failure.
|
|
4201 * @see OrthancPluginCompressAndAnswerPngImage()
|
|
4202 * @ingroup Images
|
|
4203 **/
|
|
4204 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCompressPngImage(
|
|
4205 OrthancPluginContext* context,
|
|
4206 OrthancPluginMemoryBuffer* target,
|
|
4207 OrthancPluginPixelFormat format,
|
|
4208 uint32_t width,
|
|
4209 uint32_t height,
|
|
4210 uint32_t pitch,
|
|
4211 const void* buffer)
|
|
4212 {
|
|
4213 _OrthancPluginCompressImage params;
|
|
4214 memset(¶ms, 0, sizeof(params));
|
|
4215 params.target = target;
|
|
4216 params.imageFormat = OrthancPluginImageFormat_Png;
|
|
4217 params.pixelFormat = format;
|
|
4218 params.width = width;
|
|
4219 params.height = height;
|
|
4220 params.pitch = pitch;
|
|
4221 params.buffer = buffer;
|
|
4222 params.quality = 0; /* Unused for PNG */
|
|
4223
|
|
4224 return context->InvokeService(context, _OrthancPluginService_CompressImage, ¶ms);
|
|
4225 }
|
|
4226
|
|
4227
|
|
4228 /**
|
|
4229 * @brief Encode a JPEG image.
|
|
4230 *
|
|
4231 * This function compresses the given memory buffer containing an
|
|
4232 * image using the JPEG specification, and stores the result of the
|
|
4233 * compression into a newly allocated memory buffer.
|
|
4234 *
|
|
4235 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4236 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
4237 * @param format The memory layout of the uncompressed image.
|
|
4238 * @param width The width of the image.
|
|
4239 * @param height The height of the image.
|
|
4240 * @param pitch The pitch of the image (i.e. the number of bytes
|
|
4241 * between 2 successive lines of the image in the memory buffer).
|
|
4242 * @param buffer The memory buffer containing the uncompressed image.
|
|
4243 * @param quality The quality of the JPEG encoding, between 1 (worst
|
|
4244 * quality, best compression) and 100 (best quality, worst
|
|
4245 * compression).
|
|
4246 * @return 0 if success, or the error code if failure.
|
|
4247 * @ingroup Images
|
|
4248 **/
|
|
4249 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCompressJpegImage(
|
|
4250 OrthancPluginContext* context,
|
|
4251 OrthancPluginMemoryBuffer* target,
|
|
4252 OrthancPluginPixelFormat format,
|
|
4253 uint32_t width,
|
|
4254 uint32_t height,
|
|
4255 uint32_t pitch,
|
|
4256 const void* buffer,
|
|
4257 uint8_t quality)
|
|
4258 {
|
|
4259 _OrthancPluginCompressImage params;
|
|
4260 memset(¶ms, 0, sizeof(params));
|
|
4261 params.target = target;
|
|
4262 params.imageFormat = OrthancPluginImageFormat_Jpeg;
|
|
4263 params.pixelFormat = format;
|
|
4264 params.width = width;
|
|
4265 params.height = height;
|
|
4266 params.pitch = pitch;
|
|
4267 params.buffer = buffer;
|
|
4268 params.quality = quality;
|
|
4269
|
|
4270 return context->InvokeService(context, _OrthancPluginService_CompressImage, ¶ms);
|
|
4271 }
|
|
4272
|
|
4273
|
|
4274
|
|
4275 /**
|
|
4276 * @brief Answer to a REST request with a JPEG image.
|
|
4277 *
|
|
4278 * This function answers to a REST request with a JPEG image. The
|
|
4279 * parameters of this function describe a memory buffer that
|
|
4280 * contains an uncompressed image. The image will be automatically compressed
|
|
4281 * as a JPEG image by the core system of Orthanc.
|
|
4282 *
|
|
4283 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4284 * @param output The HTTP connection to the client application.
|
|
4285 * @param format The memory layout of the uncompressed image.
|
|
4286 * @param width The width of the image.
|
|
4287 * @param height The height of the image.
|
|
4288 * @param pitch The pitch of the image (i.e. the number of bytes
|
|
4289 * between 2 successive lines of the image in the memory buffer).
|
|
4290 * @param buffer The memory buffer containing the uncompressed image.
|
|
4291 * @param quality The quality of the JPEG encoding, between 1 (worst
|
|
4292 * quality, best compression) and 100 (best quality, worst
|
|
4293 * compression).
|
|
4294 * @ingroup REST
|
|
4295 **/
|
|
4296 ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerJpegImage(
|
|
4297 OrthancPluginContext* context,
|
|
4298 OrthancPluginRestOutput* output,
|
|
4299 OrthancPluginPixelFormat format,
|
|
4300 uint32_t width,
|
|
4301 uint32_t height,
|
|
4302 uint32_t pitch,
|
|
4303 const void* buffer,
|
|
4304 uint8_t quality)
|
|
4305 {
|
|
4306 _OrthancPluginCompressAndAnswerImage params;
|
|
4307 params.output = output;
|
|
4308 params.imageFormat = OrthancPluginImageFormat_Jpeg;
|
|
4309 params.pixelFormat = format;
|
|
4310 params.width = width;
|
|
4311 params.height = height;
|
|
4312 params.pitch = pitch;
|
|
4313 params.buffer = buffer;
|
|
4314 params.quality = quality;
|
|
4315 context->InvokeService(context, _OrthancPluginService_CompressAndAnswerImage, ¶ms);
|
|
4316 }
|
|
4317
|
|
4318
|
|
4319
|
|
4320
|
|
4321 typedef struct
|
|
4322 {
|
|
4323 OrthancPluginMemoryBuffer* target;
|
|
4324 OrthancPluginHttpMethod method;
|
|
4325 const char* url;
|
|
4326 const char* username;
|
|
4327 const char* password;
|
|
4328 const void* body;
|
|
4329 uint32_t bodySize;
|
|
4330 } _OrthancPluginCallHttpClient;
|
|
4331
|
|
4332
|
|
4333 /**
|
|
4334 * @brief Issue a HTTP GET call.
|
|
4335 *
|
|
4336 * Make a HTTP GET call to the given URL. The result to the query is
|
|
4337 * stored into a newly allocated memory buffer. Favor
|
|
4338 * OrthancPluginRestApiGet() if calling the built-in REST API of the
|
|
4339 * Orthanc instance that hosts this plugin.
|
|
4340 *
|
|
4341 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4342 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
4343 * @param url The URL of interest.
|
|
4344 * @param username The username (can be <tt>NULL</tt> if no password protection).
|
|
4345 * @param password The password (can be <tt>NULL</tt> if no password protection).
|
|
4346 * @return 0 if success, or the error code if failure.
|
|
4347 * @ingroup Toolbox
|
|
4348 **/
|
|
4349 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpGet(
|
|
4350 OrthancPluginContext* context,
|
|
4351 OrthancPluginMemoryBuffer* target,
|
|
4352 const char* url,
|
|
4353 const char* username,
|
|
4354 const char* password)
|
|
4355 {
|
|
4356 _OrthancPluginCallHttpClient params;
|
|
4357 memset(¶ms, 0, sizeof(params));
|
|
4358
|
|
4359 params.target = target;
|
|
4360 params.method = OrthancPluginHttpMethod_Get;
|
|
4361 params.url = url;
|
|
4362 params.username = username;
|
|
4363 params.password = password;
|
|
4364
|
|
4365 return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms);
|
|
4366 }
|
|
4367
|
|
4368
|
|
4369 /**
|
|
4370 * @brief Issue a HTTP POST call.
|
|
4371 *
|
|
4372 * Make a HTTP POST call to the given URL. The result to the query
|
|
4373 * is stored into a newly allocated memory buffer. Favor
|
|
4374 * OrthancPluginRestApiPost() if calling the built-in REST API of
|
|
4375 * the Orthanc instance that hosts this plugin.
|
|
4376 *
|
|
4377 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4378 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
4379 * @param url The URL of interest.
|
|
4380 * @param body The content of the body of the request.
|
|
4381 * @param bodySize The size of the body of the request.
|
|
4382 * @param username The username (can be <tt>NULL</tt> if no password protection).
|
|
4383 * @param password The password (can be <tt>NULL</tt> if no password protection).
|
|
4384 * @return 0 if success, or the error code if failure.
|
|
4385 * @ingroup Toolbox
|
|
4386 **/
|
|
4387 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpPost(
|
|
4388 OrthancPluginContext* context,
|
|
4389 OrthancPluginMemoryBuffer* target,
|
|
4390 const char* url,
|
|
4391 const void* body,
|
|
4392 uint32_t bodySize,
|
|
4393 const char* username,
|
|
4394 const char* password)
|
|
4395 {
|
|
4396 _OrthancPluginCallHttpClient params;
|
|
4397 memset(¶ms, 0, sizeof(params));
|
|
4398
|
|
4399 params.target = target;
|
|
4400 params.method = OrthancPluginHttpMethod_Post;
|
|
4401 params.url = url;
|
|
4402 params.body = body;
|
|
4403 params.bodySize = bodySize;
|
|
4404 params.username = username;
|
|
4405 params.password = password;
|
|
4406
|
|
4407 return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms);
|
|
4408 }
|
|
4409
|
|
4410
|
|
4411 /**
|
|
4412 * @brief Issue a HTTP PUT call.
|
|
4413 *
|
|
4414 * Make a HTTP PUT call to the given URL. The result to the query is
|
|
4415 * stored into a newly allocated memory buffer. Favor
|
|
4416 * OrthancPluginRestApiPut() if calling the built-in REST API of the
|
|
4417 * Orthanc instance that hosts this plugin.
|
|
4418 *
|
|
4419 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4420 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
4421 * @param url The URL of interest.
|
|
4422 * @param body The content of the body of the request.
|
|
4423 * @param bodySize The size of the body of the request.
|
|
4424 * @param username The username (can be <tt>NULL</tt> if no password protection).
|
|
4425 * @param password The password (can be <tt>NULL</tt> if no password protection).
|
|
4426 * @return 0 if success, or the error code if failure.
|
|
4427 * @ingroup Toolbox
|
|
4428 **/
|
|
4429 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpPut(
|
|
4430 OrthancPluginContext* context,
|
|
4431 OrthancPluginMemoryBuffer* target,
|
|
4432 const char* url,
|
|
4433 const void* body,
|
|
4434 uint32_t bodySize,
|
|
4435 const char* username,
|
|
4436 const char* password)
|
|
4437 {
|
|
4438 _OrthancPluginCallHttpClient params;
|
|
4439 memset(¶ms, 0, sizeof(params));
|
|
4440
|
|
4441 params.target = target;
|
|
4442 params.method = OrthancPluginHttpMethod_Put;
|
|
4443 params.url = url;
|
|
4444 params.body = body;
|
|
4445 params.bodySize = bodySize;
|
|
4446 params.username = username;
|
|
4447 params.password = password;
|
|
4448
|
|
4449 return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms);
|
|
4450 }
|
|
4451
|
|
4452
|
|
4453 /**
|
|
4454 * @brief Issue a HTTP DELETE call.
|
|
4455 *
|
|
4456 * Make a HTTP DELETE call to the given URL. Favor
|
|
4457 * OrthancPluginRestApiDelete() if calling the built-in REST API of
|
|
4458 * the Orthanc instance that hosts this plugin.
|
|
4459 *
|
|
4460 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4461 * @param url The URL of interest.
|
|
4462 * @param username The username (can be <tt>NULL</tt> if no password protection).
|
|
4463 * @param password The password (can be <tt>NULL</tt> if no password protection).
|
|
4464 * @return 0 if success, or the error code if failure.
|
|
4465 * @ingroup Toolbox
|
|
4466 **/
|
|
4467 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpDelete(
|
|
4468 OrthancPluginContext* context,
|
|
4469 const char* url,
|
|
4470 const char* username,
|
|
4471 const char* password)
|
|
4472 {
|
|
4473 _OrthancPluginCallHttpClient params;
|
|
4474 memset(¶ms, 0, sizeof(params));
|
|
4475
|
|
4476 params.method = OrthancPluginHttpMethod_Delete;
|
|
4477 params.url = url;
|
|
4478 params.username = username;
|
|
4479 params.password = password;
|
|
4480
|
|
4481 return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms);
|
|
4482 }
|
|
4483
|
|
4484
|
|
4485
|
|
4486 typedef struct
|
|
4487 {
|
|
4488 OrthancPluginImage** target;
|
|
4489 const OrthancPluginImage* source;
|
|
4490 OrthancPluginPixelFormat targetFormat;
|
|
4491 } _OrthancPluginConvertPixelFormat;
|
|
4492
|
|
4493
|
|
4494 /**
|
|
4495 * @brief Change the pixel format of an image.
|
|
4496 *
|
|
4497 * This function creates a new image, changing the memory layout of the pixels.
|
|
4498 *
|
|
4499 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4500 * @param source The source image.
|
|
4501 * @param targetFormat The target pixel format.
|
|
4502 * @return The resulting image. It must be freed with OrthancPluginFreeImage().
|
|
4503 * @ingroup Images
|
|
4504 **/
|
|
4505 ORTHANC_PLUGIN_INLINE OrthancPluginImage *OrthancPluginConvertPixelFormat(
|
|
4506 OrthancPluginContext* context,
|
|
4507 const OrthancPluginImage* source,
|
|
4508 OrthancPluginPixelFormat targetFormat)
|
|
4509 {
|
|
4510 OrthancPluginImage* target = NULL;
|
|
4511
|
|
4512 _OrthancPluginConvertPixelFormat params;
|
|
4513 params.target = ⌖
|
|
4514 params.source = source;
|
|
4515 params.targetFormat = targetFormat;
|
|
4516
|
|
4517 if (context->InvokeService(context, _OrthancPluginService_ConvertPixelFormat, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4518 {
|
|
4519 return NULL;
|
|
4520 }
|
|
4521 else
|
|
4522 {
|
|
4523 return target;
|
|
4524 }
|
|
4525 }
|
|
4526
|
|
4527
|
|
4528
|
|
4529 /**
|
|
4530 * @brief Return the number of available fonts.
|
|
4531 *
|
|
4532 * This function returns the number of fonts that are built in the
|
|
4533 * Orthanc core. These fonts can be used to draw texts on images
|
|
4534 * through OrthancPluginDrawText().
|
|
4535 *
|
|
4536 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4537 * @return The number of fonts.
|
|
4538 * @ingroup Images
|
|
4539 **/
|
|
4540 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFontsCount(
|
|
4541 OrthancPluginContext* context)
|
|
4542 {
|
|
4543 uint32_t count = 0;
|
|
4544
|
|
4545 _OrthancPluginReturnSingleValue params;
|
|
4546 memset(¶ms, 0, sizeof(params));
|
|
4547 params.resultUint32 = &count;
|
|
4548
|
|
4549 if (context->InvokeService(context, _OrthancPluginService_GetFontsCount, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4550 {
|
|
4551 /* Error */
|
|
4552 return 0;
|
|
4553 }
|
|
4554 else
|
|
4555 {
|
|
4556 return count;
|
|
4557 }
|
|
4558 }
|
|
4559
|
|
4560
|
|
4561
|
|
4562
|
|
4563 typedef struct
|
|
4564 {
|
|
4565 uint32_t fontIndex; /* in */
|
|
4566 const char** name; /* out */
|
|
4567 uint32_t* size; /* out */
|
|
4568 } _OrthancPluginGetFontInfo;
|
|
4569
|
|
4570 /**
|
|
4571 * @brief Return the name of a font.
|
|
4572 *
|
|
4573 * This function returns the name of a font that is built in the Orthanc core.
|
|
4574 *
|
|
4575 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4576 * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount().
|
|
4577 * @return The font name. This is a statically-allocated string, do not free it.
|
|
4578 * @ingroup Images
|
|
4579 **/
|
|
4580 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetFontName(
|
|
4581 OrthancPluginContext* context,
|
|
4582 uint32_t fontIndex)
|
|
4583 {
|
|
4584 const char* result = NULL;
|
|
4585
|
|
4586 _OrthancPluginGetFontInfo params;
|
|
4587 memset(¶ms, 0, sizeof(params));
|
|
4588 params.name = &result;
|
|
4589 params.fontIndex = fontIndex;
|
|
4590
|
|
4591 if (context->InvokeService(context, _OrthancPluginService_GetFontInfo, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4592 {
|
|
4593 return NULL;
|
|
4594 }
|
|
4595 else
|
|
4596 {
|
|
4597 return result;
|
|
4598 }
|
|
4599 }
|
|
4600
|
|
4601
|
|
4602 /**
|
|
4603 * @brief Return the size of a font.
|
|
4604 *
|
|
4605 * This function returns the size of a font that is built in the Orthanc core.
|
|
4606 *
|
|
4607 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4608 * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount().
|
|
4609 * @return The font size.
|
|
4610 * @ingroup Images
|
|
4611 **/
|
|
4612 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFontSize(
|
|
4613 OrthancPluginContext* context,
|
|
4614 uint32_t fontIndex)
|
|
4615 {
|
|
4616 uint32_t result;
|
|
4617
|
|
4618 _OrthancPluginGetFontInfo params;
|
|
4619 memset(¶ms, 0, sizeof(params));
|
|
4620 params.size = &result;
|
|
4621 params.fontIndex = fontIndex;
|
|
4622
|
|
4623 if (context->InvokeService(context, _OrthancPluginService_GetFontInfo, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4624 {
|
|
4625 return 0;
|
|
4626 }
|
|
4627 else
|
|
4628 {
|
|
4629 return result;
|
|
4630 }
|
|
4631 }
|
|
4632
|
|
4633
|
|
4634
|
|
4635 typedef struct
|
|
4636 {
|
|
4637 OrthancPluginImage* image;
|
|
4638 uint32_t fontIndex;
|
|
4639 const char* utf8Text;
|
|
4640 int32_t x;
|
|
4641 int32_t y;
|
|
4642 uint8_t r;
|
|
4643 uint8_t g;
|
|
4644 uint8_t b;
|
|
4645 } _OrthancPluginDrawText;
|
|
4646
|
|
4647
|
|
4648 /**
|
|
4649 * @brief Draw text on an image.
|
|
4650 *
|
|
4651 * This function draws some text on some image.
|
|
4652 *
|
|
4653 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4654 * @param image The image upon which to draw the text.
|
|
4655 * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount().
|
|
4656 * @param utf8Text The text to be drawn, encoded as an UTF-8 zero-terminated string.
|
|
4657 * @param x The X position of the text over the image.
|
|
4658 * @param y The Y position of the text over the image.
|
|
4659 * @param r The value of the red color channel of the text.
|
|
4660 * @param g The value of the green color channel of the text.
|
|
4661 * @param b The value of the blue color channel of the text.
|
|
4662 * @return 0 if success, other value if error.
|
|
4663 * @ingroup Images
|
|
4664 **/
|
|
4665 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginDrawText(
|
|
4666 OrthancPluginContext* context,
|
|
4667 OrthancPluginImage* image,
|
|
4668 uint32_t fontIndex,
|
|
4669 const char* utf8Text,
|
|
4670 int32_t x,
|
|
4671 int32_t y,
|
|
4672 uint8_t r,
|
|
4673 uint8_t g,
|
|
4674 uint8_t b)
|
|
4675 {
|
|
4676 _OrthancPluginDrawText params;
|
|
4677 memset(¶ms, 0, sizeof(params));
|
|
4678 params.image = image;
|
|
4679 params.fontIndex = fontIndex;
|
|
4680 params.utf8Text = utf8Text;
|
|
4681 params.x = x;
|
|
4682 params.y = y;
|
|
4683 params.r = r;
|
|
4684 params.g = g;
|
|
4685 params.b = b;
|
|
4686
|
|
4687 return context->InvokeService(context, _OrthancPluginService_DrawText, ¶ms);
|
|
4688 }
|
|
4689
|
|
4690
|
|
4691
|
|
4692 typedef struct
|
|
4693 {
|
|
4694 OrthancPluginStorageArea* storageArea;
|
|
4695 const char* uuid;
|
|
4696 const void* content;
|
|
4697 uint64_t size;
|
|
4698 OrthancPluginContentType type;
|
|
4699 } _OrthancPluginStorageAreaCreate;
|
|
4700
|
|
4701
|
|
4702 /**
|
|
4703 * @brief Create a file inside the storage area.
|
|
4704 *
|
|
4705 * This function creates a new file inside the storage area that is
|
|
4706 * currently used by Orthanc.
|
|
4707 *
|
|
4708 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4709 * @param storageArea The storage area.
|
|
4710 * @param uuid The identifier of the file to be created.
|
|
4711 * @param content The content to store in the newly created file.
|
|
4712 * @param size The size of the content.
|
|
4713 * @param type The type of the file content.
|
|
4714 * @return 0 if success, other value if error.
|
|
4715 * @ingroup Callbacks
|
|
4716 * @deprecated This function should not be used anymore. Use "OrthancPluginRestApiPut()" on
|
|
4717 * "/{patients|studies|series|instances}/{id}/attachments/{name}" instead.
|
|
4718 **/
|
|
4719 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaCreate(
|
|
4720 OrthancPluginContext* context,
|
|
4721 OrthancPluginStorageArea* storageArea,
|
|
4722 const char* uuid,
|
|
4723 const void* content,
|
|
4724 uint64_t size,
|
|
4725 OrthancPluginContentType type)
|
|
4726 {
|
|
4727 _OrthancPluginStorageAreaCreate params;
|
|
4728 params.storageArea = storageArea;
|
|
4729 params.uuid = uuid;
|
|
4730 params.content = content;
|
|
4731 params.size = size;
|
|
4732 params.type = type;
|
|
4733
|
|
4734 return context->InvokeService(context, _OrthancPluginService_StorageAreaCreate, ¶ms);
|
|
4735 }
|
|
4736
|
|
4737
|
|
4738 typedef struct
|
|
4739 {
|
|
4740 OrthancPluginMemoryBuffer* target;
|
|
4741 OrthancPluginStorageArea* storageArea;
|
|
4742 const char* uuid;
|
|
4743 OrthancPluginContentType type;
|
|
4744 } _OrthancPluginStorageAreaRead;
|
|
4745
|
|
4746
|
|
4747 /**
|
|
4748 * @brief Read a file from the storage area.
|
|
4749 *
|
|
4750 * This function reads the content of a given file from the storage
|
|
4751 * area that is currently used by Orthanc.
|
|
4752 *
|
|
4753 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4754 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
4755 * @param storageArea The storage area.
|
|
4756 * @param uuid The identifier of the file to be read.
|
|
4757 * @param type The type of the file content.
|
|
4758 * @return 0 if success, other value if error.
|
|
4759 * @ingroup Callbacks
|
|
4760 * @deprecated This function should not be used anymore. Use "OrthancPluginRestApiGet()" on
|
|
4761 * "/{patients|studies|series|instances}/{id}/attachments/{name}" instead.
|
|
4762 **/
|
|
4763 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaRead(
|
|
4764 OrthancPluginContext* context,
|
|
4765 OrthancPluginMemoryBuffer* target,
|
|
4766 OrthancPluginStorageArea* storageArea,
|
|
4767 const char* uuid,
|
|
4768 OrthancPluginContentType type)
|
|
4769 {
|
|
4770 _OrthancPluginStorageAreaRead params;
|
|
4771 params.target = target;
|
|
4772 params.storageArea = storageArea;
|
|
4773 params.uuid = uuid;
|
|
4774 params.type = type;
|
|
4775
|
|
4776 return context->InvokeService(context, _OrthancPluginService_StorageAreaRead, ¶ms);
|
|
4777 }
|
|
4778
|
|
4779
|
|
4780 typedef struct
|
|
4781 {
|
|
4782 OrthancPluginStorageArea* storageArea;
|
|
4783 const char* uuid;
|
|
4784 OrthancPluginContentType type;
|
|
4785 } _OrthancPluginStorageAreaRemove;
|
|
4786
|
|
4787 /**
|
|
4788 * @brief Remove a file from the storage area.
|
|
4789 *
|
|
4790 * This function removes a given file from the storage area that is
|
|
4791 * currently used by Orthanc.
|
|
4792 *
|
|
4793 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4794 * @param storageArea The storage area.
|
|
4795 * @param uuid The identifier of the file to be removed.
|
|
4796 * @param type The type of the file content.
|
|
4797 * @return 0 if success, other value if error.
|
|
4798 * @ingroup Callbacks
|
|
4799 * @deprecated This function should not be used anymore. Use "OrthancPluginRestApiDelete()" on
|
|
4800 * "/{patients|studies|series|instances}/{id}/attachments/{name}" instead.
|
|
4801 **/
|
|
4802 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaRemove(
|
|
4803 OrthancPluginContext* context,
|
|
4804 OrthancPluginStorageArea* storageArea,
|
|
4805 const char* uuid,
|
|
4806 OrthancPluginContentType type)
|
|
4807 {
|
|
4808 _OrthancPluginStorageAreaRemove params;
|
|
4809 params.storageArea = storageArea;
|
|
4810 params.uuid = uuid;
|
|
4811 params.type = type;
|
|
4812
|
|
4813 return context->InvokeService(context, _OrthancPluginService_StorageAreaRemove, ¶ms);
|
|
4814 }
|
|
4815
|
|
4816
|
|
4817
|
|
4818 typedef struct
|
|
4819 {
|
|
4820 OrthancPluginErrorCode* target;
|
|
4821 int32_t code;
|
|
4822 uint16_t httpStatus;
|
|
4823 const char* message;
|
|
4824 } _OrthancPluginRegisterErrorCode;
|
|
4825
|
|
4826 /**
|
|
4827 * @brief Declare a custom error code for this plugin.
|
|
4828 *
|
|
4829 * This function declares a custom error code that can be generated
|
|
4830 * by this plugin. This declaration is used to enrich the body of
|
|
4831 * the HTTP answer in the case of an error, and to set the proper
|
|
4832 * HTTP status code.
|
|
4833 *
|
|
4834 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4835 * @param code The error code that is internal to this plugin.
|
|
4836 * @param httpStatus The HTTP status corresponding to this error.
|
|
4837 * @param message The description of the error.
|
|
4838 * @return The error code that has been assigned inside the Orthanc core.
|
|
4839 * @ingroup Toolbox
|
|
4840 **/
|
|
4841 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterErrorCode(
|
|
4842 OrthancPluginContext* context,
|
|
4843 int32_t code,
|
|
4844 uint16_t httpStatus,
|
|
4845 const char* message)
|
|
4846 {
|
|
4847 OrthancPluginErrorCode target;
|
|
4848
|
|
4849 _OrthancPluginRegisterErrorCode params;
|
|
4850 params.target = ⌖
|
|
4851 params.code = code;
|
|
4852 params.httpStatus = httpStatus;
|
|
4853 params.message = message;
|
|
4854
|
|
4855 if (context->InvokeService(context, _OrthancPluginService_RegisterErrorCode, ¶ms) == OrthancPluginErrorCode_Success)
|
|
4856 {
|
|
4857 return target;
|
|
4858 }
|
|
4859 else
|
|
4860 {
|
|
4861 /* There was an error while assigned the error. Use a generic code. */
|
|
4862 return OrthancPluginErrorCode_Plugin;
|
|
4863 }
|
|
4864 }
|
|
4865
|
|
4866
|
|
4867
|
|
4868 typedef struct
|
|
4869 {
|
|
4870 uint16_t group;
|
|
4871 uint16_t element;
|
|
4872 OrthancPluginValueRepresentation vr;
|
|
4873 const char* name;
|
|
4874 uint32_t minMultiplicity;
|
|
4875 uint32_t maxMultiplicity;
|
|
4876 } _OrthancPluginRegisterDictionaryTag;
|
|
4877
|
|
4878 /**
|
|
4879 * @brief Register a new tag into the DICOM dictionary.
|
|
4880 *
|
|
4881 * This function declares a new public tag in the dictionary of
|
|
4882 * DICOM tags that are known to Orthanc. This function should be
|
|
4883 * used in the OrthancPluginInitialize() callback.
|
|
4884 *
|
|
4885 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4886 * @param group The group of the tag.
|
|
4887 * @param element The element of the tag.
|
|
4888 * @param vr The value representation of the tag.
|
|
4889 * @param name The nickname of the tag.
|
|
4890 * @param minMultiplicity The minimum multiplicity of the tag (must be above 0).
|
|
4891 * @param maxMultiplicity The maximum multiplicity of the tag. A value of 0 means
|
|
4892 * an arbitrary multiplicity ("<tt>n</tt>").
|
|
4893 * @return 0 if success, other value if error.
|
|
4894 * @see OrthancPluginRegisterPrivateDictionaryTag()
|
|
4895 * @ingroup Toolbox
|
|
4896 **/
|
|
4897 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDictionaryTag(
|
|
4898 OrthancPluginContext* context,
|
|
4899 uint16_t group,
|
|
4900 uint16_t element,
|
|
4901 OrthancPluginValueRepresentation vr,
|
|
4902 const char* name,
|
|
4903 uint32_t minMultiplicity,
|
|
4904 uint32_t maxMultiplicity)
|
|
4905 {
|
|
4906 _OrthancPluginRegisterDictionaryTag params;
|
|
4907 params.group = group;
|
|
4908 params.element = element;
|
|
4909 params.vr = vr;
|
|
4910 params.name = name;
|
|
4911 params.minMultiplicity = minMultiplicity;
|
|
4912 params.maxMultiplicity = maxMultiplicity;
|
|
4913
|
|
4914 return context->InvokeService(context, _OrthancPluginService_RegisterDictionaryTag, ¶ms);
|
|
4915 }
|
|
4916
|
|
4917
|
|
4918
|
|
4919 typedef struct
|
|
4920 {
|
|
4921 uint16_t group;
|
|
4922 uint16_t element;
|
|
4923 OrthancPluginValueRepresentation vr;
|
|
4924 const char* name;
|
|
4925 uint32_t minMultiplicity;
|
|
4926 uint32_t maxMultiplicity;
|
|
4927 const char* privateCreator;
|
|
4928 } _OrthancPluginRegisterPrivateDictionaryTag;
|
|
4929
|
|
4930 /**
|
|
4931 * @brief Register a new private tag into the DICOM dictionary.
|
|
4932 *
|
|
4933 * This function declares a new private tag in the dictionary of
|
|
4934 * DICOM tags that are known to Orthanc. This function should be
|
|
4935 * used in the OrthancPluginInitialize() callback.
|
|
4936 *
|
|
4937 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4938 * @param group The group of the tag.
|
|
4939 * @param element The element of the tag.
|
|
4940 * @param vr The value representation of the tag.
|
|
4941 * @param name The nickname of the tag.
|
|
4942 * @param minMultiplicity The minimum multiplicity of the tag (must be above 0).
|
|
4943 * @param maxMultiplicity The maximum multiplicity of the tag. A value of 0 means
|
|
4944 * an arbitrary multiplicity ("<tt>n</tt>").
|
|
4945 * @param privateCreator The private creator of this private tag.
|
|
4946 * @return 0 if success, other value if error.
|
|
4947 * @see OrthancPluginRegisterDictionaryTag()
|
|
4948 * @ingroup Toolbox
|
|
4949 **/
|
|
4950 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterPrivateDictionaryTag(
|
|
4951 OrthancPluginContext* context,
|
|
4952 uint16_t group,
|
|
4953 uint16_t element,
|
|
4954 OrthancPluginValueRepresentation vr,
|
|
4955 const char* name,
|
|
4956 uint32_t minMultiplicity,
|
|
4957 uint32_t maxMultiplicity,
|
|
4958 const char* privateCreator)
|
|
4959 {
|
|
4960 _OrthancPluginRegisterPrivateDictionaryTag params;
|
|
4961 params.group = group;
|
|
4962 params.element = element;
|
|
4963 params.vr = vr;
|
|
4964 params.name = name;
|
|
4965 params.minMultiplicity = minMultiplicity;
|
|
4966 params.maxMultiplicity = maxMultiplicity;
|
|
4967 params.privateCreator = privateCreator;
|
|
4968
|
|
4969 return context->InvokeService(context, _OrthancPluginService_RegisterPrivateDictionaryTag, ¶ms);
|
|
4970 }
|
|
4971
|
|
4972
|
|
4973
|
|
4974 typedef struct
|
|
4975 {
|
|
4976 OrthancPluginStorageArea* storageArea;
|
|
4977 OrthancPluginResourceType level;
|
|
4978 } _OrthancPluginReconstructMainDicomTags;
|
|
4979
|
|
4980 /**
|
|
4981 * @brief Reconstruct the main DICOM tags.
|
|
4982 *
|
|
4983 * This function requests the Orthanc core to reconstruct the main
|
|
4984 * DICOM tags of all the resources of the given type. This function
|
|
4985 * can only be used as a part of the upgrade of a custom database
|
|
4986 * back-end. A database transaction will be automatically setup.
|
|
4987 *
|
|
4988 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4989 * @param storageArea The storage area.
|
|
4990 * @param level The type of the resources of interest.
|
|
4991 * @return 0 if success, other value if error.
|
|
4992 * @ingroup Callbacks
|
|
4993 **/
|
|
4994 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReconstructMainDicomTags(
|
|
4995 OrthancPluginContext* context,
|
|
4996 OrthancPluginStorageArea* storageArea,
|
|
4997 OrthancPluginResourceType level)
|
|
4998 {
|
|
4999 _OrthancPluginReconstructMainDicomTags params;
|
|
5000 params.level = level;
|
|
5001 params.storageArea = storageArea;
|
|
5002
|
|
5003 return context->InvokeService(context, _OrthancPluginService_ReconstructMainDicomTags, ¶ms);
|
|
5004 }
|
|
5005
|
|
5006
|
|
5007 typedef struct
|
|
5008 {
|
|
5009 char** result;
|
|
5010 const char* instanceId;
|
|
5011 const void* buffer;
|
|
5012 uint32_t size;
|
|
5013 OrthancPluginDicomToJsonFormat format;
|
|
5014 OrthancPluginDicomToJsonFlags flags;
|
|
5015 uint32_t maxStringLength;
|
|
5016 } _OrthancPluginDicomToJson;
|
|
5017
|
|
5018
|
|
5019 /**
|
|
5020 * @brief Format a DICOM memory buffer as a JSON string.
|
|
5021 *
|
|
5022 * This function takes as input a memory buffer containing a DICOM
|
|
5023 * file, and outputs a JSON string representing the tags of this
|
|
5024 * DICOM file.
|
|
5025 *
|
|
5026 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5027 * @param buffer The memory buffer containing the DICOM file.
|
|
5028 * @param size The size of the memory buffer.
|
|
5029 * @param format The output format.
|
|
5030 * @param flags Flags governing the output.
|
|
5031 * @param maxStringLength The maximum length of a field. Too long fields will
|
|
5032 * be output as "null". The 0 value means no maximum length.
|
|
5033 * @return The NULL value if the case of an error, or the JSON
|
|
5034 * string. This string must be freed by OrthancPluginFreeString().
|
|
5035 * @ingroup Toolbox
|
|
5036 * @see OrthancPluginDicomInstanceToJson
|
|
5037 **/
|
|
5038 ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomBufferToJson(
|
|
5039 OrthancPluginContext* context,
|
|
5040 const void* buffer,
|
|
5041 uint32_t size,
|
|
5042 OrthancPluginDicomToJsonFormat format,
|
|
5043 OrthancPluginDicomToJsonFlags flags,
|
|
5044 uint32_t maxStringLength)
|
|
5045 {
|
|
5046 char* result;
|
|
5047
|
|
5048 _OrthancPluginDicomToJson params;
|
|
5049 memset(¶ms, 0, sizeof(params));
|
|
5050 params.result = &result;
|
|
5051 params.buffer = buffer;
|
|
5052 params.size = size;
|
|
5053 params.format = format;
|
|
5054 params.flags = flags;
|
|
5055 params.maxStringLength = maxStringLength;
|
|
5056
|
|
5057 if (context->InvokeService(context, _OrthancPluginService_DicomBufferToJson, ¶ms) != OrthancPluginErrorCode_Success)
|
|
5058 {
|
|
5059 /* Error */
|
|
5060 return NULL;
|
|
5061 }
|
|
5062 else
|
|
5063 {
|
|
5064 return result;
|
|
5065 }
|
|
5066 }
|
|
5067
|
|
5068
|
|
5069 /**
|
|
5070 * @brief Format a DICOM instance as a JSON string.
|
|
5071 *
|
|
5072 * This function formats a DICOM instance that is stored in Orthanc,
|
|
5073 * and outputs a JSON string representing the tags of this DICOM
|
|
5074 * instance.
|
|
5075 *
|
|
5076 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5077 * @param instanceId The Orthanc identifier of the instance.
|
|
5078 * @param format The output format.
|
|
5079 * @param flags Flags governing the output.
|
|
5080 * @param maxStringLength The maximum length of a field. Too long fields will
|
|
5081 * be output as "null". The 0 value means no maximum length.
|
|
5082 * @return The NULL value if the case of an error, or the JSON
|
|
5083 * string. This string must be freed by OrthancPluginFreeString().
|
|
5084 * @ingroup Toolbox
|
|
5085 * @see OrthancPluginDicomInstanceToJson
|
|
5086 **/
|
|
5087 ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomInstanceToJson(
|
|
5088 OrthancPluginContext* context,
|
|
5089 const char* instanceId,
|
|
5090 OrthancPluginDicomToJsonFormat format,
|
|
5091 OrthancPluginDicomToJsonFlags flags,
|
|
5092 uint32_t maxStringLength)
|
|
5093 {
|
|
5094 char* result;
|
|
5095
|
|
5096 _OrthancPluginDicomToJson params;
|
|
5097 memset(¶ms, 0, sizeof(params));
|
|
5098 params.result = &result;
|
|
5099 params.instanceId = instanceId;
|
|
5100 params.format = format;
|
|
5101 params.flags = flags;
|
|
5102 params.maxStringLength = maxStringLength;
|
|
5103
|
|
5104 if (context->InvokeService(context, _OrthancPluginService_DicomInstanceToJson, ¶ms) != OrthancPluginErrorCode_Success)
|
|
5105 {
|
|
5106 /* Error */
|
|
5107 return NULL;
|
|
5108 }
|
|
5109 else
|
|
5110 {
|
|
5111 return result;
|
|
5112 }
|
|
5113 }
|
|
5114
|
|
5115
|
|
5116 typedef struct
|
|
5117 {
|
|
5118 OrthancPluginMemoryBuffer* target;
|
|
5119 const char* uri;
|
|
5120 uint32_t headersCount;
|
|
5121 const char* const* headersKeys;
|
|
5122 const char* const* headersValues;
|
|
5123 int32_t afterPlugins;
|
|
5124 } _OrthancPluginRestApiGet2;
|
|
5125
|
|
5126 /**
|
|
5127 * @brief Make a GET call to the Orthanc REST API, with custom HTTP headers.
|
|
5128 *
|
|
5129 * Make a GET call to the Orthanc REST API with extended
|
|
5130 * parameters. The result to the query is stored into a newly
|
|
5131 * allocated memory buffer.
|
|
5132 *
|
|
5133 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5134 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
5135 * @param uri The URI in the built-in Orthanc API.
|
|
5136 * @param headersCount The number of HTTP headers.
|
|
5137 * @param headersKeys Array containing the keys of the HTTP headers (can be <tt>NULL</tt> if no header).
|
|
5138 * @param headersValues Array containing the values of the HTTP headers (can be <tt>NULL</tt> if no header).
|
|
5139 * @param afterPlugins If 0, the built-in API of Orthanc is used.
|
|
5140 * If 1, the API is tainted by the plugins.
|
|
5141 * @return 0 if success, or the error code if failure.
|
|
5142 * @see OrthancPluginRestApiGet, OrthancPluginRestApiGetAfterPlugins
|
|
5143 * @ingroup Orthanc
|
|
5144 **/
|
|
5145 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet2(
|
|
5146 OrthancPluginContext* context,
|
|
5147 OrthancPluginMemoryBuffer* target,
|
|
5148 const char* uri,
|
|
5149 uint32_t headersCount,
|
|
5150 const char* const* headersKeys,
|
|
5151 const char* const* headersValues,
|
|
5152 int32_t afterPlugins)
|
|
5153 {
|
|
5154 _OrthancPluginRestApiGet2 params;
|
|
5155 params.target = target;
|
|
5156 params.uri = uri;
|
|
5157 params.headersCount = headersCount;
|
|
5158 params.headersKeys = headersKeys;
|
|
5159 params.headersValues = headersValues;
|
|
5160 params.afterPlugins = afterPlugins;
|
|
5161
|
|
5162 return context->InvokeService(context, _OrthancPluginService_RestApiGet2, ¶ms);
|
|
5163 }
|
|
5164
|
|
5165
|
|
5166
|
|
5167 typedef struct
|
|
5168 {
|
|
5169 OrthancPluginWorklistCallback callback;
|
|
5170 } _OrthancPluginWorklistCallback;
|
|
5171
|
|
5172 /**
|
|
5173 * @brief Register a callback to handle modality worklists requests.
|
|
5174 *
|
|
5175 * This function registers a callback to handle C-Find SCP requests
|
|
5176 * on modality worklists.
|
|
5177 *
|
|
5178 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5179 * @param callback The callback.
|
|
5180 * @return 0 if success, other value if error.
|
|
5181 * @ingroup DicomCallbacks
|
|
5182 **/
|
|
5183 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterWorklistCallback(
|
|
5184 OrthancPluginContext* context,
|
|
5185 OrthancPluginWorklistCallback callback)
|
|
5186 {
|
|
5187 _OrthancPluginWorklistCallback params;
|
|
5188 params.callback = callback;
|
|
5189
|
|
5190 return context->InvokeService(context, _OrthancPluginService_RegisterWorklistCallback, ¶ms);
|
|
5191 }
|
|
5192
|
|
5193
|
|
5194
|
|
5195 typedef struct
|
|
5196 {
|
|
5197 OrthancPluginWorklistAnswers* answers;
|
|
5198 const OrthancPluginWorklistQuery* query;
|
|
5199 const void* dicom;
|
|
5200 uint32_t size;
|
|
5201 } _OrthancPluginWorklistAnswersOperation;
|
|
5202
|
|
5203 /**
|
|
5204 * @brief Add one answer to some modality worklist request.
|
|
5205 *
|
|
5206 * This function adds one worklist (encoded as a DICOM file) to the
|
|
5207 * set of answers corresponding to some C-Find SCP request against
|
|
5208 * modality worklists.
|
|
5209 *
|
|
5210 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5211 * @param answers The set of answers.
|
|
5212 * @param query The worklist query, as received by the callback.
|
|
5213 * @param dicom The worklist to answer, encoded as a DICOM file.
|
|
5214 * @param size The size of the DICOM file.
|
|
5215 * @return 0 if success, other value if error.
|
|
5216 * @ingroup DicomCallbacks
|
|
5217 * @see OrthancPluginCreateDicom()
|
|
5218 **/
|
|
5219 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistAddAnswer(
|
|
5220 OrthancPluginContext* context,
|
|
5221 OrthancPluginWorklistAnswers* answers,
|
|
5222 const OrthancPluginWorklistQuery* query,
|
|
5223 const void* dicom,
|
|
5224 uint32_t size)
|
|
5225 {
|
|
5226 _OrthancPluginWorklistAnswersOperation params;
|
|
5227 params.answers = answers;
|
|
5228 params.query = query;
|
|
5229 params.dicom = dicom;
|
|
5230 params.size = size;
|
|
5231
|
|
5232 return context->InvokeService(context, _OrthancPluginService_WorklistAddAnswer, ¶ms);
|
|
5233 }
|
|
5234
|
|
5235
|
|
5236 /**
|
|
5237 * @brief Mark the set of worklist answers as incomplete.
|
|
5238 *
|
|
5239 * This function marks as incomplete the set of answers
|
|
5240 * corresponding to some C-Find SCP request against modality
|
|
5241 * worklists. This must be used if canceling the handling of a
|
|
5242 * request when too many answers are to be returned.
|
|
5243 *
|
|
5244 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5245 * @param answers The set of answers.
|
|
5246 * @return 0 if success, other value if error.
|
|
5247 * @ingroup DicomCallbacks
|
|
5248 **/
|
|
5249 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistMarkIncomplete(
|
|
5250 OrthancPluginContext* context,
|
|
5251 OrthancPluginWorklistAnswers* answers)
|
|
5252 {
|
|
5253 _OrthancPluginWorklistAnswersOperation params;
|
|
5254 params.answers = answers;
|
|
5255 params.query = NULL;
|
|
5256 params.dicom = NULL;
|
|
5257 params.size = 0;
|
|
5258
|
|
5259 return context->InvokeService(context, _OrthancPluginService_WorklistMarkIncomplete, ¶ms);
|
|
5260 }
|
|
5261
|
|
5262
|
|
5263 typedef struct
|
|
5264 {
|
|
5265 const OrthancPluginWorklistQuery* query;
|
|
5266 const void* dicom;
|
|
5267 uint32_t size;
|
|
5268 int32_t* isMatch;
|
|
5269 OrthancPluginMemoryBuffer* target;
|
|
5270 } _OrthancPluginWorklistQueryOperation;
|
|
5271
|
|
5272 /**
|
|
5273 * @brief Test whether a worklist matches the query.
|
|
5274 *
|
|
5275 * This function checks whether one worklist (encoded as a DICOM
|
|
5276 * file) matches the C-Find SCP query against modality
|
|
5277 * worklists. This function must be called before adding the
|
|
5278 * worklist as an answer through OrthancPluginWorklistAddAnswer().
|
|
5279 *
|
|
5280 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5281 * @param query The worklist query, as received by the callback.
|
|
5282 * @param dicom The worklist to answer, encoded as a DICOM file.
|
|
5283 * @param size The size of the DICOM file.
|
|
5284 * @return 1 if the worklist matches the query, 0 otherwise.
|
|
5285 * @ingroup DicomCallbacks
|
|
5286 **/
|
|
5287 ORTHANC_PLUGIN_INLINE int32_t OrthancPluginWorklistIsMatch(
|
|
5288 OrthancPluginContext* context,
|
|
5289 const OrthancPluginWorklistQuery* query,
|
|
5290 const void* dicom,
|
|
5291 uint32_t size)
|
|
5292 {
|
|
5293 int32_t isMatch = 0;
|
|
5294
|
|
5295 _OrthancPluginWorklistQueryOperation params;
|
|
5296 params.query = query;
|
|
5297 params.dicom = dicom;
|
|
5298 params.size = size;
|
|
5299 params.isMatch = &isMatch;
|
|
5300 params.target = NULL;
|
|
5301
|
|
5302 if (context->InvokeService(context, _OrthancPluginService_WorklistIsMatch, ¶ms) == OrthancPluginErrorCode_Success)
|
|
5303 {
|
|
5304 return isMatch;
|
|
5305 }
|
|
5306 else
|
|
5307 {
|
|
5308 /* Error: Assume non-match */
|
|
5309 return 0;
|
|
5310 }
|
|
5311 }
|
|
5312
|
|
5313
|
|
5314 /**
|
|
5315 * @brief Retrieve the worklist query as a DICOM file.
|
|
5316 *
|
|
5317 * This function retrieves the DICOM file that underlies a C-Find
|
|
5318 * SCP query against modality worklists.
|
|
5319 *
|
|
5320 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5321 * @param target Memory buffer where to store the DICOM file. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
5322 * @param query The worklist query, as received by the callback.
|
|
5323 * @return 0 if success, other value if error.
|
|
5324 * @ingroup DicomCallbacks
|
|
5325 **/
|
|
5326 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistGetDicomQuery(
|
|
5327 OrthancPluginContext* context,
|
|
5328 OrthancPluginMemoryBuffer* target,
|
|
5329 const OrthancPluginWorklistQuery* query)
|
|
5330 {
|
|
5331 _OrthancPluginWorklistQueryOperation params;
|
|
5332 params.query = query;
|
|
5333 params.dicom = NULL;
|
|
5334 params.size = 0;
|
|
5335 params.isMatch = NULL;
|
|
5336 params.target = target;
|
|
5337
|
|
5338 return context->InvokeService(context, _OrthancPluginService_WorklistGetDicomQuery, ¶ms);
|
|
5339 }
|
|
5340
|
|
5341
|
|
5342 /**
|
|
5343 * @brief Get the origin of a DICOM file.
|
|
5344 *
|
|
5345 * This function returns the origin of a DICOM instance that has been received by Orthanc.
|
|
5346 *
|
|
5347 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5348 * @param instance The instance of interest.
|
|
5349 * @return The origin of the instance.
|
|
5350 * @ingroup DicomInstance
|
|
5351 **/
|
|
5352 ORTHANC_PLUGIN_INLINE OrthancPluginInstanceOrigin OrthancPluginGetInstanceOrigin(
|
|
5353 OrthancPluginContext* context,
|
|
5354 const OrthancPluginDicomInstance* instance)
|
|
5355 {
|
|
5356 OrthancPluginInstanceOrigin origin;
|
|
5357
|
|
5358 _OrthancPluginAccessDicomInstance params;
|
|
5359 memset(¶ms, 0, sizeof(params));
|
|
5360 params.resultOrigin = &origin;
|
|
5361 params.instance = instance;
|
|
5362
|
|
5363 if (context->InvokeService(context, _OrthancPluginService_GetInstanceOrigin, ¶ms) != OrthancPluginErrorCode_Success)
|
|
5364 {
|
|
5365 /* Error */
|
|
5366 return OrthancPluginInstanceOrigin_Unknown;
|
|
5367 }
|
|
5368 else
|
|
5369 {
|
|
5370 return origin;
|
|
5371 }
|
|
5372 }
|
|
5373
|
|
5374
|
|
5375 typedef struct
|
|
5376 {
|
|
5377 OrthancPluginMemoryBuffer* target;
|
|
5378 const char* json;
|
|
5379 const OrthancPluginImage* pixelData;
|
|
5380 OrthancPluginCreateDicomFlags flags;
|
|
5381 } _OrthancPluginCreateDicom;
|
|
5382
|
|
5383 /**
|
|
5384 * @brief Create a DICOM instance from a JSON string and an image.
|
|
5385 *
|
|
5386 * This function takes as input a string containing a JSON file
|
|
5387 * describing the content of a DICOM instance. As an output, it
|
|
5388 * writes the corresponding DICOM instance to a newly allocated
|
|
5389 * memory buffer. Additionally, an image to be encoded within the
|
|
5390 * DICOM instance can also be provided.
|
|
5391 *
|
|
5392 * Private tags will be associated with the private creator whose
|
|
5393 * value is specified in the "DefaultPrivateCreator" configuration
|
|
5394 * option of Orthanc. The function OrthancPluginCreateDicom2() can
|
|
5395 * be used if another private creator must be used to create this
|
|
5396 * instance.
|
|
5397 *
|
|
5398 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5399 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
5400 * @param json The input JSON file.
|
|
5401 * @param pixelData The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme.
|
|
5402 * @param flags Flags governing the output.
|
|
5403 * @return 0 if success, other value if error.
|
|
5404 * @ingroup Toolbox
|
|
5405 * @see OrthancPluginCreateDicom2
|
|
5406 * @see OrthancPluginDicomBufferToJson
|
|
5407 **/
|
|
5408 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateDicom(
|
|
5409 OrthancPluginContext* context,
|
|
5410 OrthancPluginMemoryBuffer* target,
|
|
5411 const char* json,
|
|
5412 const OrthancPluginImage* pixelData,
|
|
5413 OrthancPluginCreateDicomFlags flags)
|
|
5414 {
|
|
5415 _OrthancPluginCreateDicom params;
|
|
5416 params.target = target;
|
|
5417 params.json = json;
|
|
5418 params.pixelData = pixelData;
|
|
5419 params.flags = flags;
|
|
5420
|
|
5421 return context->InvokeService(context, _OrthancPluginService_CreateDicom, ¶ms);
|
|
5422 }
|
|
5423
|
|
5424
|
|
5425 typedef struct
|
|
5426 {
|
|
5427 OrthancPluginDecodeImageCallback callback;
|
|
5428 } _OrthancPluginDecodeImageCallback;
|
|
5429
|
|
5430 /**
|
|
5431 * @brief Register a callback to handle the decoding of DICOM images.
|
|
5432 *
|
|
5433 * This function registers a custom callback to decode DICOM images,
|
|
5434 * extending the built-in decoder of Orthanc that uses
|
|
5435 * DCMTK. Starting with Orthanc 1.7.0, the exact behavior is
|
|
5436 * affected by the configuration option
|
|
5437 * "BuiltinDecoderTranscoderOrder" of Orthanc.
|
|
5438 *
|
|
5439 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5440 * @param callback The callback.
|
|
5441 * @return 0 if success, other value if error.
|
|
5442 * @ingroup Callbacks
|
|
5443 **/
|
|
5444 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDecodeImageCallback(
|
|
5445 OrthancPluginContext* context,
|
|
5446 OrthancPluginDecodeImageCallback callback)
|
|
5447 {
|
|
5448 _OrthancPluginDecodeImageCallback params;
|
|
5449 params.callback = callback;
|
|
5450
|
|
5451 return context->InvokeService(context, _OrthancPluginService_RegisterDecodeImageCallback, ¶ms);
|
|
5452 }
|
|
5453
|
|
5454
|
|
5455
|
|
5456 typedef struct
|
|
5457 {
|
|
5458 OrthancPluginImage** target;
|
|
5459 OrthancPluginPixelFormat format;
|
|
5460 uint32_t width;
|
|
5461 uint32_t height;
|
|
5462 uint32_t pitch;
|
|
5463 void* buffer;
|
|
5464 const void* constBuffer;
|
|
5465 uint32_t bufferSize;
|
|
5466 uint32_t frameIndex;
|
|
5467 } _OrthancPluginCreateImage;
|
|
5468
|
|
5469
|
|
5470 /**
|
|
5471 * @brief Create an image.
|
|
5472 *
|
|
5473 * This function creates an image of given size and format.
|
|
5474 *
|
|
5475 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5476 * @param format The format of the pixels.
|
|
5477 * @param width The width of the image.
|
|
5478 * @param height The height of the image.
|
|
5479 * @return The newly allocated image. It must be freed with OrthancPluginFreeImage().
|
|
5480 * @ingroup Images
|
|
5481 **/
|
|
5482 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImage(
|
|
5483 OrthancPluginContext* context,
|
|
5484 OrthancPluginPixelFormat format,
|
|
5485 uint32_t width,
|
|
5486 uint32_t height)
|
|
5487 {
|
|
5488 OrthancPluginImage* target = NULL;
|
|
5489
|
|
5490 _OrthancPluginCreateImage params;
|
|
5491 memset(¶ms, 0, sizeof(params));
|
|
5492 params.target = ⌖
|
|
5493 params.format = format;
|
|
5494 params.width = width;
|
|
5495 params.height = height;
|
|
5496
|
|
5497 if (context->InvokeService(context, _OrthancPluginService_CreateImage, ¶ms) != OrthancPluginErrorCode_Success)
|
|
5498 {
|
|
5499 return NULL;
|
|
5500 }
|
|
5501 else
|
|
5502 {
|
|
5503 return target;
|
|
5504 }
|
|
5505 }
|
|
5506
|
|
5507
|
|
5508 /**
|
|
5509 * @brief Create an image pointing to a memory buffer.
|
|
5510 *
|
|
5511 * This function creates an image whose content points to a memory
|
|
5512 * buffer managed by the plugin. Note that the buffer is directly
|
|
5513 * accessed, no memory is allocated and no data is copied.
|
|
5514 *
|
|
5515 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5516 * @param format The format of the pixels.
|
|
5517 * @param width The width of the image.
|
|
5518 * @param height The height of the image.
|
|
5519 * @param pitch The pitch of the image (i.e. the number of bytes
|
|
5520 * between 2 successive lines of the image in the memory buffer).
|
|
5521 * @param buffer The memory buffer.
|
|
5522 * @return The newly allocated image. It must be freed with OrthancPluginFreeImage().
|
|
5523 * @ingroup Images
|
|
5524 **/
|
|
5525 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImageAccessor(
|
|
5526 OrthancPluginContext* context,
|
|
5527 OrthancPluginPixelFormat format,
|
|
5528 uint32_t width,
|
|
5529 uint32_t height,
|
|
5530 uint32_t pitch,
|
|
5531 void* buffer)
|
|
5532 {
|
|
5533 OrthancPluginImage* target = NULL;
|
|
5534
|
|
5535 _OrthancPluginCreateImage params;
|
|
5536 memset(¶ms, 0, sizeof(params));
|
|
5537 params.target = ⌖
|
|
5538 params.format = format;
|
|
5539 params.width = width;
|
|
5540 params.height = height;
|
|
5541 params.pitch = pitch;
|
|
5542 params.buffer = buffer;
|
|
5543
|
|
5544 if (context->InvokeService(context, _OrthancPluginService_CreateImageAccessor, ¶ms) != OrthancPluginErrorCode_Success)
|
|
5545 {
|
|
5546 return NULL;
|
|
5547 }
|
|
5548 else
|
|
5549 {
|
|
5550 return target;
|
|
5551 }
|
|
5552 }
|
|
5553
|
|
5554
|
|
5555
|
|
5556 /**
|
|
5557 * @brief Decode one frame from a DICOM instance.
|
|
5558 *
|
|
5559 * This function decodes one frame of a DICOM image that is stored
|
|
5560 * in a memory buffer. This function will give the same result as
|
|
5561 * OrthancPluginUncompressImage() for single-frame DICOM images.
|
|
5562 *
|
|
5563 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5564 * @param buffer Pointer to a memory buffer containing the DICOM image.
|
|
5565 * @param bufferSize Size of the memory buffer containing the DICOM image.
|
|
5566 * @param frameIndex The index of the frame of interest in a multi-frame image.
|
|
5567 * @return The uncompressed image. It must be freed with OrthancPluginFreeImage().
|
|
5568 * @ingroup Images
|
|
5569 * @see OrthancPluginGetInstanceDecodedFrame()
|
|
5570 **/
|
|
5571 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginDecodeDicomImage(
|
|
5572 OrthancPluginContext* context,
|
|
5573 const void* buffer,
|
|
5574 uint32_t bufferSize,
|
|
5575 uint32_t frameIndex)
|
|
5576 {
|
|
5577 OrthancPluginImage* target = NULL;
|
|
5578
|
|
5579 _OrthancPluginCreateImage params;
|
|
5580 memset(¶ms, 0, sizeof(params));
|
|
5581 params.target = ⌖
|
|
5582 params.constBuffer = buffer;
|
|
5583 params.bufferSize = bufferSize;
|
|
5584 params.frameIndex = frameIndex;
|
|
5585
|
|
5586 if (context->InvokeService(context, _OrthancPluginService_DecodeDicomImage, ¶ms) != OrthancPluginErrorCode_Success)
|
|
5587 {
|
|
5588 return NULL;
|
|
5589 }
|
|
5590 else
|
|
5591 {
|
|
5592 return target;
|
|
5593 }
|
|
5594 }
|
|
5595
|
|
5596
|
|
5597
|
|
5598 typedef struct
|
|
5599 {
|
|
5600 char** result;
|
|
5601 const void* buffer;
|
|
5602 uint32_t size;
|
|
5603 } _OrthancPluginComputeHash;
|
|
5604
|
|
5605 /**
|
|
5606 * @brief Compute an MD5 hash.
|
|
5607 *
|
|
5608 * This functions computes the MD5 cryptographic hash of the given memory buffer.
|
|
5609 *
|
|
5610 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5611 * @param buffer The source memory buffer.
|
|
5612 * @param size The size in bytes of the source buffer.
|
|
5613 * @return The NULL value in case of error, or a string containing the cryptographic hash.
|
|
5614 * This string must be freed by OrthancPluginFreeString().
|
|
5615 * @ingroup Toolbox
|
|
5616 **/
|
|
5617 ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeMd5(
|
|
5618 OrthancPluginContext* context,
|
|
5619 const void* buffer,
|
|
5620 uint32_t size)
|
|
5621 {
|
|
5622 char* result;
|
|
5623
|
|
5624 _OrthancPluginComputeHash params;
|
|
5625 params.result = &result;
|
|
5626 params.buffer = buffer;
|
|
5627 params.size = size;
|
|
5628
|
|
5629 if (context->InvokeService(context, _OrthancPluginService_ComputeMd5, ¶ms) != OrthancPluginErrorCode_Success)
|
|
5630 {
|
|
5631 /* Error */
|
|
5632 return NULL;
|
|
5633 }
|
|
5634 else
|
|
5635 {
|
|
5636 return result;
|
|
5637 }
|
|
5638 }
|
|
5639
|
|
5640
|
|
5641 /**
|
|
5642 * @brief Compute a SHA-1 hash.
|
|
5643 *
|
|
5644 * This functions computes the SHA-1 cryptographic hash of the given memory buffer.
|
|
5645 *
|
|
5646 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5647 * @param buffer The source memory buffer.
|
|
5648 * @param size The size in bytes of the source buffer.
|
|
5649 * @return The NULL value in case of error, or a string containing the cryptographic hash.
|
|
5650 * This string must be freed by OrthancPluginFreeString().
|
|
5651 * @ingroup Toolbox
|
|
5652 **/
|
|
5653 ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeSha1(
|
|
5654 OrthancPluginContext* context,
|
|
5655 const void* buffer,
|
|
5656 uint32_t size)
|
|
5657 {
|
|
5658 char* result;
|
|
5659
|
|
5660 _OrthancPluginComputeHash params;
|
|
5661 params.result = &result;
|
|
5662 params.buffer = buffer;
|
|
5663 params.size = size;
|
|
5664
|
|
5665 if (context->InvokeService(context, _OrthancPluginService_ComputeSha1, ¶ms) != OrthancPluginErrorCode_Success)
|
|
5666 {
|
|
5667 /* Error */
|
|
5668 return NULL;
|
|
5669 }
|
|
5670 else
|
|
5671 {
|
|
5672 return result;
|
|
5673 }
|
|
5674 }
|
|
5675
|
|
5676
|
|
5677
|
|
5678 typedef struct
|
|
5679 {
|
|
5680 OrthancPluginDictionaryEntry* target;
|
|
5681 const char* name;
|
|
5682 } _OrthancPluginLookupDictionary;
|
|
5683
|
|
5684 /**
|
|
5685 * @brief Get information about the given DICOM tag.
|
|
5686 *
|
|
5687 * This functions makes a lookup in the dictionary of DICOM tags
|
|
5688 * that are known to Orthanc, and returns information about this
|
|
5689 * tag. The tag can be specified using its human-readable name
|
|
5690 * (e.g. "PatientName") or a set of two hexadecimal numbers
|
|
5691 * (e.g. "0010-0020").
|
|
5692 *
|
|
5693 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5694 * @param target Where to store the information about the tag.
|
|
5695 * @param name The name of the DICOM tag.
|
|
5696 * @return 0 if success, other value if error.
|
|
5697 * @ingroup Toolbox
|
|
5698 **/
|
|
5699 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginLookupDictionary(
|
|
5700 OrthancPluginContext* context,
|
|
5701 OrthancPluginDictionaryEntry* target,
|
|
5702 const char* name)
|
|
5703 {
|
|
5704 _OrthancPluginLookupDictionary params;
|
|
5705 params.target = target;
|
|
5706 params.name = name;
|
|
5707 return context->InvokeService(context, _OrthancPluginService_LookupDictionary, ¶ms);
|
|
5708 }
|
|
5709
|
|
5710
|
|
5711
|
|
5712 typedef struct
|
|
5713 {
|
|
5714 OrthancPluginRestOutput* output;
|
|
5715 const void* answer;
|
|
5716 uint32_t answerSize;
|
|
5717 uint32_t headersCount;
|
|
5718 const char* const* headersKeys;
|
|
5719 const char* const* headersValues;
|
|
5720 } _OrthancPluginSendMultipartItem2;
|
|
5721
|
|
5722 /**
|
|
5723 * @brief Send an item as a part of some HTTP multipart answer, with custom headers.
|
|
5724 *
|
|
5725 * This function sends an item as a part of some HTTP multipart
|
|
5726 * answer that was initiated by OrthancPluginStartMultipartAnswer(). In addition to
|
|
5727 * OrthancPluginSendMultipartItem(), this function will set HTTP header associated
|
|
5728 * with the item.
|
|
5729 *
|
|
5730 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5731 * @param output The HTTP connection to the client application.
|
|
5732 * @param answer Pointer to the memory buffer containing the item.
|
|
5733 * @param answerSize Number of bytes of the item.
|
|
5734 * @param headersCount The number of HTTP headers.
|
|
5735 * @param headersKeys Array containing the keys of the HTTP headers.
|
|
5736 * @param headersValues Array containing the values of the HTTP headers.
|
|
5737 * @return 0 if success, or the error code if failure (this notably happens
|
|
5738 * if the connection is closed by the client).
|
|
5739 * @see OrthancPluginSendMultipartItem()
|
|
5740 * @ingroup REST
|
|
5741 **/
|
|
5742 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendMultipartItem2(
|
|
5743 OrthancPluginContext* context,
|
|
5744 OrthancPluginRestOutput* output,
|
|
5745 const void* answer,
|
|
5746 uint32_t answerSize,
|
|
5747 uint32_t headersCount,
|
|
5748 const char* const* headersKeys,
|
|
5749 const char* const* headersValues)
|
|
5750 {
|
|
5751 _OrthancPluginSendMultipartItem2 params;
|
|
5752 params.output = output;
|
|
5753 params.answer = answer;
|
|
5754 params.answerSize = answerSize;
|
|
5755 params.headersCount = headersCount;
|
|
5756 params.headersKeys = headersKeys;
|
|
5757 params.headersValues = headersValues;
|
|
5758
|
|
5759 return context->InvokeService(context, _OrthancPluginService_SendMultipartItem2, ¶ms);
|
|
5760 }
|
|
5761
|
|
5762
|
|
5763 typedef struct
|
|
5764 {
|
|
5765 OrthancPluginIncomingHttpRequestFilter callback;
|
|
5766 } _OrthancPluginIncomingHttpRequestFilter;
|
|
5767
|
|
5768 /**
|
|
5769 * @brief Register a callback to filter incoming HTTP requests.
|
|
5770 *
|
|
5771 * This function registers a custom callback to filter incoming HTTP/REST
|
|
5772 * requests received by the HTTP server of Orthanc.
|
|
5773 *
|
|
5774 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5775 * @param callback The callback.
|
|
5776 * @return 0 if success, other value if error.
|
|
5777 * @ingroup Callbacks
|
|
5778 * @deprecated Please instead use OrthancPluginRegisterIncomingHttpRequestFilter2()
|
|
5779 **/
|
|
5780 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingHttpRequestFilter(
|
|
5781 OrthancPluginContext* context,
|
|
5782 OrthancPluginIncomingHttpRequestFilter callback)
|
|
5783 {
|
|
5784 _OrthancPluginIncomingHttpRequestFilter params;
|
|
5785 params.callback = callback;
|
|
5786
|
|
5787 return context->InvokeService(context, _OrthancPluginService_RegisterIncomingHttpRequestFilter, ¶ms);
|
|
5788 }
|
|
5789
|
|
5790
|
|
5791
|
|
5792 typedef struct
|
|
5793 {
|
|
5794 OrthancPluginMemoryBuffer* answerBody;
|
|
5795 OrthancPluginMemoryBuffer* answerHeaders;
|
|
5796 uint16_t* httpStatus;
|
|
5797 OrthancPluginHttpMethod method;
|
|
5798 const char* url;
|
|
5799 uint32_t headersCount;
|
|
5800 const char* const* headersKeys;
|
|
5801 const char* const* headersValues;
|
|
5802 const void* body;
|
|
5803 uint32_t bodySize;
|
|
5804 const char* username;
|
|
5805 const char* password;
|
|
5806 uint32_t timeout;
|
|
5807 const char* certificateFile;
|
|
5808 const char* certificateKeyFile;
|
|
5809 const char* certificateKeyPassword;
|
|
5810 uint8_t pkcs11;
|
|
5811 } _OrthancPluginCallHttpClient2;
|
|
5812
|
|
5813
|
|
5814
|
|
5815 /**
|
|
5816 * @brief Issue a HTTP call with full flexibility.
|
|
5817 *
|
|
5818 * Make a HTTP call to the given URL. The result to the query is
|
|
5819 * stored into a newly allocated memory buffer. The HTTP request
|
|
5820 * will be done accordingly to the global configuration of Orthanc
|
|
5821 * (in particular, the options "HttpProxy", "HttpTimeout",
|
|
5822 * "HttpsVerifyPeers", "HttpsCACertificates", and "Pkcs11" will be
|
|
5823 * taken into account).
|
|
5824 *
|
|
5825 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5826 * @param answerBody The target memory buffer (out argument).
|
|
5827 * It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
5828 * The value of this argument is ignored if the HTTP method is DELETE.
|
|
5829 * @param answerHeaders The target memory buffer for the HTTP headers in the answers (out argument).
|
|
5830 * The answer headers are formatted as a JSON object (associative array).
|
|
5831 * The buffer must be freed with OrthancPluginFreeMemoryBuffer().
|
|
5832 * This argument can be set to NULL if the plugin has no interest in the HTTP headers.
|
|
5833 * @param httpStatus The HTTP status after the execution of the request (out argument).
|
|
5834 * @param method HTTP method to be used.
|
|
5835 * @param url The URL of interest.
|
|
5836 * @param headersCount The number of HTTP headers.
|
|
5837 * @param headersKeys Array containing the keys of the HTTP headers (can be <tt>NULL</tt> if no header).
|
|
5838 * @param headersValues Array containing the values of the HTTP headers (can be <tt>NULL</tt> if no header).
|
|
5839 * @param username The username (can be <tt>NULL</tt> if no password protection).
|
|
5840 * @param password The password (can be <tt>NULL</tt> if no password protection).
|
|
5841 * @param body The HTTP body for a POST or PUT request.
|
|
5842 * @param bodySize The size of the body.
|
|
5843 * @param timeout Timeout in seconds (0 for default timeout).
|
|
5844 * @param certificateFile Path to the client certificate for HTTPS, in PEM format
|
|
5845 * (can be <tt>NULL</tt> if no client certificate or if not using HTTPS).
|
|
5846 * @param certificateKeyFile Path to the key of the client certificate for HTTPS, in PEM format
|
|
5847 * (can be <tt>NULL</tt> if no client certificate or if not using HTTPS).
|
|
5848 * @param certificateKeyPassword Password to unlock the key of the client certificate
|
|
5849 * (can be <tt>NULL</tt> if no client certificate or if not using HTTPS).
|
|
5850 * @param pkcs11 Enable PKCS#11 client authentication for hardware security modules and smart cards.
|
|
5851 * @return 0 if success, or the error code if failure.
|
|
5852 * @see OrthancPluginCallPeerApi()
|
|
5853 * @ingroup Toolbox
|
|
5854 **/
|
|
5855 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpClient(
|
|
5856 OrthancPluginContext* context,
|
|
5857 OrthancPluginMemoryBuffer* answerBody,
|
|
5858 OrthancPluginMemoryBuffer* answerHeaders,
|
|
5859 uint16_t* httpStatus,
|
|
5860 OrthancPluginHttpMethod method,
|
|
5861 const char* url,
|
|
5862 uint32_t headersCount,
|
|
5863 const char* const* headersKeys,
|
|
5864 const char* const* headersValues,
|
|
5865 const void* body,
|
|
5866 uint32_t bodySize,
|
|
5867 const char* username,
|
|
5868 const char* password,
|
|
5869 uint32_t timeout,
|
|
5870 const char* certificateFile,
|
|
5871 const char* certificateKeyFile,
|
|
5872 const char* certificateKeyPassword,
|
|
5873 uint8_t pkcs11)
|
|
5874 {
|
|
5875 _OrthancPluginCallHttpClient2 params;
|
|
5876 memset(¶ms, 0, sizeof(params));
|
|
5877
|
|
5878 params.answerBody = answerBody;
|
|
5879 params.answerHeaders = answerHeaders;
|
|
5880 params.httpStatus = httpStatus;
|
|
5881 params.method = method;
|
|
5882 params.url = url;
|
|
5883 params.headersCount = headersCount;
|
|
5884 params.headersKeys = headersKeys;
|
|
5885 params.headersValues = headersValues;
|
|
5886 params.body = body;
|
|
5887 params.bodySize = bodySize;
|
|
5888 params.username = username;
|
|
5889 params.password = password;
|
|
5890 params.timeout = timeout;
|
|
5891 params.certificateFile = certificateFile;
|
|
5892 params.certificateKeyFile = certificateKeyFile;
|
|
5893 params.certificateKeyPassword = certificateKeyPassword;
|
|
5894 params.pkcs11 = pkcs11;
|
|
5895
|
|
5896 return context->InvokeService(context, _OrthancPluginService_CallHttpClient2, ¶ms);
|
|
5897 }
|
|
5898
|
|
5899
|
|
5900 /**
|
|
5901 * @brief Generate an UUID.
|
|
5902 *
|
|
5903 * Generate a random GUID/UUID (globally unique identifier).
|
|
5904 *
|
|
5905 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5906 * @return NULL in the case of an error, or a newly allocated string
|
|
5907 * containing the UUID. This string must be freed by OrthancPluginFreeString().
|
|
5908 * @ingroup Toolbox
|
|
5909 **/
|
|
5910 ORTHANC_PLUGIN_INLINE char* OrthancPluginGenerateUuid(
|
|
5911 OrthancPluginContext* context)
|
|
5912 {
|
|
5913 char* result;
|
|
5914
|
|
5915 _OrthancPluginRetrieveDynamicString params;
|
|
5916 params.result = &result;
|
|
5917 params.argument = NULL;
|
|
5918
|
|
5919 if (context->InvokeService(context, _OrthancPluginService_GenerateUuid, ¶ms) != OrthancPluginErrorCode_Success)
|
|
5920 {
|
|
5921 /* Error */
|
|
5922 return NULL;
|
|
5923 }
|
|
5924 else
|
|
5925 {
|
|
5926 return result;
|
|
5927 }
|
|
5928 }
|
|
5929
|
|
5930
|
|
5931
|
|
5932
|
|
5933 typedef struct
|
|
5934 {
|
|
5935 OrthancPluginFindCallback callback;
|
|
5936 } _OrthancPluginFindCallback;
|
|
5937
|
|
5938 /**
|
|
5939 * @brief Register a callback to handle C-Find requests.
|
|
5940 *
|
|
5941 * This function registers a callback to handle C-Find SCP requests
|
|
5942 * that are not related to modality worklists.
|
|
5943 *
|
|
5944 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5945 * @param callback The callback.
|
|
5946 * @return 0 if success, other value if error.
|
|
5947 * @ingroup DicomCallbacks
|
|
5948 **/
|
|
5949 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterFindCallback(
|
|
5950 OrthancPluginContext* context,
|
|
5951 OrthancPluginFindCallback callback)
|
|
5952 {
|
|
5953 _OrthancPluginFindCallback params;
|
|
5954 params.callback = callback;
|
|
5955
|
|
5956 return context->InvokeService(context, _OrthancPluginService_RegisterFindCallback, ¶ms);
|
|
5957 }
|
|
5958
|
|
5959
|
|
5960 typedef struct
|
|
5961 {
|
|
5962 OrthancPluginFindAnswers *answers;
|
|
5963 const OrthancPluginFindQuery *query;
|
|
5964 const void *dicom;
|
|
5965 uint32_t size;
|
|
5966 uint32_t index;
|
|
5967 uint32_t *resultUint32;
|
|
5968 uint16_t *resultGroup;
|
|
5969 uint16_t *resultElement;
|
|
5970 char **resultString;
|
|
5971 } _OrthancPluginFindOperation;
|
|
5972
|
|
5973 /**
|
|
5974 * @brief Add one answer to some C-Find request.
|
|
5975 *
|
|
5976 * This function adds one answer (encoded as a DICOM file) to the
|
|
5977 * set of answers corresponding to some C-Find SCP request that is
|
|
5978 * not related to modality worklists.
|
|
5979 *
|
|
5980 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
5981 * @param answers The set of answers.
|
|
5982 * @param dicom The answer to be added, encoded as a DICOM file.
|
|
5983 * @param size The size of the DICOM file.
|
|
5984 * @return 0 if success, other value if error.
|
|
5985 * @ingroup DicomCallbacks
|
|
5986 * @see OrthancPluginCreateDicom()
|
|
5987 **/
|
|
5988 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginFindAddAnswer(
|
|
5989 OrthancPluginContext* context,
|
|
5990 OrthancPluginFindAnswers* answers,
|
|
5991 const void* dicom,
|
|
5992 uint32_t size)
|
|
5993 {
|
|
5994 _OrthancPluginFindOperation params;
|
|
5995 memset(¶ms, 0, sizeof(params));
|
|
5996 params.answers = answers;
|
|
5997 params.dicom = dicom;
|
|
5998 params.size = size;
|
|
5999
|
|
6000 return context->InvokeService(context, _OrthancPluginService_FindAddAnswer, ¶ms);
|
|
6001 }
|
|
6002
|
|
6003
|
|
6004 /**
|
|
6005 * @brief Mark the set of C-Find answers as incomplete.
|
|
6006 *
|
|
6007 * This function marks as incomplete the set of answers
|
|
6008 * corresponding to some C-Find SCP request that is not related to
|
|
6009 * modality worklists. This must be used if canceling the handling
|
|
6010 * of a request when too many answers are to be returned.
|
|
6011 *
|
|
6012 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6013 * @param answers The set of answers.
|
|
6014 * @return 0 if success, other value if error.
|
|
6015 * @ingroup DicomCallbacks
|
|
6016 **/
|
|
6017 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginFindMarkIncomplete(
|
|
6018 OrthancPluginContext* context,
|
|
6019 OrthancPluginFindAnswers* answers)
|
|
6020 {
|
|
6021 _OrthancPluginFindOperation params;
|
|
6022 memset(¶ms, 0, sizeof(params));
|
|
6023 params.answers = answers;
|
|
6024
|
|
6025 return context->InvokeService(context, _OrthancPluginService_FindMarkIncomplete, ¶ms);
|
|
6026 }
|
|
6027
|
|
6028
|
|
6029
|
|
6030 /**
|
|
6031 * @brief Get the number of tags in a C-Find query.
|
|
6032 *
|
|
6033 * This function returns the number of tags that are contained in
|
|
6034 * the given C-Find query.
|
|
6035 *
|
|
6036 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6037 * @param query The C-Find query.
|
|
6038 * @return The number of tags.
|
|
6039 * @ingroup DicomCallbacks
|
|
6040 **/
|
|
6041 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFindQuerySize(
|
|
6042 OrthancPluginContext* context,
|
|
6043 const OrthancPluginFindQuery* query)
|
|
6044 {
|
|
6045 uint32_t count = 0;
|
|
6046
|
|
6047 _OrthancPluginFindOperation params;
|
|
6048 memset(¶ms, 0, sizeof(params));
|
|
6049 params.query = query;
|
|
6050 params.resultUint32 = &count;
|
|
6051
|
|
6052 if (context->InvokeService(context, _OrthancPluginService_GetFindQuerySize, ¶ms) != OrthancPluginErrorCode_Success)
|
|
6053 {
|
|
6054 /* Error */
|
|
6055 return 0;
|
|
6056 }
|
|
6057 else
|
|
6058 {
|
|
6059 return count;
|
|
6060 }
|
|
6061 }
|
|
6062
|
|
6063
|
|
6064 /**
|
|
6065 * @brief Get one tag in a C-Find query.
|
|
6066 *
|
|
6067 * This function returns the group and the element of one DICOM tag
|
|
6068 * in the given C-Find query.
|
|
6069 *
|
|
6070 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6071 * @param group The group of the tag (output).
|
|
6072 * @param element The element of the tag (output).
|
|
6073 * @param query The C-Find query.
|
|
6074 * @param index The index of the tag of interest.
|
|
6075 * @return 0 if success, other value if error.
|
|
6076 * @ingroup DicomCallbacks
|
|
6077 **/
|
|
6078 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetFindQueryTag(
|
|
6079 OrthancPluginContext* context,
|
|
6080 uint16_t* group,
|
|
6081 uint16_t* element,
|
|
6082 const OrthancPluginFindQuery* query,
|
|
6083 uint32_t index)
|
|
6084 {
|
|
6085 _OrthancPluginFindOperation params;
|
|
6086 memset(¶ms, 0, sizeof(params));
|
|
6087 params.query = query;
|
|
6088 params.index = index;
|
|
6089 params.resultGroup = group;
|
|
6090 params.resultElement = element;
|
|
6091
|
|
6092 return context->InvokeService(context, _OrthancPluginService_GetFindQueryTag, ¶ms);
|
|
6093 }
|
|
6094
|
|
6095
|
|
6096 /**
|
|
6097 * @brief Get the symbolic name of one tag in a C-Find query.
|
|
6098 *
|
|
6099 * This function returns the symbolic name of one DICOM tag in the
|
|
6100 * given C-Find query.
|
|
6101 *
|
|
6102 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6103 * @param query The C-Find query.
|
|
6104 * @param index The index of the tag of interest.
|
|
6105 * @return The NULL value in case of error, or a string containing the name of the tag.
|
|
6106 * @return 0 if success, other value if error.
|
|
6107 * @ingroup DicomCallbacks
|
|
6108 **/
|
|
6109 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetFindQueryTagName(
|
|
6110 OrthancPluginContext* context,
|
|
6111 const OrthancPluginFindQuery* query,
|
|
6112 uint32_t index)
|
|
6113 {
|
|
6114 char* result;
|
|
6115
|
|
6116 _OrthancPluginFindOperation params;
|
|
6117 memset(¶ms, 0, sizeof(params));
|
|
6118 params.query = query;
|
|
6119 params.index = index;
|
|
6120 params.resultString = &result;
|
|
6121
|
|
6122 if (context->InvokeService(context, _OrthancPluginService_GetFindQueryTagName, ¶ms) != OrthancPluginErrorCode_Success)
|
|
6123 {
|
|
6124 /* Error */
|
|
6125 return NULL;
|
|
6126 }
|
|
6127 else
|
|
6128 {
|
|
6129 return result;
|
|
6130 }
|
|
6131 }
|
|
6132
|
|
6133
|
|
6134 /**
|
|
6135 * @brief Get the value associated with one tag in a C-Find query.
|
|
6136 *
|
|
6137 * This function returns the value associated with one tag in the
|
|
6138 * given C-Find query.
|
|
6139 *
|
|
6140 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6141 * @param query The C-Find query.
|
|
6142 * @param index The index of the tag of interest.
|
|
6143 * @return The NULL value in case of error, or a string containing the value of the tag.
|
|
6144 * @return 0 if success, other value if error.
|
|
6145 * @ingroup DicomCallbacks
|
|
6146 **/
|
|
6147 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetFindQueryValue(
|
|
6148 OrthancPluginContext* context,
|
|
6149 const OrthancPluginFindQuery* query,
|
|
6150 uint32_t index)
|
|
6151 {
|
|
6152 char* result;
|
|
6153
|
|
6154 _OrthancPluginFindOperation params;
|
|
6155 memset(¶ms, 0, sizeof(params));
|
|
6156 params.query = query;
|
|
6157 params.index = index;
|
|
6158 params.resultString = &result;
|
|
6159
|
|
6160 if (context->InvokeService(context, _OrthancPluginService_GetFindQueryValue, ¶ms) != OrthancPluginErrorCode_Success)
|
|
6161 {
|
|
6162 /* Error */
|
|
6163 return NULL;
|
|
6164 }
|
|
6165 else
|
|
6166 {
|
|
6167 return result;
|
|
6168 }
|
|
6169 }
|
|
6170
|
|
6171
|
|
6172
|
|
6173
|
|
6174 typedef struct
|
|
6175 {
|
|
6176 OrthancPluginMoveCallback callback;
|
|
6177 OrthancPluginGetMoveSize getMoveSize;
|
|
6178 OrthancPluginApplyMove applyMove;
|
|
6179 OrthancPluginFreeMove freeMove;
|
|
6180 } _OrthancPluginMoveCallback;
|
|
6181
|
|
6182 /**
|
|
6183 * @brief Register a callback to handle C-Move requests.
|
|
6184 *
|
|
6185 * This function registers a callback to handle C-Move SCP requests.
|
|
6186 *
|
|
6187 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6188 * @param callback The main callback.
|
|
6189 * @param getMoveSize Callback to read the number of C-Move suboperations.
|
|
6190 * @param applyMove Callback to apply one C-Move suboperation.
|
|
6191 * @param freeMove Callback to free the C-Move driver.
|
|
6192 * @return 0 if success, other value if error.
|
|
6193 * @ingroup DicomCallbacks
|
|
6194 **/
|
|
6195 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterMoveCallback(
|
|
6196 OrthancPluginContext* context,
|
|
6197 OrthancPluginMoveCallback callback,
|
|
6198 OrthancPluginGetMoveSize getMoveSize,
|
|
6199 OrthancPluginApplyMove applyMove,
|
|
6200 OrthancPluginFreeMove freeMove)
|
|
6201 {
|
|
6202 _OrthancPluginMoveCallback params;
|
|
6203 params.callback = callback;
|
|
6204 params.getMoveSize = getMoveSize;
|
|
6205 params.applyMove = applyMove;
|
|
6206 params.freeMove = freeMove;
|
|
6207
|
|
6208 return context->InvokeService(context, _OrthancPluginService_RegisterMoveCallback, ¶ms);
|
|
6209 }
|
|
6210
|
|
6211
|
|
6212
|
|
6213 typedef struct
|
|
6214 {
|
|
6215 OrthancPluginFindMatcher** target;
|
|
6216 const void* query;
|
|
6217 uint32_t size;
|
|
6218 } _OrthancPluginCreateFindMatcher;
|
|
6219
|
|
6220
|
|
6221 /**
|
|
6222 * @brief Create a C-Find matcher.
|
|
6223 *
|
|
6224 * This function creates a "matcher" object that can be used to
|
|
6225 * check whether a DICOM instance matches a C-Find query. The C-Find
|
|
6226 * query must be expressed as a DICOM buffer.
|
|
6227 *
|
|
6228 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6229 * @param query The C-Find DICOM query.
|
|
6230 * @param size The size of the DICOM query.
|
|
6231 * @return The newly allocated matcher. It must be freed with OrthancPluginFreeFindMatcher().
|
|
6232 * @ingroup Toolbox
|
|
6233 **/
|
|
6234 ORTHANC_PLUGIN_INLINE OrthancPluginFindMatcher* OrthancPluginCreateFindMatcher(
|
|
6235 OrthancPluginContext* context,
|
|
6236 const void* query,
|
|
6237 uint32_t size)
|
|
6238 {
|
|
6239 OrthancPluginFindMatcher* target = NULL;
|
|
6240
|
|
6241 _OrthancPluginCreateFindMatcher params;
|
|
6242 memset(¶ms, 0, sizeof(params));
|
|
6243 params.target = ⌖
|
|
6244 params.query = query;
|
|
6245 params.size = size;
|
|
6246
|
|
6247 if (context->InvokeService(context, _OrthancPluginService_CreateFindMatcher, ¶ms) != OrthancPluginErrorCode_Success)
|
|
6248 {
|
|
6249 return NULL;
|
|
6250 }
|
|
6251 else
|
|
6252 {
|
|
6253 return target;
|
|
6254 }
|
|
6255 }
|
|
6256
|
|
6257
|
|
6258 typedef struct
|
|
6259 {
|
|
6260 OrthancPluginFindMatcher* matcher;
|
|
6261 } _OrthancPluginFreeFindMatcher;
|
|
6262
|
|
6263 /**
|
|
6264 * @brief Free a C-Find matcher.
|
|
6265 *
|
|
6266 * This function frees a matcher that was created using OrthancPluginCreateFindMatcher().
|
|
6267 *
|
|
6268 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6269 * @param matcher The matcher of interest.
|
|
6270 * @ingroup Toolbox
|
|
6271 **/
|
|
6272 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeFindMatcher(
|
|
6273 OrthancPluginContext* context,
|
|
6274 OrthancPluginFindMatcher* matcher)
|
|
6275 {
|
|
6276 _OrthancPluginFreeFindMatcher params;
|
|
6277 params.matcher = matcher;
|
|
6278
|
|
6279 context->InvokeService(context, _OrthancPluginService_FreeFindMatcher, ¶ms);
|
|
6280 }
|
|
6281
|
|
6282
|
|
6283 typedef struct
|
|
6284 {
|
|
6285 const OrthancPluginFindMatcher* matcher;
|
|
6286 const void* dicom;
|
|
6287 uint32_t size;
|
|
6288 int32_t* isMatch;
|
|
6289 } _OrthancPluginFindMatcherIsMatch;
|
|
6290
|
|
6291 /**
|
|
6292 * @brief Test whether a DICOM instance matches a C-Find query.
|
|
6293 *
|
|
6294 * This function checks whether one DICOM instance matches C-Find
|
|
6295 * matcher that was previously allocated using
|
|
6296 * OrthancPluginCreateFindMatcher().
|
|
6297 *
|
|
6298 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6299 * @param matcher The matcher of interest.
|
|
6300 * @param dicom The DICOM instance to be matched.
|
|
6301 * @param size The size of the DICOM instance.
|
|
6302 * @return 1 if the DICOM instance matches the query, 0 otherwise.
|
|
6303 * @ingroup Toolbox
|
|
6304 **/
|
|
6305 ORTHANC_PLUGIN_INLINE int32_t OrthancPluginFindMatcherIsMatch(
|
|
6306 OrthancPluginContext* context,
|
|
6307 const OrthancPluginFindMatcher* matcher,
|
|
6308 const void* dicom,
|
|
6309 uint32_t size)
|
|
6310 {
|
|
6311 int32_t isMatch = 0;
|
|
6312
|
|
6313 _OrthancPluginFindMatcherIsMatch params;
|
|
6314 params.matcher = matcher;
|
|
6315 params.dicom = dicom;
|
|
6316 params.size = size;
|
|
6317 params.isMatch = &isMatch;
|
|
6318
|
|
6319 if (context->InvokeService(context, _OrthancPluginService_FindMatcherIsMatch, ¶ms) == OrthancPluginErrorCode_Success)
|
|
6320 {
|
|
6321 return isMatch;
|
|
6322 }
|
|
6323 else
|
|
6324 {
|
|
6325 /* Error: Assume non-match */
|
|
6326 return 0;
|
|
6327 }
|
|
6328 }
|
|
6329
|
|
6330
|
|
6331 typedef struct
|
|
6332 {
|
|
6333 OrthancPluginIncomingHttpRequestFilter2 callback;
|
|
6334 } _OrthancPluginIncomingHttpRequestFilter2;
|
|
6335
|
|
6336 /**
|
|
6337 * @brief Register a callback to filter incoming HTTP requests.
|
|
6338 *
|
|
6339 * This function registers a custom callback to filter incoming HTTP/REST
|
|
6340 * requests received by the HTTP server of Orthanc.
|
|
6341 *
|
|
6342 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6343 * @param callback The callback.
|
|
6344 * @return 0 if success, other value if error.
|
|
6345 * @ingroup Callbacks
|
|
6346 **/
|
|
6347 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingHttpRequestFilter2(
|
|
6348 OrthancPluginContext* context,
|
|
6349 OrthancPluginIncomingHttpRequestFilter2 callback)
|
|
6350 {
|
|
6351 _OrthancPluginIncomingHttpRequestFilter2 params;
|
|
6352 params.callback = callback;
|
|
6353
|
|
6354 return context->InvokeService(context, _OrthancPluginService_RegisterIncomingHttpRequestFilter2, ¶ms);
|
|
6355 }
|
|
6356
|
|
6357
|
|
6358
|
|
6359 typedef struct
|
|
6360 {
|
|
6361 OrthancPluginPeers** peers;
|
|
6362 } _OrthancPluginGetPeers;
|
|
6363
|
|
6364 /**
|
|
6365 * @brief Return the list of available Orthanc peers.
|
|
6366 *
|
|
6367 * This function returns the parameters of the Orthanc peers that are known to
|
|
6368 * the Orthanc server hosting the plugin.
|
|
6369 *
|
|
6370 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6371 * @return NULL if error, or a newly allocated opaque data structure containing the peers.
|
|
6372 * This structure must be freed with OrthancPluginFreePeers().
|
|
6373 * @ingroup Toolbox
|
|
6374 **/
|
|
6375 ORTHANC_PLUGIN_INLINE OrthancPluginPeers* OrthancPluginGetPeers(
|
|
6376 OrthancPluginContext* context)
|
|
6377 {
|
|
6378 OrthancPluginPeers* peers = NULL;
|
|
6379
|
|
6380 _OrthancPluginGetPeers params;
|
|
6381 memset(¶ms, 0, sizeof(params));
|
|
6382 params.peers = &peers;
|
|
6383
|
|
6384 if (context->InvokeService(context, _OrthancPluginService_GetPeers, ¶ms) != OrthancPluginErrorCode_Success)
|
|
6385 {
|
|
6386 return NULL;
|
|
6387 }
|
|
6388 else
|
|
6389 {
|
|
6390 return peers;
|
|
6391 }
|
|
6392 }
|
|
6393
|
|
6394
|
|
6395 typedef struct
|
|
6396 {
|
|
6397 OrthancPluginPeers* peers;
|
|
6398 } _OrthancPluginFreePeers;
|
|
6399
|
|
6400 /**
|
|
6401 * @brief Free the list of available Orthanc peers.
|
|
6402 *
|
|
6403 * This function frees the data structure returned by OrthancPluginGetPeers().
|
|
6404 *
|
|
6405 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6406 * @param peers The data structure describing the Orthanc peers.
|
|
6407 * @ingroup Toolbox
|
|
6408 **/
|
|
6409 ORTHANC_PLUGIN_INLINE void OrthancPluginFreePeers(
|
|
6410 OrthancPluginContext* context,
|
|
6411 OrthancPluginPeers* peers)
|
|
6412 {
|
|
6413 _OrthancPluginFreePeers params;
|
|
6414 params.peers = peers;
|
|
6415
|
|
6416 context->InvokeService(context, _OrthancPluginService_FreePeers, ¶ms);
|
|
6417 }
|
|
6418
|
|
6419
|
|
6420 typedef struct
|
|
6421 {
|
|
6422 uint32_t* target;
|
|
6423 const OrthancPluginPeers* peers;
|
|
6424 } _OrthancPluginGetPeersCount;
|
|
6425
|
|
6426 /**
|
|
6427 * @brief Get the number of Orthanc peers.
|
|
6428 *
|
|
6429 * This function returns the number of Orthanc peers.
|
|
6430 *
|
|
6431 * This function is thread-safe: Several threads sharing the same
|
|
6432 * OrthancPluginPeers object can simultaneously call this function.
|
|
6433 *
|
|
6434 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6435 * @param peers The data structure describing the Orthanc peers.
|
|
6436 * @result The number of peers.
|
|
6437 * @ingroup Toolbox
|
|
6438 **/
|
|
6439 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetPeersCount(
|
|
6440 OrthancPluginContext* context,
|
|
6441 const OrthancPluginPeers* peers)
|
|
6442 {
|
|
6443 uint32_t target = 0;
|
|
6444
|
|
6445 _OrthancPluginGetPeersCount params;
|
|
6446 memset(¶ms, 0, sizeof(params));
|
|
6447 params.target = ⌖
|
|
6448 params.peers = peers;
|
|
6449
|
|
6450 if (context->InvokeService(context, _OrthancPluginService_GetPeersCount, ¶ms) != OrthancPluginErrorCode_Success)
|
|
6451 {
|
|
6452 /* Error */
|
|
6453 return 0;
|
|
6454 }
|
|
6455 else
|
|
6456 {
|
|
6457 return target;
|
|
6458 }
|
|
6459 }
|
|
6460
|
|
6461
|
|
6462 typedef struct
|
|
6463 {
|
|
6464 const char** target;
|
|
6465 const OrthancPluginPeers* peers;
|
|
6466 uint32_t peerIndex;
|
|
6467 const char* userProperty;
|
|
6468 } _OrthancPluginGetPeerProperty;
|
|
6469
|
|
6470 /**
|
|
6471 * @brief Get the symbolic name of an Orthanc peer.
|
|
6472 *
|
|
6473 * This function returns the symbolic name of the Orthanc peer,
|
|
6474 * which corresponds to the key of the "OrthancPeers" configuration
|
|
6475 * option of Orthanc.
|
|
6476 *
|
|
6477 * This function is thread-safe: Several threads sharing the same
|
|
6478 * OrthancPluginPeers object can simultaneously call this function.
|
|
6479 *
|
|
6480 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6481 * @param peers The data structure describing the Orthanc peers.
|
|
6482 * @param peerIndex The index of the peer of interest.
|
|
6483 * This value must be lower than OrthancPluginGetPeersCount().
|
|
6484 * @result The symbolic name, or NULL in the case of an error.
|
|
6485 * @ingroup Toolbox
|
|
6486 **/
|
|
6487 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerName(
|
|
6488 OrthancPluginContext* context,
|
|
6489 const OrthancPluginPeers* peers,
|
|
6490 uint32_t peerIndex)
|
|
6491 {
|
|
6492 const char* target = NULL;
|
|
6493
|
|
6494 _OrthancPluginGetPeerProperty params;
|
|
6495 memset(¶ms, 0, sizeof(params));
|
|
6496 params.target = ⌖
|
|
6497 params.peers = peers;
|
|
6498 params.peerIndex = peerIndex;
|
|
6499 params.userProperty = NULL;
|
|
6500
|
|
6501 if (context->InvokeService(context, _OrthancPluginService_GetPeerName, ¶ms) != OrthancPluginErrorCode_Success)
|
|
6502 {
|
|
6503 /* Error */
|
|
6504 return NULL;
|
|
6505 }
|
|
6506 else
|
|
6507 {
|
|
6508 return target;
|
|
6509 }
|
|
6510 }
|
|
6511
|
|
6512
|
|
6513 /**
|
|
6514 * @brief Get the base URL of an Orthanc peer.
|
|
6515 *
|
|
6516 * This function returns the base URL to the REST API of some Orthanc peer.
|
|
6517 *
|
|
6518 * This function is thread-safe: Several threads sharing the same
|
|
6519 * OrthancPluginPeers object can simultaneously call this function.
|
|
6520 *
|
|
6521 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6522 * @param peers The data structure describing the Orthanc peers.
|
|
6523 * @param peerIndex The index of the peer of interest.
|
|
6524 * This value must be lower than OrthancPluginGetPeersCount().
|
|
6525 * @result The URL, or NULL in the case of an error.
|
|
6526 * @ingroup Toolbox
|
|
6527 **/
|
|
6528 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerUrl(
|
|
6529 OrthancPluginContext* context,
|
|
6530 const OrthancPluginPeers* peers,
|
|
6531 uint32_t peerIndex)
|
|
6532 {
|
|
6533 const char* target = NULL;
|
|
6534
|
|
6535 _OrthancPluginGetPeerProperty params;
|
|
6536 memset(¶ms, 0, sizeof(params));
|
|
6537 params.target = ⌖
|
|
6538 params.peers = peers;
|
|
6539 params.peerIndex = peerIndex;
|
|
6540 params.userProperty = NULL;
|
|
6541
|
|
6542 if (context->InvokeService(context, _OrthancPluginService_GetPeerUrl, ¶ms) != OrthancPluginErrorCode_Success)
|
|
6543 {
|
|
6544 /* Error */
|
|
6545 return NULL;
|
|
6546 }
|
|
6547 else
|
|
6548 {
|
|
6549 return target;
|
|
6550 }
|
|
6551 }
|
|
6552
|
|
6553
|
|
6554
|
|
6555 /**
|
|
6556 * @brief Get some user-defined property of an Orthanc peer.
|
|
6557 *
|
|
6558 * This function returns some user-defined property of some Orthanc
|
|
6559 * peer. An user-defined property is a property that is associated
|
|
6560 * with the peer in the Orthanc configuration file, but that is not
|
|
6561 * recognized by the Orthanc core.
|
|
6562 *
|
|
6563 * This function is thread-safe: Several threads sharing the same
|
|
6564 * OrthancPluginPeers object can simultaneously call this function.
|
|
6565 *
|
|
6566 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6567 * @param peers The data structure describing the Orthanc peers.
|
|
6568 * @param peerIndex The index of the peer of interest.
|
|
6569 * This value must be lower than OrthancPluginGetPeersCount().
|
|
6570 * @param userProperty The user property of interest.
|
|
6571 * @result The value of the user property, or NULL if it is not defined.
|
|
6572 * @ingroup Toolbox
|
|
6573 **/
|
|
6574 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerUserProperty(
|
|
6575 OrthancPluginContext* context,
|
|
6576 const OrthancPluginPeers* peers,
|
|
6577 uint32_t peerIndex,
|
|
6578 const char* userProperty)
|
|
6579 {
|
|
6580 const char* target = NULL;
|
|
6581
|
|
6582 _OrthancPluginGetPeerProperty params;
|
|
6583 memset(¶ms, 0, sizeof(params));
|
|
6584 params.target = ⌖
|
|
6585 params.peers = peers;
|
|
6586 params.peerIndex = peerIndex;
|
|
6587 params.userProperty = userProperty;
|
|
6588
|
|
6589 if (context->InvokeService(context, _OrthancPluginService_GetPeerUserProperty, ¶ms) != OrthancPluginErrorCode_Success)
|
|
6590 {
|
|
6591 /* No such user property */
|
|
6592 return NULL;
|
|
6593 }
|
|
6594 else
|
|
6595 {
|
|
6596 return target;
|
|
6597 }
|
|
6598 }
|
|
6599
|
|
6600
|
|
6601
|
|
6602 typedef struct
|
|
6603 {
|
|
6604 OrthancPluginMemoryBuffer* answerBody;
|
|
6605 OrthancPluginMemoryBuffer* answerHeaders;
|
|
6606 uint16_t* httpStatus;
|
|
6607 const OrthancPluginPeers* peers;
|
|
6608 uint32_t peerIndex;
|
|
6609 OrthancPluginHttpMethod method;
|
|
6610 const char* uri;
|
|
6611 uint32_t additionalHeadersCount;
|
|
6612 const char* const* additionalHeadersKeys;
|
|
6613 const char* const* additionalHeadersValues;
|
|
6614 const void* body;
|
|
6615 uint32_t bodySize;
|
|
6616 uint32_t timeout;
|
|
6617 } _OrthancPluginCallPeerApi;
|
|
6618
|
|
6619 /**
|
|
6620 * @brief Call the REST API of an Orthanc peer.
|
|
6621 *
|
|
6622 * Make a REST call to the given URI in the REST API of a remote
|
|
6623 * Orthanc peer. The result to the query is stored into a newly
|
|
6624 * allocated memory buffer. The HTTP request will be done according
|
|
6625 * to the "OrthancPeers" configuration option of Orthanc.
|
|
6626 *
|
|
6627 * This function is thread-safe: Several threads sharing the same
|
|
6628 * OrthancPluginPeers object can simultaneously call this function.
|
|
6629 *
|
|
6630 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6631 * @param answerBody The target memory buffer (out argument).
|
|
6632 * It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
6633 * The value of this argument is ignored if the HTTP method is DELETE.
|
|
6634 * @param answerHeaders The target memory buffer for the HTTP headers in the answers (out argument).
|
|
6635 * The answer headers are formatted as a JSON object (associative array).
|
|
6636 * The buffer must be freed with OrthancPluginFreeMemoryBuffer().
|
|
6637 * This argument can be set to NULL if the plugin has no interest in the HTTP headers.
|
|
6638 * @param httpStatus The HTTP status after the execution of the request (out argument).
|
|
6639 * @param peers The data structure describing the Orthanc peers.
|
|
6640 * @param peerIndex The index of the peer of interest.
|
|
6641 * This value must be lower than OrthancPluginGetPeersCount().
|
|
6642 * @param method HTTP method to be used.
|
|
6643 * @param uri The URI of interest in the REST API.
|
|
6644 * @param additionalHeadersCount The number of HTTP headers to be added to the
|
|
6645 * HTTP headers provided in the global configuration of Orthanc.
|
|
6646 * @param additionalHeadersKeys Array containing the keys of the HTTP headers (can be <tt>NULL</tt> if no header).
|
|
6647 * @param additionalHeadersValues Array containing the values of the HTTP headers (can be <tt>NULL</tt> if no header).
|
|
6648 * @param body The HTTP body for a POST or PUT request.
|
|
6649 * @param bodySize The size of the body.
|
|
6650 * @param timeout Timeout in seconds (0 for default timeout).
|
|
6651 * @return 0 if success, or the error code if failure.
|
|
6652 * @see OrthancPluginHttpClient()
|
|
6653 * @ingroup Toolbox
|
|
6654 **/
|
|
6655 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCallPeerApi(
|
|
6656 OrthancPluginContext* context,
|
|
6657 OrthancPluginMemoryBuffer* answerBody,
|
|
6658 OrthancPluginMemoryBuffer* answerHeaders,
|
|
6659 uint16_t* httpStatus,
|
|
6660 const OrthancPluginPeers* peers,
|
|
6661 uint32_t peerIndex,
|
|
6662 OrthancPluginHttpMethod method,
|
|
6663 const char* uri,
|
|
6664 uint32_t additionalHeadersCount,
|
|
6665 const char* const* additionalHeadersKeys,
|
|
6666 const char* const* additionalHeadersValues,
|
|
6667 const void* body,
|
|
6668 uint32_t bodySize,
|
|
6669 uint32_t timeout)
|
|
6670 {
|
|
6671 _OrthancPluginCallPeerApi params;
|
|
6672 memset(¶ms, 0, sizeof(params));
|
|
6673
|
|
6674 params.answerBody = answerBody;
|
|
6675 params.answerHeaders = answerHeaders;
|
|
6676 params.httpStatus = httpStatus;
|
|
6677 params.peers = peers;
|
|
6678 params.peerIndex = peerIndex;
|
|
6679 params.method = method;
|
|
6680 params.uri = uri;
|
|
6681 params.additionalHeadersCount = additionalHeadersCount;
|
|
6682 params.additionalHeadersKeys = additionalHeadersKeys;
|
|
6683 params.additionalHeadersValues = additionalHeadersValues;
|
|
6684 params.body = body;
|
|
6685 params.bodySize = bodySize;
|
|
6686 params.timeout = timeout;
|
|
6687
|
|
6688 return context->InvokeService(context, _OrthancPluginService_CallPeerApi, ¶ms);
|
|
6689 }
|
|
6690
|
|
6691
|
|
6692
|
|
6693
|
|
6694
|
|
6695 typedef struct
|
|
6696 {
|
|
6697 OrthancPluginJob** target;
|
|
6698 void *job;
|
|
6699 OrthancPluginJobFinalize finalize;
|
|
6700 const char *type;
|
|
6701 OrthancPluginJobGetProgress getProgress;
|
|
6702 OrthancPluginJobGetContent getContent;
|
|
6703 OrthancPluginJobGetSerialized getSerialized;
|
|
6704 OrthancPluginJobStep step;
|
|
6705 OrthancPluginJobStop stop;
|
|
6706 OrthancPluginJobReset reset;
|
|
6707 } _OrthancPluginCreateJob;
|
|
6708
|
|
6709 /**
|
|
6710 * @brief Create a custom job.
|
|
6711 *
|
|
6712 * This function creates a custom job to be run by the jobs engine
|
|
6713 * of Orthanc.
|
|
6714 *
|
|
6715 * Orthanc starts one dedicated thread per custom job that is
|
|
6716 * running. It is guaranteed that all the callbacks will only be
|
|
6717 * called from this single dedicated thread, in mutual exclusion: As
|
|
6718 * a consequence, it is *not* mandatory to protect the various
|
|
6719 * callbacks by mutexes.
|
|
6720 *
|
|
6721 * The custom job can nonetheless launch its own processing threads
|
|
6722 * on the first call to the "step()" callback, and stop them once
|
|
6723 * the "stop()" callback is called.
|
|
6724 *
|
|
6725 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6726 * @param job The job to be executed.
|
|
6727 * @param finalize The finalization callback.
|
|
6728 * @param type The type of the job, provided to the job unserializer.
|
|
6729 * See OrthancPluginRegisterJobsUnserializer().
|
|
6730 * @param getProgress The progress callback.
|
|
6731 * @param getContent The content callback.
|
|
6732 * @param getSerialized The serialization callback.
|
|
6733 * @param step The callback to execute the individual steps of the job.
|
|
6734 * @param stop The callback that is invoked once the job leaves the "running" state.
|
|
6735 * @param reset The callback that is invoked if a stopped job is started again.
|
|
6736 * @return The newly allocated job. It must be freed with OrthancPluginFreeJob(),
|
|
6737 * as long as it is not submitted with OrthancPluginSubmitJob().
|
|
6738 * @ingroup Toolbox
|
|
6739 * @deprecated This signature should not be used anymore since Orthanc SDK 1.11.3.
|
|
6740 **/
|
|
6741 ORTHANC_PLUGIN_INLINE OrthancPluginJob *OrthancPluginCreateJob(
|
|
6742 OrthancPluginContext *context,
|
|
6743 void *job,
|
|
6744 OrthancPluginJobFinalize finalize,
|
|
6745 const char *type,
|
|
6746 OrthancPluginJobGetProgress getProgress,
|
|
6747 OrthancPluginJobGetContent getContent,
|
|
6748 OrthancPluginJobGetSerialized getSerialized,
|
|
6749 OrthancPluginJobStep step,
|
|
6750 OrthancPluginJobStop stop,
|
|
6751 OrthancPluginJobReset reset)
|
|
6752 {
|
|
6753 OrthancPluginJob* target = NULL;
|
|
6754
|
|
6755 _OrthancPluginCreateJob params;
|
|
6756 memset(¶ms, 0, sizeof(params));
|
|
6757
|
|
6758 params.target = ⌖
|
|
6759 params.job = job;
|
|
6760 params.finalize = finalize;
|
|
6761 params.type = type;
|
|
6762 params.getProgress = getProgress;
|
|
6763 params.getContent = getContent;
|
|
6764 params.getSerialized = getSerialized;
|
|
6765 params.step = step;
|
|
6766 params.stop = stop;
|
|
6767 params.reset = reset;
|
|
6768
|
|
6769 if (context->InvokeService(context, _OrthancPluginService_CreateJob, ¶ms) != OrthancPluginErrorCode_Success ||
|
|
6770 target == NULL)
|
|
6771 {
|
|
6772 /* Error */
|
|
6773 return NULL;
|
|
6774 }
|
|
6775 else
|
|
6776 {
|
|
6777 return target;
|
|
6778 }
|
|
6779 }
|
|
6780
|
|
6781
|
|
6782 typedef struct
|
|
6783 {
|
|
6784 OrthancPluginJob** target;
|
|
6785 void *job;
|
|
6786 OrthancPluginJobFinalize finalize;
|
|
6787 const char *type;
|
|
6788 OrthancPluginJobGetProgress getProgress;
|
|
6789 OrthancPluginJobGetContent2 getContent;
|
|
6790 OrthancPluginJobGetSerialized2 getSerialized;
|
|
6791 OrthancPluginJobStep step;
|
|
6792 OrthancPluginJobStop stop;
|
|
6793 OrthancPluginJobReset reset;
|
|
6794 } _OrthancPluginCreateJob2;
|
|
6795
|
|
6796 /**
|
|
6797 * @brief Create a custom job.
|
|
6798 *
|
|
6799 * This function creates a custom job to be run by the jobs engine
|
|
6800 * of Orthanc.
|
|
6801 *
|
|
6802 * Orthanc starts one dedicated thread per custom job that is
|
|
6803 * running. It is guaranteed that all the callbacks will only be
|
|
6804 * called from this single dedicated thread, in mutual exclusion: As
|
|
6805 * a consequence, it is *not* mandatory to protect the various
|
|
6806 * callbacks by mutexes.
|
|
6807 *
|
|
6808 * The custom job can nonetheless launch its own processing threads
|
|
6809 * on the first call to the "step()" callback, and stop them once
|
|
6810 * the "stop()" callback is called.
|
|
6811 *
|
|
6812 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6813 * @param job The job to be executed.
|
|
6814 * @param finalize The finalization callback.
|
|
6815 * @param type The type of the job, provided to the job unserializer.
|
|
6816 * See OrthancPluginRegisterJobsUnserializer().
|
|
6817 * @param getProgress The progress callback.
|
|
6818 * @param getContent The content callback.
|
|
6819 * @param getSerialized The serialization callback.
|
|
6820 * @param step The callback to execute the individual steps of the job.
|
|
6821 * @param stop The callback that is invoked once the job leaves the "running" state.
|
|
6822 * @param reset The callback that is invoked if a stopped job is started again.
|
|
6823 * @return The newly allocated job. It must be freed with OrthancPluginFreeJob(),
|
|
6824 * as long as it is not submitted with OrthancPluginSubmitJob().
|
|
6825 * @ingroup Toolbox
|
|
6826 **/
|
|
6827 ORTHANC_PLUGIN_INLINE OrthancPluginJob *OrthancPluginCreateJob2(
|
|
6828 OrthancPluginContext *context,
|
|
6829 void *job,
|
|
6830 OrthancPluginJobFinalize finalize,
|
|
6831 const char *type,
|
|
6832 OrthancPluginJobGetProgress getProgress,
|
|
6833 OrthancPluginJobGetContent2 getContent,
|
|
6834 OrthancPluginJobGetSerialized2 getSerialized,
|
|
6835 OrthancPluginJobStep step,
|
|
6836 OrthancPluginJobStop stop,
|
|
6837 OrthancPluginJobReset reset)
|
|
6838 {
|
|
6839 OrthancPluginJob* target = NULL;
|
|
6840
|
|
6841 _OrthancPluginCreateJob2 params;
|
|
6842 memset(¶ms, 0, sizeof(params));
|
|
6843
|
|
6844 params.target = ⌖
|
|
6845 params.job = job;
|
|
6846 params.finalize = finalize;
|
|
6847 params.type = type;
|
|
6848 params.getProgress = getProgress;
|
|
6849 params.getContent = getContent;
|
|
6850 params.getSerialized = getSerialized;
|
|
6851 params.step = step;
|
|
6852 params.stop = stop;
|
|
6853 params.reset = reset;
|
|
6854
|
|
6855 if (context->InvokeService(context, _OrthancPluginService_CreateJob2, ¶ms) != OrthancPluginErrorCode_Success ||
|
|
6856 target == NULL)
|
|
6857 {
|
|
6858 /* Error */
|
|
6859 return NULL;
|
|
6860 }
|
|
6861 else
|
|
6862 {
|
|
6863 return target;
|
|
6864 }
|
|
6865 }
|
|
6866
|
|
6867
|
|
6868 typedef struct
|
|
6869 {
|
|
6870 OrthancPluginJob* job;
|
|
6871 } _OrthancPluginFreeJob;
|
|
6872
|
|
6873 /**
|
|
6874 * @brief Free a custom job.
|
|
6875 *
|
|
6876 * This function frees an image that was created with OrthancPluginCreateJob().
|
|
6877 *
|
|
6878 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6879 * @param job The job.
|
|
6880 * @ingroup Toolbox
|
|
6881 **/
|
|
6882 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeJob(
|
|
6883 OrthancPluginContext* context,
|
|
6884 OrthancPluginJob* job)
|
|
6885 {
|
|
6886 _OrthancPluginFreeJob params;
|
|
6887 params.job = job;
|
|
6888
|
|
6889 context->InvokeService(context, _OrthancPluginService_FreeJob, ¶ms);
|
|
6890 }
|
|
6891
|
|
6892
|
|
6893
|
|
6894 typedef struct
|
|
6895 {
|
|
6896 char** resultId;
|
|
6897 OrthancPluginJob *job;
|
|
6898 int priority;
|
|
6899 } _OrthancPluginSubmitJob;
|
|
6900
|
|
6901 /**
|
|
6902 * @brief Submit a new job to the jobs engine of Orthanc.
|
|
6903 *
|
|
6904 * This function adds the given job to the pending jobs of
|
|
6905 * Orthanc. Orthanc will take take of freeing it by invoking the
|
|
6906 * finalization callback provided to OrthancPluginCreateJob().
|
|
6907 *
|
|
6908 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6909 * @param job The job, as received by OrthancPluginCreateJob().
|
|
6910 * @param priority The priority of the job.
|
|
6911 * @return ID of the newly-submitted job. This string must be freed by OrthancPluginFreeString().
|
|
6912 * @ingroup Toolbox
|
|
6913 **/
|
|
6914 ORTHANC_PLUGIN_INLINE char *OrthancPluginSubmitJob(
|
|
6915 OrthancPluginContext *context,
|
|
6916 OrthancPluginJob *job,
|
|
6917 int priority)
|
|
6918 {
|
|
6919 char* resultId = NULL;
|
|
6920
|
|
6921 _OrthancPluginSubmitJob params;
|
|
6922 memset(¶ms, 0, sizeof(params));
|
|
6923
|
|
6924 params.resultId = &resultId;
|
|
6925 params.job = job;
|
|
6926 params.priority = priority;
|
|
6927
|
|
6928 if (context->InvokeService(context, _OrthancPluginService_SubmitJob, ¶ms) != OrthancPluginErrorCode_Success ||
|
|
6929 resultId == NULL)
|
|
6930 {
|
|
6931 /* Error */
|
|
6932 return NULL;
|
|
6933 }
|
|
6934 else
|
|
6935 {
|
|
6936 return resultId;
|
|
6937 }
|
|
6938 }
|
|
6939
|
|
6940
|
|
6941
|
|
6942 typedef struct
|
|
6943 {
|
|
6944 OrthancPluginJobsUnserializer unserializer;
|
|
6945 } _OrthancPluginJobsUnserializer;
|
|
6946
|
|
6947 /**
|
|
6948 * @brief Register an unserializer for custom jobs.
|
|
6949 *
|
|
6950 * This function registers an unserializer that decodes custom jobs
|
|
6951 * from a JSON string. This callback is invoked when the jobs engine
|
|
6952 * of Orthanc is started (on Orthanc initialization), for each job
|
|
6953 * that is stored in the Orthanc database.
|
|
6954 *
|
|
6955 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6956 * @param unserializer The job unserializer.
|
|
6957 * @ingroup Callbacks
|
|
6958 **/
|
|
6959 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterJobsUnserializer(
|
|
6960 OrthancPluginContext* context,
|
|
6961 OrthancPluginJobsUnserializer unserializer)
|
|
6962 {
|
|
6963 _OrthancPluginJobsUnserializer params;
|
|
6964 params.unserializer = unserializer;
|
|
6965
|
|
6966 context->InvokeService(context, _OrthancPluginService_RegisterJobsUnserializer, ¶ms);
|
|
6967 }
|
|
6968
|
|
6969
|
|
6970
|
|
6971 typedef struct
|
|
6972 {
|
|
6973 OrthancPluginRestOutput* output;
|
|
6974 const char* details;
|
|
6975 uint8_t log;
|
|
6976 } _OrthancPluginSetHttpErrorDetails;
|
|
6977
|
|
6978 /**
|
|
6979 * @brief Provide a detailed description for an HTTP error.
|
|
6980 *
|
|
6981 * This function sets the detailed description associated with an
|
|
6982 * HTTP error. This description will be displayed in the "Details"
|
|
6983 * field of the JSON body of the HTTP answer. It is only taken into
|
|
6984 * consideration if the REST callback returns an error code that is
|
|
6985 * different from "OrthancPluginErrorCode_Success", and if the
|
|
6986 * "HttpDescribeErrors" configuration option of Orthanc is set to
|
|
6987 * "true".
|
|
6988 *
|
|
6989 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
6990 * @param output The HTTP connection to the client application.
|
|
6991 * @param details The details of the error message.
|
|
6992 * @param log Whether to also write the detailed error to the Orthanc logs.
|
|
6993 * @ingroup REST
|
|
6994 **/
|
|
6995 ORTHANC_PLUGIN_INLINE void OrthancPluginSetHttpErrorDetails(
|
|
6996 OrthancPluginContext* context,
|
|
6997 OrthancPluginRestOutput* output,
|
|
6998 const char* details,
|
|
6999 uint8_t log)
|
|
7000 {
|
|
7001 _OrthancPluginSetHttpErrorDetails params;
|
|
7002 params.output = output;
|
|
7003 params.details = details;
|
|
7004 params.log = log;
|
|
7005 context->InvokeService(context, _OrthancPluginService_SetHttpErrorDetails, ¶ms);
|
|
7006 }
|
|
7007
|
|
7008
|
|
7009
|
|
7010 typedef struct
|
|
7011 {
|
|
7012 const char** result;
|
|
7013 const char* argument;
|
|
7014 } _OrthancPluginRetrieveStaticString;
|
|
7015
|
|
7016 /**
|
|
7017 * @brief Detect the MIME type of a file.
|
|
7018 *
|
|
7019 * This function returns the MIME type of a file by inspecting its extension.
|
|
7020 *
|
|
7021 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7022 * @param path Path to the file.
|
|
7023 * @return The MIME type. This is a statically-allocated
|
|
7024 * string, do not free it.
|
|
7025 * @ingroup Toolbox
|
|
7026 **/
|
|
7027 ORTHANC_PLUGIN_INLINE const char* OrthancPluginAutodetectMimeType(
|
|
7028 OrthancPluginContext* context,
|
|
7029 const char* path)
|
|
7030 {
|
|
7031 const char* result = NULL;
|
|
7032
|
|
7033 _OrthancPluginRetrieveStaticString params;
|
|
7034 params.result = &result;
|
|
7035 params.argument = path;
|
|
7036
|
|
7037 if (context->InvokeService(context, _OrthancPluginService_AutodetectMimeType, ¶ms) != OrthancPluginErrorCode_Success)
|
|
7038 {
|
|
7039 /* Error */
|
|
7040 return NULL;
|
|
7041 }
|
|
7042 else
|
|
7043 {
|
|
7044 return result;
|
|
7045 }
|
|
7046 }
|
|
7047
|
|
7048
|
|
7049
|
|
7050 typedef struct
|
|
7051 {
|
|
7052 const char* name;
|
|
7053 float value;
|
|
7054 OrthancPluginMetricsType type;
|
|
7055 } _OrthancPluginSetMetricsValue;
|
|
7056
|
|
7057 /**
|
|
7058 * @brief Set the value of a metrics.
|
|
7059 *
|
|
7060 * This function sets the value of a metrics to monitor the behavior
|
|
7061 * of the plugin through tools such as Prometheus. The values of all
|
|
7062 * the metrics are stored within the Orthanc context.
|
|
7063 *
|
|
7064 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7065 * @param name The name of the metrics to be set.
|
|
7066 * @param value The value of the metrics.
|
|
7067 * @param type The type of the metrics. This parameter is only taken into consideration
|
|
7068 * the first time this metrics is set.
|
|
7069 * @ingroup Toolbox
|
|
7070 **/
|
|
7071 ORTHANC_PLUGIN_INLINE void OrthancPluginSetMetricsValue(
|
|
7072 OrthancPluginContext* context,
|
|
7073 const char* name,
|
|
7074 float value,
|
|
7075 OrthancPluginMetricsType type)
|
|
7076 {
|
|
7077 _OrthancPluginSetMetricsValue params;
|
|
7078 params.name = name;
|
|
7079 params.value = value;
|
|
7080 params.type = type;
|
|
7081 context->InvokeService(context, _OrthancPluginService_SetMetricsValue, ¶ms);
|
|
7082 }
|
|
7083
|
|
7084
|
|
7085
|
|
7086 typedef struct
|
|
7087 {
|
|
7088 OrthancPluginRefreshMetricsCallback callback;
|
|
7089 } _OrthancPluginRegisterRefreshMetricsCallback;
|
|
7090
|
|
7091 /**
|
|
7092 * @brief Register a callback to refresh the metrics.
|
|
7093 *
|
|
7094 * This function registers a callback to refresh the metrics. The
|
|
7095 * callback must make calls to OrthancPluginSetMetricsValue().
|
|
7096 *
|
|
7097 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7098 * @param callback The callback function to handle the refresh.
|
|
7099 * @ingroup Callbacks
|
|
7100 **/
|
|
7101 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRefreshMetricsCallback(
|
|
7102 OrthancPluginContext* context,
|
|
7103 OrthancPluginRefreshMetricsCallback callback)
|
|
7104 {
|
|
7105 _OrthancPluginRegisterRefreshMetricsCallback params;
|
|
7106 params.callback = callback;
|
|
7107 context->InvokeService(context, _OrthancPluginService_RegisterRefreshMetricsCallback, ¶ms);
|
|
7108 }
|
|
7109
|
|
7110
|
|
7111
|
|
7112
|
|
7113 typedef struct
|
|
7114 {
|
|
7115 char** target;
|
|
7116 const void* dicom;
|
|
7117 uint32_t dicomSize;
|
|
7118 OrthancPluginDicomWebBinaryCallback callback;
|
|
7119 } _OrthancPluginEncodeDicomWeb;
|
|
7120
|
|
7121 /**
|
|
7122 * @brief Convert a DICOM instance to DICOMweb JSON.
|
|
7123 *
|
|
7124 * This function converts a memory buffer containing a DICOM instance,
|
|
7125 * into its DICOMweb JSON representation.
|
|
7126 *
|
|
7127 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7128 * @param dicom Pointer to the DICOM instance.
|
|
7129 * @param dicomSize Size of the DICOM instance.
|
|
7130 * @param callback Callback to set the value of the binary tags.
|
|
7131 * @see OrthancPluginCreateDicom()
|
|
7132 * @return The NULL value in case of error, or the JSON document. This string must
|
|
7133 * be freed by OrthancPluginFreeString().
|
|
7134 * @deprecated OrthancPluginEncodeDicomWebJson2()
|
|
7135 * @ingroup Toolbox
|
|
7136 **/
|
|
7137 ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebJson(
|
|
7138 OrthancPluginContext* context,
|
|
7139 const void* dicom,
|
|
7140 uint32_t dicomSize,
|
|
7141 OrthancPluginDicomWebBinaryCallback callback)
|
|
7142 {
|
|
7143 char* target = NULL;
|
|
7144
|
|
7145 _OrthancPluginEncodeDicomWeb params;
|
|
7146 params.target = ⌖
|
|
7147 params.dicom = dicom;
|
|
7148 params.dicomSize = dicomSize;
|
|
7149 params.callback = callback;
|
|
7150
|
|
7151 if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebJson, ¶ms) != OrthancPluginErrorCode_Success)
|
|
7152 {
|
|
7153 /* Error */
|
|
7154 return NULL;
|
|
7155 }
|
|
7156 else
|
|
7157 {
|
|
7158 return target;
|
|
7159 }
|
|
7160 }
|
|
7161
|
|
7162
|
|
7163 /**
|
|
7164 * @brief Convert a DICOM instance to DICOMweb XML.
|
|
7165 *
|
|
7166 * This function converts a memory buffer containing a DICOM instance,
|
|
7167 * into its DICOMweb XML representation.
|
|
7168 *
|
|
7169 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7170 * @param dicom Pointer to the DICOM instance.
|
|
7171 * @param dicomSize Size of the DICOM instance.
|
|
7172 * @param callback Callback to set the value of the binary tags.
|
|
7173 * @return The NULL value in case of error, or the XML document. This string must
|
|
7174 * be freed by OrthancPluginFreeString().
|
|
7175 * @see OrthancPluginCreateDicom()
|
|
7176 * @deprecated OrthancPluginEncodeDicomWebXml2()
|
|
7177 * @ingroup Toolbox
|
|
7178 **/
|
|
7179 ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebXml(
|
|
7180 OrthancPluginContext* context,
|
|
7181 const void* dicom,
|
|
7182 uint32_t dicomSize,
|
|
7183 OrthancPluginDicomWebBinaryCallback callback)
|
|
7184 {
|
|
7185 char* target = NULL;
|
|
7186
|
|
7187 _OrthancPluginEncodeDicomWeb params;
|
|
7188 params.target = ⌖
|
|
7189 params.dicom = dicom;
|
|
7190 params.dicomSize = dicomSize;
|
|
7191 params.callback = callback;
|
|
7192
|
|
7193 if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebXml, ¶ms) != OrthancPluginErrorCode_Success)
|
|
7194 {
|
|
7195 /* Error */
|
|
7196 return NULL;
|
|
7197 }
|
|
7198 else
|
|
7199 {
|
|
7200 return target;
|
|
7201 }
|
|
7202 }
|
|
7203
|
|
7204
|
|
7205
|
|
7206 typedef struct
|
|
7207 {
|
|
7208 char** target;
|
|
7209 const void* dicom;
|
|
7210 uint32_t dicomSize;
|
|
7211 OrthancPluginDicomWebBinaryCallback2 callback;
|
|
7212 void* payload;
|
|
7213 } _OrthancPluginEncodeDicomWeb2;
|
|
7214
|
|
7215 /**
|
|
7216 * @brief Convert a DICOM instance to DICOMweb JSON.
|
|
7217 *
|
|
7218 * This function converts a memory buffer containing a DICOM instance,
|
|
7219 * into its DICOMweb JSON representation.
|
|
7220 *
|
|
7221 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7222 * @param dicom Pointer to the DICOM instance.
|
|
7223 * @param dicomSize Size of the DICOM instance.
|
|
7224 * @param callback Callback to set the value of the binary tags.
|
|
7225 * @param payload User payload.
|
|
7226 * @return The NULL value in case of error, or the JSON document. This string must
|
|
7227 * be freed by OrthancPluginFreeString().
|
|
7228 * @see OrthancPluginCreateDicom()
|
|
7229 * @ingroup Toolbox
|
|
7230 **/
|
|
7231 ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebJson2(
|
|
7232 OrthancPluginContext* context,
|
|
7233 const void* dicom,
|
|
7234 uint32_t dicomSize,
|
|
7235 OrthancPluginDicomWebBinaryCallback2 callback,
|
|
7236 void* payload)
|
|
7237 {
|
|
7238 char* target = NULL;
|
|
7239
|
|
7240 _OrthancPluginEncodeDicomWeb2 params;
|
|
7241 params.target = ⌖
|
|
7242 params.dicom = dicom;
|
|
7243 params.dicomSize = dicomSize;
|
|
7244 params.callback = callback;
|
|
7245 params.payload = payload;
|
|
7246
|
|
7247 if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebJson2, ¶ms) != OrthancPluginErrorCode_Success)
|
|
7248 {
|
|
7249 /* Error */
|
|
7250 return NULL;
|
|
7251 }
|
|
7252 else
|
|
7253 {
|
|
7254 return target;
|
|
7255 }
|
|
7256 }
|
|
7257
|
|
7258
|
|
7259 /**
|
|
7260 * @brief Convert a DICOM instance to DICOMweb XML.
|
|
7261 *
|
|
7262 * This function converts a memory buffer containing a DICOM instance,
|
|
7263 * into its DICOMweb XML representation.
|
|
7264 *
|
|
7265 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7266 * @param dicom Pointer to the DICOM instance.
|
|
7267 * @param dicomSize Size of the DICOM instance.
|
|
7268 * @param callback Callback to set the value of the binary tags.
|
|
7269 * @param payload User payload.
|
|
7270 * @return The NULL value in case of error, or the XML document. This string must
|
|
7271 * be freed by OrthancPluginFreeString().
|
|
7272 * @see OrthancPluginCreateDicom()
|
|
7273 * @ingroup Toolbox
|
|
7274 **/
|
|
7275 ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebXml2(
|
|
7276 OrthancPluginContext* context,
|
|
7277 const void* dicom,
|
|
7278 uint32_t dicomSize,
|
|
7279 OrthancPluginDicomWebBinaryCallback2 callback,
|
|
7280 void* payload)
|
|
7281 {
|
|
7282 char* target = NULL;
|
|
7283
|
|
7284 _OrthancPluginEncodeDicomWeb2 params;
|
|
7285 params.target = ⌖
|
|
7286 params.dicom = dicom;
|
|
7287 params.dicomSize = dicomSize;
|
|
7288 params.callback = callback;
|
|
7289 params.payload = payload;
|
|
7290
|
|
7291 if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebXml2, ¶ms) != OrthancPluginErrorCode_Success)
|
|
7292 {
|
|
7293 /* Error */
|
|
7294 return NULL;
|
|
7295 }
|
|
7296 else
|
|
7297 {
|
|
7298 return target;
|
|
7299 }
|
|
7300 }
|
|
7301
|
|
7302
|
|
7303
|
|
7304 /**
|
|
7305 * @brief Callback executed when a HTTP header is received during a chunked transfer.
|
|
7306 *
|
|
7307 * Signature of a callback function that is called by Orthanc acting
|
|
7308 * as a HTTP client during a chunked HTTP transfer, as soon as it
|
|
7309 * receives one HTTP header from the answer of the remote HTTP
|
|
7310 * server.
|
|
7311 *
|
|
7312 * @see OrthancPluginChunkedHttpClient()
|
|
7313 * @param answer The user payload, as provided by the calling plugin.
|
|
7314 * @param key The key of the HTTP header.
|
|
7315 * @param value The value of the HTTP header.
|
|
7316 * @return 0 if success, or the error code if failure.
|
|
7317 * @ingroup Toolbox
|
|
7318 **/
|
|
7319 typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientAnswerAddHeader) (
|
|
7320 void* answer,
|
|
7321 const char* key,
|
|
7322 const char* value);
|
|
7323
|
|
7324
|
|
7325 /**
|
|
7326 * @brief Callback executed when an answer chunk is received during a chunked transfer.
|
|
7327 *
|
|
7328 * Signature of a callback function that is called by Orthanc acting
|
|
7329 * as a HTTP client during a chunked HTTP transfer, as soon as it
|
|
7330 * receives one data chunk from the answer of the remote HTTP
|
|
7331 * server.
|
|
7332 *
|
|
7333 * @see OrthancPluginChunkedHttpClient()
|
|
7334 * @param answer The user payload, as provided by the calling plugin.
|
|
7335 * @param data The content of the data chunk.
|
|
7336 * @param size The size of the data chunk.
|
|
7337 * @return 0 if success, or the error code if failure.
|
|
7338 * @ingroup Toolbox
|
|
7339 **/
|
|
7340 typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientAnswerAddChunk) (
|
|
7341 void* answer,
|
|
7342 const void* data,
|
|
7343 uint32_t size);
|
|
7344
|
|
7345
|
|
7346 /**
|
|
7347 * @brief Callback to know whether the request body is entirely read during a chunked transfer
|
|
7348 *
|
|
7349 * Signature of a callback function that is called by Orthanc acting
|
|
7350 * as a HTTP client during a chunked HTTP transfer, while reading
|
|
7351 * the body of a POST or PUT request. The plugin must answer "1" as
|
|
7352 * soon as the body is entirely read: The "request" data structure
|
|
7353 * must act as an iterator.
|
|
7354 *
|
|
7355 * @see OrthancPluginChunkedHttpClient()
|
|
7356 * @param request The user payload, as provided by the calling plugin.
|
|
7357 * @return "1" if the body is over, or "0" if there is still data to be read.
|
|
7358 * @ingroup Toolbox
|
|
7359 **/
|
|
7360 typedef uint8_t (*OrthancPluginChunkedClientRequestIsDone) (void* request);
|
|
7361
|
|
7362
|
|
7363 /**
|
|
7364 * @brief Callback to advance in the request body during a chunked transfer
|
|
7365 *
|
|
7366 * Signature of a callback function that is called by Orthanc acting
|
|
7367 * as a HTTP client during a chunked HTTP transfer, while reading
|
|
7368 * the body of a POST or PUT request. This function asks the plugin
|
|
7369 * to advance to the next chunk of data of the request body: The
|
|
7370 * "request" data structure must act as an iterator.
|
|
7371 *
|
|
7372 * @see OrthancPluginChunkedHttpClient()
|
|
7373 * @param request The user payload, as provided by the calling plugin.
|
|
7374 * @return 0 if success, or the error code if failure.
|
|
7375 * @ingroup Toolbox
|
|
7376 **/
|
|
7377 typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientRequestNext) (void* request);
|
|
7378
|
|
7379
|
|
7380 /**
|
|
7381 * @brief Callback to read the current chunk of the request body during a chunked transfer
|
|
7382 *
|
|
7383 * Signature of a callback function that is called by Orthanc acting
|
|
7384 * as a HTTP client during a chunked HTTP transfer, while reading
|
|
7385 * the body of a POST or PUT request. The plugin must provide the
|
|
7386 * content of the current chunk of data of the request body.
|
|
7387 *
|
|
7388 * @see OrthancPluginChunkedHttpClient()
|
|
7389 * @param request The user payload, as provided by the calling plugin.
|
|
7390 * @return The content of the current request chunk.
|
|
7391 * @ingroup Toolbox
|
|
7392 **/
|
|
7393 typedef const void* (*OrthancPluginChunkedClientRequestGetChunkData) (void* request);
|
|
7394
|
|
7395
|
|
7396 /**
|
|
7397 * @brief Callback to read the size of the current request chunk during a chunked transfer
|
|
7398 *
|
|
7399 * Signature of a callback function that is called by Orthanc acting
|
|
7400 * as a HTTP client during a chunked HTTP transfer, while reading
|
|
7401 * the body of a POST or PUT request. The plugin must provide the
|
|
7402 * size of the current chunk of data of the request body.
|
|
7403 *
|
|
7404 * @see OrthancPluginChunkedHttpClient()
|
|
7405 * @param request The user payload, as provided by the calling plugin.
|
|
7406 * @return The size of the current request chunk.
|
|
7407 * @ingroup Toolbox
|
|
7408 **/
|
|
7409 typedef uint32_t (*OrthancPluginChunkedClientRequestGetChunkSize) (void* request);
|
|
7410
|
|
7411
|
|
7412 typedef struct
|
|
7413 {
|
|
7414 void* answer;
|
|
7415 OrthancPluginChunkedClientAnswerAddChunk answerAddChunk;
|
|
7416 OrthancPluginChunkedClientAnswerAddHeader answerAddHeader;
|
|
7417 uint16_t* httpStatus;
|
|
7418 OrthancPluginHttpMethod method;
|
|
7419 const char* url;
|
|
7420 uint32_t headersCount;
|
|
7421 const char* const* headersKeys;
|
|
7422 const char* const* headersValues;
|
|
7423 void* request;
|
|
7424 OrthancPluginChunkedClientRequestIsDone requestIsDone;
|
|
7425 OrthancPluginChunkedClientRequestGetChunkData requestChunkData;
|
|
7426 OrthancPluginChunkedClientRequestGetChunkSize requestChunkSize;
|
|
7427 OrthancPluginChunkedClientRequestNext requestNext;
|
|
7428 const char* username;
|
|
7429 const char* password;
|
|
7430 uint32_t timeout;
|
|
7431 const char* certificateFile;
|
|
7432 const char* certificateKeyFile;
|
|
7433 const char* certificateKeyPassword;
|
|
7434 uint8_t pkcs11;
|
|
7435 } _OrthancPluginChunkedHttpClient;
|
|
7436
|
|
7437
|
|
7438 /**
|
|
7439 * @brief Issue a HTTP call, using chunked HTTP transfers.
|
|
7440 *
|
|
7441 * Make a HTTP call to the given URL using chunked HTTP
|
|
7442 * transfers. The request body is provided as an iterator over data
|
|
7443 * chunks. The answer is provided as a sequence of function calls
|
|
7444 * with the individual HTTP headers and answer chunks.
|
|
7445 *
|
|
7446 * Contrarily to OrthancPluginHttpClient() that entirely stores the
|
|
7447 * request body and the answer body in memory buffers, this function
|
|
7448 * uses chunked HTTP transfers. This results in a lower memory
|
|
7449 * consumption. Pay attention to the fact that Orthanc servers with
|
|
7450 * version <= 1.5.6 do not support chunked transfers: You must use
|
|
7451 * OrthancPluginHttpClient() if contacting such older servers.
|
|
7452 *
|
|
7453 * The HTTP request will be done accordingly to the global
|
|
7454 * configuration of Orthanc (in particular, the options "HttpProxy",
|
|
7455 * "HttpTimeout", "HttpsVerifyPeers", "HttpsCACertificates", and
|
|
7456 * "Pkcs11" will be taken into account).
|
|
7457 *
|
|
7458 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7459 * @param answer The user payload for the answer body. It will be provided to the callbacks for the answer.
|
|
7460 * @param answerAddChunk Callback function to report a data chunk from the answer body.
|
|
7461 * @param answerAddHeader Callback function to report an HTTP header sent by the remote server.
|
|
7462 * @param httpStatus The HTTP status after the execution of the request (out argument).
|
|
7463 * @param method HTTP method to be used.
|
|
7464 * @param url The URL of interest.
|
|
7465 * @param headersCount The number of HTTP headers.
|
|
7466 * @param headersKeys Array containing the keys of the HTTP headers (can be <tt>NULL</tt> if no header).
|
|
7467 * @param headersValues Array containing the values of the HTTP headers (can be <tt>NULL</tt> if no header).
|
|
7468 * @param request The user payload containing the request body, and acting as an iterator.
|
|
7469 * It will be provided to the callbacks for the request.
|
|
7470 * @param requestIsDone Callback function to tell whether the request body is entirely read.
|
|
7471 * @param requestChunkData Callback function to get the content of the current data chunk of the request body.
|
|
7472 * @param requestChunkSize Callback function to get the size of the current data chunk of the request body.
|
|
7473 * @param requestNext Callback function to advance to the next data chunk of the request body.
|
|
7474 * @param username The username (can be <tt>NULL</tt> if no password protection).
|
|
7475 * @param password The password (can be <tt>NULL</tt> if no password protection).
|
|
7476 * @param timeout Timeout in seconds (0 for default timeout).
|
|
7477 * @param certificateFile Path to the client certificate for HTTPS, in PEM format
|
|
7478 * (can be <tt>NULL</tt> if no client certificate or if not using HTTPS).
|
|
7479 * @param certificateKeyFile Path to the key of the client certificate for HTTPS, in PEM format
|
|
7480 * (can be <tt>NULL</tt> if no client certificate or if not using HTTPS).
|
|
7481 * @param certificateKeyPassword Password to unlock the key of the client certificate
|
|
7482 * (can be <tt>NULL</tt> if no client certificate or if not using HTTPS).
|
|
7483 * @param pkcs11 Enable PKCS#11 client authentication for hardware security modules and smart cards.
|
|
7484 * @return 0 if success, or the error code if failure.
|
|
7485 * @see OrthancPluginHttpClient()
|
|
7486 * @ingroup Toolbox
|
|
7487 **/
|
|
7488 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginChunkedHttpClient(
|
|
7489 OrthancPluginContext* context,
|
|
7490 void* answer,
|
|
7491 OrthancPluginChunkedClientAnswerAddChunk answerAddChunk,
|
|
7492 OrthancPluginChunkedClientAnswerAddHeader answerAddHeader,
|
|
7493 uint16_t* httpStatus,
|
|
7494 OrthancPluginHttpMethod method,
|
|
7495 const char* url,
|
|
7496 uint32_t headersCount,
|
|
7497 const char* const* headersKeys,
|
|
7498 const char* const* headersValues,
|
|
7499 void* request,
|
|
7500 OrthancPluginChunkedClientRequestIsDone requestIsDone,
|
|
7501 OrthancPluginChunkedClientRequestGetChunkData requestChunkData,
|
|
7502 OrthancPluginChunkedClientRequestGetChunkSize requestChunkSize,
|
|
7503 OrthancPluginChunkedClientRequestNext requestNext,
|
|
7504 const char* username,
|
|
7505 const char* password,
|
|
7506 uint32_t timeout,
|
|
7507 const char* certificateFile,
|
|
7508 const char* certificateKeyFile,
|
|
7509 const char* certificateKeyPassword,
|
|
7510 uint8_t pkcs11)
|
|
7511 {
|
|
7512 _OrthancPluginChunkedHttpClient params;
|
|
7513 memset(¶ms, 0, sizeof(params));
|
|
7514
|
|
7515 /* In common with OrthancPluginHttpClient() */
|
|
7516 params.httpStatus = httpStatus;
|
|
7517 params.method = method;
|
|
7518 params.url = url;
|
|
7519 params.headersCount = headersCount;
|
|
7520 params.headersKeys = headersKeys;
|
|
7521 params.headersValues = headersValues;
|
|
7522 params.username = username;
|
|
7523 params.password = password;
|
|
7524 params.timeout = timeout;
|
|
7525 params.certificateFile = certificateFile;
|
|
7526 params.certificateKeyFile = certificateKeyFile;
|
|
7527 params.certificateKeyPassword = certificateKeyPassword;
|
|
7528 params.pkcs11 = pkcs11;
|
|
7529
|
|
7530 /* For chunked body/answer */
|
|
7531 params.answer = answer;
|
|
7532 params.answerAddChunk = answerAddChunk;
|
|
7533 params.answerAddHeader = answerAddHeader;
|
|
7534 params.request = request;
|
|
7535 params.requestIsDone = requestIsDone;
|
|
7536 params.requestChunkData = requestChunkData;
|
|
7537 params.requestChunkSize = requestChunkSize;
|
|
7538 params.requestNext = requestNext;
|
|
7539
|
|
7540 return context->InvokeService(context, _OrthancPluginService_ChunkedHttpClient, ¶ms);
|
|
7541 }
|
|
7542
|
|
7543
|
|
7544
|
|
7545 /**
|
|
7546 * @brief Opaque structure that reads the content of a HTTP request body during a chunked HTTP transfer.
|
|
7547 * @ingroup Callbacks
|
|
7548 **/
|
|
7549 typedef struct _OrthancPluginServerChunkedRequestReader_t OrthancPluginServerChunkedRequestReader;
|
|
7550
|
|
7551
|
|
7552
|
|
7553 /**
|
|
7554 * @brief Callback to create a reader to handle incoming chunked HTTP transfers.
|
|
7555 *
|
|
7556 * Signature of a callback function that is called by Orthanc acting
|
|
7557 * as a HTTP server that supports chunked HTTP transfers. This
|
|
7558 * callback is only invoked if the HTTP method is POST or PUT. The
|
|
7559 * callback must create an user-specific "reader" object that will
|
|
7560 * be fed with the body of the incoming body.
|
|
7561 *
|
|
7562 * @see OrthancPluginRegisterChunkedRestCallback()
|
|
7563 * @param reader Memory location that must be filled with the newly-created reader.
|
|
7564 * @param url The URI that is accessed.
|
|
7565 * @param request The body of the HTTP request. Note that "body" and "bodySize" are not used.
|
|
7566 * @return 0 if success, or the error code if failure.
|
|
7567 **/
|
|
7568 typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderFactory) (
|
|
7569 OrthancPluginServerChunkedRequestReader** reader,
|
|
7570 const char* url,
|
|
7571 const OrthancPluginHttpRequest* request);
|
|
7572
|
|
7573
|
|
7574 /**
|
|
7575 * @brief Callback invoked whenever a new data chunk is available during a chunked transfer.
|
|
7576 *
|
|
7577 * Signature of a callback function that is called by Orthanc acting
|
|
7578 * as a HTTP server that supports chunked HTTP transfers. This callback
|
|
7579 * is invoked as soon as a new data chunk is available for the request body.
|
|
7580 *
|
|
7581 * @see OrthancPluginRegisterChunkedRestCallback()
|
|
7582 * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback.
|
|
7583 * @param data The content of the data chunk.
|
|
7584 * @param size The size of the data chunk.
|
|
7585 * @return 0 if success, or the error code if failure.
|
|
7586 **/
|
|
7587 typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderAddChunk) (
|
|
7588 OrthancPluginServerChunkedRequestReader* reader,
|
|
7589 const void* data,
|
|
7590 uint32_t size);
|
|
7591
|
|
7592
|
|
7593 /**
|
|
7594 * @brief Callback invoked whenever the request body is entirely received.
|
|
7595 *
|
|
7596 * Signature of a callback function that is called by Orthanc acting
|
|
7597 * as a HTTP server that supports chunked HTTP transfers. This
|
|
7598 * callback is invoked as soon as the full body of the HTTP request
|
|
7599 * is available. The plugin can then send its answer thanks to the
|
|
7600 * provided "output" object.
|
|
7601 *
|
|
7602 * @see OrthancPluginRegisterChunkedRestCallback()
|
|
7603 * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback.
|
|
7604 * @param output The HTTP connection to the client application.
|
|
7605 * @return 0 if success, or the error code if failure.
|
|
7606 **/
|
|
7607 typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderExecute) (
|
|
7608 OrthancPluginServerChunkedRequestReader* reader,
|
|
7609 OrthancPluginRestOutput* output);
|
|
7610
|
|
7611
|
|
7612 /**
|
|
7613 * @brief Callback invoked to release the resources associated with an incoming HTTP chunked transfer.
|
|
7614 *
|
|
7615 * Signature of a callback function that is called by Orthanc acting
|
|
7616 * as a HTTP server that supports chunked HTTP transfers. This
|
|
7617 * callback is invoked to release all the resources allocated by the
|
|
7618 * given reader. Note that this function might be invoked even if
|
|
7619 * the entire body was not read, to deal with client error or
|
|
7620 * disconnection.
|
|
7621 *
|
|
7622 * @see OrthancPluginRegisterChunkedRestCallback()
|
|
7623 * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback.
|
|
7624 **/
|
|
7625 typedef void (*OrthancPluginServerChunkedRequestReaderFinalize) (
|
|
7626 OrthancPluginServerChunkedRequestReader* reader);
|
|
7627
|
|
7628 typedef struct
|
|
7629 {
|
|
7630 const char* pathRegularExpression;
|
|
7631 OrthancPluginRestCallback getHandler;
|
|
7632 OrthancPluginServerChunkedRequestReaderFactory postHandler;
|
|
7633 OrthancPluginRestCallback deleteHandler;
|
|
7634 OrthancPluginServerChunkedRequestReaderFactory putHandler;
|
|
7635 OrthancPluginServerChunkedRequestReaderAddChunk addChunk;
|
|
7636 OrthancPluginServerChunkedRequestReaderExecute execute;
|
|
7637 OrthancPluginServerChunkedRequestReaderFinalize finalize;
|
|
7638 } _OrthancPluginChunkedRestCallback;
|
|
7639
|
|
7640
|
|
7641 /**
|
|
7642 * @brief Register a REST callback to handle chunked HTTP transfers.
|
|
7643 *
|
|
7644 * This function registers a REST callback against a regular
|
|
7645 * expression for a URI. This function must be called during the
|
|
7646 * initialization of the plugin, i.e. inside the
|
|
7647 * OrthancPluginInitialize() public function.
|
|
7648 *
|
|
7649 * Contrarily to OrthancPluginRegisterRestCallback(), the callbacks
|
|
7650 * will NOT be invoked in mutual exclusion, so it is up to the
|
|
7651 * plugin to implement the required locking mechanisms.
|
|
7652 *
|
|
7653 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7654 * @param pathRegularExpression Regular expression for the URI. May contain groups.
|
|
7655 * @param getHandler The callback function to handle REST calls using the GET HTTP method.
|
|
7656 * @param postHandler The callback function to handle REST calls using the POST HTTP method.
|
|
7657 * @param deleteHandler The callback function to handle REST calls using the DELETE HTTP method.
|
|
7658 * @param putHandler The callback function to handle REST calls using the PUT HTTP method.
|
|
7659 * @param addChunk The callback invoked when a new chunk is available for the request body of a POST or PUT call.
|
|
7660 * @param execute The callback invoked once the entire body of a POST or PUT call is read.
|
|
7661 * @param finalize The callback invoked to release the resources associated with a POST or PUT call.
|
|
7662 * @see OrthancPluginRegisterRestCallbackNoLock()
|
|
7663 *
|
|
7664 * @note
|
|
7665 * The regular expression is case sensitive and must follow the
|
|
7666 * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html).
|
|
7667 *
|
|
7668 * @ingroup Callbacks
|
|
7669 **/
|
|
7670 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterChunkedRestCallback(
|
|
7671 OrthancPluginContext* context,
|
|
7672 const char* pathRegularExpression,
|
|
7673 OrthancPluginRestCallback getHandler,
|
|
7674 OrthancPluginServerChunkedRequestReaderFactory postHandler,
|
|
7675 OrthancPluginRestCallback deleteHandler,
|
|
7676 OrthancPluginServerChunkedRequestReaderFactory putHandler,
|
|
7677 OrthancPluginServerChunkedRequestReaderAddChunk addChunk,
|
|
7678 OrthancPluginServerChunkedRequestReaderExecute execute,
|
|
7679 OrthancPluginServerChunkedRequestReaderFinalize finalize)
|
|
7680 {
|
|
7681 _OrthancPluginChunkedRestCallback params;
|
|
7682 params.pathRegularExpression = pathRegularExpression;
|
|
7683 params.getHandler = getHandler;
|
|
7684 params.postHandler = postHandler;
|
|
7685 params.deleteHandler = deleteHandler;
|
|
7686 params.putHandler = putHandler;
|
|
7687 params.addChunk = addChunk;
|
|
7688 params.execute = execute;
|
|
7689 params.finalize = finalize;
|
|
7690
|
|
7691 context->InvokeService(context, _OrthancPluginService_RegisterChunkedRestCallback, ¶ms);
|
|
7692 }
|
|
7693
|
|
7694
|
|
7695
|
|
7696
|
|
7697
|
|
7698 typedef struct
|
|
7699 {
|
|
7700 char** result;
|
|
7701 uint16_t group;
|
|
7702 uint16_t element;
|
|
7703 const char* privateCreator;
|
|
7704 } _OrthancPluginGetTagName;
|
|
7705
|
|
7706 /**
|
|
7707 * @brief Returns the symbolic name of a DICOM tag.
|
|
7708 *
|
|
7709 * This function makes a lookup to the dictionary of DICOM tags that
|
|
7710 * are known to Orthanc, and returns the symbolic name of a DICOM tag.
|
|
7711 *
|
|
7712 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7713 * @param group The group of the tag.
|
|
7714 * @param element The element of the tag.
|
|
7715 * @param privateCreator For private tags, the name of the private creator (can be NULL).
|
|
7716 * @return NULL in the case of an error, or a newly allocated string
|
|
7717 * containing the path. This string must be freed by
|
|
7718 * OrthancPluginFreeString().
|
|
7719 * @ingroup Toolbox
|
|
7720 **/
|
|
7721 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetTagName(
|
|
7722 OrthancPluginContext* context,
|
|
7723 uint16_t group,
|
|
7724 uint16_t element,
|
|
7725 const char* privateCreator)
|
|
7726 {
|
|
7727 char* result;
|
|
7728
|
|
7729 _OrthancPluginGetTagName params;
|
|
7730 params.result = &result;
|
|
7731 params.group = group;
|
|
7732 params.element = element;
|
|
7733 params.privateCreator = privateCreator;
|
|
7734
|
|
7735 if (context->InvokeService(context, _OrthancPluginService_GetTagName, ¶ms) != OrthancPluginErrorCode_Success)
|
|
7736 {
|
|
7737 /* Error */
|
|
7738 return NULL;
|
|
7739 }
|
|
7740 else
|
|
7741 {
|
|
7742 return result;
|
|
7743 }
|
|
7744 }
|
|
7745
|
|
7746
|
|
7747
|
|
7748 /**
|
|
7749 * @brief Callback executed by the storage commitment SCP.
|
|
7750 *
|
|
7751 * Signature of a factory function that creates an object to handle
|
|
7752 * one incoming storage commitment request.
|
|
7753 *
|
|
7754 * @remark The factory receives the list of the SOP class/instance
|
|
7755 * UIDs of interest to the remote storage commitment SCU. This gives
|
|
7756 * the factory the possibility to start some prefetch process
|
|
7757 * upfront in the background, before the handler object is actually
|
|
7758 * queried about the status of these DICOM instances.
|
|
7759 *
|
|
7760 * @param handler Output variable where the factory puts the handler object it created.
|
|
7761 * @param jobId ID of the Orthanc job that is responsible for handling
|
|
7762 * the storage commitment request. This job will successively look for the
|
|
7763 * status of all the individual queried DICOM instances.
|
|
7764 * @param transactionUid UID of the storage commitment transaction
|
|
7765 * provided by the storage commitment SCU. It contains the value of the
|
|
7766 * (0008,1195) DICOM tag.
|
|
7767 * @param sopClassUids Array of the SOP class UIDs (0008,0016) that are queried by the SCU.
|
|
7768 * @param sopInstanceUids Array of the SOP instance UIDs (0008,0018) that are queried by the SCU.
|
|
7769 * @param countInstances Number of DICOM instances that are queried. This is the size
|
|
7770 * of the `sopClassUids` and `sopInstanceUids` arrays.
|
|
7771 * @param remoteAet The AET of the storage commitment SCU.
|
|
7772 * @param calledAet The AET used by the SCU to contact the storage commitment SCP (i.e. Orthanc).
|
|
7773 * @return 0 if success, other value if error.
|
|
7774 * @ingroup DicomCallbacks
|
|
7775 **/
|
|
7776 typedef OrthancPluginErrorCode (*OrthancPluginStorageCommitmentFactory) (
|
|
7777 void** handler /* out */,
|
|
7778 const char* jobId,
|
|
7779 const char* transactionUid,
|
|
7780 const char* const* sopClassUids,
|
|
7781 const char* const* sopInstanceUids,
|
|
7782 uint32_t countInstances,
|
|
7783 const char* remoteAet,
|
|
7784 const char* calledAet);
|
|
7785
|
|
7786
|
|
7787 /**
|
|
7788 * @brief Callback to free one storage commitment SCP handler.
|
|
7789 *
|
|
7790 * Signature of a callback function that releases the resources
|
|
7791 * allocated by the factory of the storage commitment SCP. The
|
|
7792 * handler is the return value of a previous call to the
|
|
7793 * OrthancPluginStorageCommitmentFactory() callback.
|
|
7794 *
|
|
7795 * @param handler The handler object to be destructed.
|
|
7796 * @ingroup DicomCallbacks
|
|
7797 **/
|
|
7798 typedef void (*OrthancPluginStorageCommitmentDestructor) (void* handler);
|
|
7799
|
|
7800
|
|
7801 /**
|
|
7802 * @brief Callback to get the status of one DICOM instance in the
|
|
7803 * storage commitment SCP.
|
|
7804 *
|
|
7805 * Signature of a callback function that is successively invoked for
|
|
7806 * each DICOM instance that is queried by the remote storage
|
|
7807 * commitment SCU. The function must be tought of as a method of
|
|
7808 * the handler object that was created by a previous call to the
|
|
7809 * OrthancPluginStorageCommitmentFactory() callback. After each call
|
|
7810 * to this method, the progress of the associated Orthanc job is
|
|
7811 * updated.
|
|
7812 *
|
|
7813 * @param target Output variable where to put the status for the queried instance.
|
|
7814 * @param handler The handler object associated with this storage commitment request.
|
|
7815 * @param sopClassUid The SOP class UID (0008,0016) of interest.
|
|
7816 * @param sopInstanceUid The SOP instance UID (0008,0018) of interest.
|
|
7817 * @ingroup DicomCallbacks
|
|
7818 **/
|
|
7819 typedef OrthancPluginErrorCode (*OrthancPluginStorageCommitmentLookup) (
|
|
7820 OrthancPluginStorageCommitmentFailureReason* target,
|
|
7821 void* handler,
|
|
7822 const char* sopClassUid,
|
|
7823 const char* sopInstanceUid);
|
|
7824
|
|
7825
|
|
7826 typedef struct
|
|
7827 {
|
|
7828 OrthancPluginStorageCommitmentFactory factory;
|
|
7829 OrthancPluginStorageCommitmentDestructor destructor;
|
|
7830 OrthancPluginStorageCommitmentLookup lookup;
|
|
7831 } _OrthancPluginRegisterStorageCommitmentScpCallback;
|
|
7832
|
|
7833 /**
|
|
7834 * @brief Register a callback to handle incoming requests to the storage commitment SCP.
|
|
7835 *
|
|
7836 * This function registers a callback to handle storage commitment SCP requests.
|
|
7837 *
|
|
7838 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7839 * @param factory Factory function that creates the handler object
|
|
7840 * for incoming storage commitment requests.
|
|
7841 * @param destructor Destructor function to destroy the handler object.
|
|
7842 * @param lookup Callback function to get the status of one DICOM instance.
|
|
7843 * @return 0 if success, other value if error.
|
|
7844 * @ingroup DicomCallbacks
|
|
7845 **/
|
|
7846 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterStorageCommitmentScpCallback(
|
|
7847 OrthancPluginContext* context,
|
|
7848 OrthancPluginStorageCommitmentFactory factory,
|
|
7849 OrthancPluginStorageCommitmentDestructor destructor,
|
|
7850 OrthancPluginStorageCommitmentLookup lookup)
|
|
7851 {
|
|
7852 _OrthancPluginRegisterStorageCommitmentScpCallback params;
|
|
7853 params.factory = factory;
|
|
7854 params.destructor = destructor;
|
|
7855 params.lookup = lookup;
|
|
7856 return context->InvokeService(context, _OrthancPluginService_RegisterStorageCommitmentScpCallback, ¶ms);
|
|
7857 }
|
|
7858
|
|
7859
|
|
7860
|
|
7861 /**
|
|
7862 * @brief Callback to filter incoming DICOM instances received by Orthanc.
|
|
7863 *
|
|
7864 * Signature of a callback function that is triggered whenever
|
|
7865 * Orthanc receives a new DICOM instance (e.g. through REST API or
|
|
7866 * DICOM protocol), and that answers whether this DICOM instance
|
|
7867 * should be accepted or discarded by Orthanc.
|
|
7868 *
|
|
7869 * Note that the metadata information is not available
|
|
7870 * (i.e. GetInstanceMetadata() should not be used on "instance").
|
|
7871 *
|
|
7872 * @warning Your callback function will be called synchronously with
|
|
7873 * the core of Orthanc. This implies that deadlocks might emerge if
|
|
7874 * you call other core primitives of Orthanc in your callback (such
|
|
7875 * deadlocks are particularly visible in the presence of other plugins
|
|
7876 * or Lua scripts). It is thus strongly advised to avoid any call to
|
|
7877 * the REST API of Orthanc in the callback. If you have to call
|
|
7878 * other primitives of Orthanc, you should make these calls in a
|
|
7879 * separate thread, passing the pending events to be processed
|
|
7880 * through a message queue.
|
|
7881 *
|
|
7882 * @param instance The received DICOM instance.
|
|
7883 * @return 0 to discard the instance, 1 to store the instance, -1 if error.
|
|
7884 * @ingroup Callbacks
|
|
7885 **/
|
|
7886 typedef int32_t (*OrthancPluginIncomingDicomInstanceFilter) (
|
|
7887 const OrthancPluginDicomInstance* instance);
|
|
7888
|
|
7889
|
|
7890 typedef struct
|
|
7891 {
|
|
7892 OrthancPluginIncomingDicomInstanceFilter callback;
|
|
7893 } _OrthancPluginIncomingDicomInstanceFilter;
|
|
7894
|
|
7895 /**
|
|
7896 * @brief Register a callback to filter incoming DICOM instances.
|
|
7897 *
|
|
7898 * This function registers a custom callback to filter incoming
|
|
7899 * DICOM instances received by Orthanc (either through the REST API
|
|
7900 * or through the DICOM protocol).
|
|
7901 *
|
|
7902 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7903 * @param callback The callback.
|
|
7904 * @return 0 if success, other value if error.
|
|
7905 * @ingroup Callbacks
|
|
7906 **/
|
|
7907 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingDicomInstanceFilter(
|
|
7908 OrthancPluginContext* context,
|
|
7909 OrthancPluginIncomingDicomInstanceFilter callback)
|
|
7910 {
|
|
7911 _OrthancPluginIncomingDicomInstanceFilter params;
|
|
7912 params.callback = callback;
|
|
7913
|
|
7914 return context->InvokeService(context, _OrthancPluginService_RegisterIncomingDicomInstanceFilter, ¶ms);
|
|
7915 }
|
|
7916
|
|
7917
|
|
7918 /**
|
|
7919 * @brief Callback to filter incoming DICOM instances received by
|
|
7920 * Orthanc through C-STORE.
|
|
7921 *
|
|
7922 * Signature of a callback function that is triggered whenever
|
|
7923 * Orthanc receives a new DICOM instance using DICOM C-STORE, and
|
|
7924 * that answers whether this DICOM instance should be accepted or
|
|
7925 * discarded by Orthanc. If the instance is discarded, the callback
|
|
7926 * can specify the DIMSE error code answered by the Orthanc C-STORE
|
|
7927 * SCP.
|
|
7928 *
|
|
7929 * Note that the metadata information is not available
|
|
7930 * (i.e. GetInstanceMetadata() should not be used on "instance").
|
|
7931 *
|
|
7932 * @warning Your callback function will be called synchronously with
|
|
7933 * the core of Orthanc. This implies that deadlocks might emerge if
|
|
7934 * you call other core primitives of Orthanc in your callback (such
|
|
7935 * deadlocks are particularly visible in the presence of other plugins
|
|
7936 * or Lua scripts). It is thus strongly advised to avoid any call to
|
|
7937 * the REST API of Orthanc in the callback. If you have to call
|
|
7938 * other primitives of Orthanc, you should make these calls in a
|
|
7939 * separate thread, passing the pending events to be processed
|
|
7940 * through a message queue.
|
|
7941 *
|
|
7942 * @param dimseStatus If the DICOM instance is discarded,
|
|
7943 * DIMSE status to be sent by the C-STORE SCP of Orthanc
|
|
7944 * @param instance The received DICOM instance.
|
|
7945 * @return 0 to discard the instance, 1 to store the instance, -1 if error.
|
|
7946 * @ingroup Callbacks
|
|
7947 **/
|
|
7948 typedef int32_t (*OrthancPluginIncomingCStoreInstanceFilter) (
|
|
7949 uint16_t* dimseStatus /* out */,
|
|
7950 const OrthancPluginDicomInstance* instance);
|
|
7951
|
|
7952
|
|
7953 typedef struct
|
|
7954 {
|
|
7955 OrthancPluginIncomingCStoreInstanceFilter callback;
|
|
7956 } _OrthancPluginIncomingCStoreInstanceFilter;
|
|
7957
|
|
7958 /**
|
|
7959 * @brief Register a callback to filter incoming DICOM instances
|
|
7960 * received by Orthanc through C-STORE.
|
|
7961 *
|
|
7962 * This function registers a custom callback to filter incoming
|
|
7963 * DICOM instances received by Orthanc through the DICOM protocol.
|
|
7964 *
|
|
7965 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
7966 * @param callback The callback.
|
|
7967 * @return 0 if success, other value if error.
|
|
7968 * @ingroup Callbacks
|
|
7969 **/
|
|
7970 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingCStoreInstanceFilter(
|
|
7971 OrthancPluginContext* context,
|
|
7972 OrthancPluginIncomingCStoreInstanceFilter callback)
|
|
7973 {
|
|
7974 _OrthancPluginIncomingCStoreInstanceFilter params;
|
|
7975 params.callback = callback;
|
|
7976
|
|
7977 return context->InvokeService(context, _OrthancPluginService_RegisterIncomingCStoreInstanceFilter, ¶ms);
|
|
7978 }
|
|
7979
|
|
7980 /**
|
|
7981 * @brief Callback to keep/discard/modify a DICOM instance received
|
|
7982 * by Orthanc from any source (C-STORE or REST API)
|
|
7983 *
|
|
7984 * Signature of a callback function that is triggered whenever
|
|
7985 * Orthanc receives a new DICOM instance (through DICOM protocol or
|
|
7986 * REST API), and that specifies an action to be applied to this
|
|
7987 * newly received instance. The instance can be kept as it is, can
|
|
7988 * be modified by the plugin, or can be discarded.
|
|
7989 *
|
|
7990 * This callback is invoked immediately after reception, i.e. before
|
|
7991 * transcoding and before filtering
|
|
7992 * (cf. OrthancPluginRegisterIncomingDicomInstanceFilter()).
|
|
7993 *
|
|
7994 * @warning Your callback function will be called synchronously with
|
|
7995 * the core of Orthanc. This implies that deadlocks might emerge if
|
|
7996 * you call other core primitives of Orthanc in your callback (such
|
|
7997 * deadlocks are particularly visible in the presence of other plugins
|
|
7998 * or Lua scripts). It is thus strongly advised to avoid any call to
|
|
7999 * the REST API of Orthanc in the callback. If you have to call
|
|
8000 * other primitives of Orthanc, you should make these calls in a
|
|
8001 * separate thread, passing the pending events to be processed
|
|
8002 * through a message queue.
|
|
8003 *
|
|
8004 * @param modifiedDicomBuffer A buffer containing the modified DICOM (output).
|
|
8005 * This buffer must be allocated using OrthancPluginCreateMemoryBuffer64()
|
|
8006 * and will be freed by the Orthanc core.
|
|
8007 * @param receivedDicomBuffer A buffer containing the received DICOM (input).
|
|
8008 * @param receivedDicomBufferSize The size of the received DICOM (input).
|
|
8009 * @param origin The origin of the DICOM instance (input).
|
|
8010 * @return `OrthancPluginReceivedInstanceAction_KeepAsIs` to accept the instance as is,<br/>
|
|
8011 * `OrthancPluginReceivedInstanceAction_Modify` to store the modified DICOM contained in `modifiedDicomBuffer`,<br/>
|
|
8012 * `OrthancPluginReceivedInstanceAction_Discard` to tell Orthanc to discard the instance.
|
|
8013 * @ingroup Callbacks
|
|
8014 **/
|
|
8015 typedef OrthancPluginReceivedInstanceAction (*OrthancPluginReceivedInstanceCallback) (
|
|
8016 OrthancPluginMemoryBuffer64* modifiedDicomBuffer,
|
|
8017 const void* receivedDicomBuffer,
|
|
8018 uint64_t receivedDicomBufferSize,
|
|
8019 OrthancPluginInstanceOrigin origin);
|
|
8020
|
|
8021
|
|
8022 typedef struct
|
|
8023 {
|
|
8024 OrthancPluginReceivedInstanceCallback callback;
|
|
8025 } _OrthancPluginReceivedInstanceCallback;
|
|
8026
|
|
8027 /**
|
|
8028 * @brief Register a callback to keep/discard/modify a DICOM instance received
|
|
8029 * by Orthanc from any source (C-STORE or REST API)
|
|
8030 *
|
|
8031 * This function registers a custom callback to keep/discard/modify
|
|
8032 * incoming DICOM instances received by Orthanc from any source
|
|
8033 * (C-STORE or REST API).
|
|
8034 *
|
|
8035 * @warning Contrarily to
|
|
8036 * OrthancPluginRegisterIncomingCStoreInstanceFilter() and
|
|
8037 * OrthancPluginRegisterIncomingDicomInstanceFilter() that can be
|
|
8038 * called by multiple plugins,
|
|
8039 * OrthancPluginRegisterReceivedInstanceCallback() can only be used
|
|
8040 * by one single plugin.
|
|
8041 *
|
|
8042 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8043 * @param callback The callback.
|
|
8044 * @return 0 if success, other value if error.
|
|
8045 * @ingroup Callbacks
|
|
8046 **/
|
|
8047 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterReceivedInstanceCallback(
|
|
8048 OrthancPluginContext* context,
|
|
8049 OrthancPluginReceivedInstanceCallback callback)
|
|
8050 {
|
|
8051 _OrthancPluginReceivedInstanceCallback params;
|
|
8052 params.callback = callback;
|
|
8053
|
|
8054 return context->InvokeService(context, _OrthancPluginService_RegisterReceivedInstanceCallback, ¶ms);
|
|
8055 }
|
|
8056
|
|
8057 /**
|
|
8058 * @brief Get the transfer syntax of a DICOM file.
|
|
8059 *
|
|
8060 * This function returns a pointer to a newly created string that
|
|
8061 * contains the transfer syntax UID of the DICOM instance. The empty
|
|
8062 * string might be returned if this information is unknown.
|
|
8063 *
|
|
8064 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8065 * @param instance The instance of interest.
|
|
8066 * @return The NULL value in case of error, or a string containing the
|
|
8067 * transfer syntax UID. This string must be freed by OrthancPluginFreeString().
|
|
8068 * @ingroup DicomInstance
|
|
8069 **/
|
|
8070 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceTransferSyntaxUid(
|
|
8071 OrthancPluginContext* context,
|
|
8072 const OrthancPluginDicomInstance* instance)
|
|
8073 {
|
|
8074 char* result;
|
|
8075
|
|
8076 _OrthancPluginAccessDicomInstance params;
|
|
8077 memset(¶ms, 0, sizeof(params));
|
|
8078 params.resultStringToFree = &result;
|
|
8079 params.instance = instance;
|
|
8080
|
|
8081 if (context->InvokeService(context, _OrthancPluginService_GetInstanceTransferSyntaxUid, ¶ms) != OrthancPluginErrorCode_Success)
|
|
8082 {
|
|
8083 /* Error */
|
|
8084 return NULL;
|
|
8085 }
|
|
8086 else
|
|
8087 {
|
|
8088 return result;
|
|
8089 }
|
|
8090 }
|
|
8091
|
|
8092
|
|
8093 /**
|
|
8094 * @brief Check whether the DICOM file has pixel data.
|
|
8095 *
|
|
8096 * This function returns a Boolean value indicating whether the
|
|
8097 * DICOM instance contains the pixel data (7FE0,0010) tag.
|
|
8098 *
|
|
8099 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8100 * @param instance The instance of interest.
|
|
8101 * @return "1" if the DICOM instance contains pixel data, or "0" if
|
|
8102 * the tag is missing, or "-1" in the case of an error.
|
|
8103 * @ingroup DicomInstance
|
|
8104 **/
|
|
8105 ORTHANC_PLUGIN_INLINE int32_t OrthancPluginHasInstancePixelData(
|
|
8106 OrthancPluginContext* context,
|
|
8107 const OrthancPluginDicomInstance* instance)
|
|
8108 {
|
|
8109 int64_t hasPixelData;
|
|
8110
|
|
8111 _OrthancPluginAccessDicomInstance params;
|
|
8112 memset(¶ms, 0, sizeof(params));
|
|
8113 params.resultInt64 = &hasPixelData;
|
|
8114 params.instance = instance;
|
|
8115
|
|
8116 if (context->InvokeService(context, _OrthancPluginService_HasInstancePixelData, ¶ms) != OrthancPluginErrorCode_Success ||
|
|
8117 hasPixelData < 0 ||
|
|
8118 hasPixelData > 1)
|
|
8119 {
|
|
8120 /* Error */
|
|
8121 return -1;
|
|
8122 }
|
|
8123 else
|
|
8124 {
|
|
8125 return (hasPixelData != 0);
|
|
8126 }
|
|
8127 }
|
|
8128
|
|
8129
|
|
8130
|
|
8131
|
|
8132
|
|
8133
|
|
8134 typedef struct
|
|
8135 {
|
|
8136 OrthancPluginDicomInstance** target;
|
|
8137 const void* buffer;
|
|
8138 uint32_t size;
|
|
8139 const char* transferSyntax;
|
|
8140 } _OrthancPluginCreateDicomInstance;
|
|
8141
|
|
8142 /**
|
|
8143 * @brief Parse a DICOM instance.
|
|
8144 *
|
|
8145 * This function parses a memory buffer that contains a DICOM
|
|
8146 * file. The function returns a new pointer to a data structure that
|
|
8147 * is managed by the Orthanc core.
|
|
8148 *
|
|
8149 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8150 * @param buffer The memory buffer containing the DICOM instance.
|
|
8151 * @param size The size of the memory buffer.
|
|
8152 * @return The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance().
|
|
8153 * @ingroup DicomInstance
|
|
8154 **/
|
|
8155 ORTHANC_PLUGIN_INLINE OrthancPluginDicomInstance* OrthancPluginCreateDicomInstance(
|
|
8156 OrthancPluginContext* context,
|
|
8157 const void* buffer,
|
|
8158 uint32_t size)
|
|
8159 {
|
|
8160 OrthancPluginDicomInstance* target = NULL;
|
|
8161
|
|
8162 _OrthancPluginCreateDicomInstance params;
|
|
8163 params.target = ⌖
|
|
8164 params.buffer = buffer;
|
|
8165 params.size = size;
|
|
8166
|
|
8167 if (context->InvokeService(context, _OrthancPluginService_CreateDicomInstance, ¶ms) != OrthancPluginErrorCode_Success)
|
|
8168 {
|
|
8169 /* Error */
|
|
8170 return NULL;
|
|
8171 }
|
|
8172 else
|
|
8173 {
|
|
8174 return target;
|
|
8175 }
|
|
8176 }
|
|
8177
|
|
8178 typedef struct
|
|
8179 {
|
|
8180 OrthancPluginDicomInstance* dicom;
|
|
8181 } _OrthancPluginFreeDicomInstance;
|
|
8182
|
|
8183 /**
|
|
8184 * @brief Free a DICOM instance.
|
|
8185 *
|
|
8186 * This function frees a DICOM instance that was parsed using
|
|
8187 * OrthancPluginCreateDicomInstance().
|
|
8188 *
|
|
8189 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8190 * @param dicom The DICOM instance.
|
|
8191 * @ingroup DicomInstance
|
|
8192 **/
|
|
8193 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeDicomInstance(
|
|
8194 OrthancPluginContext* context,
|
|
8195 OrthancPluginDicomInstance* dicom)
|
|
8196 {
|
|
8197 _OrthancPluginFreeDicomInstance params;
|
|
8198 params.dicom = dicom;
|
|
8199
|
|
8200 context->InvokeService(context, _OrthancPluginService_FreeDicomInstance, ¶ms);
|
|
8201 }
|
|
8202
|
|
8203
|
|
8204 typedef struct
|
|
8205 {
|
|
8206 uint32_t* targetUint32;
|
|
8207 OrthancPluginMemoryBuffer* targetBuffer;
|
|
8208 OrthancPluginImage** targetImage;
|
|
8209 char** targetStringToFree;
|
|
8210 const OrthancPluginDicomInstance* instance;
|
|
8211 uint32_t frameIndex;
|
|
8212 OrthancPluginDicomToJsonFormat format;
|
|
8213 OrthancPluginDicomToJsonFlags flags;
|
|
8214 uint32_t maxStringLength;
|
|
8215 OrthancPluginDicomWebBinaryCallback2 dicomWebCallback;
|
|
8216 void* dicomWebPayload;
|
|
8217 } _OrthancPluginAccessDicomInstance2;
|
|
8218
|
|
8219 /**
|
|
8220 * @brief Get the number of frames in a DICOM instance.
|
|
8221 *
|
|
8222 * This function returns the number of frames that are part of a
|
|
8223 * DICOM image managed by the Orthanc core.
|
|
8224 *
|
|
8225 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8226 * @param instance The instance of interest.
|
|
8227 * @return The number of frames (will be zero in the case of an error).
|
|
8228 * @ingroup DicomInstance
|
|
8229 **/
|
|
8230 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetInstanceFramesCount(
|
|
8231 OrthancPluginContext* context,
|
|
8232 const OrthancPluginDicomInstance* instance)
|
|
8233 {
|
|
8234 uint32_t count;
|
|
8235
|
|
8236 _OrthancPluginAccessDicomInstance2 params;
|
|
8237 memset(¶ms, 0, sizeof(params));
|
|
8238 params.targetUint32 = &count;
|
|
8239 params.instance = instance;
|
|
8240
|
|
8241 if (context->InvokeService(context, _OrthancPluginService_GetInstanceFramesCount, ¶ms) != OrthancPluginErrorCode_Success)
|
|
8242 {
|
|
8243 /* Error */
|
|
8244 return 0;
|
|
8245 }
|
|
8246 else
|
|
8247 {
|
|
8248 return count;
|
|
8249 }
|
|
8250 }
|
|
8251
|
|
8252
|
|
8253 /**
|
|
8254 * @brief Get the raw content of a frame in a DICOM instance.
|
|
8255 *
|
|
8256 * This function returns a memory buffer containing the raw content
|
|
8257 * of a frame in a DICOM instance that is managed by the Orthanc
|
|
8258 * core. This is notably useful for compressed transfer syntaxes, as
|
|
8259 * it gives access to the embedded files (such as JPEG, JPEG-LS or
|
|
8260 * JPEG2k). The Orthanc core transparently reassembles the fragments
|
|
8261 * to extract the raw frame.
|
|
8262 *
|
|
8263 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8264 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
8265 * @param instance The instance of interest.
|
|
8266 * @param frameIndex The index of the frame of interest.
|
|
8267 * @return 0 if success, or the error code if failure.
|
|
8268 * @ingroup DicomInstance
|
|
8269 **/
|
|
8270 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetInstanceRawFrame(
|
|
8271 OrthancPluginContext* context,
|
|
8272 OrthancPluginMemoryBuffer* target,
|
|
8273 const OrthancPluginDicomInstance* instance,
|
|
8274 uint32_t frameIndex)
|
|
8275 {
|
|
8276 _OrthancPluginAccessDicomInstance2 params;
|
|
8277 memset(¶ms, 0, sizeof(params));
|
|
8278 params.targetBuffer = target;
|
|
8279 params.instance = instance;
|
|
8280 params.frameIndex = frameIndex;
|
|
8281
|
|
8282 return context->InvokeService(context, _OrthancPluginService_GetInstanceRawFrame, ¶ms);
|
|
8283 }
|
|
8284
|
|
8285
|
|
8286 /**
|
|
8287 * @brief Decode one frame from a DICOM instance.
|
|
8288 *
|
|
8289 * This function decodes one frame of a DICOM image that is managed
|
|
8290 * by the Orthanc core.
|
|
8291 *
|
|
8292 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8293 * @param instance The instance of interest.
|
|
8294 * @param frameIndex The index of the frame of interest.
|
|
8295 * @return The uncompressed image. It must be freed with OrthancPluginFreeImage().
|
|
8296 * @ingroup DicomInstance
|
|
8297 **/
|
|
8298 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginGetInstanceDecodedFrame(
|
|
8299 OrthancPluginContext* context,
|
|
8300 const OrthancPluginDicomInstance* instance,
|
|
8301 uint32_t frameIndex)
|
|
8302 {
|
|
8303 OrthancPluginImage* target = NULL;
|
|
8304
|
|
8305 _OrthancPluginAccessDicomInstance2 params;
|
|
8306 memset(¶ms, 0, sizeof(params));
|
|
8307 params.targetImage = ⌖
|
|
8308 params.instance = instance;
|
|
8309 params.frameIndex = frameIndex;
|
|
8310
|
|
8311 if (context->InvokeService(context, _OrthancPluginService_GetInstanceDecodedFrame, ¶ms) != OrthancPluginErrorCode_Success)
|
|
8312 {
|
|
8313 return NULL;
|
|
8314 }
|
|
8315 else
|
|
8316 {
|
|
8317 return target;
|
|
8318 }
|
|
8319 }
|
|
8320
|
|
8321
|
|
8322 /**
|
|
8323 * @brief Parse and transcode a DICOM instance.
|
|
8324 *
|
|
8325 * This function parses a memory buffer that contains a DICOM file,
|
|
8326 * then transcodes it to the given transfer syntax. The function
|
|
8327 * returns a new pointer to a data structure that is managed by the
|
|
8328 * Orthanc core.
|
|
8329 *
|
|
8330 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8331 * @param buffer The memory buffer containing the DICOM instance.
|
|
8332 * @param size The size of the memory buffer.
|
|
8333 * @param transferSyntax The transfer syntax UID for the transcoding.
|
|
8334 * @return The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance().
|
|
8335 * @ingroup DicomInstance
|
|
8336 **/
|
|
8337 ORTHANC_PLUGIN_INLINE OrthancPluginDicomInstance* OrthancPluginTranscodeDicomInstance(
|
|
8338 OrthancPluginContext* context,
|
|
8339 const void* buffer,
|
|
8340 uint32_t size,
|
|
8341 const char* transferSyntax)
|
|
8342 {
|
|
8343 OrthancPluginDicomInstance* target = NULL;
|
|
8344
|
|
8345 _OrthancPluginCreateDicomInstance params;
|
|
8346 params.target = ⌖
|
|
8347 params.buffer = buffer;
|
|
8348 params.size = size;
|
|
8349 params.transferSyntax = transferSyntax;
|
|
8350
|
|
8351 if (context->InvokeService(context, _OrthancPluginService_TranscodeDicomInstance, ¶ms) != OrthancPluginErrorCode_Success)
|
|
8352 {
|
|
8353 /* Error */
|
|
8354 return NULL;
|
|
8355 }
|
|
8356 else
|
|
8357 {
|
|
8358 return target;
|
|
8359 }
|
|
8360 }
|
|
8361
|
|
8362 /**
|
|
8363 * @brief Writes a DICOM instance to a memory buffer.
|
|
8364 *
|
|
8365 * This function returns a memory buffer containing the
|
|
8366 * serialization of a DICOM instance that is managed by the Orthanc
|
|
8367 * core.
|
|
8368 *
|
|
8369 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8370 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
8371 * @param instance The instance of interest.
|
|
8372 * @return 0 if success, or the error code if failure.
|
|
8373 * @ingroup DicomInstance
|
|
8374 **/
|
|
8375 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSerializeDicomInstance(
|
|
8376 OrthancPluginContext* context,
|
|
8377 OrthancPluginMemoryBuffer* target,
|
|
8378 const OrthancPluginDicomInstance* instance)
|
|
8379 {
|
|
8380 _OrthancPluginAccessDicomInstance2 params;
|
|
8381 memset(¶ms, 0, sizeof(params));
|
|
8382 params.targetBuffer = target;
|
|
8383 params.instance = instance;
|
|
8384
|
|
8385 return context->InvokeService(context, _OrthancPluginService_SerializeDicomInstance, ¶ms);
|
|
8386 }
|
|
8387
|
|
8388
|
|
8389 /**
|
|
8390 * @brief Format a DICOM memory buffer as a JSON string.
|
|
8391 *
|
|
8392 * This function takes as DICOM instance managed by the Orthanc
|
|
8393 * core, and outputs a JSON string representing the tags of this
|
|
8394 * DICOM file.
|
|
8395 *
|
|
8396 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8397 * @param instance The DICOM instance of interest.
|
|
8398 * @param format The output format.
|
|
8399 * @param flags Flags governing the output.
|
|
8400 * @param maxStringLength The maximum length of a field. Too long fields will
|
|
8401 * be output as "null". The 0 value means no maximum length.
|
|
8402 * @return The NULL value if the case of an error, or the JSON
|
|
8403 * string. This string must be freed by OrthancPluginFreeString().
|
|
8404 * @ingroup DicomInstance
|
|
8405 * @see OrthancPluginDicomBufferToJson
|
|
8406 **/
|
|
8407 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceAdvancedJson(
|
|
8408 OrthancPluginContext* context,
|
|
8409 const OrthancPluginDicomInstance* instance,
|
|
8410 OrthancPluginDicomToJsonFormat format,
|
|
8411 OrthancPluginDicomToJsonFlags flags,
|
|
8412 uint32_t maxStringLength)
|
|
8413 {
|
|
8414 char* result = NULL;
|
|
8415
|
|
8416 _OrthancPluginAccessDicomInstance2 params;
|
|
8417 memset(¶ms, 0, sizeof(params));
|
|
8418 params.targetStringToFree = &result;
|
|
8419 params.instance = instance;
|
|
8420 params.format = format;
|
|
8421 params.flags = flags;
|
|
8422 params.maxStringLength = maxStringLength;
|
|
8423
|
|
8424 if (context->InvokeService(context, _OrthancPluginService_GetInstanceAdvancedJson, ¶ms) != OrthancPluginErrorCode_Success)
|
|
8425 {
|
|
8426 /* Error */
|
|
8427 return NULL;
|
|
8428 }
|
|
8429 else
|
|
8430 {
|
|
8431 return result;
|
|
8432 }
|
|
8433 }
|
|
8434
|
|
8435
|
|
8436 /**
|
|
8437 * @brief Convert a DICOM instance to DICOMweb JSON.
|
|
8438 *
|
|
8439 * This function converts a DICOM instance that is managed by the
|
|
8440 * Orthanc core, into its DICOMweb JSON representation.
|
|
8441 *
|
|
8442 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8443 * @param instance The DICOM instance of interest.
|
|
8444 * @param callback Callback to set the value of the binary tags.
|
|
8445 * @param payload User payload.
|
|
8446 * @return The NULL value in case of error, or the JSON document. This string must
|
|
8447 * be freed by OrthancPluginFreeString().
|
|
8448 * @ingroup DicomInstance
|
|
8449 **/
|
|
8450 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceDicomWebJson(
|
|
8451 OrthancPluginContext* context,
|
|
8452 const OrthancPluginDicomInstance* instance,
|
|
8453 OrthancPluginDicomWebBinaryCallback2 callback,
|
|
8454 void* payload)
|
|
8455 {
|
|
8456 char* target = NULL;
|
|
8457
|
|
8458 _OrthancPluginAccessDicomInstance2 params;
|
|
8459 params.targetStringToFree = ⌖
|
|
8460 params.instance = instance;
|
|
8461 params.dicomWebCallback = callback;
|
|
8462 params.dicomWebPayload = payload;
|
|
8463
|
|
8464 if (context->InvokeService(context, _OrthancPluginService_GetInstanceDicomWebJson, ¶ms) != OrthancPluginErrorCode_Success)
|
|
8465 {
|
|
8466 /* Error */
|
|
8467 return NULL;
|
|
8468 }
|
|
8469 else
|
|
8470 {
|
|
8471 return target;
|
|
8472 }
|
|
8473 }
|
|
8474
|
|
8475
|
|
8476 /**
|
|
8477 * @brief Convert a DICOM instance to DICOMweb XML.
|
|
8478 *
|
|
8479 * This function converts a DICOM instance that is managed by the
|
|
8480 * Orthanc core, into its DICOMweb XML representation.
|
|
8481 *
|
|
8482 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8483 * @param instance The DICOM instance of interest.
|
|
8484 * @param callback Callback to set the value of the binary tags.
|
|
8485 * @param payload User payload.
|
|
8486 * @return The NULL value in case of error, or the XML document. This string must
|
|
8487 * be freed by OrthancPluginFreeString().
|
|
8488 * @ingroup DicomInstance
|
|
8489 **/
|
|
8490 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceDicomWebXml(
|
|
8491 OrthancPluginContext* context,
|
|
8492 const OrthancPluginDicomInstance* instance,
|
|
8493 OrthancPluginDicomWebBinaryCallback2 callback,
|
|
8494 void* payload)
|
|
8495 {
|
|
8496 char* target = NULL;
|
|
8497
|
|
8498 _OrthancPluginAccessDicomInstance2 params;
|
|
8499 params.targetStringToFree = ⌖
|
|
8500 params.instance = instance;
|
|
8501 params.dicomWebCallback = callback;
|
|
8502 params.dicomWebPayload = payload;
|
|
8503
|
|
8504 if (context->InvokeService(context, _OrthancPluginService_GetInstanceDicomWebXml, ¶ms) != OrthancPluginErrorCode_Success)
|
|
8505 {
|
|
8506 /* Error */
|
|
8507 return NULL;
|
|
8508 }
|
|
8509 else
|
|
8510 {
|
|
8511 return target;
|
|
8512 }
|
|
8513 }
|
|
8514
|
|
8515
|
|
8516
|
|
8517 /**
|
|
8518 * @brief Signature of a callback function to transcode a DICOM instance.
|
|
8519 * @param transcoded Target memory buffer. It must be allocated by the
|
|
8520 * plugin using OrthancPluginCreateMemoryBuffer().
|
|
8521 * @param buffer Memory buffer containing the source DICOM instance.
|
|
8522 * @param size Size of the source memory buffer.
|
|
8523 * @param allowedSyntaxes A C array of possible transfer syntaxes UIDs for the
|
|
8524 * result of the transcoding. The plugin must choose by itself the
|
|
8525 * transfer syntax that will be used for the resulting DICOM image.
|
|
8526 * @param countSyntaxes The number of transfer syntaxes that are contained
|
|
8527 * in the "allowedSyntaxes" array.
|
|
8528 * @param allowNewSopInstanceUid Whether the transcoding plugin can select
|
|
8529 * a transfer syntax that will change the SOP instance UID (or, in other
|
|
8530 * terms, whether the plugin can transcode using lossy compression).
|
|
8531 * @return 0 if success (i.e. image successfully transcoded and stored into
|
|
8532 * "transcoded"), or the error code if failure.
|
|
8533 * @ingroup Callbacks
|
|
8534 **/
|
|
8535 typedef OrthancPluginErrorCode (*OrthancPluginTranscoderCallback) (
|
|
8536 OrthancPluginMemoryBuffer* transcoded /* out */,
|
|
8537 const void* buffer,
|
|
8538 uint64_t size,
|
|
8539 const char* const* allowedSyntaxes,
|
|
8540 uint32_t countSyntaxes,
|
|
8541 uint8_t allowNewSopInstanceUid);
|
|
8542
|
|
8543
|
|
8544 typedef struct
|
|
8545 {
|
|
8546 OrthancPluginTranscoderCallback callback;
|
|
8547 } _OrthancPluginTranscoderCallback;
|
|
8548
|
|
8549 /**
|
|
8550 * @brief Register a callback to handle the transcoding of DICOM images.
|
|
8551 *
|
|
8552 * This function registers a custom callback to transcode DICOM
|
|
8553 * images, extending the built-in transcoder of Orthanc that uses
|
|
8554 * DCMTK. The exact behavior is affected by the configuration option
|
|
8555 * "BuiltinDecoderTranscoderOrder" of Orthanc.
|
|
8556 *
|
|
8557 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8558 * @param callback The callback.
|
|
8559 * @return 0 if success, other value if error.
|
|
8560 * @ingroup Callbacks
|
|
8561 **/
|
|
8562 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterTranscoderCallback(
|
|
8563 OrthancPluginContext* context,
|
|
8564 OrthancPluginTranscoderCallback callback)
|
|
8565 {
|
|
8566 _OrthancPluginTranscoderCallback params;
|
|
8567 params.callback = callback;
|
|
8568
|
|
8569 return context->InvokeService(context, _OrthancPluginService_RegisterTranscoderCallback, ¶ms);
|
|
8570 }
|
|
8571
|
|
8572
|
|
8573
|
|
8574 typedef struct
|
|
8575 {
|
|
8576 OrthancPluginMemoryBuffer* target;
|
|
8577 uint32_t size;
|
|
8578 } _OrthancPluginCreateMemoryBuffer;
|
|
8579
|
|
8580 /**
|
|
8581 * @brief Create a 32-bit memory buffer.
|
|
8582 *
|
|
8583 * This function creates a memory buffer that is managed by the
|
|
8584 * Orthanc core. The main use case of this function is for plugins
|
|
8585 * that act as DICOM transcoders.
|
|
8586 *
|
|
8587 * Your plugin should never call "free()" on the resulting memory
|
|
8588 * buffer, as the C library that is used by the plugin is in general
|
|
8589 * not the same as the one used by the Orthanc core.
|
|
8590 *
|
|
8591 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8592 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
8593 * @param size Size of the memory buffer to be created.
|
|
8594 * @return 0 if success, or the error code if failure.
|
|
8595 * @ingroup Toolbox
|
|
8596 **/
|
|
8597 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateMemoryBuffer(
|
|
8598 OrthancPluginContext* context,
|
|
8599 OrthancPluginMemoryBuffer* target,
|
|
8600 uint32_t size)
|
|
8601 {
|
|
8602 _OrthancPluginCreateMemoryBuffer params;
|
|
8603 params.target = target;
|
|
8604 params.size = size;
|
|
8605
|
|
8606 return context->InvokeService(context, _OrthancPluginService_CreateMemoryBuffer, ¶ms);
|
|
8607 }
|
|
8608
|
|
8609
|
|
8610 /**
|
|
8611 * @brief Generate a token to grant full access to the REST API of Orthanc.
|
|
8612 *
|
|
8613 * This function generates a token that can be set in the HTTP
|
|
8614 * header "Authorization" so as to grant full access to the REST API
|
|
8615 * of Orthanc using an external HTTP client. Using this function
|
|
8616 * avoids the need of adding a separate user in the
|
|
8617 * "RegisteredUsers" configuration of Orthanc, which eases
|
|
8618 * deployments.
|
|
8619 *
|
|
8620 * This feature is notably useful in multiprocess scenarios, where a
|
|
8621 * subprocess created by a plugin has no access to the
|
|
8622 * "OrthancPluginContext", and thus cannot call
|
|
8623 * "OrthancPluginRestApi[Get|Post|Put|Delete]()".
|
|
8624 *
|
|
8625 * This situation is frequently encountered in Python plugins, where
|
|
8626 * the "multiprocessing" package can be used to bypass the Global
|
|
8627 * Interpreter Lock (GIL) and thus to improve performance and
|
|
8628 * concurrency.
|
|
8629 *
|
|
8630 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8631 * @return The authorization token, or NULL value in the case of an error.
|
|
8632 * This string must be freed by OrthancPluginFreeString().
|
|
8633 * @ingroup Orthanc
|
|
8634 **/
|
|
8635 ORTHANC_PLUGIN_INLINE char* OrthancPluginGenerateRestApiAuthorizationToken(
|
|
8636 OrthancPluginContext* context)
|
|
8637 {
|
|
8638 char* result;
|
|
8639
|
|
8640 _OrthancPluginRetrieveDynamicString params;
|
|
8641 params.result = &result;
|
|
8642 params.argument = NULL;
|
|
8643
|
|
8644 if (context->InvokeService(context, _OrthancPluginService_GenerateRestApiAuthorizationToken,
|
|
8645 ¶ms) != OrthancPluginErrorCode_Success)
|
|
8646 {
|
|
8647 /* Error */
|
|
8648 return NULL;
|
|
8649 }
|
|
8650 else
|
|
8651 {
|
|
8652 return result;
|
|
8653 }
|
|
8654 }
|
|
8655
|
|
8656
|
|
8657
|
|
8658 typedef struct
|
|
8659 {
|
|
8660 OrthancPluginMemoryBuffer64* target;
|
|
8661 uint64_t size;
|
|
8662 } _OrthancPluginCreateMemoryBuffer64;
|
|
8663
|
|
8664 /**
|
|
8665 * @brief Create a 64-bit memory buffer.
|
|
8666 *
|
|
8667 * This function creates a 64-bit memory buffer that is managed by
|
|
8668 * the Orthanc core. The main use case of this function is for
|
|
8669 * plugins that read files from the storage area.
|
|
8670 *
|
|
8671 * Your plugin should never call "free()" on the resulting memory
|
|
8672 * buffer, as the C library that is used by the plugin is in general
|
|
8673 * not the same as the one used by the Orthanc core.
|
|
8674 *
|
|
8675 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8676 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
8677 * @param size Size of the memory buffer to be created.
|
|
8678 * @return 0 if success, or the error code if failure.
|
|
8679 * @ingroup Toolbox
|
|
8680 **/
|
|
8681 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateMemoryBuffer64(
|
|
8682 OrthancPluginContext* context,
|
|
8683 OrthancPluginMemoryBuffer64* target,
|
|
8684 uint64_t size)
|
|
8685 {
|
|
8686 _OrthancPluginCreateMemoryBuffer64 params;
|
|
8687 params.target = target;
|
|
8688 params.size = size;
|
|
8689
|
|
8690 return context->InvokeService(context, _OrthancPluginService_CreateMemoryBuffer64, ¶ms);
|
|
8691 }
|
|
8692
|
|
8693
|
|
8694 typedef struct
|
|
8695 {
|
|
8696 OrthancPluginStorageCreate create;
|
|
8697 OrthancPluginStorageReadWhole readWhole;
|
|
8698 OrthancPluginStorageReadRange readRange;
|
|
8699 OrthancPluginStorageRemove remove;
|
|
8700 } _OrthancPluginRegisterStorageArea2;
|
|
8701
|
|
8702 /**
|
|
8703 * @brief Register a custom storage area, with support for range request.
|
|
8704 *
|
|
8705 * This function registers a custom storage area, to replace the
|
|
8706 * built-in way Orthanc stores its files on the filesystem. This
|
|
8707 * function must be called during the initialization of the plugin,
|
|
8708 * i.e. inside the OrthancPluginInitialize() public function.
|
|
8709 *
|
|
8710 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8711 * @param create The callback function to store a file on the custom storage area.
|
|
8712 * @param readWhole The callback function to read a whole file from the custom storage area.
|
|
8713 * @param readRange The callback function to read some range of a file from the custom storage area.
|
|
8714 * If this feature is not supported by the plugin, this value can be set to NULL.
|
|
8715 * @param remove The callback function to remove a file from the custom storage area.
|
|
8716 * @ingroup Callbacks
|
|
8717 **/
|
|
8718 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea2(
|
|
8719 OrthancPluginContext* context,
|
|
8720 OrthancPluginStorageCreate create,
|
|
8721 OrthancPluginStorageReadWhole readWhole,
|
|
8722 OrthancPluginStorageReadRange readRange,
|
|
8723 OrthancPluginStorageRemove remove)
|
|
8724 {
|
|
8725 _OrthancPluginRegisterStorageArea2 params;
|
|
8726 params.create = create;
|
|
8727 params.readWhole = readWhole;
|
|
8728 params.readRange = readRange;
|
|
8729 params.remove = remove;
|
|
8730 context->InvokeService(context, _OrthancPluginService_RegisterStorageArea2, ¶ms);
|
|
8731 }
|
|
8732
|
|
8733
|
|
8734
|
|
8735 typedef struct
|
|
8736 {
|
|
8737 _OrthancPluginCreateDicom createDicom;
|
|
8738 const char* privateCreator;
|
|
8739 } _OrthancPluginCreateDicom2;
|
|
8740
|
|
8741 /**
|
|
8742 * @brief Create a DICOM instance from a JSON string and an image, with a private creator.
|
|
8743 *
|
|
8744 * This function takes as input a string containing a JSON file
|
|
8745 * describing the content of a DICOM instance. As an output, it
|
|
8746 * writes the corresponding DICOM instance to a newly allocated
|
|
8747 * memory buffer. Additionally, an image to be encoded within the
|
|
8748 * DICOM instance can also be provided.
|
|
8749 *
|
|
8750 * Contrarily to the function OrthancPluginCreateDicom(), this
|
|
8751 * function can be explicitly provided with a private creator.
|
|
8752 *
|
|
8753 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8754 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
8755 * @param json The input JSON file.
|
|
8756 * @param pixelData The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme.
|
|
8757 * @param flags Flags governing the output.
|
|
8758 * @param privateCreator The private creator to be used for the private DICOM tags.
|
|
8759 * Check out the global configuration option "Dictionary" of Orthanc.
|
|
8760 * @return 0 if success, other value if error.
|
|
8761 * @ingroup Toolbox
|
|
8762 * @see OrthancPluginCreateDicom
|
|
8763 * @see OrthancPluginDicomBufferToJson
|
|
8764 **/
|
|
8765 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateDicom2(
|
|
8766 OrthancPluginContext* context,
|
|
8767 OrthancPluginMemoryBuffer* target,
|
|
8768 const char* json,
|
|
8769 const OrthancPluginImage* pixelData,
|
|
8770 OrthancPluginCreateDicomFlags flags,
|
|
8771 const char* privateCreator)
|
|
8772 {
|
|
8773 _OrthancPluginCreateDicom2 params;
|
|
8774 params.createDicom.target = target;
|
|
8775 params.createDicom.json = json;
|
|
8776 params.createDicom.pixelData = pixelData;
|
|
8777 params.createDicom.flags = flags;
|
|
8778 params.privateCreator = privateCreator;
|
|
8779
|
|
8780 return context->InvokeService(context, _OrthancPluginService_CreateDicom2, ¶ms);
|
|
8781 }
|
|
8782
|
|
8783
|
|
8784
|
|
8785
|
|
8786
|
|
8787
|
|
8788 typedef struct
|
|
8789 {
|
|
8790 OrthancPluginMemoryBuffer* answerBody;
|
|
8791 OrthancPluginMemoryBuffer* answerHeaders;
|
|
8792 uint16_t* httpStatus;
|
|
8793 OrthancPluginHttpMethod method;
|
|
8794 const char* uri;
|
|
8795 uint32_t headersCount;
|
|
8796 const char* const* headersKeys;
|
|
8797 const char* const* headersValues;
|
|
8798 const void* body;
|
|
8799 uint32_t bodySize;
|
|
8800 uint8_t afterPlugins;
|
|
8801 } _OrthancPluginCallRestApi;
|
|
8802
|
|
8803 /**
|
|
8804 * @brief Call the REST API of Orthanc with full flexibility.
|
|
8805 *
|
|
8806 * Make a call to the given URI in the REST API of Orthanc. The
|
|
8807 * result to the query is stored into a newly allocated memory
|
|
8808 * buffer. This function is always granted full access to the REST
|
|
8809 * API (no credentials, nor security token is needed).
|
|
8810 *
|
|
8811 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
8812 * @param answerBody The target memory buffer (out argument).
|
|
8813 * It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
8814 * The value of this argument is ignored if the HTTP method is DELETE.
|
|
8815 * @param answerHeaders The target memory buffer for the HTTP headers in the answer (out argument).
|
|
8816 * The answer headers are formatted as a JSON object (associative array).
|
|
8817 * The buffer must be freed with OrthancPluginFreeMemoryBuffer().
|
|
8818 * This argument can be set to NULL if the plugin has no interest in the answer HTTP headers.
|
|
8819 * @param httpStatus The HTTP status after the execution of the request (out argument).
|
|
8820 * @param method HTTP method to be used.
|
|
8821 * @param uri The URI of interest.
|
|
8822 * @param headersCount The number of HTTP headers.
|
|
8823 * @param headersKeys Array containing the keys of the HTTP headers (can be <tt>NULL</tt> if no header).
|
|
8824 * @param headersValues Array containing the values of the HTTP headers (can be <tt>NULL</tt> if no header).
|
|
8825 * @param body The HTTP body for a POST or PUT request.
|
|
8826 * @param bodySize The size of the body.
|
|
8827 * @param afterPlugins If 0, the built-in API of Orthanc is used.
|
|
8828 * If 1, the API is tainted by the plugins.
|
|
8829 * @return 0 if success, or the error code if failure.
|
|
8830 * @see OrthancPluginRestApiGet2, OrthancPluginRestApiPost, OrthancPluginRestApiPut, OrthancPluginRestApiDelete
|
|
8831 * @ingroup Orthanc
|
|
8832 **/
|
|
8833 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCallRestApi(
|
|
8834 OrthancPluginContext* context,
|
|
8835 OrthancPluginMemoryBuffer* answerBody,
|
|
8836 OrthancPluginMemoryBuffer* answerHeaders,
|
|
8837 uint16_t* httpStatus,
|
|
8838 OrthancPluginHttpMethod method,
|
|
8839 const char* uri,
|
|
8840 uint32_t headersCount,
|
|
8841 const char* const* headersKeys,
|
|
8842 const char* const* headersValues,
|
|
8843 const void* body,
|
|
8844 uint32_t bodySize,
|
|
8845 uint8_t afterPlugins)
|
|
8846 {
|
|
8847 _OrthancPluginCallRestApi params;
|
|
8848 memset(¶ms, 0, sizeof(params));
|
|
8849
|
|
8850 params.answerBody = answerBody;
|
|
8851 params.answerHeaders = answerHeaders;
|
|
8852 params.httpStatus = httpStatus;
|
|
8853 params.method = method;
|
|
8854 params.uri = uri;
|
|
8855 params.headersCount = headersCount;
|
|
8856 params.headersKeys = headersKeys;
|
|
8857 params.headersValues = headersValues;
|
|
8858 params.body = body;
|
|
8859 params.bodySize = bodySize;
|
|
8860 params.afterPlugins = afterPlugins;
|
|
8861
|
|
8862 return context->InvokeService(context, _OrthancPluginService_CallRestApi, ¶ms);
|
|
8863 }
|
|
8864
|
|
8865
|
|
8866
|
|
8867 /**
|
|
8868 * @brief Opaque structure that represents a WebDAV collection.
|
|
8869 * @ingroup Callbacks
|
|
8870 **/
|
|
8871 typedef struct _OrthancPluginWebDavCollection_t OrthancPluginWebDavCollection;
|
|
8872
|
|
8873
|
|
8874 /**
|
|
8875 * @brief Declare a file while returning the content of a folder.
|
|
8876 *
|
|
8877 * This function declares a file while returning the content of a
|
|
8878 * WebDAV folder.
|
|
8879 *
|
|
8880 * @param collection Context of the collection.
|
|
8881 * @param name Base name of the file.
|
|
8882 * @param dateTime The date and time of creation of the file.
|
|
8883 * Check out the documentation of OrthancPluginWebDavRetrieveFile() for more information.
|
|
8884 * @param size Size of the file.
|
|
8885 * @param mimeType The MIME type of the file. If empty or set to `NULL`,
|
|
8886 * Orthanc will do a best guess depending on the file extension.
|
|
8887 * @return 0 if success, other value if error.
|
|
8888 * @ingroup Callbacks
|
|
8889 **/
|
|
8890 typedef OrthancPluginErrorCode (*OrthancPluginWebDavAddFile) (
|
|
8891 OrthancPluginWebDavCollection* collection,
|
|
8892 const char* name,
|
|
8893 uint64_t size,
|
|
8894 const char* mimeType,
|
|
8895 const char* dateTime);
|
|
8896
|
|
8897
|
|
8898 /**
|
|
8899 * @brief Declare a subfolder while returning the content of a folder.
|
|
8900 *
|
|
8901 * This function declares a subfolder while returning the content of a
|
|
8902 * WebDAV folder.
|
|
8903 *
|
|
8904 * @param collection Context of the collection.
|
|
8905 * @param name Base name of the subfolder.
|
|
8906 * @param dateTime The date and time of creation of the subfolder.
|
|
8907 * Check out the documentation of OrthancPluginWebDavRetrieveFile() for more information.
|
|
8908 * @return 0 if success, other value if error.
|
|
8909 * @ingroup Callbacks
|
|
8910 **/
|
|
8911 typedef OrthancPluginErrorCode (*OrthancPluginWebDavAddFolder) (
|
|
8912 OrthancPluginWebDavCollection* collection,
|
|
8913 const char* name,
|
|
8914 const char* dateTime);
|
|
8915
|
|
8916
|
|
8917 /**
|
|
8918 * @brief Retrieve the content of a file.
|
|
8919 *
|
|
8920 * This function is used to forward the content of a file from a
|
|
8921 * WebDAV collection, to the core of Orthanc.
|
|
8922 *
|
|
8923 * @param collection Context of the collection.
|
|
8924 * @param data Content of the file.
|
|
8925 * @param size Size of the file.
|
|
8926 * @param mimeType The MIME type of the file. If empty or set to `NULL`,
|
|
8927 * Orthanc will do a best guess depending on the file extension.
|
|
8928 * @param dateTime The date and time of creation of the file.
|
|
8929 * It must be formatted as an ISO string of form
|
|
8930 * `YYYYMMDDTHHMMSS,fffffffff` where T is the date-time
|
|
8931 * separator. It must be expressed in UTC (it is the responsibility
|
|
8932 * of the plugin to do the possible timezone
|
|
8933 * conversions). Internally, this string will be parsed using
|
|
8934 * `boost::posix_time::from_iso_string()`.
|
|
8935 * @return 0 if success, other value if error.
|
|
8936 * @ingroup Callbacks
|
|
8937 **/
|
|
8938 typedef OrthancPluginErrorCode (*OrthancPluginWebDavRetrieveFile) (
|
|
8939 OrthancPluginWebDavCollection* collection,
|
|
8940 const void* data,
|
|
8941 uint64_t size,
|
|
8942 const char* mimeType,
|
|
8943 const char* dateTime);
|
|
8944
|
|
8945
|
|
8946 /**
|
|
8947 * @brief Callback for testing the existence of a folder.
|
|
8948 *
|
|
8949 * Signature of a callback function that tests whether the given
|
|
8950 * path in the WebDAV collection exists and corresponds to a folder.
|
|
8951 *
|
|
8952 * @param isExisting Pointer to a Boolean that must be set to `1` if the folder exists, or `0` otherwise.
|
|
8953 * @param pathSize Number of levels in the path.
|
|
8954 * @param pathItems Items making the path.
|
|
8955 * @param payload The user payload.
|
|
8956 * @return 0 if success, other value if error.
|
|
8957 * @ingroup Callbacks
|
|
8958 **/
|
|
8959 typedef OrthancPluginErrorCode (*OrthancPluginWebDavIsExistingFolderCallback) (
|
|
8960 uint8_t* isExisting, /* out */
|
|
8961 uint32_t pathSize,
|
|
8962 const char* const* pathItems,
|
|
8963 void* payload);
|
|
8964
|
|
8965
|
|
8966 /**
|
|
8967 * @brief Callback for listing the content of a folder.
|
|
8968 *
|
|
8969 * Signature of a callback function that lists the content of a
|
|
8970 * folder in the WebDAV collection. The callback must call the
|
|
8971 * provided `addFile()` and `addFolder()` functions to emit the
|
|
8972 * content of the folder.
|
|
8973 *
|
|
8974 * @param isExisting Pointer to a Boolean that must be set to `1` if the folder exists, or `0` otherwise.
|
|
8975 * @param collection Context to be provided to `addFile()` and `addFolder()` functions.
|
|
8976 * @param addFile Function to add a file to the list.
|
|
8977 * @param addFolder Function to add a folder to the list.
|
|
8978 * @param pathSize Number of levels in the path.
|
|
8979 * @param pathItems Items making the path.
|
|
8980 * @param payload The user payload.
|
|
8981 * @return 0 if success, other value if error.
|
|
8982 * @ingroup Callbacks
|
|
8983 **/
|
|
8984 typedef OrthancPluginErrorCode (*OrthancPluginWebDavListFolderCallback) (
|
|
8985 uint8_t* isExisting, /* out */
|
|
8986 OrthancPluginWebDavCollection* collection,
|
|
8987 OrthancPluginWebDavAddFile addFile,
|
|
8988 OrthancPluginWebDavAddFolder addFolder,
|
|
8989 uint32_t pathSize,
|
|
8990 const char* const* pathItems,
|
|
8991 void* payload);
|
|
8992
|
|
8993
|
|
8994 /**
|
|
8995 * @brief Callback for retrieving the content of a file.
|
|
8996 *
|
|
8997 * Signature of a callback function that retrieves the content of a
|
|
8998 * file in the WebDAV collection. The callback must call the
|
|
8999 * provided `retrieveFile()` function to emit the actual content of
|
|
9000 * the file.
|
|
9001 *
|
|
9002 * @param collection Context to be provided to `retrieveFile()` function.
|
|
9003 * @param retrieveFile Function to return the content of the file.
|
|
9004 * @param pathSize Number of levels in the path.
|
|
9005 * @param pathItems Items making the path.
|
|
9006 * @param payload The user payload.
|
|
9007 * @return 0 if success, other value if error.
|
|
9008 * @ingroup Callbacks
|
|
9009 **/
|
|
9010 typedef OrthancPluginErrorCode (*OrthancPluginWebDavRetrieveFileCallback) (
|
|
9011 OrthancPluginWebDavCollection* collection,
|
|
9012 OrthancPluginWebDavRetrieveFile retrieveFile,
|
|
9013 uint32_t pathSize,
|
|
9014 const char* const* pathItems,
|
|
9015 void* payload);
|
|
9016
|
|
9017
|
|
9018 /**
|
|
9019 * @brief Callback to store a file.
|
|
9020 *
|
|
9021 * Signature of a callback function that stores a file into the
|
|
9022 * WebDAV collection.
|
|
9023 *
|
|
9024 * @param isReadOnly Pointer to a Boolean that must be set to `1` if the collection is read-only, or `0` otherwise.
|
|
9025 * @param pathSize Number of levels in the path.
|
|
9026 * @param pathItems Items making the path.
|
|
9027 * @param data Content of the file to be stored.
|
|
9028 * @param size Size of the file to be stored.
|
|
9029 * @param payload The user payload.
|
|
9030 * @return 0 if success, other value if error.
|
|
9031 * @ingroup Callbacks
|
|
9032 **/
|
|
9033 typedef OrthancPluginErrorCode (*OrthancPluginWebDavStoreFileCallback) (
|
|
9034 uint8_t* isReadOnly, /* out */
|
|
9035 uint32_t pathSize,
|
|
9036 const char* const* pathItems,
|
|
9037 const void* data,
|
|
9038 uint64_t size,
|
|
9039 void* payload);
|
|
9040
|
|
9041
|
|
9042 /**
|
|
9043 * @brief Callback to create a folder.
|
|
9044 *
|
|
9045 * Signature of a callback function that creates a folder in the
|
|
9046 * WebDAV collection.
|
|
9047 *
|
|
9048 * @param isReadOnly Pointer to a Boolean that must be set to `1` if the collection is read-only, or `0` otherwise.
|
|
9049 * @param pathSize Number of levels in the path.
|
|
9050 * @param pathItems Items making the path.
|
|
9051 * @param payload The user payload.
|
|
9052 * @return 0 if success, other value if error.
|
|
9053 * @ingroup Callbacks
|
|
9054 **/
|
|
9055 typedef OrthancPluginErrorCode (*OrthancPluginWebDavCreateFolderCallback) (
|
|
9056 uint8_t* isReadOnly, /* out */
|
|
9057 uint32_t pathSize,
|
|
9058 const char* const* pathItems,
|
|
9059 void* payload);
|
|
9060
|
|
9061
|
|
9062 /**
|
|
9063 * @brief Callback to remove a file or a folder.
|
|
9064 *
|
|
9065 * Signature of a callback function that removes a file or a folder
|
|
9066 * from the WebDAV collection.
|
|
9067 *
|
|
9068 * @param isReadOnly Pointer to a Boolean that must be set to `1` if the collection is read-only, or `0` otherwise.
|
|
9069 * @param pathSize Number of levels in the path.
|
|
9070 * @param pathItems Items making the path.
|
|
9071 * @param payload The user payload.
|
|
9072 * @return 0 if success, other value if error.
|
|
9073 * @ingroup Callbacks
|
|
9074 **/
|
|
9075 typedef OrthancPluginErrorCode (*OrthancPluginWebDavDeleteItemCallback) (
|
|
9076 uint8_t* isReadOnly, /* out */
|
|
9077 uint32_t pathSize,
|
|
9078 const char* const* pathItems,
|
|
9079 void* payload);
|
|
9080
|
|
9081
|
|
9082 typedef struct
|
|
9083 {
|
|
9084 const char* uri;
|
|
9085 OrthancPluginWebDavIsExistingFolderCallback isExistingFolder;
|
|
9086 OrthancPluginWebDavListFolderCallback listFolder;
|
|
9087 OrthancPluginWebDavRetrieveFileCallback retrieveFile;
|
|
9088 OrthancPluginWebDavStoreFileCallback storeFile;
|
|
9089 OrthancPluginWebDavCreateFolderCallback createFolder;
|
|
9090 OrthancPluginWebDavDeleteItemCallback deleteItem;
|
|
9091 void* payload;
|
|
9092 } _OrthancPluginRegisterWebDavCollection;
|
|
9093
|
|
9094 /**
|
|
9095 * @brief Register a WebDAV virtual filesystem.
|
|
9096 *
|
|
9097 * This function maps a WebDAV collection onto the given URI in the
|
|
9098 * REST API of Orthanc. This function must be called during the
|
|
9099 * initialization of the plugin, i.e. inside the
|
|
9100 * OrthancPluginInitialize() public function.
|
|
9101 *
|
|
9102 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
9103 * @param uri URI where to map the WebDAV collection (must start with a `/` character).
|
|
9104 * @param isExistingFolder Callback method to test for the existence of a folder.
|
|
9105 * @param listFolder Callback method to list the content of a folder.
|
|
9106 * @param retrieveFile Callback method to retrieve the content of a file.
|
|
9107 * @param storeFile Callback method to store a file into the WebDAV collection.
|
|
9108 * @param createFolder Callback method to create a folder.
|
|
9109 * @param deleteItem Callback method to delete a file or a folder.
|
|
9110 * @param payload The user payload.
|
|
9111 * @return 0 if success, other value if error.
|
|
9112 * @ingroup Callbacks
|
|
9113 **/
|
|
9114 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterWebDavCollection(
|
|
9115 OrthancPluginContext* context,
|
|
9116 const char* uri,
|
|
9117 OrthancPluginWebDavIsExistingFolderCallback isExistingFolder,
|
|
9118 OrthancPluginWebDavListFolderCallback listFolder,
|
|
9119 OrthancPluginWebDavRetrieveFileCallback retrieveFile,
|
|
9120 OrthancPluginWebDavStoreFileCallback storeFile,
|
|
9121 OrthancPluginWebDavCreateFolderCallback createFolder,
|
|
9122 OrthancPluginWebDavDeleteItemCallback deleteItem,
|
|
9123 void* payload)
|
|
9124 {
|
|
9125 _OrthancPluginRegisterWebDavCollection params;
|
|
9126 params.uri = uri;
|
|
9127 params.isExistingFolder = isExistingFolder;
|
|
9128 params.listFolder = listFolder;
|
|
9129 params.retrieveFile = retrieveFile;
|
|
9130 params.storeFile = storeFile;
|
|
9131 params.createFolder = createFolder;
|
|
9132 params.deleteItem = deleteItem;
|
|
9133 params.payload = payload;
|
|
9134
|
|
9135 return context->InvokeService(context, _OrthancPluginService_RegisterWebDavCollection, ¶ms);
|
|
9136 }
|
|
9137
|
|
9138
|
|
9139 /**
|
|
9140 * @brief Gets the DatabaseServerIdentifier.
|
|
9141 *
|
|
9142 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
9143 * @return the database server identifier. This is a statically-allocated
|
|
9144 * string, do not free it.
|
|
9145 * @ingroup Toolbox
|
|
9146 **/
|
|
9147 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetDatabaseServerIdentifier(
|
|
9148 OrthancPluginContext* context)
|
|
9149 {
|
|
9150 const char* result;
|
|
9151
|
|
9152 _OrthancPluginRetrieveStaticString params;
|
|
9153 params.result = &result;
|
|
9154 params.argument = NULL;
|
|
9155
|
|
9156 if (context->InvokeService(context, _OrthancPluginService_GetDatabaseServerIdentifier, ¶ms) != OrthancPluginErrorCode_Success)
|
|
9157 {
|
|
9158 /* Error */
|
|
9159 return NULL;
|
|
9160 }
|
|
9161 else
|
|
9162 {
|
|
9163 return result;
|
|
9164 }
|
|
9165 }
|
|
9166
|
|
9167
|
|
9168 /**
|
|
9169 * @brief Signature of a callback function that is triggered when
|
|
9170 * the Orthanc core requests an operation from the database plugin.
|
|
9171 * Both request and response are encoded as protobuf buffers.
|
|
9172 * @ingroup Callbacks
|
|
9173 **/
|
|
9174 typedef OrthancPluginErrorCode (*OrthancPluginCallDatabaseBackendV4) (
|
|
9175 OrthancPluginMemoryBuffer64* response,
|
|
9176 void* backend,
|
|
9177 const void* request,
|
|
9178 uint64_t requestSize);
|
|
9179
|
|
9180 /**
|
|
9181 * @brief Signature of a callback function that is triggered when
|
|
9182 * the database plugin must be finalized.
|
|
9183 * @ingroup Callbacks
|
|
9184 **/
|
|
9185 typedef void (*OrthancPluginFinalizeDatabaseBackendV4) (void* backend);
|
|
9186
|
|
9187 typedef struct
|
|
9188 {
|
|
9189 void* backend;
|
|
9190 uint32_t maxDatabaseRetries;
|
|
9191 OrthancPluginCallDatabaseBackendV4 operations;
|
|
9192 OrthancPluginFinalizeDatabaseBackendV4 finalize;
|
|
9193 } _OrthancPluginRegisterDatabaseBackendV4;
|
|
9194
|
|
9195 /**
|
|
9196 * Register a custom database back-end.
|
|
9197 *
|
|
9198 * This function was added in Orthanc SDK 1.12.0. It uses Google
|
|
9199 * Protocol Buffers for the communications between the Orthanc core
|
|
9200 * and database plugins. Check out "OrthancDatabasePlugin.proto" for
|
|
9201 * the definition of the protobuf messages.
|
|
9202 *
|
|
9203 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
9204 * @param backend Pointer to the custom database backend.
|
|
9205 * @param maxDatabaseRetries Maximum number of retries if transaction doesn't succeed.
|
|
9206 * If no retry is successful, OrthancPluginErrorCode_DatabaseCannotSerialize is generated.
|
|
9207 * @param operations Access to the operations of the custom database backend.
|
|
9208 * @param finalize Callback to deallocate the custom database backend.
|
|
9209 * @return 0 if success, other value if error.
|
|
9210 * @ingroup Callbacks
|
|
9211 **/
|
|
9212 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDatabaseBackendV4(
|
|
9213 OrthancPluginContext* context,
|
|
9214 void* backend,
|
|
9215 uint32_t maxDatabaseRetries,
|
|
9216 OrthancPluginCallDatabaseBackendV4 operations,
|
|
9217 OrthancPluginFinalizeDatabaseBackendV4 finalize)
|
|
9218 {
|
|
9219 _OrthancPluginRegisterDatabaseBackendV4 params;
|
|
9220 params.backend = backend;
|
|
9221 params.maxDatabaseRetries = maxDatabaseRetries;
|
|
9222 params.operations = operations;
|
|
9223 params.finalize = finalize;
|
|
9224
|
|
9225 return context->InvokeService(context, _OrthancPluginService_RegisterDatabaseBackendV4, ¶ms);
|
|
9226 }
|
|
9227
|
|
9228 #ifdef __cplusplus
|
|
9229 }
|
|
9230 #endif
|
|
9231
|
|
9232
|
|
9233 /** @} */
|
|
9234
|