Mercurial > hg > orthanc
comparison OrthancServer/main.cpp @ 1164:0a55d8eb194e
Configuration/Lua to select the accepted C-Store SCP transfer syntaxes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 18 Sep 2014 17:18:26 +0200 |
parents | 3db41779d8f9 |
children | fd3128b2cf45 |
comparison
equal
deleted
inserted
replaced
1163:3db41779d8f9 | 1164:0a55d8eb194e |
---|---|
148 }; | 148 }; |
149 | 149 |
150 | 150 |
151 class OrthancApplicationEntityFilter : public IApplicationEntityFilter | 151 class OrthancApplicationEntityFilter : public IApplicationEntityFilter |
152 { | 152 { |
153 private: | |
154 ServerContext& context_; | |
155 | |
153 public: | 156 public: |
157 OrthancApplicationEntityFilter(ServerContext& context) : context_(context) | |
158 { | |
159 } | |
160 | |
154 virtual bool IsAllowedConnection(const std::string& /*callingIp*/, | 161 virtual bool IsAllowedConnection(const std::string& /*callingIp*/, |
155 const std::string& /*callingAet*/) | 162 const std::string& /*callingAet*/) |
156 { | 163 { |
157 return true; | 164 return true; |
158 } | 165 } |
176 { | 183 { |
177 return true; | 184 return true; |
178 } | 185 } |
179 } | 186 } |
180 | 187 |
181 virtual bool IsAllowedTransferSyntax(const std::string& callingAet, | 188 virtual bool IsAllowedTransferSyntax(const std::string& callingIp, |
189 const std::string& callingAet, | |
182 TransferSyntax syntax) | 190 TransferSyntax syntax) |
183 { | 191 { |
184 // TODO - https://trello.com/c/8GxcTR0n | 192 std::string configuration; |
185 return true; | 193 |
194 switch (syntax) | |
195 { | |
196 case TransferSyntax_Deflated: | |
197 configuration = "DeflatedTransferSyntaxAccepted"; | |
198 break; | |
199 | |
200 case TransferSyntax_Jpeg: | |
201 configuration = "JpegTransferSyntaxAccepted"; | |
202 break; | |
203 | |
204 case TransferSyntax_Jpeg2000: | |
205 configuration = "Jpeg2000TransferSyntaxAccepted"; | |
206 break; | |
207 | |
208 case TransferSyntax_JpegLossless: | |
209 configuration = "JpegLosslessTransferSyntaxAccepted"; | |
210 break; | |
211 | |
212 case TransferSyntax_Jpip: | |
213 configuration = "JpipTransferSyntaxAccepted"; | |
214 break; | |
215 | |
216 case TransferSyntax_Mpeg2: | |
217 configuration = "Mpeg2TransferSyntaxAccepted"; | |
218 break; | |
219 | |
220 case TransferSyntax_Rle: | |
221 configuration = "RleTransferSyntaxAccepted"; | |
222 break; | |
223 | |
224 default: | |
225 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
226 } | |
227 | |
228 { | |
229 std::string lua = "Is" + configuration; | |
230 | |
231 ServerContext::LuaContextLocker locker(context_); | |
232 | |
233 if (locker.GetLua().IsExistingFunction(lua.c_str())) | |
234 { | |
235 LuaFunctionCall call(locker.GetLua(), lua.c_str()); | |
236 call.PushString(callingAet); | |
237 call.PushString(callingIp); | |
238 return call.ExecutePredicate(); | |
239 } | |
240 } | |
241 | |
242 return Configuration::GetGlobalBoolParameter(configuration, true); | |
186 } | 243 } |
187 }; | 244 }; |
188 | 245 |
189 | 246 |
190 class MyIncomingHttpRequestFilter : public IIncomingHttpRequestFilter | 247 class MyIncomingHttpRequestFilter : public IIncomingHttpRequestFilter |
410 bool isReset = false; | 467 bool isReset = false; |
411 | 468 |
412 { | 469 { |
413 // DICOM server | 470 // DICOM server |
414 DicomServer dicomServer; | 471 DicomServer dicomServer; |
415 OrthancApplicationEntityFilter dicomFilter; | 472 OrthancApplicationEntityFilter dicomFilter(context); |
416 dicomServer.SetCalledApplicationEntityTitleCheck(Configuration::GetGlobalBoolParameter("DicomCheckCalledAet", false)); | 473 dicomServer.SetCalledApplicationEntityTitleCheck(Configuration::GetGlobalBoolParameter("DicomCheckCalledAet", false)); |
417 dicomServer.SetStoreRequestHandlerFactory(serverFactory); | 474 dicomServer.SetStoreRequestHandlerFactory(serverFactory); |
418 dicomServer.SetMoveRequestHandlerFactory(serverFactory); | 475 dicomServer.SetMoveRequestHandlerFactory(serverFactory); |
419 dicomServer.SetFindRequestHandlerFactory(serverFactory); | 476 dicomServer.SetFindRequestHandlerFactory(serverFactory); |
420 dicomServer.SetPortNumber(Configuration::GetGlobalIntegerParameter("DicomPort", 4242)); | 477 dicomServer.SetPortNumber(Configuration::GetGlobalIntegerParameter("DicomPort", 4242)); |