00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef SYMBIANTRANSPORTAGENT_H_
00036 #define SYMBIANTRANSPORTAGENT_H_
00037
00038 #include <coecntrl.h>
00039
00040 #include "base/globalsdef.h"
00041 #include <http/mhttptransactioncallback.h>
00042 #include <http/mhttpdatasupplier.h>
00043
00044 #include <http/rhttpsession.h>
00045 #include <http/rhttpheaders.h>
00046
00047 #include "http/URL.h"
00048 #include "http/Proxy.h"
00049 #include "http/TransportAgent.h"
00050
00051 BEGIN_NAMESPACE
00052
00053
00054 #define MAX_RETRIES 3 // Max number of attempts sending http requests.
00055
00061 class CSymbianTransportAgent : public CBase,
00062 public MHTTPTransactionCallback,
00063 public MHTTPDataSupplier,
00064 public TransportAgent
00065 {
00066 public:
00072 static CSymbianTransportAgent* NewL(URL& aUrl,Proxy& aProxy,
00073 unsigned int aResponseTimeout = DEFAULT_MAX_TIMEOUT,
00074 unsigned int aMaxMsgSize = DEFAULT_MAX_MSG_SIZE);
00075
00081 static CSymbianTransportAgent* NewLC(URL& aUrl,Proxy& aProxy,
00082 unsigned int aResponseTimeout = DEFAULT_MAX_TIMEOUT,
00083 unsigned int aMaxMsgSize = DEFAULT_MAX_MSG_SIZE);
00084
00089 ~CSymbianTransportAgent();
00090
00095 void ConnectL();
00096
00101 void SetIap(const TUint32& aIap);
00102
00103 private:
00108 void ConstructL(URL& aUrl);
00109
00114 CSymbianTransportAgent(URL& aUrl, Proxy& aProxy,
00115 unsigned int aResponseTimeout);
00116
00124 void SetHeaderL(RHTTPHeaders aHeaders,
00125 TInt aHdrField,
00126 const TDesC8& aHdrValue);
00127
00133 void reuseActiveConnection();
00134
00138 private:
00145 void MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent& aEvent );
00146
00157 TInt MHFRunError( TInt aError,
00158 RHTTPTransaction aTransaction,
00159 const THTTPEvent& aEvent );
00160
00161
00167 void SetHttpClientError(TInt aStatus);
00168
00174 void SetHttpServerError(TInt aStatus);
00175
00176
00177
00178
00179 public:
00183 char* sendMessage(const char* msg);
00184
00185
00186
00187
00188 public:
00189 TBool GetNextDataPart(TPtrC8& aDataChunk);
00190 void ReleaseData();
00191 TInt OverallDataSize();
00192 TInt Reset();
00193
00194
00195 private:
00196
00197 TUint32 iIap;
00198
00199 RHTTPSession iHttpSession;
00200 RHTTPTransaction iHttpTransaction;
00201 MHTTPDataSupplier* iDataSupplier;
00202 HBufC8* iPostBody;
00203 HBufC8* iResponseBody;
00204 TBool iTransFailed;
00205 CActiveSchedulerWait* iASWait;
00206 };
00207
00208 END_NAMESPACE
00209
00210 #endif //SYMBIANTRANSPORTAGENT_H_