changeset 4469:5ffa4e14e4bd

move old enum TransferSyntax from OrthancFramework to OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 25 Jan 2021 18:12:59 +0100
parents 9c070a34de18
children 06d164d8a0fd
files OrthancFramework/Sources/DicomNetworking/IApplicationEntityFilter.h OrthancFramework/Sources/Enumerations.cpp OrthancFramework/Sources/Enumerations.h OrthancServer/Sources/ServerEnumerations.cpp OrthancServer/Sources/ServerEnumerations.h OrthancServer/Sources/main.cpp
diffstat 6 files changed, 115 insertions(+), 122 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomNetworking/IApplicationEntityFilter.h	Mon Jan 25 15:18:34 2021 +0100
+++ b/OrthancFramework/Sources/DicomNetworking/IApplicationEntityFilter.h	Mon Jan 25 18:12:59 2021 +0100
@@ -22,7 +22,6 @@
 
 #pragma once
 
-#include "../Compatibility.h"
 #include "../Enumerations.h"
 
 #include <string>
@@ -50,11 +49,6 @@
                                              const std::string& remoteAet,
                                              const std::string& calledAet) = 0;
     
-    ORTHANC_DEPRECATED(virtual bool IsAllowedTransferSyntax(const std::string& remoteIp,
-                                                            const std::string& remoteAet,
-                                                            const std::string& calledAet,
-                                                            TransferSyntax syntax)) = 0;
-
     virtual bool IsUnknownSopClassAccepted(const std::string& remoteIp,
                                            const std::string& remoteAet,
                                            const std::string& calledAet) = 0;
--- a/OrthancFramework/Sources/Enumerations.cpp	Mon Jan 25 15:18:34 2021 +0100
+++ b/OrthancFramework/Sources/Enumerations.cpp	Mon Jan 25 18:12:59 2021 +0100
@@ -856,40 +856,6 @@
   }
 
 
-  const char* EnumerationToString(TransferSyntax syntax)
-  {
-    switch (syntax)
-    {
-      case TransferSyntax_Deflated:
-        return "Deflated";
-
-      case TransferSyntax_Jpeg:
-        return "JPEG";
-
-      case TransferSyntax_Jpeg2000:
-        return "JPEG2000";
-
-      case TransferSyntax_JpegLossless:
-        return "JPEG Lossless";
-
-      case TransferSyntax_Jpip:
-        return "JPIP";
-
-      case TransferSyntax_Mpeg2:
-        return "MPEG2";
-
-      case TransferSyntax_Mpeg4:
-        return "MPEG4";
-
-      case TransferSyntax_Rle:
-        return "RLE";
-
-      default: 
-        throw OrthancException(ErrorCode_ParameterOutOfRange);
-    }
-  }
-
-
   const char* EnumerationToString(DicomVersion version)
   {
     switch (version)
--- a/OrthancFramework/Sources/Enumerations.h	Mon Jan 25 15:18:34 2021 +0100
+++ b/OrthancFramework/Sources/Enumerations.h	Mon Jan 25 18:12:59 2021 +0100
@@ -627,18 +627,6 @@
     DicomRequestType_NEventReport
   };
 
-  enum TransferSyntax
-  {
-    TransferSyntax_Deflated,
-    TransferSyntax_Jpeg,
-    TransferSyntax_Jpeg2000,
-    TransferSyntax_JpegLossless,
-    TransferSyntax_Jpip,
-    TransferSyntax_Mpeg2,
-    TransferSyntax_Mpeg4,  // New in Orthanc 1.6.0
-    TransferSyntax_Rle
-  };
-
   enum JobState
   {
     JobState_Pending,
@@ -788,9 +776,6 @@
   const char* EnumerationToString(DicomRequestType type);
 
   ORTHANC_PUBLIC
-  const char* EnumerationToString(TransferSyntax syntax);
-
-  ORTHANC_PUBLIC
   const char* EnumerationToString(DicomVersion version);
 
   ORTHANC_PUBLIC
--- a/OrthancServer/Sources/ServerEnumerations.cpp	Mon Jan 25 15:18:34 2021 +0100
+++ b/OrthancServer/Sources/ServerEnumerations.cpp	Mon Jan 25 18:12:59 2021 +0100
@@ -414,4 +414,38 @@
     return (metadata >= MetadataType_StartUser &&
             metadata <= MetadataType_EndUser);
   }
