src/include/symbian/http/SymbianTransportAgent.h

00001 /*
00002  * Funambol is a mobile platform developed by Funambol, Inc.
00003  * Copyright (C) 2003 - 2007 Funambol, Inc.
00004  *
00005  * This program is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Affero General Public License version 3 as published by
00007  * the Free Software Foundation with the addition of the following permission
00008  * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
00009  * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
00010  * WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
00011  *
00012  * This program is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00014  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00015  * details.
00016  *
00017  * You should have received a copy of the GNU Affero General Public License
00018  * along with this program; if not, see http://www.gnu.org/licenses or write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00020  * MA 02110-1301 USA.
00021  *
00022  * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite
00023  * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
00024  *
00025  * The interactive user interfaces in modified source and object code versions
00026  * of this program must display Appropriate Legal Notices, as required under
00027  * Section 5 of the GNU Affero General Public License version 3.
00028  *
00029  * In accordance with Section 7(b) of the GNU Affero General Public License
00030  * version 3, these Appropriate Legal Notices must retain the display of the
00031  * "Powered by Funambol" logo. If the display of the logo is not reasonably
00032  * feasible for technical reasons, the Appropriate Legal Notices must display
00033  * the words "Powered by Funambol".
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 
00058 class CSymbianTransportAgent : public CBase, 
00059                                public MHTTPTransactionCallback,
00060                                public MHTTPDataSupplier,
00061                                public TransportAgent
00062 {
00063     public:
00069         static CSymbianTransportAgent* NewL(URL& aUrl,Proxy& aProxy,
00070                              unsigned int aResponseTimeout = DEFAULT_MAX_TIMEOUT,
00071                              unsigned int aMaxMsgSize = DEFAULT_MAX_MSG_SIZE);
00072 
00078         static CSymbianTransportAgent* NewLC(URL& aUrl,Proxy& aProxy,
00079                            unsigned int aResponseTimeout = DEFAULT_MAX_TIMEOUT,
00080                            unsigned int aMaxMsgSize = DEFAULT_MAX_MSG_SIZE);
00081 
00086         ~CSymbianTransportAgent();
00087         
00092         void ConnectL();
00093 
00098         void SetIap(const TUint32& aIap);
00099 
00100     private:
00105         void ConstructL(URL& aUrl);
00106 
00111         CSymbianTransportAgent(URL& aUrl, Proxy& aProxy,
00112                                unsigned int aResponseTimeout);
00113         
00121          void SetHeaderL(RHTTPHeaders aHeaders, 
00122                           TInt aHdrField, 
00123                           const TDesC8& aHdrValue);
00124          
00125 
00126         
00130     private:
00137         void MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent& aEvent );
00138 
00149         TInt MHFRunError( TInt aError, 
00150                           RHTTPTransaction aTransaction, 
00151                           const THTTPEvent& aEvent );
00152 
00153 
00159         void SetHttpClientError(TInt aStatus);
00160         
00166         void SetHttpServerError(TInt aStatus);
00167 
00168     /*
00169      * From TransportAgent
00170      */
00171     public:
00175         char* sendMessage(const char* msg);
00176 
00177     /*
00178      * From MHttpDataSupplier
00179      */
00180     public:
00181         TBool GetNextDataPart(TPtrC8& aDataChunk);
00182         void ReleaseData();
00183         TInt OverallDataSize();
00184         TInt Reset();
00185 
00186         
00187     private: // Data
00188     
00189         TUint32                    iIap;
00190 
00191         RHTTPSession               iHttpSession;
00192         RHTTPTransaction           iHttpTransaction;
00193         MHTTPDataSupplier*         iDataSupplier;
00194         HBufC8*                    iPostBody;
00195         HBufC8*                    iResponseBody;
00196         TBool                      iTransFailed;
00197         CActiveSchedulerWait*      iASWait;
00198 };
00199 
00200 END_NAMESPACE
00201 
00202 #endif //SYMBIANTRANSPORTAGENT_H_

Generated on Fri Jul 25 15:04:15 2008 for Funambol C++ Client Library by  doxygen 1.5.1