Mercurial > hg > orthanc
diff OrthancServer/main.cpp @ 1174:c200a92734c9 db-changes
integration mainline->db-changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 19 Sep 2014 18:24:34 +0200 |
parents | 0a55d8eb194e |
children | fd3128b2cf45 |
line wrap: on
line diff
--- a/OrthancServer/main.cpp Wed Sep 17 13:25:37 2014 +0200 +++ b/OrthancServer/main.cpp Fri Sep 19 18:24:34 2014 +0200 @@ -150,7 +150,14 @@ class OrthancApplicationEntityFilter : public IApplicationEntityFilter { +private: + ServerContext& context_; + public: + OrthancApplicationEntityFilter(ServerContext& context) : context_(context) + { + } + virtual bool IsAllowedConnection(const std::string& /*callingIp*/, const std::string& /*callingAet*/) { @@ -177,6 +184,63 @@ return true; } } + + virtual bool IsAllowedTransferSyntax(const std::string& callingIp, + const std::string& callingAet, + TransferSyntax syntax) + { + std::string configuration; + + switch (syntax) + { + case TransferSyntax_Deflated: + configuration = "DeflatedTransferSyntaxAccepted"; + break; + + case TransferSyntax_Jpeg: + configuration = "JpegTransferSyntaxAccepted"; + break; + + case TransferSyntax_Jpeg2000: + configuration = "Jpeg2000TransferSyntaxAccepted"; + break; + + case TransferSyntax_JpegLossless: + configuration = "JpegLosslessTransferSyntaxAccepted"; + break; + + case TransferSyntax_Jpip: + configuration = "JpipTransferSyntaxAccepted"; + break; + + case TransferSyntax_Mpeg2: + configuration = "Mpeg2TransferSyntaxAccepted"; + break; + + case TransferSyntax_Rle: + configuration = "RleTransferSyntaxAccepted"; + break; + + default: + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + + { + std::string lua = "Is" + configuration; + + ServerContext::LuaContextLocker locker(context_); + + if (locker.GetLua().IsExistingFunction(lua.c_str())) + { + LuaFunctionCall call(locker.GetLua(), lua.c_str()); + call.PushString(callingAet); + call.PushString(callingIp); + return call.ExecutePredicate(); + } + } + + return Configuration::GetGlobalBoolParameter(configuration, true); + } }; @@ -405,7 +469,7 @@ { // DICOM server DicomServer dicomServer; - OrthancApplicationEntityFilter dicomFilter; + OrthancApplicationEntityFilter dicomFilter(context); dicomServer.SetCalledApplicationEntityTitleCheck(Configuration::GetGlobalBoolParameter("DicomCheckCalledAet", false)); dicomServer.SetStoreRequestHandlerFactory(serverFactory); dicomServer.SetMoveRequestHandlerFactory(serverFactory);