+
+
+  const char* EnumerationToString(TransferSyntax syntax)
+  {
+    switch (syntax)
+    {
+      case TransferSyntax_Deflated:
+        return "Deflated";
+
+      case TransferSyntax_Jpeg:
+        return "JPEG";
+
+      case TransferSyntax_Jpeg2000:
+        return "JPEG2000";
+
+      case TransferSyntax_JpegLossless:
+        return "JPEG Lossless";
+
+      case TransferSyntax_Jpip:
+        return "JPIP";
+
+      case TransferSyntax_Mpeg2:
+        return "MPEG2";
+
+      case TransferSyntax_Mpeg4:
+        return "MPEG4";
+
+      case TransferSyntax_Rle:
+        return "RLE";
+
+      default: 
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+  }
 }
--- a/OrthancServer/Sources/ServerEnumerations.h	Mon Jan 25 15:18:34 2021 +0100
+++ b/OrthancServer/Sources/ServerEnumerations.h	Mon Jan 25 18:12:59 2021 +0100
@@ -95,6 +95,19 @@
     StoreInstanceMode_IgnoreDuplicate
   };
 
+  // This enum was previously part of Orthanc framework (until 1.8.2)
+  enum TransferSyntax
+  {
+    TransferSyntax_Deflated,
+    TransferSyntax_Jpeg,
+    TransferSyntax_Jpeg2000,
+    TransferSyntax_JpegLossless,
+    TransferSyntax_Jpip,
+    TransferSyntax_Mpeg2,
+    TransferSyntax_Mpeg4,  // New in Orthanc 1.6.0
+    TransferSyntax_Rle
+  };
+
 
   /**
    * WARNING: Do not change the explicit values in the enumerations
@@ -219,4 +232,6 @@
   const char* EnumerationToString(Verbosity verbosity);
 
   bool IsUserMetadata(MetadataType type);
+
+  const char* EnumerationToString(TransferSyntax syntax);
 }
--- a/OrthancServer/Sources/main.cpp	Mon Jan 25 15:18:34 2021 +0100
+++ b/OrthancServer/Sources/main.cpp	Mon Jan 25 18:12:59 2021 +0100
@@ -282,6 +282,72 @@
   bool            alwaysAllowEcho_;
   bool            alwaysAllowStore_;
 
+  bool IsAllowedTransferSyntax(const std::string& remoteIp,
+                               const std::string& remoteAet,
+                               const std::string& calledAet,
+                               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_Mpeg4:
+        configuration = "Mpeg4TransferSyntaxAccepted";
+        break;
+
+      case TransferSyntax_Rle:
+        configuration = "RleTransferSyntaxAccepted";
+        break;
+
+      default: 
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+
+    {
+      std::string name = "Is" + configuration;
+
+      LuaScripting::Lock lock(context_.GetLuaScripting());
+      
+      if (lock.GetLua().IsExistingFunction(name.c_str()))
+      {
+        LuaFunctionCall call(lock.GetLua(), name.c_str());
+        call.PushString(remoteAet);
+        call.PushString(remoteIp);
+        call.PushString(calledAet);
+        return call.ExecutePredicate();
+      }
+    }
+
+    {
+      OrthancConfiguration::ReaderLock lock;
+      return lock.GetConfiguration().GetBooleanParameter(configuration, true);
+    }
+  }
+
 public:
   explicit OrthancApplicationEntityFilter(ServerContext& context) :
     context_(context)
@@ -450,73 +516,6 @@
   }
 
   
-  virtual bool IsAllowedTransferSyntax(const std::string& remoteIp,
-                                       const std::string& remoteAet,
-                                       const std::string& calledAet,
-                                       TransferSyntax syntax) ORTHANC_OVERRIDE
-  {
-    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_Mpeg4:
-        configuration = "Mpeg4TransferSyntaxAccepted";
-        break;
-
-      case TransferSyntax_Rle:
-        configuration = "RleTransferSyntaxAccepted";
-        break;
-
-      default: 
-        throw OrthancException(ErrorCode_ParameterOutOfRange);
-    }
-
-    {
-      std::string name = "Is" + configuration;
-
-      LuaScripting::Lock lock(context_.GetLuaScripting());
-      
-      if (lock.GetLua().IsExistingFunction(name.c_str()))
-      {
-        LuaFunctionCall call(lock.GetLua(), name.c_str());
-        call.PushString(remoteAet);
-        call.PushString(remoteIp);
-        call.PushString(calledAet);
-        return call.ExecutePredicate();
-      }
-    }
-
-    {
-      OrthancConfiguration::ReaderLock lock;
-      return lock.GetConfiguration().GetBooleanParameter(configuration, true);
-    }
-  }
-
-
   virtual bool IsUnknownSopClassAccepted(const std::string& remoteIp,
                                          const std::string& remoteAet,
                                          const std::string& calledAet) ORTHANC_OVERRIDE