diff Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 2996:d547f998c947 db-changes

integration mainline->db-changes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Dec 2018 20:33:13 +0100
parents 9cc3d40e389b
children c358bdb37c13
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Thu Dec 06 15:58:08 2018 +0100
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Mon Dec 10 20:33:13 2018 +0100
@@ -1356,59 +1356,23 @@
     }
   }
 
-  const char* GetMimeType(const std::string& path)
+  
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0)
+  const char* AutodetectMimeType(const std::string& path)
   {
-    size_t dot = path.find_last_of('.');
-
-    std::string extension = (dot == std::string::npos) ? "" : path.substr(dot);
-    std::transform(extension.begin(), extension.end(), extension.begin(), tolower);
+    const char* mime = OrthancPluginAutodetectMimeType(GetGlobalContext(), path.c_str());
 
-    if (extension == ".html")
-    {
-      return "text/html";
-    }
-    else if (extension == ".css")
-    {
-      return "text/css";
-    }
-    else if (extension == ".js")
-    {
-      return "application/javascript";
-    }
-    else if (extension == ".gif")
+    if (mime == NULL)
     {
-      return "image/gif";
-    }
-    else if (extension == ".svg")
-    {
-      return "image/svg+xml";
-    }
-    else if (extension == ".json")
-    {
-      return "application/json";
-    }
-    else if (extension == ".xml")
-    {
-      return "application/xml";
-    }
-    else if (extension == ".wasm")
-    {
-      return "application/wasm";
-    }
-    else if (extension == ".png")
-    {
-      return "image/png";
-    }
-    else if (extension == ".jpg" || extension == ".jpeg")
-    {
-      return "image/jpeg";
+      // Should never happen, just for safety
+      return "application/octet-stream";
     }
     else
     {
-      return "application/octet-stream";
+      return mime;
     }
   }
-
+#endif
 
 
 #if HAS_ORTHANC_PLUGIN_PEERS == 1