uiservicetab/vimpstengine/src/cvimpstenginevoipsubservice.cpp
branchRCL_3
changeset 29 9a48e301e94b
equal deleted inserted replaced
28:3104fc151679 29:9a48e301e94b
       
     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:  Class that capsulates single service data members
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDES
       
    20 #include "cvimpstenginevoipsubservice.h"
       
    21 
       
    22 #include "cvimpstenginecchhandler.h"
       
    23 #include "tvimpstconsts.h"
       
    24 #include "cvimpstengineservicetablefetcher.h"
       
    25 #include "mvimpstengineserviceconnectioneventobserver.h"
       
    26 //debug
       
    27 #include "uiservicetabtracer.h"
       
    28 
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 // ---------------------------------------------------------
       
    32 // CVIMPSTEngineVOIPSubService::NewL
       
    33 // 
       
    34 // ---------------------------------------------------------
       
    35 CVIMPSTEngineVOIPSubService* CVIMPSTEngineVOIPSubService::NewL( TUint32 aServiceId,
       
    36 									CVIMPSTEngineCchHandler& aCchHandler,
       
    37 									CVIMPSTEngineServiceTableFetcher& aTableFetcher,
       
    38 									MVIMPSTEngineServiceConnectionEventObserver& aObserver
       
    39 									)
       
    40     {
       
    41 	TRACER_AUTO;
       
    42 	TRACE( "aServiceId: %d", aServiceId);
       
    43     
       
    44     CVIMPSTEngineVOIPSubService* self = CVIMPSTEngineVOIPSubService::NewLC(aServiceId,aCchHandler,
       
    45     										aTableFetcher, aObserver);
       
    46     CleanupStack::Pop( self );
       
    47 	
       
    48     return self;
       
    49     }
       
    50 
       
    51 
       
    52 // ---------------------------------------------------------
       
    53 // CVIMPSTEngineVOIPSubService::NewLC
       
    54 // 
       
    55 // ---------------------------------------------------------
       
    56     
       
    57 CVIMPSTEngineVOIPSubService* CVIMPSTEngineVOIPSubService::NewLC( TUint32 aServiceId,
       
    58                                                    	CVIMPSTEngineCchHandler& aCchHandler,
       
    59                                                    	CVIMPSTEngineServiceTableFetcher& aTableFetcher,
       
    60                                                    	MVIMPSTEngineServiceConnectionEventObserver& aObserver )
       
    61 	{
       
    62 	TRACER_AUTO;
       
    63 	TRACE( "aServiceId: %d", aServiceId);
       
    64 	
       
    65     CVIMPSTEngineVOIPSubService* self = new (ELeave) CVIMPSTEngineVOIPSubService(
       
    66     												aServiceId,aCchHandler,aTableFetcher,
       
    67     												aObserver  );
       
    68     CleanupStack::PushL( self );
       
    69     self->ConstructL( );
       
    70     
       
    71     return self;
       
    72 	}
       
    73 
       
    74 // ---------------------------------------------------------
       
    75 // CVIMPSTEngineVOIPSubService::~CVIMPSTEngineVOIPSubService
       
    76 // 
       
    77 // ---------------------------------------------------------
       
    78 
       
    79 CVIMPSTEngineVOIPSubService::~CVIMPSTEngineVOIPSubService()
       
    80 	{
       
    81 	TRACER_AUTO;
       
    82    	
       
    83    	iCchHandler.UnRegisterCchObserver(ECCHVoIPSub);	
       
    84    	
       
    85  	}
       
    86 
       
    87 
       
    88 // ---------------------------------------------------------
       
    89 // CVIMPSTEngineVOIPSubService::ConstructL
       
    90 // 
       
    91 // ---------------------------------------------------------
       
    92 
       
    93 void CVIMPSTEngineVOIPSubService::ConstructL(  )
       
    94 	{
       
    95 	TRACER_AUTO;
       
    96 	
       
    97 	TCCHSubserviceState serviceState = ECCHUninitialized;    
       
    98     TInt error = iCchHandler.GetServiceState( 
       
    99         			iServiceId, ECCHVoIPSub, serviceState );
       
   100 	
       
   101 	iServiceState = ResolveServiceState(serviceState, error);    	
       
   102 	
       
   103 	iCchHandler.RegisterCchObserverL(this,ECCHVoIPSub);       	
       
   104     
       
   105 	TRACE( "ResolveServiceState returned ServiceState: %d", iServiceState );
       
   106 	
       
   107    	
       
   108    	}
       
   109 
       
   110 
       
   111 // ---------------------------------------------------------
       
   112 // CVIMPSTEngineVOIPSubService::CVIMPSTEngineVOIPSubService
       
   113 // 
       
   114 // ---------------------------------------------------------
       
   115 
       
   116 CVIMPSTEngineVOIPSubService::CVIMPSTEngineVOIPSubService( TUint32 aServiceId, 
       
   117                                               CVIMPSTEngineCchHandler& aCchHandler,
       
   118                                               CVIMPSTEngineServiceTableFetcher& aTableFetcher,
       
   119                                               MVIMPSTEngineServiceConnectionEventObserver& aObserver) :
       
   120 iServiceId(aServiceId),
       
   121 iCchHandler(aCchHandler),
       
   122 iTableFetcher(aTableFetcher),
       
   123 iType (TVIMPSTEnums::EVoip),
       
   124 iObserver(aObserver)
       
   125 	{
       
   126 		
       
   127 	}
       
   128 
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // CVIMPSTEngineVOIPSubService::CchEventOccuredL()
       
   132 // ---------------------------------------------------------------------------
       
   133 // 
       
   134 void CVIMPSTEngineVOIPSubService::CchEventOccuredL( TUint /*aServiceId*/, 
       
   135     TCCHSubserviceState aState, TInt aServiceError )
       
   136 	{	
       
   137 	TRACER_AUTO;
       
   138 	TRACE( " TCCHSubserviceState : %d, ServiceErr: %d",aState, aServiceError );
       
   139 	
       
   140 	if ( aServiceError && ECCHDisabled != aState )
       
   141         {
       
   142         //we might even end up in waiting for connection state for all
       
   143         //those service which are ALR enabled
       
   144         //So better check here if you get any CCH errors
       
   145         iServiceState = ResolveServiceState( aState, aServiceError );
       
   146         iObserver.HandleServceConnectionEventL();
       
   147         DoHandleCchErrorL( aServiceError );
       
   148         }
       
   149     else
       
   150         {
       
   151         iServiceState = ResolveServiceState( aState, aServiceError );    
       
   152         iObserver.HandleServceConnectionEventL();
       
   153         }	
       
   154 	
       
   155 	
       
   156     }    
       
   157 
       
   158 	
       
   159 // ---------------------------------------------------------------------------
       
   160 // CVIMPSTEngineVOIPSubService::DoHandleCchErrorL()
       
   161 // ---------------------------------------------------------------------------
       
   162 // 
       
   163 void CVIMPSTEngineVOIPSubService::DoHandleCchErrorL( 
       
   164     TInt aServiceError )
       
   165     {
       
   166 	TRACER_AUTO;
       
   167 	  TRACE(" ServiceErr: %d", aServiceError );
       
   168 	
       
   169 	/*								
       
   170 	MCchUi& cchUi = iCchHandler.CchUiApi();
       
   171 										
       
   172     switch ( aServiceError )
       
   173         {
       
   174         
       
   175         case KCCHErrorNetworkLost:  
       
   176         	{
       
   177         	cchUi.ShowDialogL( iServiceId, MCchUiObserver::ECchUiDialogTypeNoConnectionAvailable );
       
   178             break;
       
   179             }
       
   180             
       
   181         default:
       
   182             {
       
   183             break;
       
   184             }
       
   185             
       
   186         }
       
   187         */
       
   188 	
       
   189         
       
   190     }	
       
   191     
       
   192     
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // CVIMPSTEngineVOIPSubService::ResolveServiceState
       
   196 // ---------------------------------------------------------------------------
       
   197 // 
       
   198 TVIMPSTEnums::TVIMPSTRegistrationState CVIMPSTEngineVOIPSubService::ResolveServiceState(
       
   199 										TCCHSubserviceState aState, 
       
   200             							TInt aServiceError )
       
   201     {
       
   202 	TRACER_AUTO;
       
   203         
       
   204     TVIMPSTEnums::TVIMPSTRegistrationState state = TVIMPSTEnums::ESVCENotRegistered;       
       
   205     
       
   206     TRACE( " iServiceId: %d, ServiceState: %d", iServiceId, aState ); 
       
   207 
       
   208     TBool handleServiceStates = ETrue;
       
   209     if ( aServiceError && ECCHDisabled != aState )
       
   210         {    
       
   211 		//Only if the Service supports ALR, the state can goto WaitingForNetwork
       
   212 		//Still API from CCH is required to know whether ALR is supported or not
       
   213         if ( (KCCHErrorInvalidSettings != aServiceError) && (ECCHConnecting == aState) )        
       
   214             {   
       
   215             TRACE( "ESVCEWaitingForNetwork" );
       
   216             handleServiceStates = EFalse;  
       
   217             state = TVIMPSTEnums::ESVCEWaitingForNetwork;	           
       
   218             }
       
   219         }
       
   220     
       
   221     if ( handleServiceStates )
       
   222         {        
       
   223         switch ( aState )
       
   224             {
       
   225             case ECCHEnabled:
       
   226                 {
       
   227                 TRACE( " ESVCERegistered" );    
       
   228                 state = TVIMPSTEnums::ESVCERegistered;
       
   229                 }
       
   230                 break;
       
   231 
       
   232             case ECCHDisconnecting:      
       
   233                 {
       
   234                 TRACE( " ESVCENetworkDisConnecting");   
       
   235                 state = TVIMPSTEnums::ESVCENetworkDisConnecting;
       
   236                 }
       
   237                 break;
       
   238 
       
   239             case ECCHUninitialized:
       
   240             case ECCHDisabled:  
       
   241                 {
       
   242                 TRACE( " ESVCENotRegistered" );   
       
   243                 state = TVIMPSTEnums::ESVCENotRegistered;
       
   244                 }
       
   245                 break;
       
   246                 
       
   247             case ECCHConnecting:               
       
   248                 {
       
   249                 TRACE(" ESVCENetworkConnecting" );    
       
   250                 state = TVIMPSTEnums::ESVCENetworkConnecting;
       
   251                 }
       
   252                 break;
       
   253             
       
   254             default:
       
   255                 break;
       
   256             }
       
   257         }        
       
   258         
       
   259 	        
       
   260     return state;  
       
   261 	
       
   262     }
       
   263 
       
   264 
       
   265 // ---------------------------------------------------------------------------
       
   266 // CVIMPSTEngineVOIPSubService::SubServiceState
       
   267 // ---------------------------------------------------------------------------
       
   268 // 
       
   269 TVIMPSTEnums::TVIMPSTRegistrationState CVIMPSTEngineVOIPSubService::SubServiceState() const
       
   270 	{
       
   271 	TRACER_AUTO;
       
   272 	TRACE( " ServiceId: %d ServiceState: %d",iServiceId, iServiceState );
       
   273 	return iServiceState;
       
   274 	}
       
   275  
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // CVIMPSTEngineVOIPSubService::Type
       
   279 // ---------------------------------------------------------------------------
       
   280 // 
       
   281 TVIMPSTEnums::SubServiceType CVIMPSTEngineVOIPSubService::Type() const	
       
   282 	{
       
   283 	TRACER_AUTO;
       
   284 	TRACE( "Type: %d", iType );
       
   285 	TRACE( " [0x%x]", this );
       
   286 	return iType;	
       
   287 	}
       
   288 
       
   289 
       
   290     
       
   291 //  End of File
       
   292