emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/excorporate cee32a6 65/93: Excorporate: Add support for


From: Stefan Monnier
Subject: [elpa] externals/excorporate cee32a6 65/93: Excorporate: Add support for synchronous operations
Date: Sun, 29 Nov 2020 15:43:10 -0500 (EST)

branch: externals/excorporate
commit cee32a6178c2f4e22faf599926cc5a9518387564
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>

    Excorporate: Add support for synchronous operations
    
    * packages/excorporate/excorporate.el (exco--fsm): Support
    synchronous finite state machine calls in :retrieving-data state.
    (exco-operate): Throw error if callback argument is nil.
    (exco-operate-synchronously): New function.
---
 excorporate.el | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/excorporate.el b/excorporate.el
index 25f2b5c..a478262 100644
--- a/excorporate.el
+++ b/excorporate.el
@@ -560,20 +560,26 @@ the FSM should transition to on success."
   (list state-data nil))
 
 (define-state exco--fsm :retrieving-data
-  (_fsm state-data event _callback)
+  (_fsm state-data event fsm-result-callback)
   (let* ((identifier (plist-get state-data :identifier))
         (wsdl (plist-get state-data :service-wsdl))
         (name (pop event))
         (arguments (pop event))
         (callback (pop event)))
-    (apply #'soap-invoke-async
-          (lambda (response)
-            (funcall callback identifier response))
-          nil
-          wsdl
-          "ExchangeServicePort"
-          name
-          arguments))
+    (if callback
+       ;; exco-operate.
+       (apply #'soap-invoke-async
+              (lambda (response)
+                (funcall callback identifier response))
+              nil
+              wsdl
+              "ExchangeServicePort"
+              name
+              arguments)
+      ;; exco-operate-synchronously.
+      (funcall
+       fsm-result-callback
+       (apply #'soap-invoke wsdl "ExchangeServicePort" name arguments))))
   (list :retrieving-data state-data nil))
 
 (defun exco--ensure-connection ()
@@ -631,10 +637,19 @@ use the `cdr' of the pair as the service URL."
 IDENTIFIER is the connection identifier.  Execute operation NAME
 with ARGUMENTS then call CALLBACK with two arguments, IDENTIFIER
 and the server's response."
+  (when (null callback) (error "CALLBACK cannot be nil"))
   (exco--with-fsm identifier
     (fsm-send fsm (list name arguments callback)))
   nil)
 
+(defun exco-operate-synchronously (identifier name arguments)
+  "Execute a service operation synchronously.
+IDENTIFIER is the connection identifier.  Execute operation NAME
+with ARGUMENTS then call CALLBACK with two arguments, IDENTIFIER
+and the server's response."
+  (exco--with-fsm identifier
+    (fsm-call fsm (list name arguments))))
+
 (defun exco-server-version (identifier)
   "Return the server version for connection IDENTIFIER, as a string.
 Examples are \"Exchange2010\", \"Exchange2010_SP1\",



reply via email to

[Prev in Thread] Current Thread [Next in Thread]