natfw/tsrc/natfwtestconsoles/natfwtestconsole/inc/testclient.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2007 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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef TESTCLIENT_H
       
    22 #define TESTCLIENT_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <es_sock.h>
       
    26 #include <in_sock.h>
       
    27 
       
    28 #include "timeouttimer.h"
       
    29 
       
    30 class MTestClientNotifier;
       
    31 
       
    32 
       
    33 /**
       
    34  *  ?one_line_short_description
       
    35  *
       
    36  *  ?more_complete_description
       
    37  *
       
    38  *  @lib ?library
       
    39  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    40  */
       
    41 class MTestClientNotifier
       
    42     {   
       
    43         
       
    44 public:
       
    45     
       
    46     enum TClientNotify
       
    47         {
       
    48         EOpened = 1,
       
    49         EConnected,
       
    50         ETimerOccured
       
    51         };
       
    52         
       
    53     virtual void Notify( TClientNotify aNotify, TInt aError ) = 0;
       
    54 
       
    55     };
       
    56     
       
    57     
       
    58 /**
       
    59  *  ?one_line_short_description
       
    60  *
       
    61  *  ?more_complete_description
       
    62  *
       
    63  *  @lib ?library
       
    64  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    65  */    
       
    66 class CTestClient : public CActive, public MTimeoutNotifier
       
    67     {
       
    68 public:
       
    69     static CTestClient* NewL( MTestClientNotifier* aNotifier );
       
    70     
       
    71     static CTestClient* NewLC( MTestClientNotifier* aNotifier );
       
    72     
       
    73     void OpenL( TUint aIapId );
       
    74     
       
    75     void ConnectL( TInetAddr& aAddr, TUint aTimeoutTime = 0 );
       
    76     
       
    77     void ResolveLocalAddrL( TInetAddr& aAddr, TUint32 aIap );
       
    78     
       
    79     void CheckAndSetAddr(   TInetAddr& aTarget,
       
    80                             TInetAddr& aCandidate,
       
    81                             TUint32 aCandidateIap,
       
    82                             TUint32 aSpecifiedIap ) const;
       
    83                             
       
    84     void SetAddr(   TInetAddr& aTarget,
       
    85                     const TInetAddr& aSource ) const;
       
    86                     
       
    87     virtual ~CTestClient();
       
    88     
       
    89 protected: // from CActive
       
    90     void RunL();
       
    91     void DoCancel();
       
    92 
       
    93 protected: // from MTimeoutNotifier
       
    94     void TimerExpired();
       
    95         
       
    96 private:
       
    97     CTestClient( MTestClientNotifier* aNotifier );
       
    98     void ConstructL();
       
    99     
       
   100 private: // members
       
   101 
       
   102     enum TTestClientState
       
   103         {
       
   104         EOpen = 1,
       
   105         EReady,
       
   106         EConnecting,
       
   107         EConnected
       
   108         };
       
   109         
       
   110     MTestClientNotifier* iNotifier;
       
   111     TTestClientState iState;
       
   112     TUint iPort;
       
   113     RSocket iSocket;
       
   114     RSocketServ iServer;
       
   115     RConnection iConnection;
       
   116     TInetAddr iLocalAddr;
       
   117     CTimeOutTimer* iTimer;
       
   118     };
       
   119 
       
   120 #endif // TESTCLIENT_H