hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CProtocolTCP.h
branchRCL_3
changeset 59 8ad140f3dd41
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     1 /*
       
     2 * Copyright (c) 2009 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:  TCP protocol implementation for IP proxy
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CPROTOCOLTCP_H
       
    21 #define CPROTOCOLTCP_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "MBPProtocol.h"
       
    25 #include "MBPExpression.h"
       
    26 #include "MExpressionObserverTCP.h"
       
    27 
       
    28 #include <e32base.h>
       
    29 
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class MProtocolObserverTCP;
       
    33 class MSocketWriter;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38 * HTTPProxy protocol implementation. Writes and interpretes data in
       
    39 * protocol frame.
       
    40 */
       
    41 NONSHARABLE_CLASS( CProtocolTCP ) : public CBase, public MBPProtocol,
       
    42                                     public MExpressionObserverTCP
       
    43     {
       
    44 
       
    45     public:  // Constructors and destructor
       
    46 
       
    47         /**
       
    48         * Factory function.
       
    49         * @param aObserver Pointer to observer.
       
    50         * @return New CProtocol instance.
       
    51         */
       
    52         static CProtocolTCP* NewL( MProtocolObserverTCP* aObserver );
       
    53 
       
    54         /**
       
    55         * Factory function.
       
    56         * @param aObserver Pointer to observer.
       
    57         * @return New CProtocol instance.
       
    58         */
       
    59         static CProtocolTCP* NewLC( MProtocolObserverTCP* aObserver );
       
    60 
       
    61         /**
       
    62         * Destructor.
       
    63         */
       
    64         ~CProtocolTCP();
       
    65 
       
    66     public: // From MExpressionObserverTCP
       
    67 
       
    68         void FrameStarted();
       
    69         void FrameParsedL( TUint aPort, const TDesC8& aData );
       
    70         void ProtocolErrorL( TInt aErrorCode, const TDesC8& aReceivedData );
       
    71         void OpenLocalTCPConnectionL( TUint aPort );
       
    72         void OpenListeningTCPConnectionL( TUint aPort );
       
    73         void CloseTCPConnectionL( TUint aPort );
       
    74         void CloseAllTCPConnections();
       
    75 
       
    76     public: // From MBPProtocol
       
    77 
       
    78         void WriteFrameL( MSocketWriter& aSocketWriter,
       
    79             TUint aPeerPort, TUint aOriginalPort, const TDesC8& aData ) const;
       
    80 
       
    81         TBool HandleReceivedDataL( TDes8& aData, TInt& aStartPos, TInt& aLength );
       
    82 
       
    83     public: // New functions
       
    84 
       
    85         /**
       
    86         * Sends command via HTI to close the TCP connection
       
    87         * @param aPort Remote port to close
       
    88         */
       
    89         void SendCloseTCPConnection( MSocketWriter& aSocketWriter,
       
    90                                           TUint aPort );
       
    91 
       
    92     protected:
       
    93 
       
    94         /**
       
    95         * Default constructor.
       
    96         * @param aObserver Pointer to observer.
       
    97         */
       
    98         CProtocolTCP( MProtocolObserverTCP* aObserver );
       
    99 
       
   100         /**
       
   101         * 2nd phase constructor.
       
   102         */
       
   103         void ConstructL();
       
   104 
       
   105 
       
   106     private:    // Owned data
       
   107 
       
   108         CArrayPtr<MBPExpression>* iExpressionArray;
       
   109 
       
   110     private:    // Not owned data
       
   111         MProtocolObserverTCP* iObserver;
       
   112 
       
   113     };
       
   114 
       
   115 #endif      // CPROTOCOLTCP_H
       
   116 
       
   117 // End of File