vpnengine/ikesocket/inc/connobserver.h
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Link connection status observer
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_CONNOBSERVER_H
       
    19 #define C_CONNOBSERVER_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <in_sock.h>
       
    23 
       
    24 // FORWARD DECLARATIONS
       
    25 
       
    26 class MIkeDebug;
       
    27 class RConnection;
       
    28 
       
    29 /**
       
    30  *  Link disconnection callback interface.
       
    31  *
       
    32  *  Callback interface for notifying about link disconnection.
       
    33  *
       
    34  *  @lib ikesocket.lib
       
    35  */
       
    36 NONSHARABLE_CLASS( MConnObserverCallback )
       
    37     {
       
    38 public:    
       
    39     /**
       
    40      * Notifies about link disconnection.
       
    41      * 
       
    42      * @param aStatus Link disconnection status
       
    43      */
       
    44     virtual void LinkDisconnected( const TInt aStatus ) = 0;    
       
    45     };
       
    46 
       
    47 /**
       
    48  *  Link connection status observer.
       
    49  *
       
    50  *  This class provides functionality for observing when link connection has
       
    51  *  been disconnected.
       
    52  *
       
    53  *  @lib ikesocket.lib
       
    54  */
       
    55 NONSHARABLE_CLASS( CConnObserver ) : private CActive
       
    56     {
       
    57 public:
       
    58     /**
       
    59      * Two-phased constructor.
       
    60      * 
       
    61      * @param aConnection Connection which is used for observing
       
    62      * @param aCallback Callback interface
       
    63      * @param aDebug Debug trace interface
       
    64      */
       
    65     static CConnObserver* NewL( RConnection& aConnection,
       
    66                                 MConnObserverCallback& aCallback,
       
    67                                 MIkeDebug& aDebug );        
       
    68 
       
    69     /**
       
    70      * Destructor.
       
    71      */
       
    72     ~CConnObserver();
       
    73 
       
    74     /**
       
    75      * Requests notification about link disconnection. Link disconnection will
       
    76      * be notified via MConnObserverCallback callback interface, when link has
       
    77      * been disconnected.
       
    78      */
       
    79     void NotifyDisconnect();
       
    80     
       
    81     /**
       
    82      * Cancels link disconnection notification request.
       
    83      */
       
    84     void CancelNotify();                    
       
    85 
       
    86 private:
       
    87     
       
    88 // from base class CActive
       
    89     
       
    90     /**
       
    91      * From CActive.
       
    92      * Handles an active object's request completion event about link
       
    93      * disconnection progress notification. Notifies client about link
       
    94      * disconnection via callback interface. Does not leave. 
       
    95      */
       
    96     void RunL();
       
    97     
       
    98     /**
       
    99      * From CActive.
       
   100      * Implements cancellation of a link disconnection progress notification.
       
   101      */
       
   102     void DoCancel();
       
   103 
       
   104 private:        
       
   105     CConnObserver( RConnection& aConnection,
       
   106                    MConnObserverCallback& aCallback,
       
   107                    MIkeDebug& aDebug );
       
   108     
       
   109     void ConstructL();
       
   110     
       
   111 private: // data
       
   112     /**
       
   113      * Connection used for observing link disconnection.
       
   114      * Not own.
       
   115      */
       
   116     RConnection&               iConnection;
       
   117         
       
   118     /**
       
   119      * Buffer for Network Interface Progress.
       
   120      * Own.
       
   121      */
       
   122     TNifProgressBuf            iProgressBuf;
       
   123 
       
   124     /**
       
   125      * Callback interface for notifying link disconnection.
       
   126      * Not own.
       
   127      */
       
   128     MConnObserverCallback&     iCallback;
       
   129     
       
   130     /**
       
   131      * Debug trace interface.
       
   132      * Not own.
       
   133      */
       
   134     MIkeDebug&                 iDebug;
       
   135     };
       
   136 
       
   137 
       
   138 #endif // C_CONNOBSERVER_H