changeset 291:87376a645ee1 am-2

renaming
author am@osimis.io
date Thu, 30 Aug 2018 17:06:22 +0200
parents 36ebe6ec8fe8
children df5011cf903c
files Applications/Generic/BasicNativeApplicationContext.cpp Applications/Generic/BasicNativeApplicationContext.h Applications/Generic/BasicNativeApplicationRunner.cpp Applications/Generic/BasicNativeApplicationRunner.h Applications/Generic/NativeStoneApplicationContext.cpp Applications/Generic/NativeStoneApplicationContext.h Applications/Generic/NativeStoneApplicationRunner.cpp Applications/Generic/NativeStoneApplicationRunner.h Applications/Qt/BasicQtApplicationRunner.cpp Applications/Qt/BasicQtApplicationRunner.h Applications/Qt/QCairoWidget.cpp Applications/Qt/QCairoWidget.h Applications/Qt/QStoneMainWindow.cpp Applications/Qt/QStoneMainWindow.h Applications/Samples/Qt/SampleMainWindow.cpp Applications/Samples/Qt/SampleMainWindow.h Applications/Samples/Qt/SampleQtApplicationRunner.h Platforms/Generic/OracleWebService.h Platforms/Generic/WebServiceCommandBase.cpp Platforms/Generic/WebServiceCommandBase.h Platforms/Generic/WebServiceGetCommand.cpp Platforms/Generic/WebServiceGetCommand.h Platforms/Generic/WebServicePostCommand.cpp Platforms/Generic/WebServicePostCommand.h Resources/CMake/OrthancStoneConfiguration.cmake
diffstat 25 files changed, 483 insertions(+), 483 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Generic/BasicNativeApplicationContext.cpp	Thu Aug 30 16:56:08 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Affero General Public License for more details.
- * 
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-
-#include "BasicNativeApplicationContext.h"
-#include "../../Platforms/Generic/OracleWebService.h"
-
-namespace OrthancStone
-{
-  IWidget& BasicNativeApplicationContext::SetCentralWidget(IWidget* widget)   // Takes ownership
-  {
-    centralViewport_->SetCentralWidget(widget);
-    return *widget;
-  }
-
-
-  void BasicNativeApplicationContext::UpdateThread(BasicNativeApplicationContext* that)
-  {
-    while (!that->stopped_)
-    {
-      {
-        GlobalMutexLocker locker(*that);
-        that->GetCentralViewport().UpdateContent();
-      }
-      
-      boost::this_thread::sleep(boost::posix_time::milliseconds(that->updateDelayInMs_));
-    }
-  }
-  
-
-  BasicNativeApplicationContext::BasicNativeApplicationContext() :
-    centralViewport_(new OrthancStone::WidgetViewport()),
-    stopped_(true),
-    updateDelayInMs_(100)   // By default, 100ms between each refresh of the content
-  {
-    srand(time(NULL)); 
-  }
-
-
-  void BasicNativeApplicationContext::Start()
-  {
-    dynamic_cast<OracleWebService*>(webService_)->Start();
-
-    if (centralViewport_->HasUpdateContent())
-    {
-      stopped_ = false;
-      updateThread_ = boost::thread(UpdateThread, this);
-    }
-  }
-
-
-  void BasicNativeApplicationContext::Stop()
-  {
-    stopped_ = true;
-    
-    if (updateThread_.joinable())
-    {
-      updateThread_.join();
-    }
-    
-    dynamic_cast<OracleWebService*>(webService_)->Stop();
-  }
-}
--- a/Applications/Generic/BasicNativeApplicationContext.h	Thu Aug 30 16:56:08 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Affero General Public License for more details.
- * 
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-
-#pragma once
-
-#include "../../Framework/Viewport/WidgetViewport.h"
-#include "../../Framework/Volumes/ISlicedVolume.h"
-#include "../../Framework/Volumes/IVolumeLoader.h"
-
-#include <list>
-#include <boost/thread.hpp>
-#include "../StoneApplicationContext.h"
-
-namespace OrthancStone
-{
-  class BasicNativeApplicationContext : public StoneApplicationContext
-  {
-  private:
-
-    static void UpdateThread(BasicNativeApplicationContext* that);
-
-    boost::mutex        globalMutex_;
-    std::unique_ptr<WidgetViewport>      centralViewport_;
-    boost::thread       updateThread_;
-    bool                stopped_;
-    unsigned int        updateDelayInMs_;
-
-  public:
-    class GlobalMutexLocker: public boost::noncopyable
-    {
-      boost::mutex::scoped_lock  lock_;
-    public:
-      GlobalMutexLocker(BasicNativeApplicationContext& that):
-        lock_(that.globalMutex_)
-      {}
-    };
-
-    BasicNativeApplicationContext();
-
-    virtual ~BasicNativeApplicationContext() {}
-
-    virtual IWidget& SetCentralWidget(IWidget* widget);   // Takes ownership
-    IViewport& GetCentralViewport() {return *(centralViewport_.get());}
-
-    void Start();
-
-    void Stop();
-
-    void SetUpdateDelay(unsigned int delayInMs)
-    {
-      updateDelayInMs_ = delayInMs;
-    }
-
-  };
-}
--- a/Applications/Generic/BasicNativeApplicationRunner.cpp	Thu Aug 30 16:56:08 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,240 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-
-#if ORTHANC_ENABLE_NATIVE != 1
-#error this file shall be included only with the ORTHANC_ENABLE_NATIVE set to 1
-#endif
-
-#include "BasicNativeApplicationRunner.h"
-#include "BasicNativeApplicationContext.h"
-#include <boost/program_options.hpp>
-
-#include "../../Framework/Toolbox/MessagingToolbox.h"
-
-#include <Core/Logging.h>
-#include <Core/HttpClient.h>
-#include <Core/Toolbox.h>
-#include <Plugins/Samples/Common/OrthancHttpConnection.h>
-#include "../../Platforms/Generic/OracleWebService.h"
-
-namespace OrthancStone
-{
-  // Anonymous namespace to avoid clashes against other compilation modules
-  namespace
-  {
-    class LogStatusBar : public IStatusBar
-    {
-    public:
-      virtual void ClearMessage()
-      {
-      }
-
-      virtual void SetMessage(const std::string& message)
-      {
-        LOG(WARNING) << message;
-      }
-    };
-  }
-
-  int BasicNativeApplicationRunner::Execute(int argc,
-                                            char* argv[])
-  {
-    /******************************************************************
-     * Initialize all the subcomponents of Orthanc Stone
-     ******************************************************************/
-
-    Orthanc::Logging::Initialize();
-    Orthanc::Toolbox::InitializeOpenSsl();
-    Orthanc::HttpClient::GlobalInitialize();
-
-    Initialize();
-
-    /******************************************************************
-     * Declare and parse the command-line options of the application
-     ******************************************************************/
-
-    boost::program_options::options_description options;
-
-    { // generic options
-      boost::program_options::options_description generic("Generic options");
-      generic.add_options()
-          ("help", "Display this help and exit")
-          ("verbose", "Be verbose in logs")
-          ("orthanc", boost::program_options::value<std::string>()->default_value("http://localhost:8042/"),
-           "URL to the Orthanc server")
-          ("username", "Username for the Orthanc server")
-          ("password", "Password for the Orthanc server")
-          ("https-verify", boost::program_options::value<bool>()->default_value(true), "Check HTTPS certificates")
-          ;
-
-      options.add(generic);
-    }
-
-    // platform specific options
-    DeclareCommandLineOptions(options);
-    
-    // application specific options
-    application_.DeclareStartupOptions(options);
-
-    boost::program_options::variables_map parameters;
-    bool error = false;
-
-    try
-    {
-      boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
-                                    options(options).run(), parameters);
-      boost::program_options::notify(parameters);
-    }
-    catch (boost::program_options::error& e)
-    {
-      LOG(ERROR) << "Error while parsing the command-line arguments: " << e.what();
-      error = true;
-    }
-
-
-    /******************************************************************
-     * Configure the application with the command-line parameters
-     ******************************************************************/
-
-    if (error || parameters.count("help"))
-    {
-      std::cout << std::endl
-                << "Usage: " << argv[0] << " [OPTION]..."
-                << std::endl
-                << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research."
-                << std::endl << std::endl
-                << "Demonstration application of Orthanc Stone using SDL."
-                << std::endl;
-
-      std::cout << options << "\n";
-      return error ? -1 : 0;
-    }
-
-    if (parameters.count("https-verify") &&
-        !parameters["https-verify"].as<bool>())
-    {
-      LOG(WARNING) << "Turning off verification of HTTPS certificates (unsafe)";
-      Orthanc::HttpClient::ConfigureSsl(false, "");
-    }
-
-    if (parameters.count("verbose"))
-    {
-      Orthanc::Logging::EnableInfoLevel(true);
-    }
-
-    ParseCommandLineOptions(parameters);
-
-
-    bool success = true;
-    try
-    {
-      /****************************************************************
-       * Initialize the connection to the Orthanc server
-       ****************************************************************/
-
-      Orthanc::WebServiceParameters webServiceParameters;
-
-      if (parameters.count("orthanc"))
-      {
-        webServiceParameters.SetUrl(parameters["orthanc"].as<std::string>());
-      }
-
-      if (parameters.count("username"))
-      {
-        webServiceParameters.SetUsername(parameters["username"].as<std::string>());
-      }
-
-      if (parameters.count("password"))
-      {
-        webServiceParameters.SetPassword(parameters["password"].as<std::string>());
-      }
-
-      LOG(WARNING) << "URL to the Orthanc REST API: " << webServiceParameters.GetUrl();
-
-      {
-        OrthancPlugins::OrthancHttpConnection orthanc(webServiceParameters);
-        if (!MessagingToolbox::CheckOrthancVersion(orthanc))
-        {
-          LOG(ERROR) << "Your version of Orthanc is incompatible with Stone of Orthanc, please upgrade";
-          throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
-        }
-      }
-
-
-      /****************************************************************
-       * Initialize the application
-       ****************************************************************/
-
-      LOG(WARNING) << "Creating the widgets of the application";
-
-      LogStatusBar statusBar;
-
-      BasicNativeApplicationContext context;
-      Oracle oracle(4); // use 4 threads to download content
-      OracleWebService webService(broker_, oracle, webServiceParameters, context);
-      context.SetWebService(webService);
-
-      application_.Initialize(&context, statusBar, parameters);
-
-      {
-        BasicNativeApplicationContext::GlobalMutexLocker locker(context);
-        context.SetCentralWidget(application_.GetCentralWidget());
-        context.GetCentralViewport().SetStatusBar(statusBar);
-      }
-
-      std::string title = application_.GetTitle();
-      if (title.empty())
-      {
-        title = "Stone of Orthanc";
-      }
-
-      /****************************************************************
-       * Run the application
-       ****************************************************************/
-
-      Run(context, title, argc, argv);
-
-      /****************************************************************
-       * Finalize the application
-       ****************************************************************/
-
-      LOG(WARNING) << "The application is stopping";
-      application_.Finalize();
-    }
-    catch (Orthanc::OrthancException& e)
-    {
-      LOG(ERROR) << "EXCEPTION: " << e.What();
-      success = false;
-    }
-
-
-    /******************************************************************
-     * Finalize all the subcomponents of Orthanc Stone
-     ******************************************************************/
-
-    Finalize();
-    Orthanc::HttpClient::GlobalFinalize();
-    Orthanc::Toolbox::FinalizeOpenSsl();
-
-    return (success ? 0 : -1);
-  }
-
-}
--- a/Applications/Generic/BasicNativeApplicationRunner.h	Thu Aug 30 16:56:08 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-
-#pragma once
-
-#include "../IStoneApplication.h"
-
-#if ORTHANC_ENABLE_NATIVE != 1
-#error this file shall be included only with the ORTHANC_ENABLE_NATIVE set to 1
-#endif
-
-namespace OrthancStone
-{
-  class BasicNativeApplicationContext;
-
-  class BasicNativeApplicationRunner
-  {
-  protected:
-    MessageBroker&      broker_;
-    IStoneApplication&  application_;
-  public:
-
-    BasicNativeApplicationRunner(MessageBroker& broker,
-                                 IStoneApplication& application)
-      : broker_(broker),
-        application_(application)
-    {
-    }
-    int Execute(int argc,
-                char* argv[]);
-
-    virtual void Initialize() = 0;
-    virtual void DeclareCommandLineOptions(boost::program_options::options_description& options) = 0;
-    virtual void ParseCommandLineOptions(const boost::program_options::variables_map& parameters) = 0;
-
-    virtual void Run(BasicNativeApplicationContext& context, const std::string& title, int argc, char* argv[]) = 0;
-    virtual void Finalize() = 0;
-  };
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Generic/NativeStoneApplicationContext.cpp	Thu Aug 30 17:06:22 2018 +0200
@@ -0,0 +1,80 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+#include "NativeStoneApplicationContext.h"
+#include "../../Platforms/Generic/OracleWebService.h"
+
+namespace OrthancStone
+{
+  IWidget& NativeStoneApplicationContext::SetCentralWidget(IWidget* widget)   // Takes ownership
+  {
+    centralViewport_->SetCentralWidget(widget);
+    return *widget;
+  }
+
+
+  void NativeStoneApplicationContext::UpdateThread(NativeStoneApplicationContext* that)
+  {
+    while (!that->stopped_)
+    {
+      {
+        GlobalMutexLocker locker(*that);
+        that->GetCentralViewport().UpdateContent();
+      }
+      
+      boost::this_thread::sleep(boost::posix_time::milliseconds(that->updateDelayInMs_));
+    }
+  }
+  
+
+  NativeStoneApplicationContext::NativeStoneApplicationContext() :
+    centralViewport_(new OrthancStone::WidgetViewport()),
+    stopped_(true),
+    updateDelayInMs_(100)   // By default, 100ms between each refresh of the content
+  {
+    srand(time(NULL)); 
+  }
+
+
+  void NativeStoneApplicationContext::Start()
+  {
+    dynamic_cast<OracleWebService*>(webService_)->Start();
+
+    if (centralViewport_->HasUpdateContent())
+    {
+      stopped_ = false;
+      updateThread_ = boost::thread(UpdateThread, this);
+    }
+  }
+
+
+  void NativeStoneApplicationContext::Stop()
+  {
+    stopped_ = true;
+    
+    if (updateThread_.joinable())
+    {
+      updateThread_.join();
+    }
+    
+    dynamic_cast<OracleWebService*>(webService_)->Stop();
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Generic/NativeStoneApplicationContext.h	Thu Aug 30 17:06:22 2018 +0200
@@ -0,0 +1,73 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+#pragma once
+
+#include "../../Framework/Viewport/WidgetViewport.h"
+#include "../../Framework/Volumes/ISlicedVolume.h"
+#include "../../Framework/Volumes/IVolumeLoader.h"
+
+#include <list>
+#include <boost/thread.hpp>
+#include "../StoneApplicationContext.h"
+
+namespace OrthancStone
+{
+  class NativeStoneApplicationContext : public StoneApplicationContext
+  {
+  private:
+
+    static void UpdateThread(NativeStoneApplicationContext* that);
+
+    boost::mutex        globalMutex_;
+    std::unique_ptr<WidgetViewport>      centralViewport_;
+    boost::thread       updateThread_;
+    bool                stopped_;
+    unsigned int        updateDelayInMs_;
+
+  public:
+    class GlobalMutexLocker: public boost::noncopyable
+    {
+      boost::mutex::scoped_lock  lock_;
+    public:
+      GlobalMutexLocker(NativeStoneApplicationContext& that):
+        lock_(that.globalMutex_)
+      {}
+    };
+
+    NativeStoneApplicationContext();
+
+    virtual ~NativeStoneApplicationContext() {}
+
+    virtual IWidget& SetCentralWidget(IWidget* widget);   // Takes ownership
+    IViewport& GetCentralViewport() {return *(centralViewport_.get());}
+
+    void Start();
+
+    void Stop();
+
+    void SetUpdateDelay(unsigned int delayInMs)
+    {
+      updateDelayInMs_ = delayInMs;
+    }
+
+  };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Generic/NativeStoneApplicationRunner.cpp	Thu Aug 30 17:06:22 2018 +0200
@@ -0,0 +1,240 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+#if ORTHANC_ENABLE_NATIVE != 1
+#error this file shall be included only with the ORTHANC_ENABLE_NATIVE set to 1
+#endif
+
+#include "NativeStoneApplicationRunner.h"
+#include "NativeStoneApplicationContext.h"
+#include <boost/program_options.hpp>
+
+#include "../../Framework/Toolbox/MessagingToolbox.h"
+
+#include <Core/Logging.h>
+#include <Core/HttpClient.h>
+#include <Core/Toolbox.h>
+#include <Plugins/Samples/Common/OrthancHttpConnection.h>
+#include "../../Platforms/Generic/OracleWebService.h"
+
+namespace OrthancStone
+{
+  // Anonymous namespace to avoid clashes against other compilation modules
+  namespace
+  {
+    class LogStatusBar : public IStatusBar
+    {
+    public:
+      virtual void ClearMessage()
+      {
+      }
+
+      virtual void SetMessage(const std::string& message)
+      {
+        LOG(WARNING) << message;
+      }
+    };
+  }
+
+  int NativeStoneApplicationRunner::Execute(int argc,
+                                            char* argv[])
+  {
+    /******************************************************************
+     * Initialize all the subcomponents of Orthanc Stone
+     ******************************************************************/
+
+    Orthanc::Logging::Initialize();
+    Orthanc::Toolbox::InitializeOpenSsl();
+    Orthanc::HttpClient::GlobalInitialize();
+
+    Initialize();
+
+    /******************************************************************
+     * Declare and parse the command-line options of the application
+     ******************************************************************/
+
+    boost::program_options::options_description options;
+
+    { // generic options
+      boost::program_options::options_description generic("Generic options");
+      generic.add_options()
+          ("help", "Display this help and exit")
+          ("verbose", "Be verbose in logs")
+          ("orthanc", boost::program_options::value<std::string>()->default_value("http://localhost:8042/"),
+           "URL to the Orthanc server")
+          ("username", "Username for the Orthanc server")
+          ("password", "Password for the Orthanc server")
+          ("https-verify", boost::program_options::value<bool>()->default_value(true), "Check HTTPS certificates")
+          ;
+
+      options.add(generic);
+    }
+
+    // platform specific options
+    DeclareCommandLineOptions(options);
+    
+    // application specific options
+    application_.DeclareStartupOptions(options);
+
+    boost::program_options::variables_map parameters;
+    bool error = false;
+
+    try
+    {
+      boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
+                                    options(options).run(), parameters);
+      boost::program_options::notify(parameters);
+    }
+    catch (boost::program_options::error& e)
+    {
+      LOG(ERROR) << "Error while parsing the command-line arguments: " << e.what();
+      error = true;
+    }
+
+
+    /******************************************************************
+     * Configure the application with the command-line parameters
+     ******************************************************************/
+
+    if (error || parameters.count("help"))
+    {
+      std::cout << std::endl
+                << "Usage: " << argv[0] << " [OPTION]..."
+                << std::endl
+                << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research."
+                << std::endl << std::endl
+                << "Demonstration application of Orthanc Stone using SDL."
+                << std::endl;
+
+      std::cout << options << "\n";
+      return error ? -1 : 0;
+    }
+
+    if (parameters.count("https-verify") &&
+        !parameters["https-verify"].as<bool>())
+    {
+      LOG(WARNING) << "Turning off verification of HTTPS certificates (unsafe)";
+      Orthanc::HttpClient::ConfigureSsl(false, "");
+    }
+
+    if (parameters.count("verbose"))
+    {
+      Orthanc::Logging::EnableInfoLevel(true);
+    }
+
+    ParseCommandLineOptions(parameters);
+
+
+    bool success = true;
+    try
+    {
+      /****************************************************************
+       * Initialize the connection to the Orthanc server
+       ****************************************************************/
+
+      Orthanc::WebServiceParameters webServiceParameters;
+
+      if (parameters.count("orthanc"))
+      {
+        webServiceParameters.SetUrl(parameters["orthanc"].as<std::string>());
+      }
+
+      if (parameters.count("username"))
+      {
+        webServiceParameters.SetUsername(parameters["username"].as<std::string>());
+      }
+
+      if (parameters.count("password"))
+      {
+        webServiceParameters.SetPassword(parameters["password"].as<std::string>());
+      }
+
+      LOG(WARNING) << "URL to the Orthanc REST API: " << webServiceParameters.GetUrl();
+
+      {
+        OrthancPlugins::OrthancHttpConnection orthanc(webServiceParameters);
+        if (!MessagingToolbox::CheckOrthancVersion(orthanc))
+        {
+          LOG(ERROR) << "Your version of Orthanc is incompatible with Stone of Orthanc, please upgrade";
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
+        }
+      }
+
+
+      /****************************************************************
+       * Initialize the application
+       ****************************************************************/
+
+      LOG(WARNING) << "Creating the widgets of the application";
+
+      LogStatusBar statusBar;
+
+      NativeStoneApplicationContext context;
+      Oracle oracle(4); // use 4 threads to download content
+      OracleWebService webService(broker_, oracle, webServiceParameters, context);
+      context.SetWebService(webService);
+
+      application_.Initialize(&context, statusBar, parameters);
+
+      {
+        NativeStoneApplicationContext::GlobalMutexLocker locker(context);
+        context.SetCentralWidget(application_.GetCentralWidget());
+        context.GetCentralViewport().SetStatusBar(statusBar);
+      }
+
+      std::string title = application_.GetTitle();
+      if (title.empty())
+      {
+        title = "Stone of Orthanc";
+      }
+
+      /****************************************************************
+       * Run the application
+       ****************************************************************/
+
+      Run(context, title, argc, argv);
+
+      /****************************************************************
+       * Finalize the application
+       ****************************************************************/
+
+      LOG(WARNING) << "The application is stopping";
+      application_.Finalize();
+    }
+    catch (Orthanc::OrthancException& e)
+    {
+      LOG(ERROR) << "EXCEPTION: " << e.What();
+      success = false;
+    }
+
+
+    /******************************************************************
+     * Finalize all the subcomponents of Orthanc Stone
+     ******************************************************************/
+
+    Finalize();
+    Orthanc::HttpClient::GlobalFinalize();
+    Orthanc::Toolbox::FinalizeOpenSsl();
+
+    return (success ? 0 : -1);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Generic/NativeStoneApplicationRunner.h	Thu Aug 30 17:06:22 2018 +0200
@@ -0,0 +1,58 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+#pragma once
+
+#include "../IStoneApplication.h"
+
+#if ORTHANC_ENABLE_NATIVE != 1
+#error this file shall be included only with the ORTHANC_ENABLE_NATIVE set to 1
+#endif
+
+namespace OrthancStone
+{
+  class NativeStoneApplicationContext;
+
+  class NativeStoneApplicationRunner
+  {
+  protected:
+    MessageBroker&      broker_;
+    IStoneApplication&  application_;
+  public:
+
+    NativeStoneApplicationRunner(MessageBroker& broker,
+                                 IStoneApplication& application)
+      : broker_(broker),
+        application_(application)
+    {
+    }
+    int Execute(int argc,
+                char* argv[]);
+
+    virtual void Initialize() = 0;
+    virtual void DeclareCommandLineOptions(boost::program_options::options_description& options) = 0;
+    virtual void ParseCommandLineOptions(const boost::program_options::variables_map& parameters) = 0;
+
+    virtual void Run(NativeStoneApplicationContext& context, const std::string& title, int argc, char* argv[]) = 0;
+    virtual void Finalize() = 0;
+  };
+
+}
--- a/Applications/Qt/BasicQtApplicationRunner.cpp	Thu Aug 30 16:56:08 2018 +0200
+++ b/Applications/Qt/BasicQtApplicationRunner.cpp	Thu Aug 30 17:06:22 2018 +0200
@@ -46,7 +46,7 @@
   {
   }
 
-  void BasicQtApplicationRunner::Run(BasicNativeApplicationContext& context, const std::string& title, int argc, char* argv[])
+  void BasicQtApplicationRunner::Run(NativeStoneApplicationContext& context, const std::string& title, int argc, char* argv[])
   {
     context.Start();
 
--- a/Applications/Qt/BasicQtApplicationRunner.h	Thu Aug 30 16:56:08 2018 +0200
+++ b/Applications/Qt/BasicQtApplicationRunner.h	Thu Aug 30 17:06:22 2018 +0200
@@ -21,7 +21,7 @@
 
 #pragma once
 
-#include "../Generic/BasicNativeApplicationRunner.h"
+#include "../Generic/NativeStoneApplicationRunner.h"
 #include "QStoneMainWindow.h"
 
 #if ORTHANC_ENABLE_QT != 1
@@ -30,16 +30,16 @@
 
 namespace OrthancStone
 {
-  class BasicQtApplicationRunner : public BasicNativeApplicationRunner
+  class BasicQtApplicationRunner : public NativeStoneApplicationRunner
   {
   protected:
     std::auto_ptr<QStoneMainWindow> window_;
 
-    virtual void InitializeMainWindow(BasicNativeApplicationContext& context) = 0;
+    virtual void InitializeMainWindow(NativeStoneApplicationContext& context) = 0;
   public:
     BasicQtApplicationRunner(MessageBroker& broker,
                              IStoneApplication& application)
-      : BasicNativeApplicationRunner(broker, application)
+      : NativeStoneApplicationRunner(broker, application)
     {
     }
 
@@ -48,7 +48,7 @@
 
     virtual void DeclareCommandLineOptions(boost::program_options::options_description& options);
     virtual void ParseCommandLineOptions(const boost::program_options::variables_map& parameters) {}
-    virtual void Run(BasicNativeApplicationContext& context, const std::string& title, int argc, char* argv[]);
+    virtual void Run(NativeStoneApplicationContext& context, const std::string& title, int argc, char* argv[]);
     virtual void Finalize();
   };
 
--- a/Applications/Qt/QCairoWidget.cpp	Thu Aug 30 16:56:08 2018 +0200
+++ b/Applications/Qt/QCairoWidget.cpp	Thu Aug 30 17:06:22 2018 +0200
@@ -36,7 +36,7 @@
 {
 }
 
-void QCairoWidget::SetContext(OrthancStone::BasicNativeApplicationContext& context)
+void QCairoWidget::SetContext(OrthancStone::NativeStoneApplicationContext& context)
 {
   context_ = &context;
   context_->GetCentralViewport().Register(*this); // get notified each time the content of the central viewport changes
@@ -48,7 +48,7 @@
 
   if (image_.get() != NULL && context_ != NULL)
   {
-    OrthancStone::BasicNativeApplicationContext::GlobalMutexLocker locker(*context_);
+    OrthancStone::NativeStoneApplicationContext::GlobalMutexLocker locker(*context_);
     OrthancStone::IViewport& viewport = context_->GetCentralViewport();
     Orthanc::ImageAccessor a = surface_.GetAccessor();
     viewport.Render(a);
--- a/Applications/Qt/QCairoWidget.h	Thu Aug 30 16:56:08 2018 +0200
+++ b/Applications/Qt/QCairoWidget.h	Thu Aug 30 17:06:22 2018 +0200
@@ -21,7 +21,7 @@
 #pragma once
 
 #include "../../Framework/Widgets/CairoWidget.h"
-#include "../../Applications/Generic/BasicNativeApplicationContext.h"
+#include "../../Applications/Generic/NativeStoneApplicationContext.h"
 #include "../../Framework/Viewport/CairoSurface.h"
 
 #include <QWidget>
@@ -36,7 +36,7 @@
 private:
   std::auto_ptr<QImage>         image_;
   OrthancStone::CairoSurface    surface_;
-  OrthancStone::BasicNativeApplicationContext* context_;
+  OrthancStone::NativeStoneApplicationContext* context_;
 
 protected:
   virtual void paintEvent(QPaintEvent *event);
@@ -58,7 +58,7 @@
  
   virtual ~QCairoWidget();
 
-  void SetContext(OrthancStone::BasicNativeApplicationContext& context);
+  void SetContext(OrthancStone::NativeStoneApplicationContext& context);
 
   virtual void OnViewportContentChanged(const OrthancStone::IViewport& /*sceneNotUsed*/)
   {
--- a/Applications/Qt/QStoneMainWindow.cpp	Thu Aug 30 16:56:08 2018 +0200
+++ b/Applications/Qt/QStoneMainWindow.cpp	Thu Aug 30 17:06:22 2018 +0200
@@ -23,7 +23,7 @@
 namespace OrthancStone
 {
 
-  QStoneMainWindow::QStoneMainWindow(BasicNativeApplicationContext& context, QWidget *parent) :
+  QStoneMainWindow::QStoneMainWindow(NativeStoneApplicationContext& context, QWidget *parent) :
     QMainWindow(parent),
     context_(context)
   {
--- a/Applications/Qt/QStoneMainWindow.h	Thu Aug 30 16:56:08 2018 +0200
+++ b/Applications/Qt/QStoneMainWindow.h	Thu Aug 30 17:06:22 2018 +0200
@@ -22,7 +22,7 @@
 #include <QMainWindow>
 
 #include "QCairoWidget.h"
-#include "../Generic/BasicNativeApplicationContext.h"
+#include "../Generic/NativeStoneApplicationContext.h"
 
 namespace OrthancStone
 {
@@ -31,11 +31,11 @@
     Q_OBJECT
 
   private:
-    OrthancStone::BasicNativeApplicationContext& context_;
+    OrthancStone::NativeStoneApplicationContext& context_;
     QCairoWidget          *cairoCentralWidget_;
 
   protected:  // you must inherit this class
-    QStoneMainWindow(BasicNativeApplicationContext& context, QWidget *parent = 0);
+    QStoneMainWindow(NativeStoneApplicationContext& context, QWidget *parent = 0);
     void SetCentralStoneWidget(QCairoWidget* centralWidget);
   public:
     virtual ~QStoneMainWindow();
--- a/Applications/Samples/Qt/SampleMainWindow.cpp	Thu Aug 30 16:56:08 2018 +0200
+++ b/Applications/Samples/Qt/SampleMainWindow.cpp	Thu Aug 30 17:06:22 2018 +0200
@@ -32,7 +32,7 @@
   namespace Samples
   {
 
-    SampleMainWindow::SampleMainWindow(OrthancStone::BasicNativeApplicationContext& context, OrthancStone::Samples::SampleApplicationBase& stoneSampleApplication, QWidget *parent) :
+    SampleMainWindow::SampleMainWindow(OrthancStone::NativeStoneApplicationContext& context, OrthancStone::Samples::SampleApplicationBase& stoneSampleApplication, QWidget *parent) :
       QStoneMainWindow(context, parent),
       ui_(new Ui::SampleMainWindow),
       stoneSampleApplication_(stoneSampleApplication)
--- a/Applications/Samples/Qt/SampleMainWindow.h	Thu Aug 30 16:56:08 2018 +0200
+++ b/Applications/Samples/Qt/SampleMainWindow.h	Thu Aug 30 17:06:22 2018 +0200
@@ -43,7 +43,7 @@
       SampleApplicationBase&  stoneSampleApplication_;
 
     public:
-      explicit SampleMainWindow(OrthancStone::BasicNativeApplicationContext& context, SampleApplicationBase& stoneSampleApplication, QWidget *parent = 0);
+      explicit SampleMainWindow(OrthancStone::NativeStoneApplicationContext& context, SampleApplicationBase& stoneSampleApplication, QWidget *parent = 0);
       ~SampleMainWindow();
 
     private slots:
--- a/Applications/Samples/Qt/SampleQtApplicationRunner.h	Thu Aug 30 16:56:08 2018 +0200
+++ b/Applications/Samples/Qt/SampleQtApplicationRunner.h	Thu Aug 30 17:06:22 2018 +0200
@@ -35,7 +35,7 @@
     class SampleQtApplicationRunner : public OrthancStone::BasicQtApplicationRunner
     {
     protected:
-      virtual void InitializeMainWindow(OrthancStone::BasicNativeApplicationContext& context)
+      virtual void InitializeMainWindow(OrthancStone::NativeStoneApplicationContext& context)
       {
         window_.reset(new SampleMainWindow(context, dynamic_cast<OrthancStone::Samples::SampleApplicationBase&>(application_)));
       }
--- a/Platforms/Generic/OracleWebService.h	Thu Aug 30 16:56:08 2018 +0200
+++ b/Platforms/Generic/OracleWebService.h	Thu Aug 30 17:06:22 2018 +0200
@@ -25,7 +25,7 @@
 #include "Oracle.h"
 #include "WebServiceGetCommand.h"
 #include "WebServicePostCommand.h"
-#include "../../Applications/Generic/BasicNativeApplicationContext.h"
+#include "../../Applications/Generic/NativeStoneApplicationContext.h"
 
 namespace OrthancStone
 {
@@ -34,14 +34,14 @@
   {
   private:
     Oracle&                        oracle_;
-    BasicNativeApplicationContext& context_;
+    NativeStoneApplicationContext& context_;
     Orthanc::WebServiceParameters  parameters_;
 
   public:
     OracleWebService(MessageBroker& broker,
                      Oracle& oracle,
                      const Orthanc::WebServiceParameters& parameters,
-                     BasicNativeApplicationContext& context) :
+                     NativeStoneApplicationContext& context) :
       IWebService(broker),
       oracle_(oracle),
       context_(context),
--- a/Platforms/Generic/WebServiceCommandBase.cpp	Thu Aug 30 16:56:08 2018 +0200
+++ b/Platforms/Generic/WebServiceCommandBase.cpp	Thu Aug 30 17:06:22 2018 +0200
@@ -31,7 +31,7 @@
                                                const std::string& uri,
                                                const IWebService::Headers& headers,
                                                Orthanc::IDynamicObject* payload /* takes ownership */,
-                                               BasicNativeApplicationContext& context) :
+                                               NativeStoneApplicationContext& context) :
     IObservable(broker),
     callback_(callback),
     parameters_(parameters),
@@ -48,7 +48,7 @@
 
   void WebServiceCommandBase::Commit()
   {
-    BasicNativeApplicationContext::GlobalMutexLocker lock(context_);  // we want to make sure that, i.e, the UpdateThread is not triggered while we are updating the "model" with the result of a WebServiceCommand
+    NativeStoneApplicationContext::GlobalMutexLocker lock(context_);  // we want to make sure that, i.e, the UpdateThread is not triggered while we are updating the "model" with the result of a WebServiceCommand
 
     if (success_)
     {
--- a/Platforms/Generic/WebServiceCommandBase.h	Thu Aug 30 16:56:08 2018 +0200
+++ b/Platforms/Generic/WebServiceCommandBase.h	Thu Aug 30 17:06:22 2018 +0200
@@ -25,7 +25,7 @@
 
 #include "../../Framework/Toolbox/IWebService.h"
 #include "../../Framework/Messages/IObservable.h"
-#include "../../Applications/Generic/BasicNativeApplicationContext.h"
+#include "../../Applications/Generic/NativeStoneApplicationContext.h"
 
 #include <Core/WebServiceParameters.h>
 
@@ -43,7 +43,7 @@
     std::auto_ptr<Orthanc::IDynamicObject>  payload_;
     bool                                    success_;
     std::string                             answer_;
-    BasicNativeApplicationContext&          context_;
+    NativeStoneApplicationContext&          context_;
 
   public:
     WebServiceCommandBase(MessageBroker& broker,
@@ -52,7 +52,7 @@
                           const std::string& uri,
                           const std::map<std::string, std::string>& headers,
                           Orthanc::IDynamicObject* payload /* takes ownership */,
-                          BasicNativeApplicationContext& context);
+                          NativeStoneApplicationContext& context);
 
     virtual void Execute() = 0;
 
--- a/Platforms/Generic/WebServiceGetCommand.cpp	Thu Aug 30 16:56:08 2018 +0200
+++ b/Platforms/Generic/WebServiceGetCommand.cpp	Thu Aug 30 17:06:22 2018 +0200
@@ -31,7 +31,7 @@
                                              const std::string& uri,
                                              const IWebService::Headers& headers,
                                              Orthanc::IDynamicObject* payload /* takes ownership */,
-                                             BasicNativeApplicationContext& context) :
+                                             NativeStoneApplicationContext& context) :
     WebServiceCommandBase(broker, callback, parameters, uri, headers, payload, context)
   {
   }
--- a/Platforms/Generic/WebServiceGetCommand.h	Thu Aug 30 16:56:08 2018 +0200
+++ b/Platforms/Generic/WebServiceGetCommand.h	Thu Aug 30 17:06:22 2018 +0200
@@ -34,7 +34,7 @@
                          const std::string& uri,
                          const IWebService::Headers& headers,
                          Orthanc::IDynamicObject* payload /* takes ownership */,
-                         BasicNativeApplicationContext& context);
+                         NativeStoneApplicationContext& context);
 
     virtual void Execute();
   };
--- a/Platforms/Generic/WebServicePostCommand.cpp	Thu Aug 30 16:56:08 2018 +0200
+++ b/Platforms/Generic/WebServicePostCommand.cpp	Thu Aug 30 17:06:22 2018 +0200
@@ -32,7 +32,7 @@
                                                const IWebService::Headers& headers,
                                                const std::string& body,
                                                Orthanc::IDynamicObject* payload /* takes ownership */,
-                                               BasicNativeApplicationContext& context) :
+                                               NativeStoneApplicationContext& context) :
     WebServiceCommandBase(broker, callback, parameters, uri, headers, payload, context),
     body_(body)
   {
--- a/Platforms/Generic/WebServicePostCommand.h	Thu Aug 30 16:56:08 2018 +0200
+++ b/Platforms/Generic/WebServicePostCommand.h	Thu Aug 30 17:06:22 2018 +0200
@@ -38,7 +38,7 @@
                           const IWebService::Headers& headers,
                           const std::string& body,
                           Orthanc::IDynamicObject* payload /* takes ownership */,
-                          BasicNativeApplicationContext& context);
+                          NativeStoneApplicationContext& context);
 
     virtual void Execute();
   };
--- a/Resources/CMake/OrthancStoneConfiguration.cmake	Thu Aug 30 16:56:08 2018 +0200
+++ b/Resources/CMake/OrthancStoneConfiguration.cmake	Thu Aug 30 17:06:22 2018 +0200
@@ -177,8 +177,8 @@
 
   if (ENABLE_SDL OR ENABLE_QT)
     list(APPEND APPLICATIONS_SOURCES
-      ${ORTHANC_STONE_ROOT}/Applications/Generic/BasicNativeApplicationRunner.cpp
-      ${ORTHANC_STONE_ROOT}/Applications/Generic/BasicNativeApplicationContext.cpp
+      ${ORTHANC_STONE_ROOT}/Applications/Generic/NativeStoneApplicationRunner.cpp
+      ${ORTHANC_STONE_ROOT}/Applications/Generic/NativeStoneApplicationContext.cpp
       )
     if (ENABLE_SDL)
       list(APPEND APPLICATIONS_SOURCES