hotspotfw/internetconnectivitytestservice/inc/ictshttphandler.h
changeset 0 56b72877c1cb
child 18 aaabc7526ded
equal deleted inserted replaced
-1:000000000000 0:56b72877c1cb
       
     1 /*
       
     2 * Copyright (c) 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:   Contains implementation for HTTP::HEAD test
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef ICTSHTTPHANDLER_H
       
    21 #define ICTSHTTPHANDLER_H
       
    22 
       
    23 #include <ecom/ecom.h>
       
    24 #include <es_enum.h>
       
    25 #include <http.h>
       
    26 
       
    27 #include "ictscommon.h"
       
    28 
       
    29 class CIctsEngine;
       
    30 
       
    31 /**
       
    32  *  Handles HTTP related things.
       
    33  *
       
    34  *  Sends HTTP::HEAD and interact with HTTP FW. Returns results to 
       
    35  *  caller.
       
    36  *
       
    37  *  @lib ictsclientinterface.lib
       
    38  */
       
    39 class CIctsHttpHandler : public CTimer, public MHTTPTransactionCallback 
       
    40     {
       
    41     
       
    42     public:
       
    43 
       
    44         /**
       
    45         * Static constructor.
       
    46         */    
       
    47         static CIctsHttpHandler* NewL( CIctsEngine& aOwner,
       
    48                                         TInt aHttpResponseTime );
       
    49     
       
    50         /**
       
    51         * Destructor.
       
    52         */
       
    53         virtual ~CIctsHttpHandler();
       
    54     
       
    55         /**
       
    56         * Send HTTP::HEAD request 
       
    57         *
       
    58         * @param aIPAddress IP address
       
    59         * @param aIapID IAP id
       
    60         * @param aNetworkId Network id
       
    61         * @return KErrNone if successful
       
    62         */
       
    63         TInt SendHttpRequestL( TDesC8& aIPAddress, 
       
    64                             TUint32 aIapID, 
       
    65                              TUint32 aNetworkId );
       
    66         
       
    67         /**
       
    68         * Cancels HTTP::HEAD request 
       
    69         *
       
    70         * @return None
       
    71         */
       
    72         void CancelHttpRequestL();
       
    73     
       
    74     public: // from MHTTPTransactionCallback
       
    75 
       
    76         /**
       
    77         * Callback for HTTP FW to call when HTTP events occur
       
    78         *
       
    79         * @param aTransaction HTTP transaction
       
    80         * @param aEvent HTTP event
       
    81         * @return None
       
    82         */
       
    83         virtual void MHFRunL( RHTTPTransaction aTransaction, 
       
    84                                 const THTTPEvent& aEvent);
       
    85     
       
    86         /**
       
    87         * Callback for HTTP FW to call when HTTP errors occur
       
    88         *
       
    89         * @param aError error code
       
    90         * @param aTransaction HTTP transaction
       
    91         * @param aEvent HTTP event
       
    92         * @return None
       
    93         */                        
       
    94         virtual TInt MHFRunError( TInt aError, 
       
    95                                     RHTTPTransaction aTransaction, 
       
    96                                       const THTTPEvent& aEvent);
       
    97     
       
    98 
       
    99     protected:  // Functions from base classes
       
   100         
       
   101         /**
       
   102         * From CActive Handles an active object's request completion event.
       
   103         */
       
   104         void RunL();
       
   105     
       
   106     private:
       
   107     
       
   108         /**
       
   109         * C++ default constructor.
       
   110         *
       
   111         * @param aOwner Owner of this instance
       
   112         * @param aHttpResponseTime Max time for response
       
   113         */
       
   114         CIctsHttpHandler( CIctsEngine& aOwner, TInt aHttpResponseTime );
       
   115 
       
   116         /**
       
   117         * By default Symbian 2nd phase constructor is private.
       
   118         */
       
   119         void ConstructL();
       
   120     
       
   121         /**
       
   122         * Set HTTP connection info 
       
   123         *
       
   124         * @param aConnection Network connection
       
   125         * @param aSocketServ Socket server
       
   126         * @return None
       
   127         */
       
   128         void SetHttpConnectionInfoL( RConnection& aConnection, 
       
   129                                      RSocketServ& aSocketServ );
       
   130         /**
       
   131         * Send HTTP request 
       
   132         *
       
   133         * @param aIp IP address
       
   134         * @return None
       
   135         */
       
   136         void SendHttpGetL( TDesC8& aIp ); 
       
   137 
       
   138         /**
       
   139         * Check http prefix in URL/IP address
       
   140         *
       
   141         * @param aIPAddress URL
       
   142         * @return ETrue if found, else EFalse
       
   143         */ 
       
   144         TBool CheckHttp( TDesC8& aIPAddress );
       
   145     
       
   146     private: // data
       
   147 
       
   148         /**
       
   149         * Handle to HTTP session
       
   150         * Own.  
       
   151         */
       
   152         RHTTPSession iHttpSession;
       
   153     
       
   154         /**
       
   155         * Handle to HTTP transaction
       
   156         * Own.  
       
   157         */
       
   158         RHTTPTransaction iHttpTransaction;
       
   159 
       
   160         /**
       
   161         * Handle to socket server
       
   162         * Own.  
       
   163         */
       
   164         RSocketServ iSocketServ;
       
   165     
       
   166         /**
       
   167         * Handle to connection
       
   168         * Own.  
       
   169         */
       
   170         RConnection iConnection;
       
   171     
       
   172         /**
       
   173         * String from HTTP FW
       
   174         */
       
   175         TBuf< KHttpResponseLength > iString;
       
   176     
       
   177     
       
   178         /**
       
   179         * Reference of owner class
       
   180         * Not Own.  
       
   181         */
       
   182         CIctsEngine& iOwner;
       
   183     
       
   184         /**
       
   185         * Waiting time of HTTP response 
       
   186         */
       
   187         TInt iHttpResponseTime;
       
   188         
       
   189         /**
       
   190         * Is attached to connection
       
   191         */
       
   192         TBool iAttachDone;
       
   193     };
       
   194 
       
   195 #endif // ICTSHTTPHANDLER_H