Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __PROGRESSIVE_SOAP_CALL__
00020 #define __PROGRESSIVE_SOAP_CALL__
00021
00022 #ifdef _MSC_VER
00023 #include "msc_stdint.h"
00024 #else
00025 #include <stdint.h>
00026 #endif
00027 #include <boost/bind.hpp>
00028 #include "InterruptableAsyncWorker.h"
00029 #include "soa_soup.h"
00030
00031 class ProgressiveSoapCall : public boost::enable_shared_from_this<ProgressiveSoapCall>
00032 {
00033 public:
00034 ProgressiveSoapCall(const std::string& uri, soa::function_call& fc, const std::string& ssl_ca_file)
00035 : m_uri(uri),
00036 m_mi(soa::method_invocation("urn:AbiCollabSOAP", fc)),
00037 m_ssl_ca_file(ssl_ca_file),
00038 m_worker_ptr()
00039 {}
00040
00041 soa::GenericPtr run()
00042 {
00043 UT_DEBUGMSG(("ProgressiveSoapCall::run()\n"));
00044
00045 m_worker_ptr.reset(new InterruptableAsyncWorker<bool>(
00046 boost::bind(&ProgressiveSoapCall::invoke, shared_from_this())
00047 ));
00048
00049
00050 try
00051 {
00052 bool res = m_worker_ptr->run();
00053 if (!res)
00054 return soa::GenericPtr();
00055 return soa::parse_response(m_result, m_mi.function().response());
00056 }
00057 catch (InterruptedException e)
00058 {
00059 UT_DEBUGMSG(("Soap call interrupted!\n"));
00060 return soa::GenericPtr();
00061 }
00062 }
00063
00064 private:
00065 bool invoke()
00066 {
00067 UT_DEBUGMSG(("ProgressiveSoapCall::invoke()\n"));
00068 return soup_soa::invoke(
00069 m_uri, m_mi, m_ssl_ca_file,
00070 boost::bind(&ProgressiveSoapCall::_progress_cb, this, _1, _2, _3),
00071 m_result
00072 );
00073 }
00074
00075 void _progress_cb(SoupSession* session, SoupMessage* msg, uint32_t progress)
00076 {
00077 UT_DEBUGMSG(("ProgressiveSoapCall::_progress_cb()\n"));
00078 UT_return_if_fail(session && msg);
00079 UT_return_if_fail(m_worker_ptr);
00080
00081 if (m_worker_ptr->cancelled())
00082 {
00083 #ifdef SOUP24
00084 soup_session_cancel_message(session, msg, SOUP_STATUS_CANCELLED);
00085 #else
00086 soup_message_set_status(msg, SOUP_STATUS_CANCELLED);
00087 soup_session_cancel_message(session, msg);
00088 #endif
00089 return;
00090 }
00091
00092 m_worker_ptr->progress(progress);
00093 }
00094
00095 std::string m_uri;
00096 soa::method_invocation m_mi;
00097 std::string m_ssl_ca_file;
00098
00099 boost::shared_ptr< InterruptableAsyncWorker<bool> >
00100 m_worker_ptr;
00101
00102 std::string m_result;
00103 };
00104
00105 #endif