alwayson_net_plugin/pdpcontextmanager2/src/caoconnectionimpl.cpp
changeset 0 5a93021fdf25
child 3 f7816ffc66ed
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2004,2006 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:  Implements the CAOConnectionImpl class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    21 #include <es_enum_partner.h>
       
    22 #endif
       
    23 #include <es_enum.h>
       
    24 #include <etelpckt.h>
       
    25 #include <in_sock.h>
       
    26 
       
    27 #include "caoconnectionimpl.h"
       
    28 #include "maosettings.h"
       
    29 #include "logger.h"
       
    30 #include "maoconnectionobserver.h"
       
    31 
       
    32 // UNNAMED NAMESPACE FOR LOCAL DEFINITIONS
       
    33 namespace
       
    34     {
       
    35     // CONSTANTS
       
    36     _LIT( KPanicCat, "ConnectionImpl" );
       
    37     
       
    38     // Default value that indicates that we do not want to prompt user for IAP
       
    39     const TCommDbDialogPref KDlgPreference = ECommDbDialogPrefDoNotPrompt;
       
    40     
       
    41     // DATA TYPES
       
    42     enum TPanicCode
       
    43         {
       
    44         ENone,
       
    45         EConnectionAlreadyActive,
       
    46         ENotActive,
       
    47         EInvalidState,
       
    48         EAlreadyActive,
       
    49         EReuqestNotPending
       
    50         };
       
    51     
       
    52     // LOCAL FUNCTIONS
       
    53     LOCAL_C void Panic( TPanicCode aCode )
       
    54         {
       
    55         User::Panic( KPanicCat, aCode );
       
    56         }
       
    57     }
       
    58 
       
    59 // METHODS
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // Two-phased constructor.
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CAOConnectionImpl* CAOConnectionImpl::NewL(
       
    66     MAOConnectionObserver& aObserver,
       
    67     MAOSettings&           aSettings,
       
    68     RSocketServ*           aSocketServ )
       
    69     {
       
    70     LOG_1( _L("CAOConnectionImpl::NewL") );
       
    71     
       
    72     CAOConnectionImpl* self = new( ELeave ) CAOConnectionImpl(
       
    73         aObserver,
       
    74         aSettings,
       
    75         aSocketServ );
       
    76     
       
    77     CleanupStack::PushL( self );
       
    78     self->ConstructL();
       
    79     CleanupStack::Pop( self );
       
    80         
       
    81     return self;
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // Destructor
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 CAOConnectionImpl::~CAOConnectionImpl()
       
    89     {
       
    90     LOG_1( _L("CAOConnectionImpl::~CAOConnectionImpl") );
       
    91     
       
    92     Cancel();
       
    93     
       
    94     delete iCommsDatabase;
       
    95     iConnection.Close();
       
    96     }
       
    97 
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CAOConnectionImpl::ActivateConnection
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 void CAOConnectionImpl::ActivateConnection()
       
   104     {
       
   105     LOG_1( _L("CAOConnectionImpl::ActivateConnection") );
       
   106         
       
   107     __ASSERT_DEBUG( !IsActive() && iState == EDisconnected,
       
   108         Panic( EConnectionAlreadyActive ) );
       
   109         
       
   110     // Change state to EOpeningLink
       
   111     ChangeState( EOpeningLink );
       
   112     
       
   113     // Check IAP
       
   114     TUint iap = iSettings.AccessPointId();
       
   115     if ( IsValidIAP( iap ) )
       
   116         {
       
   117         // Check that we really have RConnection handle opened
       
   118         TInt err = KErrNone;
       
   119         if( !iConnection.SubSessionHandle() )
       
   120             {
       
   121             // Socket serv is closed only in destructor
       
   122             err = iConnection.Open( *iSocketServ );
       
   123             }
       
   124     
       
   125         if( err == KErrNone )
       
   126             {
       
   127 			// Set acces point settings
       
   128 			iAccessPointSettings.SetIapId( iap );
       
   129 			iAccessPointSettings.SetDialogPreference( KDlgPreference );
       
   130         
       
   131 			// Start connection
       
   132     		iConnection.Start( iAccessPointSettings, iStatus );
       
   133 			SetActive();
       
   134             }
       
   135         else
       
   136             {
       
   137             ActivateSelf( KErrNotSupported );
       
   138             }
       
   139         }
       
   140     else
       
   141         {
       
   142         // Something is wrong. Complete self with error KErrNotSupported ->
       
   143         // leads to permanent failure.
       
   144         ActivateSelf( KErrNotSupported );
       
   145         }
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CAOConnectionImpl::CancelConnection
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 void CAOConnectionImpl::CancelConnection()
       
   153     {
       
   154     LOG_1( _L("CAOConnectionImpl::CancelConnection") );
       
   155     Cancel();
       
   156     LOG_2( _L("CAOConnectionImpl::CancelConnection: Cur. state: %d"),
       
   157         iState );
       
   158     }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // CAOConnectionImpl::IsConnectedToDefaultIAP
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 TBool CAOConnectionImpl::IsConnectedToDefaultIAP()
       
   165     {
       
   166     LOG_1( _L("CAOConnectionImpl::IsConnectedToDefaultIAP") );
       
   167     
       
   168     // Check if we have PDP context open to default IAP
       
   169     TBool connected = EFalse;
       
   170     TUint connectionCount = 0;
       
   171     TInt err = iConnection.EnumerateConnections( connectionCount );
       
   172     if ( err == KErrNone )
       
   173         {
       
   174         TPckgBuf<TConnectionInfoV2> connectionInfo;
       
   175         for ( TInt i = 0; i < connectionCount; i++ )
       
   176             {
       
   177             err = iConnection.GetConnectionInfo( i + 1, connectionInfo );
       
   178             if ( err == KErrNone )
       
   179                 {
       
   180                 if ( connectionInfo().iIapId == iSettings.AccessPointId() )
       
   181                     {
       
   182                     LOG_1( _L("CAOConnectionImpl::IsConnectedToDefaultIAP: \
       
   183                                Connected to default IAP") );
       
   184                     connected = ETrue;
       
   185                     break;
       
   186                     }
       
   187                 }
       
   188             }
       
   189         }
       
   190         
       
   191     LOG_2( _L("CAOConnectionImpl::IsConnectedToDefaultIAP: Connected: %d "),
       
   192         connected );
       
   193         
       
   194     return connected;
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // CAOConnectionImpl::NumberOfConnections
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 TInt CAOConnectionImpl::NumberOfConnections()
       
   202     {
       
   203     LOG_1( _L("CAOConnectionImpl::NumberOfConnections") );
       
   204     
       
   205     TUint connectionCount = 0;
       
   206     TInt err = iConnection.EnumerateConnections( connectionCount );
       
   207     if( err != KErrNone )
       
   208         {
       
   209         connectionCount = 0;
       
   210         }
       
   211     LOG_2( _L("> Number of connections: %d"), connectionCount );
       
   212         
       
   213     return static_cast<TInt>( connectionCount );
       
   214     }
       
   215     
       
   216 // ---------------------------------------------------------------------------
       
   217 // CAOConnectionImpl::CloseConnection
       
   218 // ---------------------------------------------------------------------------
       
   219 //
       
   220 void CAOConnectionImpl::CloseConnection()
       
   221     {
       
   222     LOG_1( _L("CAOConnectionImpl::CloseConnection") );
       
   223     
       
   224     if ( iState == EListeningAccessPoint )
       
   225         {
       
   226         if ( IsActive() )
       
   227             {
       
   228             iConnection.CancelProgressNotification();	
       
   229             }
       
   230         	
       
   231     	iConnection.Close();
       
   232         
       
   233         // To really close: re-open
       
   234         TInt err = iConnection.Open( *iSocketServ );
       
   235         LOG_2( _L("> Re-opened connection handle: Err: %d"), err );
       
   236 
       
   237         ChangeState( EDisconnected );
       
   238         }
       
   239     }
       
   240         
       
   241 // ---------------------------------------------------------------------------
       
   242 // Constructor
       
   243 // ---------------------------------------------------------------------------
       
   244 //
       
   245 CAOConnectionImpl::CAOConnectionImpl(
       
   246                                       MAOConnectionObserver& aObserver,
       
   247                                       MAOSettings&           aSettings,
       
   248                                       RSocketServ*           aSocketServ ):
       
   249     CActive( CActive::EPriorityStandard ),
       
   250     iObserver( aObserver ),
       
   251     iSettings( aSettings ),
       
   252     iSocketServ( aSocketServ ),
       
   253     iState( EDisconnected )
       
   254     {
       
   255     LOG_1( _L("CAOConnectionImpl::CAOConnectionImpl") );
       
   256     
       
   257     CActiveScheduler::Add( this );
       
   258     }
       
   259 
       
   260 // ---------------------------------------------------------------------------
       
   261 // Symbian 2nd phase constructor
       
   262 // ---------------------------------------------------------------------------
       
   263 //
       
   264 void CAOConnectionImpl::ConstructL()
       
   265     {
       
   266     LOG_1( _L("CAOConnectionImpl::ConstructL") );
       
   267     
       
   268     User::LeaveIfError( iConnection.Open( *iSocketServ, KAfInet ) );
       
   269     iCommsDatabase = CCommsDatabase::NewL( EDatabaseTypeUnspecified );
       
   270     }
       
   271 
       
   272 // ---------------------------------------------------------------------------
       
   273 // CAOConnectionImpl::IsValidIAP
       
   274 // ---------------------------------------------------------------------------
       
   275 //
       
   276 TBool CAOConnectionImpl::IsValidIAP( TUint32 aId ) const
       
   277     {
       
   278     LOG_1( _L("CAOConnectionImpl::IsValidIAP") );
       
   279     
       
   280     CCommsDbTableView* table = NULL;
       
   281     
       
   282     // E32USER Cbase panic 79 is raised if OpenViewMatchingUintLC does not
       
   283     // leave inside trap. Therefore pop table out from cleanup stack before
       
   284     // exiting from TRAP harness.
       
   285     TRAPD( error, table = iCommsDatabase->OpenViewMatchingUintLC(
       
   286         TPtrC( IAP ),
       
   287         TPtrC( COMMDB_ID ),
       
   288         aId );
       
   289         CleanupStack::Pop( table ) );
       
   290     
       
   291     if ( error == KErrNone )
       
   292         {
       
   293         error = table->GotoFirstRecord();
       
   294         }
       
   295     delete table;
       
   296     
       
   297     return error == KErrNone;
       
   298     }
       
   299 
       
   300 // ---------------------------------------------------------------------------
       
   301 // CAOConnectionImpl::CompleteSelf
       
   302 // ---------------------------------------------------------------------------
       
   303 //
       
   304 void CAOConnectionImpl::CompleteSelf( TRequestStatus& aStatus, TInt aReason )
       
   305     {
       
   306     LOG_1( _L("CAOConnectionImpl::CompleteSelf") );
       
   307     
       
   308     __ASSERT_DEBUG( IsActive(), Panic( ENotActive ) );
       
   309     __ASSERT_DEBUG( aStatus == KRequestPending, Panic( EReuqestNotPending ) );
       
   310     
       
   311     TRequestStatus* status = &aStatus;
       
   312     User::RequestComplete( status, aReason );
       
   313     }
       
   314 
       
   315 // ---------------------------------------------------------------------------
       
   316 // CAOConnectionImpl::HandleOpeningLinkL
       
   317 // ---------------------------------------------------------------------------
       
   318 //
       
   319 void CAOConnectionImpl::HandleOpeningLinkL( TInt aStatus )
       
   320     {
       
   321     LOG_1( _L("CAOConnectionImpl::HandleOpeningLinkL") );
       
   322     
       
   323     if ( aStatus == KErrNone )
       
   324         {
       
   325         // First check current status
       
   326         TInt err = iConnection.Progress( iProgressBuf() );
       
   327         if ( err == KErrNone && iProgressBuf().iError == KErrNone )
       
   328             {
       
   329             IssueProgressNotification();
       
   330             if ( iProgressBuf().iStage == KLinkLayerOpen )
       
   331                 {
       
   332                 // Link open
       
   333                 ChangeState( EListeningAccessPoint );
       
   334                 iObserver.HandlePDPContextActivatedL();
       
   335                 }
       
   336             }
       
   337         else
       
   338             {
       
   339             BrodcastActivationFailedError( err );
       
   340             }
       
   341         }
       
   342     else
       
   343         {
       
   344         BrodcastActivationFailedError( aStatus );
       
   345         }
       
   346     }
       
   347 
       
   348 // ---------------------------------------------------------------------------
       
   349 // CAOConnectionImpl::HandleListeningAccessPointL
       
   350 // ---------------------------------------------------------------------------
       
   351 //
       
   352 void CAOConnectionImpl::HandleListeningAccessPointL( TInt aStatus )
       
   353     {
       
   354     LOG_1( _L("CAOConnectionImpl::HandleListeningAccessPointL") );
       
   355     LOG_2( _L("> aStatus: %d"), aStatus );
       
   356     LOG_2( _L("> iProgressBuf().iError: %d"), iProgressBuf().iError );
       
   357     
       
   358     if ( aStatus == KErrNone && iProgressBuf().iError == KErrNone )
       
   359         {
       
   360         // Check connection status
       
   361         switch ( iProgressBuf().iStage )
       
   362             {
       
   363             case KLinkLayerClosed:
       
   364                 {
       
   365                 LOG_1( _L("> Link closed") );
       
   366                 
       
   367                 // Connection disconnected
       
   368                 // Stop connection just in case
       
   369                 StopConnection();
       
   370                 
       
   371                 // Notify and change state
       
   372                 BrodcastDisconnectedError( KErrDisconnected );
       
   373                 break;
       
   374                 }
       
   375             case KLinkLayerOpen:
       
   376                 {
       
   377                 LOG_1( _L("> Link open") );
       
   378                 
       
   379                 // everything ok -> continue listening
       
   380                 IssueProgressNotification();
       
   381                 break;
       
   382                 }
       
   383             case KDataTransferTemporarilyBlocked:
       
   384                 {
       
   385                 LOG_1( _L("> Link temporarily blocked") );
       
   386                 
       
   387                 // Data transfer temporarily blocked
       
   388                 // Continue listening and notify
       
   389                 IssueProgressNotification();
       
   390                 iObserver.HandlePDPContextTemporarilyBlockedL();
       
   391                 break;
       
   392                 }
       
   393             case KConnectionClosed:
       
   394                 {
       
   395                 LOG_1( _L("> Connection closed") );
       
   396                     
       
   397                 // Notify and change state
       
   398                 BrodcastDisconnectedError( KErrDisconnected );
       
   399                 break;
       
   400                 }                
       
   401             default:
       
   402                 {
       
   403                 LOG_2( _L("iProgressBuf().iStage: %d"),
       
   404                         iProgressBuf().iStage );
       
   405                 
       
   406                 // Just continue listening
       
   407                 IssueProgressNotification();
       
   408                 break;
       
   409                 }
       
   410             }
       
   411         }
       
   412     else
       
   413         {
       
   414         // Handle error
       
   415         BrodcastDisconnectedError( aStatus );
       
   416         }
       
   417     }
       
   418 
       
   419 // ---------------------------------------------------------------------------
       
   420 // CAOConnectionImpl::ChangeState
       
   421 // ---------------------------------------------------------------------------
       
   422 //
       
   423 void CAOConnectionImpl::ChangeState( TInternalState aNewState )
       
   424     {
       
   425 #ifdef LOGGING_ENABLED
       
   426     TInternalState old = iState;
       
   427     iState = aNewState;
       
   428     LOG_3( _L("CAOConnectionImpl::ChangeState >> Changing state %d -> %d"),
       
   429         old, iState );
       
   430 #else
       
   431     iState = aNewState;
       
   432 #endif // LOGGING_ENABLED
       
   433     }
       
   434 
       
   435 // ---------------------------------------------------------------------------
       
   436 // CAOConnectionImpl::IssueProgressNotification
       
   437 // ---------------------------------------------------------------------------
       
   438 //
       
   439 void CAOConnectionImpl::IssueProgressNotification()
       
   440     {
       
   441     LOG_1( _L("CAOConnectionImpl::IssueProgressNotification") );
       
   442     
       
   443     __ASSERT_DEBUG( !IsActive(), Panic( EConnectionAlreadyActive ) );
       
   444     
       
   445     iConnection.ProgressNotification( iProgressBuf, iStatus );
       
   446     SetActive();
       
   447     }
       
   448 
       
   449 // ---------------------------------------------------------------------------
       
   450 // CAOConnectionImpl::BrodcastDisconnectedError
       
   451 // ---------------------------------------------------------------------------
       
   452 //
       
   453 #ifdef LOGGING_ENABLED
       
   454 void CAOConnectionImpl::BrodcastDisconnectedError( TInt aError )
       
   455 #else
       
   456 void CAOConnectionImpl::BrodcastDisconnectedError( TInt /*aError*/ )
       
   457 #endif
       
   458     {
       
   459     LOG_2( _L("CAOConnectionImpl::BrodcastDisconnectedError: aError: %d"),
       
   460            aError );
       
   461     
       
   462     ChangeState( EDisconnected );
       
   463     TRAP_IGNORE( iObserver.HandlePDPContextDisconnectedL(
       
   464         MAOConnectionManager::EDisconnected ) );
       
   465     }
       
   466 
       
   467 // ---------------------------------------------------------------------------
       
   468 // CAOConnectionImpl::BrodcastActivationFailedError
       
   469 // ---------------------------------------------------------------------------
       
   470 //
       
   471 void CAOConnectionImpl::BrodcastActivationFailedError( TInt aError )
       
   472     {
       
   473     LOG_2( _L("CAOConnectionImpl::BrodcastActivationFailedError: aError: %d"),
       
   474         aError );
       
   475     
       
   476     ChangeState( EDisconnected );
       
   477     TRAP_IGNORE( iObserver.HandlePDPContextActivationFailedL(
       
   478         FailureReason( aError ) ) );
       
   479     }
       
   480 
       
   481 // ---------------------------------------------------------------------------
       
   482 // CAOConnectionImpl::FailureReason
       
   483 // ---------------------------------------------------------------------------
       
   484 //
       
   485 MAOConnectionManager::TFailureReason CAOConnectionImpl::FailureReason(
       
   486     TInt aError )
       
   487     {
       
   488     LOG_2( _L("CAOConnectionImpl::FailureReason: aError: %d"), aError );
       
   489     
       
   490     // Determine error cause
       
   491     MAOConnectionManager::TFailureReason reason =
       
   492         MAOConnectionManager::EPermanent;
       
   493     switch ( aError )
       
   494         {
       
   495         // Temporary cause
       
   496         case KErrGprsUserAuthenticationFailure:
       
   497         case KErrGprsActivationRejectedByGGSN:
       
   498         case KErrGprsActivationRejected:
       
   499         case KErrGprsServiceOptionTemporarilyOutOfOrder:
       
   500         case KErrConnectionTerminated:
       
   501             {
       
   502             LOG_1( _L("> Temporary failure") );
       
   503             reason = MAOConnectionManager::ETemporary;
       
   504             break;
       
   505             }
       
   506         // Permanent cause
       
   507         default:
       
   508             {
       
   509             LOG_1( _L("> Permanent failure") );
       
   510             reason = MAOConnectionManager::EPermanent;
       
   511             break;
       
   512             }
       
   513         }
       
   514         
       
   515     LOG_2( _L("CAOConnectionImpl::FailureReason: Reason: %d"), reason );
       
   516             
       
   517     return reason;
       
   518     }
       
   519     
       
   520 // ---------------------------------------------------------------------------
       
   521 // CAOConnectionImpl::ActivateSelf
       
   522 // ---------------------------------------------------------------------------
       
   523 //
       
   524 void CAOConnectionImpl::ActivateSelf( TInt aReason )
       
   525     {
       
   526     LOG_2( _L("CAOConnectionImpl::ActivateSelf: aReason: %d"), aReason );
       
   527     
       
   528     __ASSERT_DEBUG( !IsActive(), Panic( EAlreadyActive ) );
       
   529     
       
   530     iStatus = KRequestPending;
       
   531     SetActive();
       
   532     CompleteSelf( iStatus, aReason );
       
   533     }
       
   534 
       
   535 // ---------------------------------------------------------------------------
       
   536 // CAOConnectionImpl::StopConnection
       
   537 // ---------------------------------------------------------------------------
       
   538 //
       
   539 void CAOConnectionImpl::StopConnection()
       
   540     {
       
   541     LOG_1( _L("CAOConnectionImpl::StopConnection") );
       
   542     
       
   543     TInt err = iConnection.Stop( RConnection::EStopAuthoritative );
       
   544     LOG_2( _L("> Stopped connection: Err: %d"), err );
       
   545     
       
   546     iConnection.Close();
       
   547     LOG_1( _L("> Closed connection handle") );
       
   548     
       
   549     err = iConnection.Open( *iSocketServ );
       
   550     LOG_2( _L("> Re-opened connection handle: Err: %d"), err );
       
   551     }
       
   552 
       
   553 
       
   554 
       
   555 // ---------------------------------------------------------------------------
       
   556 // CAOConnectionImpl::RunL
       
   557 // ---------------------------------------------------------------------------
       
   558 //
       
   559 void CAOConnectionImpl::RunL()
       
   560     {
       
   561     LOG_2( _L("CAOConnectionImpl::RunL: iStatus: %d"), iStatus.Int() );
       
   562     
       
   563     TInt status = iStatus.Int();
       
   564     switch ( iState )
       
   565         {
       
   566         case EDisconnected:
       
   567             {
       
   568             // nothing to do
       
   569             break;
       
   570             }
       
   571         case EOpeningLink:
       
   572             {
       
   573             HandleOpeningLinkL( status );
       
   574             break;
       
   575             }
       
   576         case EListeningAccessPoint:
       
   577             {
       
   578             HandleListeningAccessPointL( status );
       
   579             break;
       
   580             }
       
   581         default:
       
   582             {
       
   583             LOG_1( _L("CAOConnectionImpl::RunL >> Invalid state!") );
       
   584             Panic( EInvalidState );
       
   585             break;
       
   586             }
       
   587         }
       
   588     }
       
   589 
       
   590 // ---------------------------------------------------------------------------
       
   591 // CAOConnectionImpl::DoCancel
       
   592 // ---------------------------------------------------------------------------
       
   593 //
       
   594 void CAOConnectionImpl::DoCancel()
       
   595     {
       
   596     LOG_1( _L("CAOConnectionImpl::DoCancel") );
       
   597     
       
   598     TInternalState currentState = iState;
       
   599     ChangeState( EDisconnected );
       
   600     switch ( currentState )
       
   601         {
       
   602         case EDisconnected:
       
   603             {
       
   604             // Nothing to do
       
   605             break;
       
   606             }
       
   607         case EOpeningLink:
       
   608         case EListeningAccessPoint:
       
   609             {
       
   610             // Ignore error code since there is nothing that can be done if
       
   611             // these fail
       
   612             iConnection.CancelProgressNotification();
       
   613             StopConnection();
       
   614             break;
       
   615             }
       
   616         default:
       
   617             {
       
   618             LOG_1( _L("CAOConnectionImpl::DoCancel >> Invalid state!") );
       
   619             Panic( EInvalidState );
       
   620             break;
       
   621             }
       
   622         }
       
   623     }
       
   624 
       
   625 // ---------------------------------------------------------------------------
       
   626 // CAOConnectionImpl::RunError
       
   627 // ---------------------------------------------------------------------------
       
   628 //
       
   629 TInt CAOConnectionImpl::RunError( TInt aError )
       
   630     {
       
   631     LOG_2( _L("CAOConnectionImpl::RunError: aError: %d"), aError );
       
   632     
       
   633     switch ( iState )
       
   634         {
       
   635         case EDisconnected:
       
   636         case EOpeningLink:
       
   637         case EListeningAccessPoint:
       
   638             {
       
   639             BrodcastDisconnectedError( aError );
       
   640             break;
       
   641             }
       
   642         default:
       
   643             {
       
   644             LOG_1( _L("CAOConnectionImpl::RunError >> Invalid state!") );
       
   645             Panic( EInvalidState );
       
   646             break;
       
   647             }
       
   648         }
       
   649     ChangeState( EDisconnected );
       
   650     
       
   651     return KErrNone;
       
   652     }
       
   653