messagingappbase/ncnlist/src/CNcnMsgWaitingManager.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2004 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:   Methods for CNcnMsgWaitingManager class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include 	<etelmm.h>
       
    22 
       
    23 #include	"NcnVariant.hrh"
       
    24 #include    "NcnDebug.h"
       
    25 #include    "NcnModelBase.h"
       
    26 #include    "CNcnMsgWaitingManager.h"
       
    27 #include    "CVoiceMailManager.h"
       
    28 
       
    29 #ifdef _DEBUG
       
    30 
       
    31 class CNcnMsgWaitingManagerObserver : 
       
    32 	public CActive
       
    33 	{
       
    34     public:  // Constructors and destructor
       
    35 
       
    36         /**
       
    37          * Two-phased constructor.
       
    38          * @param aModel Reference to ncn model
       
    39          */
       
    40         static CNcnMsgWaitingManagerObserver* NewL( RMobilePhone &aMobilePhone );
       
    41 
       
    42         /**
       
    43          * Destructor.
       
    44          */
       
    45         virtual ~CNcnMsgWaitingManagerObserver();
       
    46                 
       
    47     public: // From CActive
       
    48     
       
    49         /**
       
    50          * RunL
       
    51          */
       
    52         void RunL();
       
    53 
       
    54         /**
       
    55          * DoCancel
       
    56          */
       
    57         void DoCancel();
       
    58                                                                 
       
    59     private:  // Constructors and destructor
       
    60 
       
    61         /**
       
    62          * C++ default constructor.
       
    63          * @param aMsvSessionHandler Msv session handler reference.
       
    64          */
       
    65         CNcnMsgWaitingManagerObserver( RMobilePhone &aMobilePhone );
       
    66         
       
    67         /**
       
    68          * 2nd. phase constructor.
       
    69          */
       
    70         void ConstructL( );
       
    71         
       
    72 	private:
       
    73 	        
       
    74 		void PrintStatus();        
       
    75 		        
       
    76     private: // Data
       
    77             
       
    78 		TBool iChangeNotifySubscribed;            
       
    79             
       
    80 		RMobilePhone &iMobilePhone;
       
    81 		
       
    82         // Struct is a container for indicator flags and message counts
       
    83         RMobilePhone::TMobilePhoneMessageWaitingV1      iMsgWaiting;  
       
    84                       
       
    85 		// Package for iMsgWaitingV1                      
       
    86         RMobilePhone::TMobilePhoneMessageWaitingV1Pckg  iMsgWaitingPckg;   
       
    87             
       
    88             
       
    89 	}; // CNcnMsgWaitingManagerObserver
       
    90 	
       
    91 	
       
    92 	
       
    93 	
       
    94 	CNcnMsgWaitingManagerObserver::CNcnMsgWaitingManagerObserver( RMobilePhone &aMobilePhone ) :
       
    95 	    CActive( EPriorityNormal ),
       
    96 		iChangeNotifySubscribed( EFalse ),
       
    97 	    iMobilePhone( aMobilePhone ),
       
    98 	    iMsgWaiting(),
       
    99 	  	iMsgWaitingPckg( iMsgWaiting )
       
   100 	    {
       
   101 	    CActiveScheduler::Add( this );            
       
   102 	    }
       
   103 	
       
   104 	CNcnMsgWaitingManagerObserver* CNcnMsgWaitingManagerObserver::NewL( RMobilePhone &aMobilePhone )
       
   105 	    {
       
   106 	    CNcnMsgWaitingManagerObserver* self = new (ELeave) CNcnMsgWaitingManagerObserver( aMobilePhone );
       
   107 	    
       
   108 	    CleanupStack::PushL( self );
       
   109 	    self->ConstructL();
       
   110 	    CleanupStack::Pop( self );
       
   111 	    
       
   112 	    return self;
       
   113 	    }
       
   114 	
       
   115 	void CNcnMsgWaitingManagerObserver::ConstructL()
       
   116 	    {
       
   117 	    //iMobilePhone.GetIccMessageWaitingIndicators( iStatus, iMsgWaitingPckg );
       
   118 	    //SetActive();
       
   119 	    }
       
   120 	    
       
   121 	CNcnMsgWaitingManagerObserver::~CNcnMsgWaitingManagerObserver()
       
   122 	    {
       
   123 	    NCN_RDEBUG( _L("~CNcnMsgWaitingManager") );
       
   124 	    Cancel();
       
   125 	    }
       
   126 	    
       
   127 	    
       
   128 	void CNcnMsgWaitingManagerObserver::RunL()
       
   129 	    {
       
   130 	    NCN_RDEBUG_INT( _L("CNcnMsgWaitingManagerObserver::RunL: iStatus = %d"), iStatus.Int() );	    
       
   131 	    TInt err = iStatus.Int();
       
   132 	    
       
   133 	    // subscribe for notifications
       
   134 	    iMobilePhone.NotifyIccMessageWaitingIndicatorsChange( iStatus, iMsgWaitingPckg );
       
   135 	    SetActive();
       
   136 	    
       
   137 	    iChangeNotifySubscribed = ETrue; // get-request completed, DoCancel() must now cancel notify request
       
   138 	    
       
   139 	    if ( err == KErrNone )
       
   140 	        {
       
   141 	        PrintStatus();
       
   142 	        }
       
   143 	    }
       
   144 	    
       
   145 	void CNcnMsgWaitingManagerObserver::DoCancel()
       
   146 	    {	    
       
   147 	    if ( IsActive() )
       
   148 	        {
       
   149 	        if ( iChangeNotifySubscribed )
       
   150 	            {
       
   151 	            iMobilePhone.CancelAsyncRequest( EMobilePhoneNotifyIccMessageWaitingIndicatorsChange );  
       
   152 	            }
       
   153 	        else
       
   154 	            {
       
   155 	            iMobilePhone.CancelAsyncRequest( EMobilePhoneGetIccMessageWaitingIndicators );    
       
   156 	            }
       
   157 	        }
       
   158 	    }
       
   159 	    	    
       
   160 	void CNcnMsgWaitingManagerObserver::PrintStatus()
       
   161 		{
       
   162 		NCN_RDEBUG_INT( _L("CNcnMsgWaitingManagerObserver::PrintStatus: Voice mail line 1 active %d"), 
       
   163 			( iMsgWaiting.iDisplayStatus& RMobilePhone::KDisplayVoicemailActive ) ? ETrue : EFalse );
       
   164 		NCN_RDEBUG_INT( _L("CNcnMsgWaitingManagerObserver::PrintStatus: Voice mail line 2 active %d"), 
       
   165 			( iMsgWaiting.iDisplayStatus& RMobilePhone::KDisplayAuxVoicemailActive ) ? ETrue : EFalse );
       
   166 		NCN_RDEBUG_INT( _L("CNcnMsgWaitingManagerObserver::PrintStatus: Fax active %d"), 
       
   167 			( iMsgWaiting.iDisplayStatus& RMobilePhone::KDisplayFaxActive ) ? ETrue : EFalse );
       
   168 		NCN_RDEBUG_INT( _L("CNcnMsgWaitingManagerObserver::PrintStatus: Email active %d"), 
       
   169 			( iMsgWaiting.iDisplayStatus& RMobilePhone::KDisplayEmailActive ) ? ETrue : EFalse );
       
   170 		NCN_RDEBUG_INT( _L("CNcnMsgWaitingManagerObserver::PrintStatus: Other active %d"), 
       
   171 			( iMsgWaiting.iDisplayStatus& RMobilePhone::KDisplayOtherActive ) ? ETrue : EFalse );
       
   172 		NCN_RDEBUG_INT( _L("CNcnMsgWaitingManagerObserver::PrintStatus: Display data active %d"), 
       
   173 			( iMsgWaiting.iDisplayStatus& RMobilePhone::KDisplayDataActive ) ? ETrue : EFalse );
       
   174 
       
   175 		NCN_RDEBUG_INT( _L("CNcnMsgWaitingManagerObserver::PrintStatus: Voice mail line 1 count %d"), 
       
   176 			iMsgWaiting.iVoiceMsgs );
       
   177 		NCN_RDEBUG_INT( _L("CNcnMsgWaitingManagerObserver::PrintStatus: Voice mail line 2 count %d"), 
       
   178 			iMsgWaiting.iAuxVoiceMsgs );
       
   179 		NCN_RDEBUG_INT( _L("CNcnMsgWaitingManagerObserver::PrintStatus: Fax count %d"), 
       
   180 			iMsgWaiting.iFaxMsgs );
       
   181 		NCN_RDEBUG_INT( _L("CNcnMsgWaitingManagerObserver::PrintStatus: Email count %d"), 
       
   182 			iMsgWaiting.iEmailMsgs );
       
   183 		NCN_RDEBUG_INT( _L("CNcnMsgWaitingManagerObserver::PrintStatus: Other message count %d"), 
       
   184 			iMsgWaiting.iOtherMsgs );
       
   185 		}	    
       
   186 	    
       
   187 	
       
   188 #endif // _DEBUG
       
   189 
       
   190 // ================= LOCAL CONSTANTS =======================
       
   191 
       
   192 
       
   193 // ================= MEMBER FUNCTIONS =======================
       
   194 
       
   195 // ----------------------------------------------------
       
   196 //  CNcnMsgWaitingManager::CNcnMsgWaitingManager
       
   197 // ----------------------------------------------------
       
   198 // 
       
   199 CNcnMsgWaitingManager::CNcnMsgWaitingManager( CNcnModelBase &aModel ) :
       
   200     CActive( EPriorityNormal ),
       
   201     iModel( aModel ),    
       
   202     iMsgWaiting(),
       
   203   	iMsgWaitingPckg( iMsgWaiting )
       
   204     {
       
   205     CActiveScheduler::Add( this );
       
   206     }
       
   207 
       
   208 // ----------------------------------------------------
       
   209 //  CNcnMsgWaitingManager::NewL
       
   210 // ----------------------------------------------------
       
   211 //  
       
   212 CNcnMsgWaitingManager* CNcnMsgWaitingManager::NewL( CNcnModelBase &aModel )
       
   213     {
       
   214     CNcnMsgWaitingManager* self = new (ELeave) CNcnMsgWaitingManager( aModel );
       
   215     
       
   216     CleanupStack::PushL( self );
       
   217     self->ConstructL();
       
   218     CleanupStack::Pop( self );
       
   219     
       
   220     return self;
       
   221     }
       
   222 
       
   223 // ----------------------------------------------------
       
   224 //  CNcnMsgWaitingManager::ConstructL
       
   225 // ----------------------------------------------------
       
   226 //  
       
   227 void CNcnMsgWaitingManager::ConstructL()
       
   228     {
       
   229     TInt err;       
       
   230     
       
   231     err = iTelServer.Connect();
       
   232     NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::ConstructL: iTelServer.Connect returned %d"), err );
       
   233 	User::LeaveIfError( err );
       
   234 
       
   235 	err = iTelServer.GetPhoneInfo( 0, iPhoneInfo );
       
   236     NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::ConstructL: iTelServer.GetPhoneInfo returned %d"), err );	
       
   237     User::LeaveIfError( err ); 
       
   238         
       
   239 	err = iMobilePhone.Open( iTelServer, iPhoneInfo.iName );   
       
   240     NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::ConstructL: iMobilePhone.Open returned %d"), err );		     
       
   241     User::LeaveIfError( err );                  
       
   242                 
       
   243 #if 0
       
   244 	iObserver = CNcnMsgWaitingManagerObserver::NewL( iMobilePhone );
       
   245 #endif	                
       
   246 
       
   247     }
       
   248 
       
   249 // ----------------------------------------------------
       
   250 //  CNcnMsgWaitingManager::GetFirstIndicatorStatus
       
   251 // ----------------------------------------------------
       
   252 //  
       
   253 void CNcnMsgWaitingManager::GetFirstIndicatorStatus()
       
   254     {
       
   255     Cancel();
       
   256     iState = ENcnGetIndicator;
       
   257 	iStatus = KRequestPending;
       
   258 	iMobilePhone.GetIccMessageWaitingIndicators( iStatus, iMsgWaitingPckg );                          
       
   259 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::GetFirstIndicatorStatus: iMobilePhone.GetIccMessageWaitingIndicators iStatus %d"), iStatus.Int() );		     	
       
   260     SetActive();  
       
   261             
       
   262     NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::GetFirstIndicatorStatus: GetIccMessageWaitingIndicators returned %d"), iStatus.Int() );
       
   263 
       
   264     }
       
   265 
       
   266 // ----------------------------------------------------
       
   267 //  CNcnMsgWaitingManager::~CNcnMsgWaitingManager
       
   268 // ----------------------------------------------------
       
   269 //    
       
   270 CNcnMsgWaitingManager::~CNcnMsgWaitingManager()
       
   271     {
       
   272     Cancel();
       
   273 
       
   274 #ifdef _DEBUG    
       
   275 	if( iObserver )
       
   276 		{
       
   277 	    iObserver->Cancel();
       
   278 	    delete iObserver;			
       
   279 		}
       
   280 #endif
       
   281     
       
   282     iMobilePhone.Close();
       
   283     iTelServer.Close();
       
   284     
       
   285     iReqQueue.Close();
       
   286     }
       
   287 
       
   288 // ----------------------------------------------------
       
   289 //  CNcnMsgWaitingManager::RunL
       
   290 // ----------------------------------------------------
       
   291 // 
       
   292 void CNcnMsgWaitingManager::RunL()
       
   293     {
       
   294 	TInt err = iStatus.Int();
       
   295 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::RunL: iState %d"), iState );
       
   296 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::RunL: return value %d"), err );		
       
   297     NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::RunL: there are %d requests in queue"), iReqQueue.Count() );
       
   298 
       
   299 #ifdef _DEBUG
       
   300     NCN_RDEBUG( _L("CNcnMsgWaitingManager::RunL: Following requests are in queue:") );
       
   301     for( int i = 0; i < iReqQueue.Count(); ++i )
       
   302         {
       
   303         TNcnReqQueueElement elem = iReqQueue[0];	
       
   304         NCN_RDEBUG_INT2( _L("%d: iCmd = %d"), i, elem.iCmd );			
       
   305         NCN_RDEBUG_INT2( _L("%d: iField = %d"), i, elem.iField );			
       
   306         NCN_RDEBUG_INT2( _L("%d: iParam1 = %d"), i, elem.iParam1 );			
       
   307         NCN_RDEBUG_INT2( _L("%d: iParam2 = %d"), i, elem.iParam2 );									
       
   308         }
       
   309 #endif		
       
   310 
       
   311     // Check if there is any requests in work queue. 
       
   312     if( iReqQueue.Count() )		
       
   313         {
       
   314         TNcnReqQueueElement elem = iReqQueue[0];
       
   315         iReqQueue.Remove( 0 );
       
   316 #ifdef _DEBUG
       
   317         NCN_RDEBUG( _L("CNcnMsgWaitingManager::RunL: Handling request:") );
       
   318         NCN_RDEBUG_INT( _L("0: iCmd = %d"), elem.iCmd );			
       
   319         NCN_RDEBUG_INT( _L("0: iField = %d"), elem.iField );			
       
   320         NCN_RDEBUG_INT( _L("0: iParam1 = %d"), elem.iParam1 );			
       
   321         NCN_RDEBUG_INT( _L("0: iParam2 = %d"), elem.iParam2 );									
       
   322 #endif					
       
   323         iState = elem.iCmd;							
       
   324         if( elem.iCmd == ENcnSetCount )
       
   325             {
       
   326             SetMessageCount( (TNcnMessageType)elem.iField, elem.iParam1, elem.iParam2 );
       
   327             }
       
   328         else if( elem.iCmd == ENcnSetIndicator )				
       
   329             {
       
   330             SetIndicator( (TNcnIndicator)elem.iField, elem.iParam1 );					
       
   331             }
       
   332         }
       
   333     else
       
   334         {
       
   335         NCN_RDEBUG( _L("CNcnMsgWaitingManager::RunL: state ENcnIdle") );
       
   336         iState = ENcnIdle;				
       
   337         }		
       
   338     
       
   339     
       
   340     if ( !iConstructionReady )
       
   341         {
       
   342         iConstructionReady = ETrue;
       
   343         iModel.VoiceMailManager().UpdateVMNotifications();
       
   344         
       
   345         }
       
   346     }
       
   347 
       
   348 // ----------------------------------------------------
       
   349 //  CNcnMsgWaitingManager::RunError
       
   350 // ----------------------------------------------------
       
   351 // 
       
   352 TInt CNcnMsgWaitingManager::RunError( TInt aError )
       
   353     {
       
   354 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::RunError: aError %d"), aError );    
       
   355 
       
   356     return aError;
       
   357     }
       
   358 
       
   359 // ----------------------------------------------------
       
   360 //  CNcnMsgWaitingManager::DoCancel
       
   361 // ----------------------------------------------------
       
   362 //  
       
   363 void CNcnMsgWaitingManager::DoCancel()
       
   364     {
       
   365 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::DoCancel: iState %d"), iState );
       
   366     
       
   367     if( IsActive() )
       
   368 	    {
       
   369 		switch( iState )
       
   370 			{
       
   371 			case ENcnGetIndicator:
       
   372 			case ENcnGetCount:
       
   373 				iMobilePhone.CancelAsyncRequest( EMobilePhoneGetIccMessageWaitingIndicators );
       
   374 				iState = ENcnIdle;
       
   375 				break;
       
   376 			case ENcnSetIndicator:
       
   377 			case ENcnSetCount:
       
   378 				iMobilePhone.CancelAsyncRequest( EMobilePhoneSetIccMessageWaitingIndicators );
       
   379 				iState = ENcnIdle;
       
   380 				break;
       
   381 			case ENcnNotifyMsgWaiting:
       
   382 				iMobilePhone.CancelAsyncRequest( EMobilePhoneNotifyIccMessageWaitingIndicatorsChange );
       
   383 				iState = ENcnIdle;
       
   384 				break;
       
   385 			default:
       
   386 				break;						
       
   387 			}    	    	
       
   388 	    }
       
   389     }
       
   390 
       
   391 
       
   392 // ----------------------------------------------------
       
   393 //  CNcnMsgWaitingManager::SetIndicator
       
   394 // ----------------------------------------------------
       
   395 //  
       
   396 TInt CNcnMsgWaitingManager::SetIndicator( 
       
   397     const TNcnIndicator aIndicator, 
       
   398     TBool aEnable )
       
   399     {    
       
   400 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::SetIndicator: iState %d"), iState );
       
   401 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::SetIndicator: indicator %d"), aIndicator );
       
   402 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::SetIndicator: enable %d"), aEnable );	
       
   403 		
       
   404     switch( aIndicator )
       
   405 	    {
       
   406 		case ENcnIndicatorFax:
       
   407 			DoSetIndicator( RMobilePhone::KDisplayFaxActive, aEnable );			
       
   408 			break;
       
   409 			
       
   410 		case ENcnIndicatorEmail:
       
   411 			DoSetIndicator( RMobilePhone::KDisplayEmailActive, aEnable );			
       
   412 			break;
       
   413 			
       
   414 		case ENcnIndicatorOther:
       
   415 			DoSetIndicator( RMobilePhone::KDisplayOtherActive, aEnable );	
       
   416 			break;
       
   417 						
       
   418 		case ENcnIndicatorVMLine1:
       
   419 			DoSetIndicator( RMobilePhone::KDisplayVoicemailActive, aEnable );		
       
   420 			break;
       
   421 			
       
   422 		case ENcnIndicatorVMLine2:
       
   423 			DoSetIndicator( RMobilePhone::KDisplayAuxVoicemailActive, aEnable );
       
   424 			break;  
       
   425 	    
       
   426 		default:
       
   427 			break;	    	
       
   428 	    }
       
   429     
       
   430     if( IsActive() )
       
   431 	    {
       
   432 	    NCN_RDEBUG( _L("CNcnMsgWaitingManager::SetIndicator: Already actived. Adding request to queue") );
       
   433 		TNcnReqQueueElement elem( ENcnSetIndicator, aIndicator, aEnable );
       
   434 		iReqQueue.Append( elem );
       
   435 	    }
       
   436 	else
       
   437 		{
       
   438 		NCN_RDEBUG( _L("CNcnMsgWaitingManager::SetIndicator: Activating waiting manager") );
       
   439 	    iState = ENcnSetIndicator;
       
   440 		iStatus = KRequestPending;	    
       
   441 	    iMobilePhone.SetIccMessageWaitingIndicators( iStatus, iMsgWaitingPckg );	    
       
   442 	    SetActive();	    	   
       
   443 	    NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::SetIndicator: iStatus %d"), iStatus.Int() );	    			
       
   444 		}	    
       
   445 
       
   446     return KErrNone;
       
   447     }
       
   448       
       
   449 // ----------------------------------------------------
       
   450 //  CNcnMsgWaitingManager::DoSetIndicator
       
   451 // ----------------------------------------------------
       
   452 //          
       
   453 void CNcnMsgWaitingManager::DoSetIndicator( TInt aId, TBool aEnable )        
       
   454 	{	
       
   455 	NCN_RDEBUG( _L("CNcnMsgWaitingManager::DoSetIndicator") );
       
   456 	if( aEnable )		
       
   457 		{
       
   458 		iMsgWaiting.iDisplayStatus |= aId;			
       
   459 		}
       
   460 	else
       
   461 		{
       
   462 		iMsgWaiting.iDisplayStatus &= ~ aId;					
       
   463 		}		
       
   464 	}
       
   465       
       
   466 // ----------------------------------------------------
       
   467 //  CNcnMsgWaitingManager::SetMessageCount
       
   468 // ----------------------------------------------------
       
   469 //                  
       
   470 TInt CNcnMsgWaitingManager::SetMessageCount( 
       
   471     const TNcnMessageType aMsgType, 
       
   472     TUint aCount,
       
   473     TBool aEnableIndicator )
       
   474     {    
       
   475 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::SetMessageCount: iState %d"), iState );
       
   476 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::SetMessageCount: message type %d"), aMsgType );
       
   477 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::SetMessageCount: message count %d"), aCount );
       
   478 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::SetMessageCount: enable indicator %d"), aEnableIndicator );	
       
   479 						
       
   480     switch( aMsgType )
       
   481 	    {
       
   482 		case ENcnMessageTypeFax:
       
   483 			DoSetIndicator( RMobilePhone::KDisplayFaxActive, aEnableIndicator );
       
   484 			iMsgWaiting.iFaxMsgs = aCount;			
       
   485 			break;
       
   486 			
       
   487 		case ENcnMessageTypeEmail:
       
   488 			DoSetIndicator( RMobilePhone::KDisplayEmailActive, aEnableIndicator );
       
   489 			iMsgWaiting.iEmailMsgs = aCount;			
       
   490 			break;
       
   491 			
       
   492 		case ENcnMessageTypeOther:
       
   493 			DoSetIndicator( RMobilePhone::KDisplayOtherActive, aEnableIndicator );	
       
   494 			iMsgWaiting.iOtherMsgs = aCount;
       
   495 			break;
       
   496 						
       
   497 		case ENcnMessageTypeVMLine1:
       
   498 			DoSetIndicator( RMobilePhone::KDisplayVoicemailActive, aEnableIndicator );
       
   499 			iMsgWaiting.iVoiceMsgs = aCount;					
       
   500 			break;
       
   501 			
       
   502 		case ENcnMessageTypeVMLine2:
       
   503 			DoSetIndicator( RMobilePhone::KDisplayAuxVoicemailActive, aEnableIndicator );
       
   504 			iMsgWaiting.iAuxVoiceMsgs = aCount;			
       
   505 			break;  
       
   506 	    
       
   507 		default:
       
   508 			break;	    	
       
   509 	    }	   	    
       
   510 
       
   511 	if( IsActive() )
       
   512 		{
       
   513 	    NCN_RDEBUG( _L("CNcnMsgWaitingManager::SetMessageCount: Already actived. Adding request to queue") );		
       
   514 		TNcnReqQueueElement elem( ENcnSetCount, aMsgType, aEnableIndicator, aCount );
       
   515 		iReqQueue.Append( elem );					
       
   516 		}
       
   517 	else
       
   518 		{
       
   519 		NCN_RDEBUG( _L("CNcnMsgWaitingManager::SetMessageCount: Activating waiting manager") );		
       
   520 	    iState = ENcnSetCount;
       
   521 		iStatus = KRequestPending;	    
       
   522 	    iMobilePhone.SetIccMessageWaitingIndicators( iStatus, iMsgWaitingPckg );	    
       
   523 	    SetActive();	    
       
   524 	    NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::SetMessageCount: iStatus %d"), iStatus.Int() );	    			
       
   525 		}		
       
   526 
       
   527     return KErrNone;
       
   528     }
       
   529 
       
   530 // ----------------------------------------------------
       
   531 //  CNcnMsgWaitingManager::GetMessageCount
       
   532 // ----------------------------------------------------
       
   533 //      
       
   534 TInt CNcnMsgWaitingManager::GetMessageCount( const TNcnMessageType aMsgType, TUint &aCount )
       
   535     {
       
   536 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::GetMessageCount: iState %d"), iState );
       
   537 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::GetMessageCount: message type %d"), aMsgType );
       
   538     
       
   539 	// Is there a need to refresh message counts at this point?	
       
   540     switch( aMsgType )
       
   541 	    {
       
   542 		case ENcnMessageTypeFax:
       
   543 			aCount = iMsgWaiting.iFaxMsgs;			
       
   544 			break;
       
   545 			
       
   546 		case ENcnMessageTypeEmail:
       
   547 			aCount = iMsgWaiting.iEmailMsgs;
       
   548 			break;
       
   549 			
       
   550 		case ENcnMessageTypeOther:
       
   551 			aCount = iMsgWaiting.iOtherMsgs;
       
   552 			break;
       
   553 						
       
   554 		case ENcnMessageTypeVMLine1:
       
   555 			aCount = iMsgWaiting.iVoiceMsgs;
       
   556 			break;
       
   557 			
       
   558 		case ENcnMessageTypeVMLine2:
       
   559 			aCount = iMsgWaiting.iAuxVoiceMsgs;
       
   560 			break;  
       
   561 	    
       
   562 		default:
       
   563 			break;	    	
       
   564 	    }
       
   565 	    
       
   566 	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::GetMessageCount: message count %d"), aCount );	    	
       
   567 
       
   568     return KErrNone;
       
   569     }                    
       
   570             
       
   571 // ----------------------------------------------------
       
   572 //  CNcnMsgWaitingManager::GetIndicator
       
   573 // ----------------------------------------------------
       
   574 //    
       
   575 TInt CNcnMsgWaitingManager::GetIndicator( const TNcnIndicator aIndicator, TBool& aEnabled )
       
   576     {
       
   577  	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::GetIndicator: iState %d"), iState );
       
   578  	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::GetIndicator: aIndicator %d"), aIndicator );
       
   579  
       
   580     switch( aIndicator )
       
   581 	    {
       
   582 		case ENcnIndicatorFax:
       
   583 			aEnabled = ( iMsgWaiting.iDisplayStatus & RMobilePhone::KDisplayFaxActive ) ? ETrue : EFalse;
       
   584 			break;
       
   585 			
       
   586 		case ENcnIndicatorEmail:
       
   587 			aEnabled = ( iMsgWaiting.iDisplayStatus & RMobilePhone::KDisplayEmailActive ) ? ETrue : EFalse;		
       
   588 			break;
       
   589 			
       
   590 		case ENcnIndicatorOther:
       
   591 			aEnabled = ( iMsgWaiting.iDisplayStatus & RMobilePhone::KDisplayOtherActive ) ? ETrue : EFalse;				
       
   592 			break;
       
   593 						
       
   594 		case ENcnIndicatorVMLine1:
       
   595 			aEnabled = ( iMsgWaiting.iDisplayStatus & RMobilePhone::KDisplayVoicemailActive ) ? ETrue : EFalse;		
       
   596 			break;
       
   597 			
       
   598 		case ENcnIndicatorVMLine2:
       
   599 			aEnabled = ( iMsgWaiting.iDisplayStatus & RMobilePhone::KDisplayAuxVoicemailActive ) ? ETrue : EFalse;		
       
   600 			break;  
       
   601 	    
       
   602 		default:
       
   603 			break;	    	
       
   604 	    }
       
   605 	        
       
   606  	NCN_RDEBUG_INT( _L("CNcnMsgWaitingManager::GetIndicator: indicator state %d"), aEnabled );	        	        
       
   607 
       
   608     return KErrNone;
       
   609     }
       
   610 
       
   611 // ----------------------------------------------------
       
   612 //  CNcnMsgWaitingManager::ConstructionReady
       
   613 // ----------------------------------------------------
       
   614 //    
       
   615 TBool CNcnMsgWaitingManager::ConstructionReady()
       
   616     {
       
   617     return iConstructionReady;
       
   618     }
       
   619 
       
   620 
       
   621 
       
   622 //  End of File