Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Samples/Basic/Plugin.c @ 5342:65d55cc86a41
clarified error message
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 28 Jun 2023 11:54:41 +0200 |
parents | f2e1ad71e49c |
children | cba09fd1e234 |
rev | line source |
---|---|
886 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1282
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5185
0ea402b4d901
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
0ea402b4d901
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
886 | 7 * |
1375
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
9 * modify it under the terms of the GNU General Public License as |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
10 * published by the Free Software Foundation, either version 3 of the |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
11 * License, or (at your option) any later version. |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
12 * |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
16 * General Public License for more details. |
886 | 17 * |
1375
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
886 | 20 **/ |
21 | |
22 | |
1425
97268448bdfc
refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1375
diff
changeset
|
23 #include <orthanc/OrthancCPlugin.h> |
886 | 24 |
25 #include <string.h> | |
26 #include <stdio.h> | |
27 | |
898
7000fc86fe62
improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
897
diff
changeset
|
28 static OrthancPluginContext* context = NULL; |
886 | 29 |
1651
2e692c83e2f3
improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1650
diff
changeset
|
30 static OrthancPluginErrorCode customError; |
1650 | 31 |
886 | 32 |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
33 OrthancPluginErrorCode Callback1(OrthancPluginRestOutput* output, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
34 const char* url, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
35 const OrthancPluginHttpRequest* request) |
894 | 36 { |
37 char buffer[1024]; | |
897
bafc9d592632
REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
896
diff
changeset
|
38 uint32_t i; |
bafc9d592632
REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
896
diff
changeset
|
39 |
2957
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
40 if (request->method != OrthancPluginHttpMethod_Get) |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
41 { |
3206 | 42 /** |
43 * NB: Calling "OrthancPluginSendMethodNotAllowed(context, output, | |
44 * "GET");" is preferable. This is a sample to demonstrate | |
45 * "OrthancPluginSetHttpErrorDetails()". | |
46 **/ | |
2997
5a6a2c5bf73f
fix basic plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2957
diff
changeset
|
47 OrthancPluginSetHttpErrorDetails(context, output, "This Callback1() can only be used by a GET call", 1 /* log */); |
2957
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
48 return OrthancPluginErrorCode_ParameterOutOfRange; |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
49 } |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
50 |
3543
cac5a3ddd441
fix warning in plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3216
diff
changeset
|
51 sprintf(buffer, "Callback on URL [%s] with body [%s]\n", url, (const char*) request->body); |
1041
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
52 OrthancPluginLogWarning(context, buffer); |
897
bafc9d592632
REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
896
diff
changeset
|
53 |
1042
8d1845feb277
set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1041
diff
changeset
|
54 OrthancPluginSetCookie(context, output, "hello", "world"); |
899 | 55 OrthancPluginAnswerBuffer(context, output, buffer, strlen(buffer), "text/plain"); |
897
bafc9d592632
REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
896
diff
changeset
|
56 |
1041
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
57 OrthancPluginLogWarning(context, ""); |
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
58 |
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
59 for (i = 0; i < request->groupsCount; i++) |
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
60 { |
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
61 sprintf(buffer, " REGEX GROUP %d = [%s]", i, request->groups[i]); |
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
62 OrthancPluginLogWarning(context, buffer); |
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
63 } |
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
64 |
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
65 OrthancPluginLogWarning(context, ""); |
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
66 |
899 | 67 for (i = 0; i < request->getCount; i++) |
897
bafc9d592632
REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
896
diff
changeset
|
68 { |
1041
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
69 sprintf(buffer, " GET [%s] = [%s]", request->getKeys[i], request->getValues[i]); |
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
70 OrthancPluginLogWarning(context, buffer); |
897
bafc9d592632
REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
896
diff
changeset
|
71 } |
bafc9d592632
REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
896
diff
changeset
|
72 |
2135
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1962
diff
changeset
|
73 OrthancPluginLogWarning(context, ""); |
1041
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
74 |
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
75 for (i = 0; i < request->headersCount; i++) |
901
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
76 { |
1041
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
77 sprintf(buffer, " HEADERS [%s] = [%s]", request->headersKeys[i], request->headersValues[i]); |
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
78 OrthancPluginLogWarning(context, buffer); |
901
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
79 } |
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
80 |
1042
8d1845feb277
set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1041
diff
changeset
|
81 OrthancPluginLogWarning(context, ""); |
1041
2c49b7dffcec
plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
82 |
2135
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1962
diff
changeset
|
83 return OrthancPluginErrorCode_Success; |
894 | 84 } |
85 | |
86 | |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
87 OrthancPluginErrorCode Callback2(OrthancPluginRestOutput* output, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
88 const char* url, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
89 const OrthancPluginHttpRequest* request) |
901
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
90 { |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
91 /* Answer with a sample 16bpp image. */ |
901
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
92 |
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
93 uint16_t buffer[256 * 256]; |
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
94 uint32_t x, y, value; |
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
95 |
1042
8d1845feb277
set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1041
diff
changeset
|
96 if (request->method != OrthancPluginHttpMethod_Get) |
8d1845feb277
set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1041
diff
changeset
|
97 { |
8d1845feb277
set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1041
diff
changeset
|
98 OrthancPluginSendMethodNotAllowed(context, output, "GET"); |
1043 | 99 } |
100 else | |
101 { | |
102 value = 0; | |
103 for (y = 0; y < 256; y++) | |
104 { | |
105 for (x = 0; x < 256; x++, value++) | |
106 { | |
107 buffer[value] = value; | |
108 } | |
109 } | |
110 | |
111 OrthancPluginCompressAndAnswerPngImage(context, output, OrthancPluginPixelFormat_Grayscale16, | |
112 256, 256, sizeof(uint16_t) * 256, buffer); | |
1042
8d1845feb277
set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1041
diff
changeset
|
113 } |
8d1845feb277
set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1041
diff
changeset
|
114 |
2135
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1962
diff
changeset
|
115 return OrthancPluginErrorCode_Success; |
901
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
116 } |
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
117 |
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
118 |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
119 OrthancPluginErrorCode Callback3(OrthancPluginRestOutput* output, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
120 const char* url, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
121 const OrthancPluginHttpRequest* request) |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
122 { |
1044 | 123 if (request->method != OrthancPluginHttpMethod_Get) |
124 { | |
125 OrthancPluginSendMethodNotAllowed(context, output, "GET"); | |
126 } | |
127 else | |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
128 { |
1044 | 129 OrthancPluginMemoryBuffer dicom; |
130 if (!OrthancPluginGetDicomForInstance(context, &dicom, request->groups[0])) | |
131 { | |
132 /* No error, forward the DICOM file */ | |
133 OrthancPluginAnswerBuffer(context, output, dicom.data, dicom.size, "application/dicom"); | |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
134 |
1044 | 135 /* Free memory */ |
136 OrthancPluginFreeMemoryBuffer(context, &dicom); | |
137 } | |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
138 } |
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
139 |
2135
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1962
diff
changeset
|
140 return OrthancPluginErrorCode_Success; |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
141 } |
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
142 |
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
143 |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
144 OrthancPluginErrorCode Callback4(OrthancPluginRestOutput* output, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
145 const char* url, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
146 const OrthancPluginHttpRequest* request) |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
147 { |
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
148 /* Answer with a sample 8bpp image. */ |
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
149 |
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
150 uint8_t buffer[256 * 256]; |
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
151 uint32_t x, y, value; |
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
152 |
1044 | 153 if (request->method != OrthancPluginHttpMethod_Get) |
154 { | |
155 OrthancPluginSendMethodNotAllowed(context, output, "GET"); | |
156 } | |
157 else | |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
158 { |
1044 | 159 value = 0; |
160 for (y = 0; y < 256; y++) | |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
161 { |
1044 | 162 for (x = 0; x < 256; x++, value++) |
163 { | |
164 buffer[value] = x; | |
165 } | |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
166 } |
1044 | 167 |
168 OrthancPluginCompressAndAnswerPngImage(context, output, OrthancPluginPixelFormat_Grayscale8, | |
169 256, 256, 256, buffer); | |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
170 } |
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
171 |
2135
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1962
diff
changeset
|
172 return OrthancPluginErrorCode_Success; |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
173 } |
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
174 |
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
175 |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
176 OrthancPluginErrorCode Callback5(OrthancPluginRestOutput* output, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
177 const char* url, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
178 const OrthancPluginHttpRequest* request) |
1282
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
179 { |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
180 /** |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
181 * Demonstration the difference between the |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
182 * "OrthancPluginRestApiXXX()" and the |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
183 * "OrthancPluginRestApiXXXAfterPlugins()" mechanisms to forward |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
184 * REST calls. |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
185 * |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
186 * # curl http://localhost:8042/forward/built-in/system |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
187 * # curl http://localhost:8042/forward/plugins/system |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
188 * # curl http://localhost:8042/forward/built-in/plugin/image |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
189 * => FAILURE (because the "/plugin/image" URI is implemented by this plugin) |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
190 * # curl http://localhost:8042/forward/plugins/plugin/image => SUCCESS |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
191 **/ |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
192 |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
193 OrthancPluginMemoryBuffer tmp; |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
194 int isBuiltIn, error; |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
195 |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
196 if (request->method != OrthancPluginHttpMethod_Get) |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
197 { |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
198 OrthancPluginSendMethodNotAllowed(context, output, "GET"); |
2957
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
199 return OrthancPluginErrorCode_Success; |
1282
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
200 } |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
201 |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
202 isBuiltIn = strcmp("plugins", request->groups[0]); |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
203 |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
204 if (isBuiltIn) |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
205 { |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
206 error = OrthancPluginRestApiGet(context, &tmp, request->groups[1]); |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
207 } |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
208 else |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
209 { |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
210 error = OrthancPluginRestApiGetAfterPlugins(context, &tmp, request->groups[1]); |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
211 } |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
212 |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
213 if (error) |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
214 { |
2135
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1962
diff
changeset
|
215 return OrthancPluginErrorCode_InternalError; |
1282
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
216 } |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
217 else |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
218 { |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
219 OrthancPluginAnswerBuffer(context, output, tmp.data, tmp.size, "application/octet-stream"); |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
220 OrthancPluginFreeMemoryBuffer(context, &tmp); |
2135
cadfe0a2a393
fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1962
diff
changeset
|
221 return OrthancPluginErrorCode_Success; |
1282
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
222 } |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
223 } |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
224 |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
225 |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
226 OrthancPluginErrorCode CallbackCreateDicom(OrthancPluginRestOutput* output, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
227 const char* url, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
228 const OrthancPluginHttpRequest* request) |
1137
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
229 { |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
230 const char* pathLocator = "\"Path\" : \""; |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
231 char info[1024]; |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
232 char *id, *eos; |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
233 OrthancPluginMemoryBuffer tmp; |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
234 |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
235 if (request->method != OrthancPluginHttpMethod_Post) |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
236 { |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
237 OrthancPluginSendMethodNotAllowed(context, output, "POST"); |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
238 } |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
239 else |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
240 { |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
241 /* Make POST request to create a new DICOM instance */ |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
242 sprintf(info, "{\"PatientName\":\"Test\"}"); |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
243 OrthancPluginRestApiPost(context, &tmp, "/tools/create-dicom", info, strlen(info)); |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
244 |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
245 /** |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
246 * Recover the ID of the created instance is constructed by a |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
247 * quick-and-dirty parsing of a JSON string. |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
248 **/ |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
249 id = strstr((char*) tmp.data, pathLocator) + strlen(pathLocator); |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
250 eos = strchr(id, '\"'); |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
251 eos[0] = '\0'; |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
252 |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
253 /* Delete the newly created DICOM instance. */ |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
254 OrthancPluginRestApiDelete(context, id); |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
255 OrthancPluginFreeMemoryBuffer(context, &tmp); |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
256 |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
257 /* Set some cookie */ |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
258 OrthancPluginSetCookie(context, output, "hello", "world"); |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
259 |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
260 /* Set some HTTP header */ |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
261 OrthancPluginSetHttpHeader(context, output, "Cache-Control", "max-age=0, no-cache"); |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
262 |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
263 OrthancPluginAnswerBuffer(context, output, "OK\n", 3, "text/plain"); |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
264 } |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
265 |
1627
da7854deb662
Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1425
diff
changeset
|
266 return OrthancPluginErrorCode_Success; |
1137
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
267 } |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
268 |
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
269 |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
270 void DicomWebBinaryCallback( |
3205
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
271 OrthancPluginDicomWebNode* node, |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
272 OrthancPluginDicomWebSetBinaryNode setter, |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
273 uint32_t levelDepth, |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
274 const uint16_t* levelTagGroup, |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
275 const uint16_t* levelTagElement, |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
276 const uint32_t* levelIndex, |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
277 uint16_t tagGroup, |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
278 uint16_t tagElement, |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
279 OrthancPluginValueRepresentation vr) |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
280 { |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
281 setter(node, OrthancPluginDicomWebBinaryMode_BulkDataUri, "HelloURI"); |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
282 } |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
283 |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
284 |
5319
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
285 OrthancPluginErrorCode CallbackDicomWeb(OrthancPluginRestOutput* output, |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
286 const char* url, |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
287 const OrthancPluginHttpRequest* request) |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
288 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
289 if (request->method != OrthancPluginHttpMethod_Get) |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
290 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
291 OrthancPluginSendMethodNotAllowed(context, output, "GET"); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
292 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
293 else |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
294 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
295 OrthancPluginLoadDicomInstanceMode mode = OrthancPluginLoadDicomInstanceMode_WholeDicom; |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
296 if (request->getCount == 1) |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
297 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
298 if (strcmp(request->getKeys[0], "until-pixel-data") == 0) |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
299 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
300 mode = OrthancPluginLoadDicomInstanceMode_UntilPixelData; |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
301 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
302 else if (strcmp(request->getKeys[0], "empty-pixel-data") == 0) |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
303 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
304 mode = OrthancPluginLoadDicomInstanceMode_EmptyPixelData; |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
305 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
306 else |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
307 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
308 return OrthancPluginErrorCode_ParameterOutOfRange; |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
309 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
310 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
311 |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
312 OrthancPluginDicomInstance* instance = OrthancPluginLoadDicomInstance(context, request->groups[0], mode); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
313 if (instance == NULL) |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
314 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
315 return OrthancPluginErrorCode_UnknownResource; |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
316 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
317 |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
318 char* json = OrthancPluginEncodeDicomWebXml(context, |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
319 OrthancPluginGetInstanceData(context, instance), |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
320 OrthancPluginGetInstanceSize(context, instance), |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
321 DicomWebBinaryCallback); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
322 OrthancPluginFreeDicomInstance(context, instance); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
323 |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
324 if (json != NULL) |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
325 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
326 OrthancPluginAnswerBuffer(context, output, json, strlen(json), "application/json"); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
327 OrthancPluginFreeString(context, json); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
328 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
329 else |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
330 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
331 return OrthancPluginErrorCode_InternalError; |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
332 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
333 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
334 |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
335 return OrthancPluginErrorCode_Success; |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
336 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
337 |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
338 |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
339 OrthancPluginErrorCode OnStoredCallback(const OrthancPluginDicomInstance* instance, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
340 const char* instanceId) |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
341 { |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
342 char buffer[256]; |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
343 FILE* fp; |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
344 char* json; |
1191
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
345 static int first = 1; |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
346 |
1815
2abfdca9b915
OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1780
diff
changeset
|
347 sprintf(buffer, "Just received a DICOM instance of size %d and ID %s from origin %d (AET %s)", |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
348 (int) OrthancPluginGetInstanceSize(context, instance), instanceId, |
1815
2abfdca9b915
OrthancPluginGetInstanceOrigin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1780
diff
changeset
|
349 OrthancPluginGetInstanceOrigin(context, instance), |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
350 OrthancPluginGetInstanceRemoteAet(context, instance)); |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
351 |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
352 OrthancPluginLogWarning(context, buffer); |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
353 |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
354 fp = fopen("PluginReceivedInstance.dcm", "wb"); |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
355 fwrite(OrthancPluginGetInstanceData(context, instance), |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
356 OrthancPluginGetInstanceSize(context, instance), 1, fp); |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
357 fclose(fp); |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
358 |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
359 json = OrthancPluginGetInstanceSimplifiedJson(context, instance); |
1191
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
360 if (first) |
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
361 { |
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
362 printf("[%s]\n", json); |
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
363 } |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
364 OrthancPluginFreeString(context, json); |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
365 |
1067
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
366 if (OrthancPluginHasInstanceMetadata(context, instance, "ReceptionDate")) |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
367 { |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
368 printf("Received on [%s]\n", OrthancPluginGetInstanceMetadata(context, instance, "ReceptionDate")); |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
369 } |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
370 else |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
371 { |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
372 OrthancPluginLogError(context, "Instance has no reception date, should never happen!"); |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
373 } |
ace99e272203
access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
374 |
3205
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
375 json = OrthancPluginEncodeDicomWebXml(context, |
3216 | 376 OrthancPluginGetInstanceData(context, instance), |
377 OrthancPluginGetInstanceSize(context, instance), | |
378 DicomWebBinaryCallback); | |
3205
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
379 if (first) |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
380 { |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
381 printf("[%s]\n", json); |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
382 first = 0; /* Only print the first DICOM instance */ |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
383 } |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
384 OrthancPluginFreeString(context, json); |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
385 |
6c86d4d407da
new in plugin sdk: OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
386 |
1627
da7854deb662
Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1425
diff
changeset
|
387 return OrthancPluginErrorCode_Success; |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
388 } |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
389 |
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
390 |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
391 OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
392 OrthancPluginResourceType resourceType, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
393 const char* resourceId) |
1191
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
394 { |
3216 | 395 char info[1024]; |
396 | |
2957
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
397 OrthancPluginMemoryBuffer tmp; |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
398 memset(&tmp, 0, sizeof(tmp)); |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
399 |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
400 sprintf(info, "Change %d on resource %s of type %d", changeType, |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
401 (resourceId == NULL ? "<none>" : resourceId), resourceType); |
1191
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
402 OrthancPluginLogWarning(context, info); |
1199
a843ee8bb903
separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1191
diff
changeset
|
403 |
2957
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
404 switch (changeType) |
1199
a843ee8bb903
separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1191
diff
changeset
|
405 { |
2957
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
406 case OrthancPluginChangeType_NewInstance: |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
407 { |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
408 sprintf(info, "/instances/%s/metadata/AnonymizedFrom", resourceId); |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
409 if (OrthancPluginRestApiGet(context, &tmp, info) == 0) |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
410 { |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
411 sprintf(info, " Instance %s comes from the anonymization of instance", resourceId); |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
412 strncat(info, (const char*) tmp.data, tmp.size); |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
413 OrthancPluginLogWarning(context, info); |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
414 OrthancPluginFreeMemoryBuffer(context, &tmp); |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
415 } |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
416 |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
417 break; |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
418 } |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
419 |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
420 case OrthancPluginChangeType_OrthancStarted: |
1199
a843ee8bb903
separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1191
diff
changeset
|
421 { |
3179
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
422 OrthancPluginSetMetricsValue(context, "sample_started", 1, OrthancPluginMetricsType_Default); |
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
423 |
2957
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
424 /* Make REST requests to the built-in Orthanc API */ |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
425 OrthancPluginRestApiGet(context, &tmp, "/changes"); |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
426 OrthancPluginFreeMemoryBuffer(context, &tmp); |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
427 OrthancPluginRestApiGet(context, &tmp, "/changes?limit=1"); |
1199
a843ee8bb903
separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1191
diff
changeset
|
428 OrthancPluginFreeMemoryBuffer(context, &tmp); |
2957
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
429 |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
430 /* Play with PUT by defining a new target modality. */ |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
431 sprintf(info, "[ \"STORESCP\", \"localhost\", 2000 ]"); |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
432 OrthancPluginRestApiPut(context, &tmp, "/modalities/demo", info, strlen(info)); |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
433 |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
434 break; |
1199
a843ee8bb903
separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1191
diff
changeset
|
435 } |
2957
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
436 |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
437 case OrthancPluginChangeType_OrthancStopped: |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
438 OrthancPluginLogWarning(context, "Orthanc has stopped"); |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
439 break; |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
440 |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
441 default: |
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
442 break; |
1199
a843ee8bb903
separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1191
diff
changeset
|
443 } |
a843ee8bb903
separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1191
diff
changeset
|
444 |
1627
da7854deb662
Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1425
diff
changeset
|
445 return OrthancPluginErrorCode_Success; |
1191
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
446 } |
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
447 |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
448 |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
449 int32_t FilterIncomingHttpRequest(OrthancPluginHttpMethod method, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
450 const char* uri, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
451 const char* ip, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
452 uint32_t headersCount, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
453 const char* const* headersKeys, |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
454 const char* const* headersValues) |
1962 | 455 { |
456 uint32_t i; | |
457 | |
458 if (headersCount > 0) | |
459 { | |
460 OrthancPluginLogInfo(context, "HTTP headers of an incoming REST request:"); | |
461 for (i = 0; i < headersCount; i++) | |
462 { | |
463 char info[1024]; | |
464 sprintf(info, " %s: %s", headersKeys[i], headersValues[i]); | |
465 OrthancPluginLogInfo(context, info); | |
466 } | |
467 } | |
468 | |
469 if (method == OrthancPluginHttpMethod_Get || | |
470 method == OrthancPluginHttpMethod_Post) | |
471 { | |
472 return 1; /* Allowed */ | |
473 } | |
474 else | |
475 { | |
476 return 0; /* Only allow GET and POST requests */ | |
477 } | |
478 } | |
479 | |
480 | |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
481 static void RefreshMetrics() |
3179
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
482 { |
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
483 static unsigned int count = 0; |
3216 | 484 OrthancPluginSetMetricsValue(context, "sample_counter", |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
485 (float) (count++), OrthancPluginMetricsType_Default); |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
486 } |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
487 |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
488 |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
489 static int32_t FilterIncomingDicomInstance(const OrthancPluginDicomInstance* instance) |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
490 { |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
491 char buf[1024]; |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
492 char* s; |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
493 int32_t hasPixelData; |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
494 |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
495 s = OrthancPluginGetInstanceTransferSyntaxUid(context, instance); |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
496 sprintf(buf, "Incoming transfer syntax: %s", s); |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
497 OrthancPluginFreeString(context, s); |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
498 OrthancPluginLogWarning(context, buf); |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
499 |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
500 hasPixelData = OrthancPluginHasInstancePixelData(context, instance); |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
501 sprintf(buf, "Incoming has pixel data: %d", hasPixelData); |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
502 OrthancPluginLogWarning(context, buf); |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
503 |
3854 | 504 /* Reject all instances without pixel data */ |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
505 return hasPixelData; |
3179
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
506 } |
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
507 |
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
508 |
898
7000fc86fe62
improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
897
diff
changeset
|
509 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) |
886 | 510 { |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
511 char info[1024], *s; |
1280
d6a65dc6d0ac
Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1249
diff
changeset
|
512 int counter, i; |
1861
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1815
diff
changeset
|
513 OrthancPluginDictionaryEntry entry; |
894 | 514 |
1040
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1039
diff
changeset
|
515 context = c; |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1039
diff
changeset
|
516 OrthancPluginLogWarning(context, "Sample plugin is initializing"); |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1039
diff
changeset
|
517 |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1039
diff
changeset
|
518 /* Check the version of the Orthanc core */ |
1039
5a5a4890ffca
check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
913
diff
changeset
|
519 if (OrthancPluginCheckVersion(c) == 0) |
5a5a4890ffca
check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
913
diff
changeset
|
520 { |
1040
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1039
diff
changeset
|
521 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", |
1039
5a5a4890ffca
check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
913
diff
changeset
|
522 c->orthancVersion, |
5a5a4890ffca
check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
913
diff
changeset
|
523 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, |
5a5a4890ffca
check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
913
diff
changeset
|
524 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, |
5a5a4890ffca
check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
913
diff
changeset
|
525 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); |
1040
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1039
diff
changeset
|
526 OrthancPluginLogError(context, info); |
1039
5a5a4890ffca
check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
913
diff
changeset
|
527 return -1; |
5a5a4890ffca
check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
913
diff
changeset
|
528 } |
5a5a4890ffca
check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
913
diff
changeset
|
529 |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
530 /* Print some information about Orthanc */ |
886 | 531 sprintf(info, "The version of Orthanc is '%s'", context->orthancVersion); |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
532 OrthancPluginLogWarning(context, info); |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
533 |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
534 s = OrthancPluginGetOrthancPath(context); |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
535 sprintf(info, " Path to Orthanc: %s", s); |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
536 OrthancPluginLogWarning(context, info); |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
537 OrthancPluginFreeString(context, s); |
886 | 538 |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
539 s = OrthancPluginGetOrthancDirectory(context); |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
540 sprintf(info, " Directory of Orthanc: %s", s); |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
541 OrthancPluginLogWarning(context, info); |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
542 OrthancPluginFreeString(context, s); |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
543 |
1425
97268448bdfc
refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1375
diff
changeset
|
544 s = OrthancPluginGetConfiguration(context); |
97268448bdfc
refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1375
diff
changeset
|
545 sprintf(info, " Content of the configuration file:\n"); |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
546 OrthancPluginLogWarning(context, info); |
1425
97268448bdfc
refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1375
diff
changeset
|
547 OrthancPluginLogWarning(context, s); |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
548 OrthancPluginFreeString(context, s); |
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
549 |
1280
d6a65dc6d0ac
Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1249
diff
changeset
|
550 /* Print the command-line arguments of Orthanc */ |
d6a65dc6d0ac
Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1249
diff
changeset
|
551 counter = OrthancPluginGetCommandLineArgumentsCount(context); |
d6a65dc6d0ac
Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1249
diff
changeset
|
552 for (i = 0; i < counter; i++) |
d6a65dc6d0ac
Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1249
diff
changeset
|
553 { |
d6a65dc6d0ac
Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1249
diff
changeset
|
554 s = OrthancPluginGetCommandLineArgument(context, i); |
d6a65dc6d0ac
Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1249
diff
changeset
|
555 sprintf(info, " Command-line argument %d: \"%s\"", i, s); |
d6a65dc6d0ac
Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1249
diff
changeset
|
556 OrthancPluginLogWarning(context, info); |
d6a65dc6d0ac
Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1249
diff
changeset
|
557 OrthancPluginFreeString(context, s); |
d6a65dc6d0ac
Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1249
diff
changeset
|
558 } |
d6a65dc6d0ac
Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1249
diff
changeset
|
559 |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1137
diff
changeset
|
560 /* Register the callbacks */ |
901
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
561 OrthancPluginRegisterRestCallback(context, "/(plu.*)/hello", Callback1); |
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
899
diff
changeset
|
562 OrthancPluginRegisterRestCallback(context, "/plu.*/image", Callback2); |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
563 OrthancPluginRegisterRestCallback(context, "/plugin/instances/([^/]+)/info", Callback3); |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
564 OrthancPluginRegisterRestCallback(context, "/instances/([^/]+)/preview", Callback4); |
1282
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
565 OrthancPluginRegisterRestCallback(context, "/forward/(built-in)(/.+)", Callback5); |
7bccdd221e2b
Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
566 OrthancPluginRegisterRestCallback(context, "/forward/(plugins)(/.+)", Callback5); |
1137
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
567 OrthancPluginRegisterRestCallback(context, "/plugin/create", CallbackCreateDicom); |
5319
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
568 OrthancPluginRegisterRestCallback(context, "/instances/([^/]+)/dicom-web", CallbackDicomWeb); |
904
2732b5f57d9c
sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
903
diff
changeset
|
569 |
1066
bb82e5e818e9
OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1044
diff
changeset
|
570 OrthancPluginRegisterOnStoredInstanceCallback(context, OnStoredCallback); |
1191
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
571 OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback); |
1962 | 572 OrthancPluginRegisterIncomingHttpRequestFilter(context, FilterIncomingHttpRequest); |
3179
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
573 OrthancPluginRegisterRefreshMetricsCallback(context, RefreshMetrics); |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
574 OrthancPluginRegisterIncomingDicomInstanceFilter(context, FilterIncomingDicomInstance); |
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
575 |
3179
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
576 |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1200
diff
changeset
|
577 /* Declare several properties of the plugin */ |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1200
diff
changeset
|
578 OrthancPluginSetRootUri(context, "/plugin/hello"); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1200
diff
changeset
|
579 OrthancPluginSetDescription(context, "This is the description of the sample plugin that can be seen in Orthanc Explorer."); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1200
diff
changeset
|
580 OrthancPluginExtendOrthancExplorer(context, "alert('Hello Orthanc! From sample plugin with love.');"); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1200
diff
changeset
|
581 |
2957
ccf61f6e22ef
New function in the SDK: "OrthancPluginSetHttpErrorDetails()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
582 customError = OrthancPluginRegisterErrorCode(context, 4, 402, "Hello world"); |
1137
d9c27f9f1a51
OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1067
diff
changeset
|
583 |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1651
diff
changeset
|
584 OrthancPluginRegisterDictionaryTag(context, 0x0014, 0x1020, OrthancPluginValueRepresentation_DA, |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1651
diff
changeset
|
585 "ValidationExpiryDate", 1, 1); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1651
diff
changeset
|
586 |
1861
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1815
diff
changeset
|
587 OrthancPluginLookupDictionary(context, &entry, "ValidationExpiryDate"); |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1815
diff
changeset
|
588 OrthancPluginLookupDictionary(context, &entry, "0010-0010"); |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1815
diff
changeset
|
589 |
886 | 590 return 0; |
591 } | |
592 | |
593 | |
594 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | |
595 { | |
903 | 596 OrthancPluginLogWarning(context, "Sample plugin is finalizing"); |
886 | 597 } |
598 | |
599 | |
888
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
886
diff
changeset
|
600 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() |
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
886
diff
changeset
|
601 { |
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
886
diff
changeset
|
602 return "sample"; |
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
886
diff
changeset
|
603 } |
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
886
diff
changeset
|
604 |
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
886
diff
changeset
|
605 |
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
886
diff
changeset
|
606 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() |
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
886
diff
changeset
|
607 { |
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
886
diff
changeset
|
608 return "1.0"; |
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
886
diff
changeset
|
609 } |
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
886
diff
changeset
|
610 |