codhandler/codeng/inc/HttpWapSession.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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: 
       
    15 *      Declaration of class CHttpWapSession.
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef HTTP_WAP_SESSION_H
       
    22 #define HTTP_WAP_SESSION_H
       
    23 
       
    24 // INCLUDES
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <http/mhttpsessioneventcallback.h>
       
    28 #include "HttpSessionBase.h"
       
    29 
       
    30 // CLASS DECLARATION
       
    31 
       
    32 /**
       
    33 * WAP Session.
       
    34 */
       
    35 NONSHARABLE_CLASS( CHttpWapSession )
       
    36 : public CHttpSessionBase,
       
    37   public MHTTPSessionEventCallback
       
    38 
       
    39     {
       
    40     public:     // Constructors and destructor.
       
    41 
       
    42         /**
       
    43         * Two phased constructor. Leaves on failure.
       
    44         * @param aGateway WAP gateway.
       
    45         * @return The created session.
       
    46         */      
       
    47         static CHttpWapSession* NewL( const TDesC8& aGateway );
       
    48         
       
    49         /**
       
    50         * Destructor.
       
    51         */
       
    52         virtual ~CHttpWapSession();
       
    53 
       
    54     public:     // from CHttpSessionBase
       
    55 
       
    56         /**
       
    57         * Connect session.
       
    58         * @param aStatus Completes when done.
       
    59         */
       
    60         virtual void ConnectL( TRequestStatus* aStatus );
       
    61 
       
    62         /**
       
    63         * Disconnect session. Safe to call if not connected. Use this to
       
    64         * cancel an outstanding ConnectL.
       
    65         */
       
    66         virtual void Disconnect();
       
    67 
       
    68     protected:    // Constructors and destructor.
       
    69 
       
    70         /**
       
    71         * Constructor.
       
    72         */
       
    73         CHttpWapSession();
       
    74 
       
    75         /**
       
    76         * Second phase constructor. Leaves on failure.
       
    77         * @param aGateway WAP gateway.
       
    78         */      
       
    79         void ConstructL( const TDesC8& aGateway );
       
    80         
       
    81 
       
    82         /**
       
    83         * Handle session event.
       
    84         * @param aEvent The event that has occurred.
       
    85         */
       
    86         void MHFSessionRunL( const THTTPSessionEvent& aEvent );
       
    87 
       
    88         /**
       
    89         * Handle errors occured in MHFSessionRunL().
       
    90         * @param aError The leave code that MHFSessionRunL left with.
       
    91         * @param aEvent The Event that was being processed.
       
    92         * @return KErrNone.
       
    93         */
       
    94         TInt MHFSessionRunError
       
    95             ( TInt aError, const THTTPSessionEvent& aEvent );
       
    96 
       
    97     private:    // new methods
       
    98 
       
    99         /**
       
   100         * Clean up and notify parent.
       
   101         * @param aResult Result of the operation.
       
   102         */
       
   103         void Done( TInt aResult );
       
   104 
       
   105         /**
       
   106         * Get a shared string from the session stringpool.
       
   107         * @param aId Id of string.
       
   108         * @return Shared string from HTTP string table. No need to close.
       
   109         */
       
   110         inline RStringF StringF( HTTP::TStrings aId );
       
   111 
       
   112     private:    // types
       
   113 
       
   114         enum TState         ///< State.
       
   115             {
       
   116             EInit,          ///< Initial state (session is not open).
       
   117             EConnecting,    ///< Connecting.
       
   118             EConnected,     ///< Session is open and connected.
       
   119             EDisconnecting  ///< Disconnecting.
       
   120             };
       
   121 
       
   122     private:    // data
       
   123 
       
   124         TState iState;                  ///< State.
       
   125         TRequestStatus* iParentStatus;  ///< Parent status.
       
   126         RStringF iGateway;              ///< Gateway. Owned.
       
   127         TBool iGatewayOpen;             ///< ETrue if gateway string is open.
       
   128         CActiveSchedulerWait* iWait;    ///< Wait object (for disconnect).
       
   129 
       
   130     };
       
   131 
       
   132 #include "HttpWapSession.inl"
       
   133 
       
   134 #endif /* def HTTP_WAP_SESSION_H */