vpnengine/ikesocket/src/connobserver.cpp
changeset 0 33413c0669b9
child 12 a15e6baef510
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 
       
    19 // INCLUDE FILES
       
    20 #include "connobserver.h"
       
    21 #include "ikedebug.h"
       
    22 #include "ikesocketassert.h"
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // Two-phased constructor.
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CConnObserver* CConnObserver::NewL( RConnection& aConnection,
       
    31                                     MConnObserverCallback& aCallback,
       
    32                                     MIkeDebug& aDebug )
       
    33     {
       
    34     CConnObserver* self = new (ELeave) CConnObserver( aConnection,
       
    35                                                       aCallback,
       
    36                                                       aDebug );
       
    37     
       
    38     CleanupStack::PushL(self);
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop(self);
       
    41     
       
    42     return self;
       
    43     }
       
    44     
       
    45 // ---------------------------------------------------------------------------
       
    46 // Destructor.
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CConnObserver::~CConnObserver()
       
    50     {
       
    51     DEBUG_LOG( _L("CConnObserver::~CConnObserver") );    
       
    52     Cancel();
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // Requests notification about link disconnection.
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 void CConnObserver::NotifyDisconnect()
       
    60     {
       
    61     IKESOCKET_ASSERT( !IsActive() );
       
    62 
       
    63     iConnection.ProgressNotification( iProgressBuf,
       
    64                                       iStatus,
       
    65                                       KLinkLayerClosed );
       
    66     DEBUG_LOG( _L("RConnection::ProgressNotification() started") );    
       
    67     SetActive();
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // Cancels link disconnection notification request.
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 void CConnObserver::CancelNotify()
       
    75     {
       
    76     Cancel();    
       
    77     }
       
    78     
       
    79 // ---------------------------------------------------------------------------
       
    80 // Constructor.
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 CConnObserver::CConnObserver( RConnection& aConnection,
       
    84                               MConnObserverCallback& aCallback,
       
    85                               MIkeDebug& aDebug ) 
       
    86  :CActive(EPriorityStandard),
       
    87  iConnection( aConnection ),
       
    88  iCallback( aCallback ),
       
    89  iDebug( aDebug )
       
    90     {
       
    91     CActiveScheduler::Add(this);    //Added to the Active Scheduler
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // Second phase construction.
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CConnObserver::ConstructL()
       
    99     {
       
   100     DEBUG_LOG( _L("CConnObserver::ConstructL") );
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // From class CActive
       
   105 // Handles completion of progress notification.
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CConnObserver::RunL()
       
   109     {
       
   110     DEBUG_LOG1( _L("CConnObserver::RunL(), iStatus=%d"), iStatus.Int() );    
       
   111     iCallback.LinkDisconnected( iStatus.Int() );
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // From class CActive
       
   116 // Cancels progress notification.
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 void CConnObserver::DoCancel()
       
   120     {
       
   121     iConnection.CancelProgressNotification();
       
   122     DEBUG_LOG( _L("RConnection::CancelProgressNotification() called") );    
       
   123     }
       
   124