initial checkin
[xmlrpc4s.git] / inc / XmlRpcClient.h
blob80d1370bd679f6bdf7e1bb8c144819b12a29c611
1 /*
2 * XmlRpcClient.h
4 * xmlrpc4s - XML-RPC library for Symbian environments
5 * based on xmlrpc-s - Copyright (C) 2007 Timo Salminen
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License version 2.1 as published by the Free Software Foundation.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * Contact: Timo Salminen <firstname.surname at oulu.fi>
23 #ifndef __XMLRPCCLIENT_H_
24 #define __XMLRPCCLIENT_H_
26 #include <e32std.h>
27 #include <e32des16.h>
28 #include "XmlRpcValue.h"
29 #include "XmlRpcConstants.h"
30 #include "XmlRpcClientInterface.h"
31 #include "HttpClientEngine.h"
32 #include "XmlRpcResponseHandlerInterface.h"
34 //Forward declarations:
35 class CXmlRpcValue;
37 /**
38 * Invokes the XML-RPC calls using the given RpcInvocationInterface and
39 * returns the valus obtained as a result for remote method call. Used
40 * in client side of distributed system
42 * @author Timo Salminen
44 class CXmlRpcClient : public MXmlRpcClientInterface, public MXmlRpcResponseHandlerInterface, public CBase
46 public:
48 /**
49 * Constructs the new CXmlRpcClient.
51 * @param aHostAddress Address of the server.
52 * @param aUri Uri parameter of XmlRpc call (for instance '/RPC2').
53 * @param aTargetId Identifier of the target object. (For a call to method "foo.bar()" the aTargetId would be "foo".)
54 * @param aInterface Interface, using which the client communicates.
56 IMPORT_C static CXmlRpcClient* NewL( const TDesC8& aHostAddress,
57 const TDesC8& aHostPath,
58 const TDesC8& aTargetId,
59 const TBool aUseTls);
61 /**
62 * Constructs the new CXmlRpcClient.
64 * @param aHostAddress Address of the server.
65 * @param aUri Uri parameter of XmlRpc call (for instance '/RPC2').
66 * @param aTargetId Identifier of the target object.
67 * @param aInterface Interface, using which the client communicates.
69 IMPORT_C static CXmlRpcClient* NewLC( const TDesC8& aHostAddress,
70 const TDesC8& aHostPath,
71 const TDesC8& aTargetId,
72 const TBool aUseTls);
74 //! Destructor
75 IMPORT_C virtual ~CXmlRpcClient();
77 // From MXmlRpcClientInterface
78 IMPORT_C TBool InvokeL(MXmlRpcResponseHandlerInterface* aInterface, const TDesC8& aMethod,
79 RPointerArray<CXmlRpcValue>* aArray,
80 CXmlRpcValue& aResult );
83 Function: RespondL()
84 Callback handler of XmlRpcResponseHandlerInterface to notify the
85 object about an available response.
87 void RespondL();
89 private:
91 //! Generates the body for XML-RPC call
92 virtual TBool GenerateXmlRpcBodyL( const TDesC8& aMethod,
93 const RPointerArray<CXmlRpcValue>* aArray );
95 //! For parsing the XmlRpc call response
96 virtual TBool ParseResponseL( );
98 CXmlRpcClient( );
100 void ConstructL( const TDesC8& aHostAddress, const TDesC8& aHostPath,
101 const TDesC8& aTargetId,
102 const TBool aUseTls);
105 Function: DoCancel()
106 Implements cancellation of an outstanding request. Implements
107 cancellation of an outstanding request.
109 void DoCancel( );
112 Function: RespondError
113 Called if there was a Fault in the RPC.
115 TInt RespondErrorL (TInt aError);
117 RBuf8 iHostAddr;
118 RBuf8 iHostPath;
119 RBuf8 iTargetId;
120 CHttpClientEngine* iHttpClientEngine;
121 RBuf8 iRequest;
122 // buffer storing the "RAW" HTTP response body:
123 RBuf8 iResponse;
124 CXmlRpcValue* iResponseParsedPtr;
125 TBool iUseTls;
127 MXmlRpcResponseHandlerInterface* iResponseHandlerInterface;
128 RCriticalSection iMutex;
130 #endif