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(const URL& aUrl,Proxy& aProxy,
00073 unsigned int aResponseTimeout = DEFAULT_MAX_TIMEOUT,
00074 unsigned int aMaxMsgSize = DEFAULT_MAX_MSG_SIZE);
00075
00081 static CSymbianTransportAgent* NewLC(const 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
00097
00098 private:
00103 void ConstructL(const URL& aUrl);
00104
00109 CSymbianTransportAgent(const URL& aUrl, Proxy& aProxy,
00110 unsigned int aResponseTimeout);
00111
00119 void SetHeaderL(RHTTPHeaders aHeaders,
00120 TInt aHdrField,
00121 const TDesC8& aHdrValue);
00122
00128 void reuseActiveConnection();
00129
00133 private:
00140 void MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent& aEvent );
00141
00152 TInt MHFRunError( TInt aError,
00153 RHTTPTransaction aTransaction,
00154 const THTTPEvent& aEvent );
00155
00156
00162 void SetHttpClientError(TInt aStatus);
00163
00169 void SetHttpServerError(TInt aStatus);
00170
00171
00172
00173
00174 public:
00178 char* sendMessage(const char* msg);
00179 char* sendMessage(const char* msg, unsigned int size);
00180
00181
00182
00183
00184 public:
00185 TBool GetNextDataPart(TPtrC8& aDataChunk);
00186 void ReleaseData();
00187 TInt OverallDataSize();
00188 TInt Reset();
00189
00190
00191 private:
00192
00193 RHTTPSession iHttpSession;
00194 RHTTPTransaction iHttpTransaction;
00195 MHTTPDataSupplier* iDataSupplier;
00196 HBufC8* iPostBody;
00197 HBufC8* iResponseBody;
00198 TBool iTransFailed;
00199 CActiveSchedulerWait* iASWait;
00200 };
00201
00202 END_NAMESPACE
00203
00204 #endif //SYMBIANTRANSPORTAGENT_H_