annotate Plugins/Samples/Basic/Plugin.c @ 1651:2e692c83e2f3

improved custom error login
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Sep 2015 17:29:39 +0200
parents 9f34ebfaf2c9
children 5360cdba70d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1282
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1282
diff changeset
4 * Department, University Hospital of Liege, Belgium
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
1375
3d76e26b3865 fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
6 * 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
7 * 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
8 * 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
9 * License, or (at your option) any later version.
3d76e26b3865 fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
10 *
3d76e26b3865 fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
11 * 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
12 * 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
13 * 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
14 * General Public License for more details.
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 *
1375
3d76e26b3865 fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
16 * 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
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 **/
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1375
diff changeset
21 #include <orthanc/OrthancCPlugin.h>
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include <string.h>
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include <stdio.h>
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
898
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
26 static OrthancPluginContext* context = NULL;
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1650
diff changeset
28 static OrthancPluginErrorCode customError;
1650
9f34ebfaf2c9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
29
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
31 ORTHANC_PLUGINS_API int32_t Callback1(OrthancPluginRestOutput* output,
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
32 const char* url,
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
33 const OrthancPluginHttpRequest* request)
894
690aeb4cb899 REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
34 {
690aeb4cb899 REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
35 char buffer[1024];
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 896
diff changeset
36 uint32_t i;
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 896
diff changeset
37
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
38 sprintf(buffer, "Callback on URL [%s] with body [%s]\n", url, request->body);
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
39 OrthancPluginLogWarning(context, buffer);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 896
diff changeset
40
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
41 OrthancPluginSetCookie(context, output, "hello", "world");
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
42 OrthancPluginAnswerBuffer(context, output, buffer, strlen(buffer), "text/plain");
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 896
diff changeset
43
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
44 OrthancPluginLogWarning(context, "");
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
45
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
46 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
47 {
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
48 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
49 OrthancPluginLogWarning(context, buffer);
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
50 }
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
51
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
52 OrthancPluginLogWarning(context, "");
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
53
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
54 for (i = 0; i < request->getCount; i++)
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 896
diff changeset
55 {
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
56 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
57 OrthancPluginLogWarning(context, buffer);
897
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 896
diff changeset
58 }
bafc9d592632 REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 896
diff changeset
59
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
60 OrthancPluginLogWarning(context, "");
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
61
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
62 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
63 {
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
64 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
65 OrthancPluginLogWarning(context, buffer);
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
66 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
67
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
68 OrthancPluginLogWarning(context, "");
1041
2c49b7dffcec plugins have access to the HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1040
diff changeset
69
894
690aeb4cb899 REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
70 return 1;
690aeb4cb899 REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
71 }
690aeb4cb899 REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
72
690aeb4cb899 REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
73
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
74 ORTHANC_PLUGINS_API int32_t Callback2(OrthancPluginRestOutput* output,
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
75 const char* url,
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
76 const OrthancPluginHttpRequest* request)
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
77 {
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
78 /* 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
79
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
80 uint16_t buffer[256 * 256];
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
81 uint32_t x, y, value;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
82
1042
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
83 if (request->method != OrthancPluginHttpMethod_Get)
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
84 {
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
85 OrthancPluginSendMethodNotAllowed(context, output, "GET");
1043
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
86 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
87 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
88 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
89 value = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
90 for (y = 0; y < 256; y++)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
91 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
92 for (x = 0; x < 256; x++, value++)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
93 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
94 buffer[value] = value;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
95 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
96 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
97
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
98 OrthancPluginCompressAndAnswerPngImage(context, output, OrthancPluginPixelFormat_Grayscale16,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
99 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
100 }
8d1845feb277 set cookies, not allowed methods, unauthorized in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1041
diff changeset
101
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
102 return 0;
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
103 }
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
104
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
105
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
106 ORTHANC_PLUGINS_API int32_t Callback3(OrthancPluginRestOutput* output,
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
107 const char* url,
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
108 const OrthancPluginHttpRequest* request)
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
109 {
1044
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
110 if (request->method != OrthancPluginHttpMethod_Get)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
111 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
112 OrthancPluginSendMethodNotAllowed(context, output, "GET");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
113 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
114 else
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
115 {
1044
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
116 OrthancPluginMemoryBuffer dicom;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
117 if (!OrthancPluginGetDicomForInstance(context, &dicom, request->groups[0]))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
118 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
119 /* No error, forward the DICOM file */
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
120 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
121
1044
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
122 /* Free memory */
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
123 OrthancPluginFreeMemoryBuffer(context, &dicom);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
124 }
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
125 }
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
126
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
127 return 0;
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
128 }
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
129
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
130
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
131 ORTHANC_PLUGINS_API int32_t Callback4(OrthancPluginRestOutput* output,
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
132 const char* url,
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
133 const OrthancPluginHttpRequest* request)
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
134 {
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
135 /* Answer with a sample 8bpp image. */
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
136
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
137 uint8_t buffer[256 * 256];
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
138 uint32_t x, y, value;
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
139
1044
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
140 if (request->method != OrthancPluginHttpMethod_Get)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
141 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
142 OrthancPluginSendMethodNotAllowed(context, output, "GET");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
143 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
144 else
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
145 {
1044
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
146 value = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
147 for (y = 0; y < 256; y++)
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
148 {
1044
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
149 for (x = 0; x < 256; x++, value++)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
150 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
151 buffer[value] = x;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
152 }
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
153 }
1044
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
155 OrthancPluginCompressAndAnswerPngImage(context, output, OrthancPluginPixelFormat_Grayscale8,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1043
diff changeset
156 256, 256, 256, buffer);
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
157 }
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
158
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
159 return 0;
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
160 }
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
161
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
162
1282
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
163 ORTHANC_PLUGINS_API int32_t Callback5(OrthancPluginRestOutput* output,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
164 const char* url,
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
165 const OrthancPluginHttpRequest* request)
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
166 {
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
167 /**
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
168 * Demonstration the difference between the
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
169 * "OrthancPluginRestApiXXX()" and the
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
170 * "OrthancPluginRestApiXXXAfterPlugins()" mechanisms to forward
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
171 * REST calls.
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
172 *
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
173 * # 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
174 * # 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
175 * # 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
176 * => 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
177 * # 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
178 **/
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 OrthancPluginMemoryBuffer tmp;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
181 int isBuiltIn, error;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
182
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
183 if (request->method != OrthancPluginHttpMethod_Get)
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
184 {
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
185 OrthancPluginSendMethodNotAllowed(context, output, "GET");
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
186 return 0;
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
187 }
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
188
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
189 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
190
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
191 if (isBuiltIn)
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 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
194 }
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
195 else
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
196 {
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
197 printf("ICI1\n");
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
198 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
199 printf("ICI2\n");
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 if (error)
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 return -1;
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 else
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 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
209 OrthancPluginFreeMemoryBuffer(context, &tmp);
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
210 return 0;
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
7bccdd221e2b Plugins can do REST calls to other plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
214
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
215 ORTHANC_PLUGINS_API OrthancPluginErrorCode CallbackCreateDicom(OrthancPluginRestOutput* output,
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
216 const char* url,
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
217 const OrthancPluginHttpRequest* request)
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
218 {
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
219 const char* pathLocator = "\"Path\" : \"";
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
220 char info[1024];
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
221 char *id, *eos;
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
222 OrthancPluginMemoryBuffer tmp;
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
223
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
224 if (request->method != OrthancPluginHttpMethod_Post)
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
225 {
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
226 OrthancPluginSendMethodNotAllowed(context, output, "POST");
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
227 }
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
228 else
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 /* Make POST request to create a new DICOM instance */
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
231 sprintf(info, "{\"PatientName\":\"Test\"}");
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
232 OrthancPluginRestApiPost(context, &tmp, "/tools/create-dicom", info, strlen(info));
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
233
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 * Recover the ID of the created instance is constructed by a
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
236 * quick-and-dirty parsing of a JSON string.
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
237 **/
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
238 id = strstr((char*) tmp.data, pathLocator) + strlen(pathLocator);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
239 eos = strchr(id, '\"');
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
240 eos[0] = '\0';
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
241
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
242 /* Delete the newly created DICOM instance. */
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
243 OrthancPluginRestApiDelete(context, id);
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
244 OrthancPluginFreeMemoryBuffer(context, &tmp);
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 /* Set some cookie */
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
247 OrthancPluginSetCookie(context, output, "hello", "world");
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 /* Set some HTTP header */
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
250 OrthancPluginSetHttpHeader(context, output, "Cache-Control", "max-age=0, no-cache");
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
251
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
252 OrthancPluginAnswerBuffer(context, output, "OK\n", 3, "text/plain");
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
253 }
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
254
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
255 return OrthancPluginErrorCode_Success;
1137
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
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
258
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
259 ORTHANC_PLUGINS_API OrthancPluginErrorCode OnStoredCallback(OrthancPluginDicomInstance* instance,
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
260 const char* instanceId)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
261 {
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
262 char buffer[256];
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
263 FILE* fp;
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
264 char* json;
1191
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
265 static int first = 1;
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
266
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
267 sprintf(buffer, "Just received a DICOM instance of size %d and ID %s from AET %s",
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
268 (int) OrthancPluginGetInstanceSize(context, instance), instanceId,
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
269 OrthancPluginGetInstanceRemoteAet(context, instance));
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
270
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
271 OrthancPluginLogWarning(context, buffer);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
272
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
273 fp = fopen("PluginReceivedInstance.dcm", "wb");
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
274 fwrite(OrthancPluginGetInstanceData(context, instance),
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
275 OrthancPluginGetInstanceSize(context, instance), 1, fp);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
276 fclose(fp);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
277
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
278 json = OrthancPluginGetInstanceSimplifiedJson(context, instance);
1191
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
279 if (first)
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
280 {
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
281 /* Only print the first DICOM instance */
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
282 printf("[%s]\n", json);
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
283 first = 0;
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
284 }
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
285 OrthancPluginFreeString(context, json);
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
286
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
287 if (OrthancPluginHasInstanceMetadata(context, instance, "ReceptionDate"))
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
288 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
289 printf("Received on [%s]\n", OrthancPluginGetInstanceMetadata(context, instance, "ReceptionDate"));
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
290 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
291 else
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
292 {
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
293 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
294 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
295
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
296 return OrthancPluginErrorCode_Success;
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
297 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
298
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
299
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
300 ORTHANC_PLUGINS_API OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType,
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
301 OrthancPluginResourceType resourceType,
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
302 const char* resourceId)
1191
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
303 {
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
304 char info[1024];
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1191
diff changeset
305 OrthancPluginMemoryBuffer tmp;
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1191
diff changeset
306
1191
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
307 sprintf(info, "Change %d on resource %s of type %d", changeType, resourceId, resourceType);
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
308 OrthancPluginLogWarning(context, info);
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1191
diff changeset
309
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1191
diff changeset
310 if (changeType == OrthancPluginChangeType_NewInstance)
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1191
diff changeset
311 {
1200
1e1390665639 fix sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
312 sprintf(info, "/instances/%s/metadata/AnonymizedFrom", resourceId);
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1191
diff changeset
313 if (OrthancPluginRestApiGet(context, &tmp, info) == 0)
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1191
diff changeset
314 {
1200
1e1390665639 fix sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
315 sprintf(info, " Instance %s comes from the anonymization of instance", resourceId);
1e1390665639 fix sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1199
diff changeset
316 strncat(info, (const char*) tmp.data, tmp.size);
1199
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1191
diff changeset
317 OrthancPluginLogWarning(context, info);
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1191
diff changeset
318 OrthancPluginFreeMemoryBuffer(context, &tmp);
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1191
diff changeset
319 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1191
diff changeset
320 }
a843ee8bb903 separated thread for change callbacks in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1191
diff changeset
321
1627
da7854deb662 Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1425
diff changeset
322 return OrthancPluginErrorCode_Success;
1191
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
323 }
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
324
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
325
898
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
326 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c)
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 {
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
328 OrthancPluginMemoryBuffer tmp;
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
329 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
330 int counter, i;
894
690aeb4cb899 REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
331
1040
d06186cdc502 check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1039
diff changeset
332 context = c;
d06186cdc502 check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1039
diff changeset
333 OrthancPluginLogWarning(context, "Sample plugin is initializing");
d06186cdc502 check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1039
diff changeset
334
d06186cdc502 check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1039
diff changeset
335 /* Check the version of the Orthanc core */
1039
5a5a4890ffca check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 913
diff changeset
336 if (OrthancPluginCheckVersion(c) == 0)
5a5a4890ffca check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 913
diff changeset
337 {
1040
d06186cdc502 check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1039
diff changeset
338 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
339 c->orthancVersion,
5a5a4890ffca check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 913
diff changeset
340 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
5a5a4890ffca check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 913
diff changeset
341 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
5a5a4890ffca check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 913
diff changeset
342 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
1040
d06186cdc502 check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1039
diff changeset
343 OrthancPluginLogError(context, info);
1039
5a5a4890ffca check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 913
diff changeset
344 return -1;
5a5a4890ffca check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 913
diff changeset
345 }
5a5a4890ffca check version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 913
diff changeset
346
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
347 /* Print some information about Orthanc */
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 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
349 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
350
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
351 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
352 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
353 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
354 OrthancPluginFreeString(context, s);
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
356 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
357 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
358 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
359 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
360
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1375
diff changeset
361 s = OrthancPluginGetConfiguration(context);
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1375
diff changeset
362 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
363 OrthancPluginLogWarning(context, info);
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1375
diff changeset
364 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
365 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
366
1280
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1249
diff changeset
367 /* 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
368 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
369 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
370 {
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1249
diff changeset
371 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
372 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
373 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
374 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
375 }
d6a65dc6d0ac Plugins can access the command-line arguments used to launch Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1249
diff changeset
376
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
377 /* Register the callbacks */
901
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
378 OrthancPluginRegisterRestCallback(context, "/(plu.*)/hello", Callback1);
7d88f3f4a3b3 refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
379 OrthancPluginRegisterRestCallback(context, "/plu.*/image", Callback2);
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
380 OrthancPluginRegisterRestCallback(context, "/plugin/instances/([^/]+)/info", Callback3);
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
381 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
382 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
383 OrthancPluginRegisterRestCallback(context, "/forward/(plugins)(/.+)", Callback5);
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
384 OrthancPluginRegisterRestCallback(context, "/plugin/create", CallbackCreateDicom);
904
2732b5f57d9c sample to forward dicom data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 903
diff changeset
385
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1044
diff changeset
386 OrthancPluginRegisterOnStoredInstanceCallback(context, OnStoredCallback);
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387
1191
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
388 OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback);
d49505e377e3 demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
389
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1200
diff changeset
390 /* 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
391 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
392 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
393 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
394
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
395 /* Make REST requests to the built-in Orthanc API */
1425
97268448bdfc refactoring of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1375
diff changeset
396 memset(&tmp, 0, sizeof(tmp));
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
397 OrthancPluginRestApiGet(context, &tmp, "/changes");
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
398 OrthancPluginFreeMemoryBuffer(context, &tmp);
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
399 OrthancPluginRestApiGet(context, &tmp, "/changes?limit=1");
912
dcb2469f00f4 PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 904
diff changeset
400 OrthancPluginFreeMemoryBuffer(context, &tmp);
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1067
diff changeset
401
913
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
402 /* Play with PUT by defining a new target modality. */
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
403 sprintf(info, "[ \"STORESCP\", \"localhost\", 2000 ]");
3e43de893d88 POST, DELETE, PUT from Orthanc plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 912
diff changeset
404 OrthancPluginRestApiPut(context, &tmp, "/modalities/demo", info, strlen(info));
1249
40725595aaf0 Plugins can get/set global properties to save their configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1232
diff changeset
405
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1650
diff changeset
406 customError = OrthancPluginRegisterErrorCode(context, 4, 402, "Hello world");
1650
9f34ebfaf2c9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1627
diff changeset
407
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 return 0;
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 }
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 ORTHANC_PLUGINS_API void OrthancPluginFinalize()
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 {
903
06b9a30f1e6d fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 902
diff changeset
414 OrthancPluginLogWarning(context, "Sample plugin is finalizing");
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 }
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417
888
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
418 ORTHANC_PLUGINS_API const char* OrthancPluginGetName()
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
419 {
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
420 return "sample";
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
421 }
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
422
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
423
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
424 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion()
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
425 {
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
426 return "1.0";
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
427 }
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
428