pnpmobileservices/pnpms/OnlineSupport/inc/CCMSocketsEngine.h
changeset 0 3ce708148e4d
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Socket engine class used for the DNS query
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CCMSOCKETSENGINE_H
       
    21 #define CCMSOCKETSENGINE_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <es_sock.h>
       
    26 #include <http/mhttptransactioncallback.h>
       
    27 #include <http/rhttpsession.h>
       
    28 #include <http/rhttptransaction.h>
       
    29 
       
    30 // CONSTANTS
       
    31 const TInt KMaximumLengthOfAddress = 100;
       
    32 
       
    33 // MACROS
       
    34 // None
       
    35 
       
    36 // DATA TYPES
       
    37 // None
       
    38 
       
    39 // FUNCTION PROTOTYPES
       
    40 // None
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 // None
       
    44 
       
    45 // CLASS DECLARATION
       
    46 class MCMSocketsEngineNotifier;
       
    47 
       
    48 /**
       
    49 *  Sockets engine class 
       
    50 *  Used to test the DNS connection 
       
    51 *
       
    52 *  @lib Confmanager.app
       
    53 *  @since 2.0
       
    54 */
       
    55 class CCMSocketsEngine :
       
    56     public CActive,
       
    57     public MHTTPTransactionCallback
       
    58     {
       
    59     public:  // Constructors and destructor
       
    60         
       
    61         enum TEngineStatus 
       
    62             {
       
    63             EStatusUnknown,
       
    64             EStatusConnecting,
       
    65             EStatusResolving,
       
    66             EStatusMakingHttpHeadRequest,
       
    67             EStatusReady
       
    68             };
       
    69         /**
       
    70         * Two-phased constructor.
       
    71         */
       
    72         static CCMSocketsEngine* NewL( MCMSocketsEngineNotifier& aNotifier);
       
    73         
       
    74         /**
       
    75         * Destructor.
       
    76         */
       
    77         ~CCMSocketsEngine();
       
    78 
       
    79     public: // New functions
       
    80 
       
    81         /**
       
    82         * Starts the DNS query
       
    83         * @since 2.0
       
    84         * @param aAp the access point id to use for the connection
       
    85         * @param aAddress address 
       
    86         */
       
    87         void ConnectL( TUint32 aAp, const TDesC& aAddress );
       
    88 
       
    89         /**
       
    90         * Starts the DNS query
       
    91         * @since 2.0
       
    92         * @param aAp the access point id to use for the connection
       
    93         * @param aAddress address 
       
    94         */
       
    95         void ConnectL( const TDesC& aAddress );
       
    96         
       
    97         /**
       
    98         * Ends the DNS query
       
    99         * @since 2.0
       
   100         */
       
   101         void Disconnect( );
       
   102 
       
   103         /**
       
   104         * Sets the value for the iLeaveOpen
       
   105         * @since 2.0
       
   106         */
       
   107         void SetOpen( TBool aOpen );
       
   108 
       
   109         const TDesC& ProxyIp(){ return *iProxyIp; };
       
   110         const TInt ProxyPort(){ return iProxyPort; };
       
   111         const TUint32 IapId(){ return iIapId; };
       
   112         const TBool ProxyDefined(){ return iProxyIp->Length() > 0; };
       
   113 
       
   114         /*!
       
   115         @return iSocketServ
       
   116         */
       
   117         RSocketServ& SocketServ(){ return iSocketServ; };
       
   118 
       
   119         /*!
       
   120         @return iConnection
       
   121         */
       
   122         RConnection& Connection(){ return iConnection; };
       
   123         
       
   124 	/*!
       
   125         @return IAPID
       
   126         */
       
   127 
       
   128         TUint32 ReturnIAPID();
       
   129 
       
   130     public: // from MHTTPTransactionCallback
       
   131 
       
   132         /*!
       
   133         Called when the filter's registration conditions are satisfied
       
   134         for events that    occur on a transaction.    Note that this function
       
   135         is not allowed to leave if called with certain events
       
   136         */
       
   137         void MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent &aEvent );
       
   138         /*!
       
   139         Called when RunL leaves from a transaction event. This works
       
   140         in the same way as CActve::RunError; return KErrNone if you
       
   141         have handled the error. If you don't completely handle the
       
   142         error, a panic will occur.
       
   143         */
       
   144         TInt MHFRunError( TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent );
       
   145 
       
   146     protected:  // New functions
       
   147         
       
   148         
       
   149 
       
   150     protected:  // Functions from base classes
       
   151         
       
   152        
       
   153 
       
   154     private: // Functions from base classes
       
   155         
       
   156         /**
       
   157         * From CActive Handles an active object’s request completion event.
       
   158         * @since 2.0
       
   159         * @return void
       
   160         */
       
   161         void RunL();
       
   162 
       
   163         /**
       
   164         * From CActive  Cancels any outstanding request
       
   165         * @return void
       
   166         */
       
   167         void DoCancel();
       
   168 
       
   169         /**
       
   170         * From CActive  Cancels any outstanding request
       
   171         * @return TInt should be always KErrNone
       
   172         */
       
   173         TInt RunError(TInt aError);    
       
   174 
       
   175     private:
       
   176 
       
   177         /**
       
   178         * C++ default constructor.
       
   179         */
       
   180         CCMSocketsEngine( MCMSocketsEngineNotifier& aNotifier);
       
   181 
       
   182         /**
       
   183         * By default Symbian 2nd phase constructor is private.
       
   184         */
       
   185         void ConstructL();
       
   186 
       
   187         void MakeHttpHeadRequestL( const TDesC& aProxyAddress, const TUint aProxyPort );
       
   188         TBool CheckForProxyL( const TUint32 aIapId );
       
   189     public:     // Data
       
   190         
       
   191     protected:  // Data
       
   192         
       
   193 
       
   194     private:    // Data
       
   195         /*! Interface to UI class */
       
   196         MCMSocketsEngineNotifier& iSocketsEngineNotifier; 
       
   197         // Socket server
       
   198         RSocketServ iSocketServ;
       
   199         //  host name resolution (DNS)
       
   200         RHostResolver iResolver;
       
   201         /*! Connection */
       
   202         RConnection iConnection;
       
   203         /*! Connection open flag */
       
   204         TBool iConnectionOpen;
       
   205         // Name entry for the resolver
       
   206         TNameEntry iNameEntry;
       
   207         // if This is true then the iResolver exsists
       
   208         TBool iResolverExsists;
       
   209         // Status of the engine
       
   210         TEngineStatus iEngineStatus;
       
   211         // address to be resolved
       
   212         TBuf <KMaximumLengthOfAddress> iWapPage;
       
   213         // If this is true then the connection will be left open after the engine is deleted
       
   214         TBool iLeaveOpen;
       
   215         // if this is true then the connection exsists
       
   216         TBool iConnectionExsists;     
       
   217         /*! Proxy IP, empty descriptor for none */
       
   218         HBufC* iProxyIp;
       
   219         /*! Proxy port, 0 for none */
       
   220         TInt iProxyPort;
       
   221         /*! Tells if there is a proxy defined for the current AP */
       
   222         TBool iProxyDefined;
       
   223 
       
   224         /*! Http session */
       
   225         RHTTPSession iSession;
       
   226         /*! Http session open flag */
       
   227         TBool iHttpSessionOpen;
       
   228         /*! String pool for http session */
       
   229         RStringPool iSessionStringPool;
       
   230         /*! Http transaction*/
       
   231         RHTTPTransaction iTransaction;
       
   232         /*! Http transaction open flag */
       
   233         TBool iTransactionOpen;
       
   234 
       
   235         /** Id for the current AccessPoint this id refers to the WAP_IAP table.*/
       
   236         TUint32 iIapId;
       
   237 
       
   238     public:     // Friend classes
       
   239             
       
   240     protected:  // Friend classes
       
   241         
       
   242     private:    // Friend classes
       
   243         
       
   244 
       
   245     };
       
   246 
       
   247 #endif      // CCMSocketsEngine_H   
       
   248             
       
   249 // End of File