changeset 143:82ab647f7e73

fix deprecated calls
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 22 Mar 2024 15:26:19 +0100
parents c6edc5caca7a
children dc54e850f586
files Common/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp Common/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h Common/StoragePlugin.cpp
diffstat 3 files changed, 54 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Common/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp	Sat Mar 02 11:26:20 2024 +0100
+++ b/Common/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp	Fri Mar 22 15:26:19 2024 +0100
@@ -4026,4 +4026,48 @@
       result[request->headersKeys[i]] = request->headersValues[i];
     }    
   }
+
+#if !ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4)
+  static void SetPluginProperty(const std::string& pluginIdentifier,
+                                _OrthancPluginProperty property,
+                                const std::string& value)
+  {
+    _OrthancPluginSetPluginProperty params;
+    params.plugin = pluginIdentifier.c_str();
+    params.property = property;
+    params.value = value.c_str();
+
+    GetGlobalContext()->InvokeService(GetGlobalContext(), _OrthancPluginService_SetPluginProperty, &params);
+  }
+#endif
+
+  void SetRootUri(const std::string& pluginIdentifier,
+                  const std::string& uri)
+  {
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4)
+    OrthancPluginSetRootUri2(GetGlobalContext(), pluginIdentifier.c_str(), uri.c_str());
+#else
+    SetPluginProperty(pluginIdentifier, _OrthancPluginProperty_RootUri, uri);
+#endif
+  }
+
+  void SetDescription(const std::string& pluginIdentifier,
+                      const std::string& description)
+  {
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4)
+    OrthancPluginSetDescription2(GetGlobalContext(), pluginIdentifier.c_str(), description.c_str());
+#else
+    SetPluginProperty(pluginIdentifier, _OrthancPluginProperty_Description, description);
+#endif
+  }
+
+  void ExtendOrthancExplorer(const std::string& pluginIdentifier,
+                             const std::string& javascript)
+  {
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4)
+    OrthancPluginExtendOrthancExplorer2(GetGlobalContext(), pluginIdentifier.c_str(), javascript.c_str());
+#else
+    SetPluginProperty(pluginIdentifier, _OrthancPluginProperty_OrthancExplorer, javascript);
+#endif
+  }
 }
--- a/Common/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h	Sat Mar 02 11:26:20 2024 +0100
+++ b/Common/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h	Fri Mar 22 15:26:19 2024 +0100
@@ -1435,4 +1435,13 @@
                          IWebDavCollection& collection);
   };
 #endif
+
+  void SetRootUri(const std::string& pluginIdentifier,
+                  const std::string& uri);
+
+  void SetDescription(const std::string& pluginIdentifier,
+                      const std::string& description);
+
+  void ExtendOrthancExplorer(const std::string& pluginIdentifier,
+                             const std::string& javascript);
 }
--- a/Common/StoragePlugin.cpp	Sat Mar 02 11:26:20 2024 +0100
+++ b/Common/StoragePlugin.cpp	Fri Mar 22 15:26:19 2024 +0100
@@ -534,7 +534,7 @@
     OrthancPlugins::OrthancConfiguration orthancConfig;
 
     OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + " plugin is initializing");
-    OrthancPluginSetDescription(context, StoragePluginFactory::GetStorageDescription());
+    OrthancPlugins::SetDescription(StoragePluginFactory::GetStoragePluginName(), StoragePluginFactory::GetStorageDescription());
 
     /* Check the version of the Orthanc core */
     if (OrthancPluginCheckVersion(context) == 0)