diff Plugins/Samples/Basic/Plugin.c @ 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 d6a65dc6d0ac
line wrap: on
line diff
--- a/Plugins/Samples/Basic/Plugin.c	Tue Dec 09 12:17:59 2014 +0100
+++ b/Plugins/Samples/Basic/Plugin.c	Mon Dec 15 10:20:33 2014 +0100
@@ -280,6 +280,7 @@
 {
   OrthancPluginMemoryBuffer tmp;
   char info[1024], *s;
+  int counter;
 
   context = c;
   OrthancPluginLogWarning(context, "Sample plugin is initializing");
@@ -340,7 +341,18 @@
   /* Play with PUT by defining a new target modality. */
   sprintf(info, "[ \"STORESCP\", \"localhost\", 2000 ]");
   OrthancPluginRestApiPut(context, &tmp, "/modalities/demo", info, strlen(info));
- 
+
+  /* Play with global properties: A global counter is incremented 
+     each time the plugin starts. */
+  s = OrthancPluginGetGlobalProperty(context, 1024, "0");
+  sscanf(s, "%d", &counter);
+  sprintf(info, "Number of times this plugin was started: %d", counter);
+  OrthancPluginLogWarning(context, info);
+  counter++;
+  sprintf(info, "%d", counter);
+  OrthancPluginSetGlobalProperty(context, 1024, info);
+  OrthancPluginFreeString(context, s);
+
   return 0;
 }