changeset 502:3ae7563b4fe1 am-touch-events

more orthancApiClient overloads
author amazy
date Mon, 25 Feb 2019 17:57:37 +0100
parents 64d90190a08c
children 77e0eb83ff63
files Framework/Toolbox/OrthancApiClient.cpp Framework/Toolbox/OrthancApiClient.h
diffstat 2 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Toolbox/OrthancApiClient.cpp	Wed Feb 20 20:57:43 2019 +0100
+++ b/Framework/Toolbox/OrthancApiClient.cpp	Mon Feb 25 17:57:37 2019 +0100
@@ -248,6 +248,21 @@
     web_.PostAsync(baseUrl_ + uri, IWebService::HttpHeaders(), body, NULL, NULL, NULL);
   }
 
+  void OrthancApiClient::PostBinaryAsync(
+      const std::string& uri,
+      const std::string& body,
+      MessageHandler<EmptyResponseReadyMessage>* successCallback,
+      MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
+      Orthanc::IDynamicObject* payload   /* takes ownership */)
+  {
+    web_.PostAsync(baseUrl_ + uri, IWebService::HttpHeaders(), body,
+                   new WebServicePayload(successCallback, failureCallback, payload),
+                   new Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage>
+                   (*this, &OrthancApiClient::NotifyHttpSuccess),
+                   new Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage>
+                   (*this, &OrthancApiClient::NotifyHttpError));
+  }
+
   void OrthancApiClient::PostJsonAsyncExpectJson(
       const std::string& uri,
       const Json::Value& data,
@@ -269,6 +284,18 @@
     return PostBinaryAsync(uri, body);
   }
 
+  void OrthancApiClient::PostJsonAsync(
+      const std::string& uri,
+      const Json::Value& data,
+      MessageHandler<EmptyResponseReadyMessage>* successCallback,
+      MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
+      Orthanc::IDynamicObject* payload   /* takes ownership */)
+  {
+    std::string body;
+    MessagingToolbox::JsonToString(body, data);
+    return PostBinaryAsync(uri, body, successCallback, failureCallback, payload);
+  }
+
   void OrthancApiClient::DeleteAsync(
       const std::string& uri,
       MessageHandler<EmptyResponseReadyMessage>* successCallback,
--- a/Framework/Toolbox/OrthancApiClient.h	Wed Feb 20 20:57:43 2019 +0100
+++ b/Framework/Toolbox/OrthancApiClient.h	Mon Feb 25 17:57:37 2019 +0100
@@ -201,10 +201,25 @@
     void PostJsonAsync(const std::string& uri,
                        const Json::Value& data);
 
+    // schedule a POST request and don't expect any response.
+    void PostJsonAsync(const std::string& uri,
+                       const Json::Value& data,
+                       MessageHandler<EmptyResponseReadyMessage>* successCallback,
+                       MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,
+                       Orthanc::IDynamicObject* payload = NULL   /* takes ownership */);
+
+
     // schedule a POST request and don't mind the response.
     void PostBinaryAsync(const std::string& uri,
                          const std::string& body);
 
+    // schedule a POST request and don't expect any response.
+    void PostBinaryAsync(const std::string& uri,
+                         const std::string& body,
+                         MessageHandler<EmptyResponseReadyMessage>* successCallback,
+                         MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,
+                         Orthanc::IDynamicObject* payload = NULL   /* takes ownership */);
+
     // schedule a DELETE request expecting an empty response.
     void DeleteAsync(const std::string& uri,
                      MessageHandler<EmptyResponseReadyMessage>* successCallback,