diff Plugins/Engine/OrthancPlugins.cpp @ 1249:40725595aaf0

Plugins can get/set global properties to save their configuration
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 15 Dec 2014 10:20:33 +0100
parents f1c01451a8ee
children 2ffe07abd9d8
line wrap: on
line diff
--- a/Plugins/Engine/OrthancPlugins.cpp	Tue Dec 09 12:17:59 2014 +0100
+++ b/Plugins/Engine/OrthancPlugins.cpp	Mon Dec 15 10:20:33 2014 +0100
@@ -1026,11 +1026,35 @@
         return true;
       }
 
-      case _OrthancPluginService_SetProperty:
+      case _OrthancPluginService_SetPluginProperty:
+      {
+        const _OrthancPluginSetPluginProperty& p = 
+          *reinterpret_cast<const _OrthancPluginSetPluginProperty*>(parameters);
+        pimpl_->properties_[std::make_pair(p.plugin, p.property)] = p.value;
+        return true;
+      }
+
+      case _OrthancPluginService_SetGlobalProperty:
       {
-        const _OrthancPluginSetProperty& p = 
-          *reinterpret_cast<const _OrthancPluginSetProperty*>(parameters);
-        pimpl_->properties_[std::make_pair(p.plugin, p.property)] = p.value;
+        const _OrthancPluginGlobalProperty& p = 
+          *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);
+        if (p.property < 1024)
+        {
+          return false;
+        }
+        else
+        {
+          pimpl_->context_.GetIndex().SetGlobalProperty(static_cast<GlobalProperty>(p.property), p.value);
+          return true;
+        }
+      }
+
+      case _OrthancPluginService_GetGlobalProperty:
+      {
+        const _OrthancPluginGlobalProperty& p = 
+          *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);
+        std::string result = pimpl_->context_.GetIndex().GetGlobalProperty(static_cast<GlobalProperty>(p.property), p.value);
+        *(p.result) = CopyString(result);
         return true;
       }