hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CLocalTCPConnection.h
branchRCL_3
changeset 59 8ad140f3dd41
parent 0 a03f92240627
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:  Local TCP connection for emulator testing
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CLOCALTCPCONNECTION_H
       
    21 #define CLOCALTCPCONNECTION_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <es_sock.h>
       
    26 #include <in_sock.h>
       
    27 
       
    28 
       
    29 // DATA TYPES
       
    30 enum TLocalTCPConnState
       
    31     {
       
    32     ELTCStateDisconnected = 0,
       
    33     ELTCStateConnecting,
       
    34     ELTCStateConnected,
       
    35     ELTCStateDisconnecting
       
    36     };
       
    37 
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 class MLocalTCPConnectionObserver;
       
    41 
       
    42 // CLASS DECLARATION
       
    43 
       
    44 /**
       
    45 *  Local TCP connection, which connects to local TCP port.
       
    46 *
       
    47 */
       
    48 NONSHARABLE_CLASS( CLocalTCPConnection ) : public CActive
       
    49     {
       
    50     public:  // Constructors and destructor
       
    51 
       
    52         /**
       
    53         * Factory function.
       
    54         * @param aObserver TCP connection observer.
       
    55         * @param aPort Port to connect to.
       
    56         * @return New CLocalTCPConnection instance.
       
    57         */
       
    58         static CLocalTCPConnection* NewL(
       
    59             MLocalTCPConnectionObserver* aObserver, TInt aPort );
       
    60 
       
    61         /**
       
    62         * Factory function.
       
    63         * @param aObserver TCP connection observer.
       
    64         * @param aPort Port to connect to.
       
    65         * @return New CLocalTCPConnection instance.
       
    66         */
       
    67         static CLocalTCPConnection* NewLC(
       
    68             MLocalTCPConnectionObserver* aObserver, TInt aPort );
       
    69 
       
    70         /**
       
    71         * Destructor.
       
    72         */
       
    73         ~CLocalTCPConnection();
       
    74 
       
    75     public: // New functions
       
    76 
       
    77         void IssueConnectL();
       
    78         void IssueDisconnect();
       
    79         void SetObserver( MLocalTCPConnectionObserver* aObserver );
       
    80         TBool IsConnected();
       
    81         RSocket* Socket();
       
    82         void SetSocketOwnership( TBool aOwns );
       
    83 
       
    84     public: // Functions from base classes
       
    85 
       
    86         /**
       
    87         * From CActive. Pending request has been completed.
       
    88         */
       
    89         void RunL();
       
    90 
       
    91         /**
       
    92         * From CActive. Pending request has been cancelled.
       
    93         */
       
    94         void DoCancel();
       
    95 
       
    96         /**
       
    97         * From CActive. RunL has leaved.
       
    98         */
       
    99         TInt RunError( TInt aError );
       
   100 
       
   101     public: // New methods
       
   102 
       
   103         /**
       
   104         * Returns the port number of this connection
       
   105         * @return Port number
       
   106         */
       
   107         TInt Port();
       
   108 
       
   109     private:
       
   110 
       
   111         /**
       
   112         * Default constructor.
       
   113         */
       
   114         CLocalTCPConnection( MLocalTCPConnectionObserver* aObserver,
       
   115                              TInt aPort );
       
   116 
       
   117         /**
       
   118         * 2nd phase constructor.
       
   119         */
       
   120         void ConstructL();
       
   121 
       
   122     private:    // Data
       
   123         MLocalTCPConnectionObserver* iObserver;
       
   124         RSocketServ iSocketServer;
       
   125         RSocket* iSocket;
       
   126         TInetAddr iAddr;
       
   127         TLocalTCPConnState iState;
       
   128         TBool iOwnsSocket;
       
   129     };
       
   130 
       
   131 #endif      // CLOCALTCPCONNECTION_H
       
   132 
       
   133 // End of File