voipplugins/sipconnectionprovider/src/scpsubservice.cpp
changeset 0 a4daefaec16c
child 10 ed1e38b404e5
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2005-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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "scpsubservice.h"
       
    20 #include "scpservice.h"
       
    21 #include "scplogger.h"
       
    22 #include "scputility.h"
       
    23 #include "scpservicehandlerbase.h"
       
    24 #include "scpprofilehandler.h"
       
    25 #include "scpservicestorage.h"
       
    26 #include "scpstatecontainer.h"
       
    27 #include "scpvoiphandler.h"
       
    28 #include "scpvmbxhandler.h"
       
    29 #include "scppresencehandler.h"
       
    30 #include "scpimhandler.h"
       
    31 #include "scpsubserviceobserver.h"
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CScpSubService::NewL
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CScpSubService* CScpSubService::NewL( TInt aId, 
       
    38                                       TInt aSubServiceId,
       
    39                                       TCCHSubserviceType aSubServiceType,
       
    40                                       CScpService& aService )
       
    41     {
       
    42     SCPLOGSTRING( "CScpSubService::CScpSubService" );
       
    43 
       
    44     CScpSubService* self = new ( ELeave ) CScpSubService( aId, 
       
    45                                                           aSubServiceId,
       
    46                                                           aSubServiceType,
       
    47                                                           aService );
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL();
       
    50     CleanupStack::Pop( self );
       
    51     return self;
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CScpSubService::ConstructL
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CScpSubService::ConstructL()
       
    59     {
       
    60     SCPLOGSTRING2( "CScpSubService[0x%x]::ConstructL", this );
       
    61 
       
    62     switch( iSubServiceType )
       
    63         {
       
    64         case ECCHVoIPSub:
       
    65             iServiceHandler = CScpVoipHandler::NewL( *this );
       
    66             SetPresenceToObserveVoIP();
       
    67             break;
       
    68  
       
    69         case ECCHVMBxSub:
       
    70             iServiceHandler = CScpVmbxHandler::NewL( *this );  
       
    71             break;
       
    72 
       
    73         case ECCHIMSub:
       
    74             iServiceHandler = CScpImHandler::NewL( *this );
       
    75             break;
       
    76 
       
    77         case ECCHPresenceSub:
       
    78             iServiceHandler = CScpPresenceHandler::NewL( *this );
       
    79             break;
       
    80 
       
    81         default:
       
    82             __ASSERT_DEBUG( EFalse, User::Panic( KNullDesC, KErrGeneral ) );
       
    83             User::Leave( KErrNotFound );
       
    84             break;
       
    85         }
       
    86     }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CScpSubService::CScpSubService
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 CScpSubService::CScpSubService( TInt aId, 
       
    93                                 TInt aSubServiceId,
       
    94                                 TCCHSubserviceType aSubServiceType,
       
    95                                 CScpService& aService ) :
       
    96     iId( aId ),
       
    97     iSubServiceId( aSubServiceId ),
       
    98     iSubServiceType( aSubServiceType ),
       
    99     iService( aService ),
       
   100     iSipProfileId( 0 ),
       
   101     iEnableRequestedState( EScpNoRequest ),
       
   102     iSubServiceDisconnected( EFalse ),
       
   103     iApId( 0 ),
       
   104     iSnapId( 0 ),
       
   105     iLastReportedError( KErrNone ),
       
   106     iReserved( EFalse ),
       
   107     iSubServiceState( TScpStateContainer::Instance( ECCHDisabled ) )
       
   108     {
       
   109     SCPLOGSTRING3( "CScpSubService[0x%x]::CScpSubService type: %d", 
       
   110                    this, aSubServiceType );
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CScpSubService::~CScpSubService
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 CScpSubService::~CScpSubService()
       
   118     {
       
   119     SCPLOGSTRING2( "CScpSubService[0x%x]::~CScpSubService", this );
       
   120 
       
   121     delete iServiceHandler;
       
   122     }
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CScpSubService::EnableL
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 void CScpSubService::EnableL()
       
   129     {
       
   130     SCPLOGSTRING2( "CScpSubService[0x%x]::EnableL", this );
       
   131 
       
   132     iSubServiceState->EnableL( *this );
       
   133     EnableOccured();
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CScpSubService::EnableOccured
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void CScpSubService::EnableOccured()
       
   141     {
       
   142     switch ( iSubServiceType )
       
   143         {
       
   144         case ECCHPresenceSub:
       
   145             {
       
   146             iEnableCounter++;
       
   147             }
       
   148             break;
       
   149             
       
   150         case ECCHVoIPSub:
       
   151         case ECCHIMSub:
       
   152         case ECCHVMBxSub:
       
   153         case ECCHUnknown:
       
   154         default:
       
   155             break;
       
   156         }
       
   157         
       
   158     SCPLOGSTRING3( "CScpSubService[0x%x]::EnableOccured : %d", this, iEnableCounter );
       
   159     }
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // CScpSubService::EnableCounter
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 TInt CScpSubService::EnableCounter()
       
   166     {
       
   167     SCPLOGSTRING3( "CScpSubService[0x%x]::EnableCounter : %d", this, iEnableCounter );
       
   168     return iEnableCounter;
       
   169     }
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // CScpSubService::ResetEnableCounter
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 void CScpSubService::ResetEnableCounter()
       
   176     {
       
   177     SCPLOGSTRING2( "CScpSubService[0x%x]::ResetEnableCounter", this );
       
   178     iEnableCounter = 0;
       
   179     }
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // CScpSubService::Disable
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 TInt CScpSubService::Disable()
       
   186     {
       
   187     SCPLOGSTRING2( "CScpSubService[0x%x]::Disable", this );
       
   188 
       
   189     return iSubServiceState->Disable( *this );
       
   190     }
       
   191 
       
   192 // -----------------------------------------------------------------------------
       
   193 // CScpSubService::Id
       
   194 // -----------------------------------------------------------------------------
       
   195 //
       
   196 TInt CScpSubService::Id() const
       
   197     {
       
   198     SCPLOGSTRING2( "CScpSubService[0x%x]::Id", this );
       
   199 
       
   200     return iId;
       
   201     }
       
   202 
       
   203 // -----------------------------------------------------------------------------
       
   204 // CScpSubService::SubServiceId
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 TInt CScpSubService::SubServiceId() const
       
   208     {
       
   209     SCPLOGSTRING2( "CScpSubService[0x%x]::SubServiceId", this );
       
   210 
       
   211     return iSubServiceId;
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // CScpSubService::ServiceStorage
       
   216 // -----------------------------------------------------------------------------
       
   217 //
       
   218 CScpServiceStorage& CScpSubService::ServiceStorage() const
       
   219     {
       
   220     SCPLOGSTRING2( "CScpSubService[0x%x]::ServiceStorage", this );
       
   221 
       
   222     return iService.ServiceStorage();
       
   223     }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CScpSubService::ProfileHandler
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 CScpProfileHandler& CScpSubService::ProfileHandler() const
       
   230     {
       
   231     SCPLOGSTRING2( "CScpSubService[0x%x]::ProfileHandler", this );
       
   232 
       
   233     return iService.ProfileHandler();
       
   234     }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CScpSubService::State
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 TCCHSubserviceState CScpSubService::State() const
       
   241     {
       
   242     SCPLOGSTRING2( "CScpSubService[0x%x]::State: %d", this );
       
   243 
       
   244     return iSubServiceState->State();
       
   245     }
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 // CScpSubService::SubServiceType
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 TCCHSubserviceType CScpSubService::SubServiceType() const
       
   252     {
       
   253     SCPLOGSTRING2( "CScpSubService[0x%x]::Type", this );
       
   254 
       
   255     return iSubServiceType;
       
   256     }
       
   257 
       
   258 // -----------------------------------------------------------------------------
       
   259 // CScpSubService::SetSipProfileId
       
   260 // -----------------------------------------------------------------------------
       
   261 //
       
   262 void CScpSubService::SetSipProfileId( TInt aSipProfileId )
       
   263     {
       
   264     SCPLOGSTRING3( "CScpSubService[0x%x]::SetSipProfileId profile id", 
       
   265                    this, aSipProfileId );
       
   266 
       
   267     iSipProfileId = aSipProfileId;
       
   268     }
       
   269 
       
   270 // -----------------------------------------------------------------------------
       
   271 // CScpSubService::SipProfileId
       
   272 // -----------------------------------------------------------------------------
       
   273 //
       
   274 TInt CScpSubService::SipProfileId() const
       
   275     {
       
   276     SCPLOGSTRING2( "CScpSubService[0x%x]::SipProfileId", this );
       
   277 
       
   278     return iSipProfileId;
       
   279     }
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CScpSubService::EnableRequestedState
       
   283 // -----------------------------------------------------------------------------
       
   284 //
       
   285 void CScpSubService::SetEnableRequestedState( TEnableState aEnableRequestedState )
       
   286     {
       
   287     SCPLOGSTRING2( "CScpSubService[0x%x]::SetEnableRequestedState", this );
       
   288 
       
   289     iEnableRequestedState = aEnableRequestedState;
       
   290     }
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 // CScpSubService::EnableRequestedState
       
   294 // -----------------------------------------------------------------------------
       
   295 //
       
   296 CScpSubService::TEnableState CScpSubService::EnableRequestedState() const
       
   297     {
       
   298     SCPLOGSTRING2( "CScpSubService[0x%x]::EnableRequestedState", this );
       
   299 
       
   300     return iEnableRequestedState;
       
   301     }
       
   302 
       
   303 // -----------------------------------------------------------------------------
       
   304 // CScpSubService::SetSubServiceDisconnected
       
   305 // -----------------------------------------------------------------------------
       
   306 //
       
   307 void CScpSubService::SetSubServiceDisconnected( TBool aSubServiceDisconnected )
       
   308     {
       
   309     SCPLOGSTRING3( "CScpSubService[0x%x]::SetSubServiceDisconnected: %d", this, 
       
   310                    aSubServiceDisconnected );
       
   311 
       
   312     iSubServiceDisconnected = aSubServiceDisconnected;
       
   313     }
       
   314 
       
   315 // -----------------------------------------------------------------------------
       
   316 // CScpSubService::SubServiceDisconnected
       
   317 // -----------------------------------------------------------------------------
       
   318 //
       
   319 TBool CScpSubService::SubServiceDisconnected() const
       
   320     {
       
   321     SCPLOGSTRING3( "CScpSubService[0x%x]::SubServiceDisconnected: %d", this, 
       
   322                    iSubServiceDisconnected );
       
   323 
       
   324     return iSubServiceDisconnected;
       
   325     }
       
   326 
       
   327 // -----------------------------------------------------------------------------
       
   328 // CScpSubService::SetApId
       
   329 // -----------------------------------------------------------------------------
       
   330 //
       
   331 void CScpSubService::SetApId( TUint32 aApId )
       
   332     {
       
   333     SCPLOGSTRING3( "CScpSubService[0x%x]::SetApId ap id: %d", this, aApId );
       
   334 
       
   335     iApId = aApId;
       
   336     }
       
   337 
       
   338 // -----------------------------------------------------------------------------
       
   339 // CScpSubService::ApId
       
   340 // -----------------------------------------------------------------------------
       
   341 //
       
   342 TUint32 CScpSubService::ApId() const
       
   343     {
       
   344     SCPLOGSTRING2( "CScpSubService[0x%x]::ApId", this );
       
   345 
       
   346     return iApId;
       
   347     }
       
   348 
       
   349 // -----------------------------------------------------------------------------
       
   350 // CScpSubService::SetSnapId
       
   351 // -----------------------------------------------------------------------------
       
   352 //
       
   353 void CScpSubService::SetSnapId( TUint32 aSnapId )
       
   354     {
       
   355     SCPLOGSTRING3( "CScpSubService[0x%x]::SetSnapId snap id: %d", this, aSnapId );
       
   356 
       
   357     iSnapId = aSnapId;
       
   358     }
       
   359 
       
   360 // -----------------------------------------------------------------------------
       
   361 // CScpSubService::SnapId
       
   362 // -----------------------------------------------------------------------------
       
   363 //
       
   364 TUint32 CScpSubService::SnapId() const
       
   365     {
       
   366     SCPLOGSTRING2( "CScpSubService[0x%x]::SnapId", this );
       
   367 
       
   368     return iSnapId;
       
   369     }
       
   370 
       
   371 // -----------------------------------------------------------------------------
       
   372 // CScpSubService::GetIapType
       
   373 // -----------------------------------------------------------------------------
       
   374 //
       
   375 TScpIapType CScpSubService::GetIapType() const
       
   376     {
       
   377     SCPLOGSTRING2( "CScpSubService[0x%x]::GetIapType", this );
       
   378 
       
   379     TScpIapType type = EScpUnknownType;
       
   380 
       
   381     // Check that the sip profile is not using WLAN iap
       
   382     CScpProfileHandler& profileHandler = iService.ProfileHandler();
       
   383 
       
   384     CScpSipConnection* sipConnection = NULL;
       
   385 
       
   386     if( profileHandler.SipConnectionExists( iSipProfileId ) )
       
   387         {
       
   388         sipConnection = profileHandler.GetSipConnection( iSipProfileId );
       
   389         }
       
   390     else
       
   391         {
       
   392         TRAP_IGNORE( sipConnection = 
       
   393                      profileHandler.CreateSipConnectionL( iSipProfileId ) );
       
   394         }
       
   395 
       
   396     __ASSERT_DEBUG( sipConnection, User::Panic( KNullDesC, KErrGeneral ) );
       
   397 
       
   398     if( sipConnection )
       
   399         {
       
   400         TRAP_IGNORE( type = sipConnection->GetIapTypeL() );
       
   401         }
       
   402 
       
   403     return type;
       
   404     }      
       
   405             
       
   406 // -----------------------------------------------------------------------------
       
   407 // CScpSubService::ServiceHandler
       
   408 // -----------------------------------------------------------------------------
       
   409 //
       
   410 CScpServiceHandlerBase& CScpSubService::ServiceHandler() const
       
   411     {
       
   412     SCPLOGSTRING2( "CScpSubService[0x%x]::ServiceHandler", this );
       
   413 
       
   414     return *iServiceHandler;
       
   415     }
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 // CScpSubService::LastReportedError
       
   419 // -----------------------------------------------------------------------------
       
   420 //
       
   421 TInt CScpSubService::LastReportedError() const
       
   422     {
       
   423     SCPLOGSTRING3( "CScpSubService[0x%x]::LastReportedError: %d", 
       
   424                    this, iLastReportedError );
       
   425 
       
   426     return iLastReportedError;
       
   427     }
       
   428 
       
   429 // -----------------------------------------------------------------------------
       
   430 // CScpSubService::SetLastReportedError
       
   431 // -----------------------------------------------------------------------------
       
   432 //
       
   433 void CScpSubService::SetLastReportedError(
       
   434     const TInt aError )
       
   435     {
       
   436     SCPLOGSTRING3( "CScpSubService[0x%x]::SetLastReportedError: %d", 
       
   437                    this, aError );
       
   438 
       
   439     iLastReportedError = aError;
       
   440     }
       
   441 
       
   442 // -----------------------------------------------------------------------------
       
   443 // CScpSubService::SetReserved
       
   444 // -----------------------------------------------------------------------------
       
   445 //
       
   446 void CScpSubService::SetReserved( TBool aReserved )
       
   447     {
       
   448     SCPLOGSTRING3( "CScpSubService[0x%x]::SetReserved: %d", this, aReserved );
       
   449 
       
   450     iReserved = aReserved;
       
   451 
       
   452     CScpProfileHandler& profileHandler = iService.ProfileHandler();
       
   453     profileHandler.SetSipProfileReserved( iSipProfileId, iReserved );
       
   454     }
       
   455 
       
   456 // -----------------------------------------------------------------------------
       
   457 // CScpSubService::IsReserved
       
   458 // -----------------------------------------------------------------------------
       
   459 //
       
   460 TBool CScpSubService::IsReserved() const
       
   461     {
       
   462     SCPLOGSTRING3( "CScpSubService[0x%x]::IsReserved: %d", this, iReserved );
       
   463 
       
   464     return iReserved;
       
   465     }
       
   466 
       
   467 // -----------------------------------------------------------------------------
       
   468 // CScpSubService::IsRoaming
       
   469 // -----------------------------------------------------------------------------
       
   470 //
       
   471 TBool CScpSubService::IsRoaming() const
       
   472     {
       
   473     SCPLOGSTRING3( "CScpSubService[0x%x]::IsRoaming: %d", this, iRoaming );
       
   474 
       
   475     return iRoaming;
       
   476     }
       
   477 
       
   478 // -----------------------------------------------------------------------------
       
   479 // CScpSubService::ChangeState
       
   480 // -----------------------------------------------------------------------------
       
   481 //
       
   482 void CScpSubService::ChangeState( TCCHSubserviceState aState, TInt aError )
       
   483     {
       
   484     SCPLOGSTRING5( "CScpSubService[0x%x]::ChangeState from %d to %d error: %d", this,
       
   485                     iSubServiceState->State(), aState, aError );
       
   486     SCPLOGSTRING3( "CScpSubService[0x%x]::ChangeState type %d", this, iSubServiceType );
       
   487     __ASSERT_DEBUG( aState != ECCHUninitialized, User::Panic( KNullDesC, KErrGeneral ) );
       
   488 
       
   489     __ASSERT_DEBUG( iSubServiceState->State() == ECCHDisabled ? 
       
   490                     aState != ECCHDisconnecting : ETrue, 
       
   491                     User::Panic( KNullDesC, KErrGeneral ) );
       
   492     __ASSERT_DEBUG( iSubServiceState->State() == ECCHConnecting ? 
       
   493                     aState != ECCHDisabled || KErrCancel == aError : ETrue, 
       
   494                     User::Panic( KNullDesC, KErrGeneral ) );
       
   495     __ASSERT_DEBUG( iSubServiceState->State() == ECCHDisconnecting ? 
       
   496                     aState == ECCHDisabled : ETrue, 
       
   497                     User::Panic( KNullDesC, KErrGeneral ) );
       
   498     __ASSERT_DEBUG( iSubServiceState->State() == ECCHEnabled ? 
       
   499                     aState != ECCHDisabled : ETrue, 
       
   500                     User::Panic( KNullDesC, KErrGeneral ) );
       
   501 
       
   502     if ( aState != iSubServiceState->State() ||
       
   503         ( aState == iSubServiceState->State() && iLastReportedError != aError ) )
       
   504         {
       
   505         iLastReportedError = aError;
       
   506         
       
   507         switch( aState )
       
   508             {
       
   509             case ECCHConnecting:
       
   510                 {
       
   511                 iSubServiceState = 
       
   512                     TScpStateContainer::Instance( ECCHConnecting );
       
   513                 }
       
   514                 break;
       
   515 
       
   516             case ECCHEnabled:
       
   517                 {
       
   518                 iSubServiceState = 
       
   519                     TScpStateContainer::Instance( ECCHEnabled );
       
   520                 }
       
   521                 break;
       
   522 
       
   523             case ECCHDisconnecting:
       
   524                 {
       
   525                 iSubServiceState = 
       
   526                     TScpStateContainer::Instance( ECCHDisconnecting );
       
   527                 }
       
   528                 break;
       
   529 
       
   530             case ECCHDisabled:
       
   531                 {
       
   532                 iSubServiceState = 
       
   533                     TScpStateContainer::Instance( ECCHDisabled );
       
   534                 }
       
   535                 break;
       
   536 
       
   537             default:
       
   538                 __ASSERT_DEBUG( EFalse, User::Panic( KNullDesC, KErrGeneral ) );
       
   539                 break;
       
   540 
       
   541             }
       
   542 
       
   543         TBool sendEvent = ETrue;
       
   544         
       
   545         // During connection refreshing we don't send events about disabling
       
   546         if ( iEnableRequestedState == EScpRefreshed )
       
   547             {
       
   548             if ( aState == ECCHDisconnecting || aState == ECCHDisabled )
       
   549                 {
       
   550                 sendEvent = EFalse;
       
   551                 }
       
   552             }
       
   553             
       
   554         if ( sendEvent )
       
   555             {
       
   556             TServiceSelection selection( iSubServiceId, iSubServiceType );
       
   557 
       
   558             MCchServiceObserver& observer = iService.ServiceObserver();
       
   559             observer.ServiceStateChanged( selection,
       
   560                                           aState,
       
   561                                           aError );
       
   562             
       
   563             if ( ECCHDisabled == aState )
       
   564                 {
       
   565                 ResetEnableCounter();
       
   566                 // No need to hold the last reported error, if all 
       
   567                 // subservices are in disabled state
       
   568                 if ( iService.IsAllSubservicesDisabled() )
       
   569                     {
       
   570                     iService.ChangeLastReportedErrors( KErrNone );
       
   571                     }
       
   572                 }
       
   573             }
       
   574                                           
       
   575         if ( iSubServiceObserver ) 
       
   576             {
       
   577             SCPLOGSTRING2( "CScpSubService[0x%x]::ChangeState HandleSubServiceChange", this );
       
   578             iSubServiceObserver->HandleSubServiceChange( aState, aError );
       
   579             }
       
   580         }
       
   581     }
       
   582 
       
   583 // -----------------------------------------------------------------------------
       
   584 // CScpSubService::HandleConnectionEvent
       
   585 // -----------------------------------------------------------------------------
       
   586 //
       
   587 void CScpSubService::HandleConnectionEvent( TScpConnectionEvent aEvent )
       
   588     {
       
   589     SCPLOGSTRING4( "CScpSubService[0x%x]::HandleConnectionEvent event: %d state: %d", 
       
   590                    this, aEvent, iSubServiceState->State() );
       
   591     __ASSERT_DEBUG( aEvent != EScpUnknown, User::Panic( KNullDesC, KErrGeneral ) );
       
   592 
       
   593     // All other events than EScpRoaming finish roaming
       
   594     iRoaming = EFalse;
       
   595     
       
   596     switch ( aEvent )
       
   597         {
       
   598         case EScpNetworkFound:
       
   599             {
       
   600             iSubServiceState->NetworkFound( *this );
       
   601             }
       
   602             break;
       
   603 
       
   604         case EScpNetworkNotFound:
       
   605             {
       
   606             iSubServiceState->NetworkNotFound( *this );
       
   607             }
       
   608             break;
       
   609 
       
   610         case EScpNetworkLost:
       
   611             {
       
   612             iSubServiceState->NetworkLost( *this );
       
   613             }
       
   614             break;
       
   615 
       
   616         case EScpRegistered:
       
   617             {
       
   618             iSubServiceState->ServiceConnected( *this );
       
   619             }
       
   620             break;
       
   621 
       
   622         case EScpRegistrationFailed:
       
   623             {
       
   624             iSubServiceState->ServiceConnectionFailed( *this );
       
   625             }
       
   626             break;
       
   627         case EScpInvalidSettings:
       
   628             {
       
   629             iSubServiceState->ServiceInvalidSettings( *this );
       
   630             }
       
   631             break;
       
   632         case EScpDeregistered:
       
   633             {
       
   634             iSubServiceState->ServiceDisconnected( *this );
       
   635             }
       
   636             break;
       
   637 
       
   638         case EScpBandwidthLimited:
       
   639             {
       
   640             iSubServiceState->BandwidthLimited( *this );
       
   641             }
       
   642             break;
       
   643 
       
   644         case EScpAuthenticationFailed:
       
   645             {
       
   646             iSubServiceState->AuthenticationFailed( *this );
       
   647             }
       
   648             break;
       
   649             
       
   650         case EScpRoaming:
       
   651             {
       
   652             iRoaming = ETrue;
       
   653             iSubServiceState->Roaming( *this );
       
   654             }
       
   655             break;
       
   656             
       
   657         case EScpRegistrationCanceled:
       
   658             {
       
   659             iSubServiceState->ServiceConnectionCanceled( *this );
       
   660             }
       
   661             break;
       
   662             
       
   663         case EScpBearerNotSupported:
       
   664             {
       
   665             iSubServiceState->BearerNotSupported( *this );
       
   666             }
       
   667             break;
       
   668             
       
   669         case EScpRegistrationPending:
       
   670             {
       
   671             iSubServiceState->RegistrationPending( *this );
       
   672             }
       
   673             break;
       
   674             
       
   675         default:
       
   676             __ASSERT_DEBUG( EFalse, User::Panic( KNullDesC, KErrGeneral ) );
       
   677             break;
       
   678         }
       
   679 
       
   680     // Remove user disabled sub services if correct
       
   681     // network event received
       
   682     if ( iEnableRequestedState == EScpDisabled &&
       
   683          ( aEvent == EScpDeregistered ||
       
   684            aEvent == EScpRegistrationFailed ||
       
   685            aEvent == EScpNetworkLost ||
       
   686            aEvent == EScpNetworkNotFound ) )
       
   687         {
       
   688         CScpServiceStorage& storage = ServiceStorage();
       
   689         storage.RemoveDisabledServices();
       
   690         }
       
   691     else if ( iEnableRequestedState == EScpRefreshed &&
       
   692              aEvent == EScpDeregistered )
       
   693         {
       
   694         // We can only ingnore the error
       
   695         TRAP_IGNORE( EnableL() );
       
   696         }
       
   697     }
       
   698 
       
   699 // -----------------------------------------------------------------------------
       
   700 // CScpSubService::SetSubServiceObserver
       
   701 // -----------------------------------------------------------------------------
       
   702 //
       
   703 void CScpSubService::SetSubServiceObserver( MScpSubServiceObserver* aSubServiceObserver )
       
   704     {
       
   705     SCPLOGSTRING3( "CScpSubService[0x%x]::SetSubServiceObserver aSubServiceObserver[0x%x]", 
       
   706         this, aSubServiceObserver );
       
   707         
       
   708     iSubServiceObserver = aSubServiceObserver;
       
   709     }
       
   710   
       
   711 // -----------------------------------------------------------------------------
       
   712 // CScpSubService::SetPresenceToObserveVoIPL
       
   713 // -----------------------------------------------------------------------------
       
   714 // 
       
   715 void CScpSubService::SetPresenceToObserveVoIP()
       
   716     {
       
   717     SCPLOGSTRING2( "CScpSubService[0x%x]::SetPresenceToObserveVoIP", this );
       
   718     CScpSubService* presenceSubService = iService.GetSubServiceByType( ECCHPresenceSub );
       
   719     if ( presenceSubService )
       
   720         {
       
   721         SCPLOGSTRING( "CScpSubService::SetPresenceToObserveVoIPL - presenceSubService exists" );
       
   722         CScpPresenceHandler* presenceHandler =
       
   723             static_cast<CScpPresenceHandler*>( &presenceSubService->ServiceHandler() );
       
   724           SetSubServiceObserver( presenceHandler );
       
   725         }
       
   726     }
       
   727 
       
   728 // End of file