idlefw/plugins/devicestatus/src/aioperatornamepublisher.cpp
branchRCL_3
changeset 114 a5a39a295112
child 118 8baec10861af
equal deleted inserted replaced
113:0efa10d348c0 114:a5a39a295112
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Operator/Service provider name publisher.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <StringLoader.h>
       
    20 #include <centralrepository.h>
       
    21 #include <avkondomainpskeys.h>
       
    22 #include <e32property.h>
       
    23 #include <aidevicestatuscontentmodel.h>
       
    24 #include <ProEngFactory.h>
       
    25 #include <MProfileEngine.h>
       
    26 #include <MProfile.h>
       
    27 #include <MProfileName.h>
       
    28 #include <MProEngNotifyHandler.h>
       
    29 
       
    30 #include <aidevstaplgres.rsg>
       
    31 #include "aioperatornamepublisher.h"
       
    32 #include "ainetworkinfolistener.h"
       
    33 #include "aiprioritizer.h"
       
    34 #include "ainwidpriorities.h"
       
    35 #include "activeidle2domaincrkeys.h"
       
    36 
       
    37 //Delay used to animate
       
    38 const TInt KCleanOperationDelay = 2 * 1000000;
       
    39 
       
    40 
       
    41 const TInt KBitShiftByFour = 4;
       
    42 const TInt KIsDigitLowLimit = 0;
       
    43 const TInt KIsDigitHighLimit = 10;
       
    44 const TInt KOfflineProfileId =  5;
       
    45 
       
    46 LOCAL_C void AppendDigit( TDes& aCode, TInt aValue )
       
    47     {
       
    48     // add a digit if valid value.
       
    49     if ( aValue >= KIsDigitLowLimit && aValue < KIsDigitHighLimit )
       
    50         {
       
    51         aCode.AppendNumUC( static_cast<TUint8>( aValue ) );
       
    52         }
       
    53     }
       
    54 
       
    55 
       
    56 //Convert string to integer.
       
    57 LOCAL_C TInt StrToInt( const TDesC& aDesc )
       
    58     {
       
    59     TLex lex( aDesc );
       
    60 
       
    61     TInt ret;
       
    62     TInt err = lex.Val( ret );
       
    63 
       
    64     if( err != KErrNone )
       
    65         {
       
    66         ret = KErrNotFound;
       
    67         }
       
    68     return ret;
       
    69     }
       
    70 
       
    71 
       
    72 // ======== MEMBER FUNCTIONS ========
       
    73 
       
    74 CAiOperatorNamePublisher::CAiOperatorNamePublisher()
       
    75 : iPriority( EAiInvalidPriority )
       
    76     {
       
    77     }
       
    78 
       
    79 
       
    80 void CAiOperatorNamePublisher::ConstructL()
       
    81     {
       
    82     iListener = CAiNetworkInfoListener::InstanceL();
       
    83     iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard );
       
    84     iProfileEngine = CreateProfileEngineL();
       
    85     iProfileNotifier = ProEngFactory::NewNotifyHandlerL();
       
    86     iProfileNotifier->RequestProfileActivationNotificationsL( *this );
       
    87     }
       
    88 
       
    89 
       
    90 CAiOperatorNamePublisher* CAiOperatorNamePublisher::NewL()
       
    91     {
       
    92     CAiOperatorNamePublisher* self = new( ELeave ) CAiOperatorNamePublisher;
       
    93     CleanupStack::PushL( self );
       
    94     self->ConstructL();
       
    95     CleanupStack::Pop( self );
       
    96     return self;
       
    97     }
       
    98 
       
    99 
       
   100 CAiOperatorNamePublisher::~CAiOperatorNamePublisher()
       
   101     {
       
   102     if( iListener )
       
   103         {
       
   104 	    iListener->RemoveObserver( *this );
       
   105         iListener->Release();
       
   106         }
       
   107     if( iPeriodic )
       
   108         {
       
   109         iPeriodic->Cancel();
       
   110         delete iPeriodic;
       
   111         }
       
   112     if ( iProfileNotifier )
       
   113         {
       
   114         iProfileNotifier->CancelAll();
       
   115         delete iProfileNotifier;
       
   116         }
       
   117     if( iProfileEngine )
       
   118         {
       
   119         iProfileEngine->Release();
       
   120         }
       
   121     }
       
   122 
       
   123 
       
   124 void CAiOperatorNamePublisher::ResumeL()
       
   125     {
       
   126     iListener->AddObserverL( *this );
       
   127     }
       
   128 
       
   129 
       
   130 void CAiOperatorNamePublisher::HandleNetworkInfoChange(
       
   131                 const MNWMessageObserver::TNWMessages& /*aMessage*/,
       
   132                 const TNWInfo& /*aInfo*/,
       
   133                 const TBool aShowOpInd )
       
   134     {
       
   135     if ( iSuspended )
       
   136         {
       
   137         return;
       
   138         }
       
   139     
       
   140     if( aShowOpInd )
       
   141         {
       
   142         TRAP_IGNORE  ( RefreshL( ETrue ));
       
   143         }
       
   144     else
       
   145         {
       
   146         if ( iProfileEngine->ActiveProfileId() != KOfflineProfileId )
       
   147             {
       
   148             TRAP_IGNORE (
       
   149                 iPrioritizer->TryToCleanL( *iBroadcaster,
       
   150                                         EAiDeviceStatusContentNetworkIdentity,
       
   151                                         iPriority ));
       
   152             }
       
   153         }    
       
   154     }
       
   155 
       
   156 
       
   157 void CAiOperatorNamePublisher::Subscribe( MAiContentObserver& /*aObserver*/,
       
   158 									                CHsContentPublisher& aExtension,
       
   159                                                     MAiPublishPrioritizer& aPrioritizer,
       
   160                                                     MAiPublisherBroadcaster& aBroadcaster )
       
   161     {
       
   162     iExtension = &aExtension;
       
   163     iPrioritizer = &aPrioritizer;
       
   164     iBroadcaster = &aBroadcaster;
       
   165     }
       
   166 
       
   167 void CAiOperatorNamePublisher::RefreshIfActiveL( TBool aClean )
       
   168     {
       
   169     if ( !iSuspended )
       
   170         {
       
   171         RefreshL( aClean );
       
   172         }
       
   173     }
       
   174 
       
   175 void CAiOperatorNamePublisher::RefreshL( TBool aClean )
       
   176     {
       
   177     iSuccess = EFalse;
       
   178 
       
   179     if ( iSuspended )
       
   180         {
       
   181         return;
       
   182         }
       
   183     
       
   184     if ( iProfileEngine->ActiveProfileId() == KOfflineProfileId )
       
   185         {
       
   186         MProfile* profile = iProfileEngine->ActiveProfileLC();
       
   187         const MProfileName& name = profile->ProfileName();
       
   188         iPrioritizer->TryToPublishL( *iBroadcaster,
       
   189                                       EAiDeviceStatusContentNetworkIdentity,
       
   190                                       name.Name(),
       
   191                                       iPriority );
       
   192         iSuccess = ETrue;
       
   193         CleanupStack::PopAndDestroy();//profile
       
   194         return;
       
   195         }
       
   196     
       
   197     if( aClean )
       
   198         {
       
   199         iPrioritizer->TryToCleanL( *iBroadcaster,
       
   200                                     EAiDeviceStatusContentNetworkIdentity,
       
   201                                     iPriority );
       
   202         }
       
   203 
       
   204     const TNWInfo& nwInfo = iListener->NetworkInfo();
       
   205 
       
   206 #if defined(WINSCW) || defined(__WINS__)
       
   207     // Show operator name in emulator
       
   208 #else
       
   209     if ( nwInfo.iRegistrationStatus == ENWNotRegisteredNoService ||
       
   210     	 	nwInfo.iRegistrationStatus == ENWRegistrationUnknown ||
       
   211     	 	!iListener->IsOperatorIndicatorAllowed() )
       
   212     	{
       
   213     	return;
       
   214     	}
       
   215 #endif
       
   216 
       
   217     TBool showSimultaneously = EFalse;
       
   218 
       
   219     TUid uid = { KCRUidActiveIdleLV };
       
   220     CRepository* cenRep = CRepository::NewLC( uid );
       
   221     TInt err = cenRep->Get( KAISPNAndEONS, showSimultaneously );
       
   222     if( err )
       
   223     	{
       
   224     	showSimultaneously = EFalse;
       
   225     	}
       
   226     CleanupStack::PopAndDestroy( cenRep );
       
   227     
       
   228     const TBool isKeyLockEnabled = IsKeyLockEnabled();
       
   229 
       
   230     //Check if PLMN  must be shown.
       
   231 
       
   232     const TBool showPLMN = nwInfo.iServiceProviderNameDisplayReq & ENWDisplayPLMNRequired;
       
   233 
       
   234     TBool isInSPDI = EFalse;
       
   235     TBool showSPN = EFalse;
       
   236 
       
   237     //Check if we are in SPDI and SPN (Service Provider Name) must be shown.
       
   238     CheckServiceProviderDisplayListStatus(  StrToInt( nwInfo.iCountryCode ),
       
   239                                             StrToInt( nwInfo.iNetworkId ),
       
   240                                             showSPN,
       
   241                                             isInSPDI );
       
   242 
       
   243     //SPN must be shown if it is defined in PLMNField or if it is set in service provider name
       
   244     //display requirements.
       
   245     showSPN =
       
   246         showSPN ||
       
   247         ( nwInfo.iServiceProviderNameDisplayReq & ENWDisplaySPNRequired );
       
   248 
       
   249     
       
   250 #if defined(WINSCW) || defined(__WINS__)
       
   251     _LIT( KOperator, "Operator" );    
       
   252     const TPtrC serviceProviderName( KOperator() );
       
   253 #else
       
   254     const TPtrC serviceProviderName = nwInfo.iSPName;
       
   255 #endif
       
   256         
       
   257     if ( ( !IsRoaming() || isInSPDI ) && serviceProviderName.Length() )
       
   258         {
       
   259         if ( showPLMN )
       
   260             {
       
   261             if ( showSimultaneously )
       
   262             	{
       
   263             	//spn & plmn (SPN.And.EONS)
       
   264             	HBufC* operatorName = ConstructOperatorNameStringL( serviceProviderName );
       
   265             	CleanupStack::PushL( operatorName );
       
   266 
       
   267             	iPriority = EAiServiceProviderName;
       
   268 	            iPrioritizer->TryToPublishL( *iBroadcaster,
       
   269 	                                        	EAiDeviceStatusContentNetworkIdentity,
       
   270 	                                        	operatorName->Des(),
       
   271 	                                        	iPriority );
       
   272 	            CleanupStack::PopAndDestroy(operatorName);
       
   273             	}
       
   274             else if( isKeyLockEnabled )
       
   275             	{
       
   276             	//only plmn
       
   277         		ShowNetworkIdentityNameL( ETrue );
       
   278             	}
       
   279             else
       
   280             	{
       
   281 	            //spn & plmn (SPN.And.EONS.No)
       
   282 	            iPriority = EAiServiceProviderName;
       
   283 	            iPrioritizer->TryToPublishL( *iBroadcaster,
       
   284 	                                        	EAiDeviceStatusContentNetworkIdentity,
       
   285 	                                        	serviceProviderName,
       
   286 	                                        	iPriority );
       
   287 	            StartDelayedPLMNOperation();//to publish PLMN name
       
   288             	}
       
   289             }
       
   290         else
       
   291             {
       
   292             //only spn
       
   293             iPriority = EAiServiceProviderName;
       
   294             iPrioritizer->TryToPublishL( *iBroadcaster,
       
   295                                             EAiDeviceStatusContentNetworkIdentity,
       
   296                                             serviceProviderName,
       
   297                                             iPriority );
       
   298             iSuccess = ETrue;
       
   299             }
       
   300         }
       
   301     else
       
   302         {
       
   303         if ( showSPN && serviceProviderName.Length() )
       
   304             {
       
   305             if ( showSimultaneously )
       
   306             	{
       
   307             	//spn & plmn (SPN.And.EONS)
       
   308             	HBufC* operatorName = ConstructOperatorNameStringL( serviceProviderName );
       
   309             	CleanupStack::PushL( operatorName );
       
   310 
       
   311             	iPriority = EAiServiceProviderName;
       
   312 	            iPrioritizer->TryToPublishL( *iBroadcaster,
       
   313 	                                        	EAiDeviceStatusContentNetworkIdentity,
       
   314 	                                        	operatorName->Des(),
       
   315 	                                        	iPriority );
       
   316 	            CleanupStack::PopAndDestroy(operatorName);
       
   317             	}
       
   318             else if( isKeyLockEnabled )
       
   319             	{
       
   320             	//only plmn
       
   321         		ShowNetworkIdentityNameL( ETrue );
       
   322             	}
       
   323             else
       
   324             	{
       
   325 	            //spn & plmn (SPN.And.EONS.No)
       
   326 	            iPriority = EAiServiceProviderName;
       
   327 	            iPrioritizer->TryToPublishL( *iBroadcaster,
       
   328 	                                        	EAiDeviceStatusContentNetworkIdentity,
       
   329 	                                        	serviceProviderName,
       
   330 	                                        	iPriority );
       
   331 	            StartDelayedPLMNOperation();//to publish PLMN name
       
   332             	}
       
   333             }
       
   334 		else
       
   335         	{
       
   336         	//only plmn
       
   337         	ShowNetworkIdentityNameL( ETrue );
       
   338         	}
       
   339         }
       
   340     }
       
   341 
       
   342 HBufC* CAiOperatorNamePublisher::ConstructOperatorNameStringL( const TDesC& aServiceProviderName )
       
   343 	{
       
   344 	ShowNetworkIdentityNameL( EFalse );
       
   345 
       
   346     CCoeEnv* coeEnv = CCoeEnv::Static();
       
   347     HBufC* opnSpnFormatString = StringLoader::LoadLC( R_AI_OPN_SPN_SEPARATOR_FORMAT,
       
   348             													coeEnv );
       
   349     HBufC* opnSpnStringTemp = HBufC::NewLC( iNetworkIdentityName.Length()
       
   350             									+ opnSpnFormatString->Length()
       
   351             									+ aServiceProviderName.Length() );
       
   352 
       
   353     HBufC* opnSpnString = HBufC::NewLC( iNetworkIdentityName.Length()
       
   354             									+ opnSpnFormatString->Length()
       
   355             									+ aServiceProviderName.Length() );
       
   356 
       
   357     TPtr opnSpnStringTempPtr = opnSpnStringTemp->Des();
       
   358     StringLoader::Format( opnSpnStringTempPtr,
       
   359     					*opnSpnFormatString,
       
   360     					1,
       
   361     					aServiceProviderName );
       
   362 
       
   363     TPtr opnSpnStringPtr = opnSpnString->Des();
       
   364 	StringLoader::Format( opnSpnStringPtr,
       
   365 						  opnSpnStringTempPtr,
       
   366 						  0,
       
   367 						  iNetworkIdentityName );
       
   368 
       
   369 	CleanupStack::Pop( opnSpnString );
       
   370 	CleanupStack::PopAndDestroy( opnSpnStringTemp ); //opnSpnStringTemp, opnSpnFormatString
       
   371 	CleanupStack::PopAndDestroy( opnSpnFormatString );
       
   372 
       
   373 	return opnSpnString;
       
   374 	}
       
   375 
       
   376 
       
   377 
       
   378 void CAiOperatorNamePublisher::ShowNetworkIdentityNameL( TBool aTryToPublish )
       
   379 	{
       
   380 	const TNWInfo& nwInfo = iListener->NetworkInfo();
       
   381 
       
   382 	iNetworkIdentityName.Set( KNullDesC );
       
   383 
       
   384 	iPriority = EAiInvalidPriority;
       
   385 
       
   386 	// *** Network operator name (CPHS-ONS) ***
       
   387     if( nwInfo.iNPName.Length() > 0 &&
       
   388     		nwInfo.iOperatorNameInfo.iType != RMmCustomAPI::EOperatorNameFlexiblePlmn  &&
       
   389     			nwInfo.iRegistrationStatus == ENWRegisteredOnHomeNetwork )
       
   390     	{
       
   391     	//priority
       
   392     	iPriority = EAiNetworkOperatorName;
       
   393     	//name
       
   394     	iNetworkIdentityName.Set( nwInfo.iNPName );
       
   395     	//publish network identity name
       
   396     	if( aTryToPublish )
       
   397     		{
       
   398 			iPrioritizer->TryToPublishL( *iBroadcaster,
       
   399                                	   		EAiDeviceStatusContentNetworkIdentity,
       
   400                                     	iNetworkIdentityName,
       
   401                                     	iPriority );
       
   402     		}
       
   403 
       
   404         iSuccess = ETrue;
       
   405     	return;
       
   406     	}
       
   407 
       
   408     // *** Operator name ***
       
   409     if( nwInfo.iOperatorNameInfo.iName.Length() > 0 )
       
   410     	{
       
   411     	//priority
       
   412     	OperatorNamePriority( iPriority );
       
   413     	//name
       
   414     	iNetworkIdentityName.Set( nwInfo.iOperatorNameInfo.iName );
       
   415     	//converted name
       
   416 	    HBufC* convertedOperatorName = NULL;
       
   417 
       
   418 	    if ( nwInfo.iOperatorNameInfo.iType == RMmCustomAPI::EOperatorNameFlexiblePlmn )
       
   419 	        {
       
   420 	        // Long & short name may be in the same buffer.
       
   421 	        const TInt separatorPos = iNetworkIdentityName.Locate( KFlexibleNameSeparator );
       
   422 	        if ( separatorPos != KErrNotFound )
       
   423 	            {
       
   424 	            convertedOperatorName = nwInfo.iOperatorNameInfo.iName.Left( separatorPos ).AllocLC();
       
   425 	            }
       
   426 	        }
       
   427 	    else if ( nwInfo.iOperatorNameInfo.iType ==
       
   428 	                  RMmCustomAPI::EOperatorNameMccMnc ||
       
   429 	              nwInfo.iOperatorNameInfo.iType ==
       
   430 	                  RMmCustomAPI::EOperatorNameCountryMcn )
       
   431 	        {
       
   432 	        // Perform display language specific conversion.
       
   433 	        convertedOperatorName = nwInfo.iOperatorNameInfo.iName.AllocLC();
       
   434 	        TPtr ptr = convertedOperatorName->Des();
       
   435 	        AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );
       
   436 	        }
       
   437 	    else
       
   438 	        {
       
   439 	        // No changes needed.
       
   440 	        }
       
   441 
       
   442 		if ( convertedOperatorName )
       
   443 	        {
       
   444 	        iNetworkIdentityName.Set( *convertedOperatorName );
       
   445 	        }
       
   446 
       
   447 		if( iPriority != EAiInvalidPriority )
       
   448 			{
       
   449 			//Publish network identity name
       
   450 			if( aTryToPublish )
       
   451     			{
       
   452 				iPrioritizer->TryToPublishL( *iBroadcaster,
       
   453 	                               			EAiDeviceStatusContentNetworkIdentity,
       
   454 	                                		iNetworkIdentityName,
       
   455 	                                		iPriority );
       
   456     			}
       
   457 
       
   458 	        iSuccess = ETrue;
       
   459 			}
       
   460 
       
   461 		if ( convertedOperatorName )
       
   462 	        {
       
   463 	        CleanupStack::PopAndDestroy( convertedOperatorName );
       
   464 	        convertedOperatorName = NULL;
       
   465 	        }
       
   466 
       
   467 		if( iPriority != EAiInvalidPriority )
       
   468 	    	{
       
   469 	    	return;
       
   470 	    	}
       
   471 	    }
       
   472 
       
   473 	// *** Network info name ***
       
   474 	if( iPriority == EAiInvalidPriority )
       
   475 		{
       
   476 	    //priority
       
   477 	    iPriority = EAiOperatorNetInfoName;
       
   478 
       
   479 	    if ( nwInfo.iLongName.Length() > 0 )
       
   480 			{
       
   481 		    iNetworkIdentityName.Set( nwInfo.iLongName );
       
   482 		    }
       
   483 		else if ( nwInfo.iShortName.Length() > 0 )
       
   484 		    {
       
   485 		    iNetworkIdentityName.Set( nwInfo.iShortName );
       
   486 		    }
       
   487 		else if ( nwInfo.iDisplayTag.Length() > 0 )
       
   488 		    {
       
   489 		    iNetworkIdentityName.Set( nwInfo.iDisplayTag );
       
   490 		    }
       
   491 		else
       
   492 		   	{
       
   493 		    iPriority = EAiInvalidPriority;
       
   494 		    }
       
   495 
       
   496 		//Publish network identity name
       
   497 		if( aTryToPublish )
       
   498     		{
       
   499 			iPrioritizer->TryToPublishL( *iBroadcaster,
       
   500 	                               		EAiDeviceStatusContentNetworkIdentity,
       
   501 	                                	iNetworkIdentityName,
       
   502 	                                	iPriority );
       
   503     		}
       
   504 
       
   505 	    iSuccess = ETrue;
       
   506 	    return;
       
   507 	    }
       
   508 	}
       
   509 
       
   510 
       
   511 void CAiOperatorNamePublisher::CheckServiceProviderDisplayListStatus(
       
   512     TInt aMCC,
       
   513     TInt aMNC,
       
   514     TBool& aShowSPN,
       
   515     TBool& aIsInSPDI ) const
       
   516     {
       
   517 
       
   518     // Not in list by default
       
   519     aIsInSPDI = EFalse;
       
   520     aShowSPN = EFalse;
       
   521 
       
   522     if ( !CurrentNetworkOk() )
       
   523         {
       
   524         return;
       
   525         }
       
   526 
       
   527 
       
   528     const TNWInfo& nwInfo = iListener->NetworkInfo();
       
   529 
       
   530     TInt bufferLength = nwInfo.iPLMNField.Length();
       
   531      if ( !bufferLength )
       
   532         {
       
   533         return;
       
   534         }
       
   535 
       
   536     const TUint8* field =
       
   537         reinterpret_cast< const TUint8* >( nwInfo.iPLMNField.Ptr() );
       
   538 
       
   539     TInt octetIndex = 0;
       
   540 
       
   541     // Update SPN showing. (in 3GPP a tag).
       
   542     aShowSPN = static_cast<TUint8>( field[ octetIndex ] ) ? EFalse : ETrue ;
       
   543     octetIndex++;
       
   544 
       
   545     // Number of PLMN pairs. (in 3GPP number of octets).
       
   546     const TUint8 length = static_cast<TUint8>( ( field[ octetIndex ] ) );
       
   547     octetIndex++;
       
   548 
       
   549     // Empty list (always with SIM and sometimes with UICC)
       
   550     if ( !( length > 0 ) )
       
   551         {
       
   552         return;
       
   553         }
       
   554 
       
   555     // Compare MCC&MNC pairs
       
   556     TNWCountryCode mcc;
       
   557     TNWIdentity    mnc;
       
   558 
       
   559     const TUint numberOfPairs = length;      // each pair has 3 octets
       
   560 
       
   561     for( TUint pair = 0; pair < numberOfPairs; pair++ )
       
   562         {
       
   563         // 1st octet
       
   564         AppendDigit( mcc, field[ octetIndex ] & 0x0F );
       
   565         AppendDigit( mcc, ( field[ octetIndex ] & 0xF0 ) >> KBitShiftByFour );
       
   566         octetIndex++;
       
   567 
       
   568         // 2nd octet
       
   569         AppendDigit( mcc, field[ octetIndex ] & 0x0F );
       
   570         TInt tmp = ( field[ octetIndex ] & 0xF0 ) >> KBitShiftByFour;
       
   571         octetIndex++;
       
   572 
       
   573         // 3rd octet
       
   574         AppendDigit( mnc, field[ octetIndex ] & 0x0F );
       
   575         AppendDigit( mnc, ( field[ octetIndex ] & 0xF0 ) >> KBitShiftByFour );
       
   576         octetIndex++;
       
   577 
       
   578         AppendDigit( mnc, tmp ); // mnc 3rd digit.
       
   579 
       
   580         TInt imcc = StrToInt( mcc );
       
   581         TInt imnc = StrToInt( mnc );
       
   582 
       
   583         if ( ( aMNC == imnc ) && ( aMCC == imcc ) )
       
   584             {
       
   585             // match.
       
   586             aIsInSPDI = ETrue;
       
   587             break;
       
   588             }
       
   589 
       
   590 
       
   591         // Reset
       
   592         mnc.Zero();
       
   593         mcc.Zero();
       
   594         }
       
   595     }
       
   596 
       
   597 
       
   598 TBool CAiOperatorNamePublisher::CurrentNetworkOk() const
       
   599     {
       
   600     TBool ok = iListener->MessageReceived(
       
   601                             MNWMessageObserver::ENWMessageNetworkInfoChange ) ||
       
   602                iListener->MessageReceived(
       
   603                             MNWMessageObserver::ENWMessageNetworkRegistrationStatusChange );
       
   604 
       
   605     ok = ok & ( iListener->NetworkInfo().iStatus == ENWStatusCurrent );
       
   606 
       
   607     return ok;
       
   608     }
       
   609 
       
   610 
       
   611 TBool CAiOperatorNamePublisher::IsRoaming() const
       
   612     {
       
   613     const TNWInfo& nwInfo = iListener->NetworkInfo();
       
   614 
       
   615     return iListener->MessageReceived(
       
   616                 MNWMessageObserver::ENWMessageNetworkRegistrationStatusChange ) &&
       
   617            ( nwInfo.iRegistrationStatus == ENWRegisteredRoaming );
       
   618     }
       
   619 
       
   620 
       
   621 
       
   622 void CAiOperatorNamePublisher::StartDelayedPLMNOperation()
       
   623     {
       
   624     if( !iPeriodic->IsActive() )
       
   625         {
       
   626         iPeriodic->Start( KCleanOperationDelay,
       
   627                           KCleanOperationDelay,
       
   628                           TCallBack( CleanAndShowPLMNOperationCallback, this ) );
       
   629         }
       
   630     }
       
   631 
       
   632 
       
   633 TInt CAiOperatorNamePublisher::CleanAndShowPLMNOperationCallback( TAny* aPtr )
       
   634     {
       
   635     CAiOperatorNamePublisher* self =
       
   636                     static_cast<CAiOperatorNamePublisher*>( aPtr );
       
   637 
       
   638     if( self )
       
   639         {
       
   640         self->iPeriodic->Cancel();
       
   641 		// check if got suspended while timer was active
       
   642         if ( !self->iSuspended )
       
   643             {
       
   644             TRAP_IGNORE
       
   645                 (
       
   646                 //clean
       
   647                 self->DoCleanOperationL();
       
   648                 //show PLMN name
       
   649                 self->ShowNetworkIdentityNameL( ETrue );
       
   650                 );
       
   651             }
       
   652         }
       
   653 
       
   654     return KErrNone;
       
   655     }
       
   656 
       
   657 
       
   658 void CAiOperatorNamePublisher::DoCleanOperationL()
       
   659     {
       
   660     iPrioritizer->TryToCleanL( *iBroadcaster,
       
   661                                 EAiDeviceStatusContentNetworkIdentity,
       
   662                                 EAiServiceProviderName );
       
   663     }
       
   664 
       
   665 
       
   666 TBool CAiOperatorNamePublisher::RefreshL( TInt aContentId, TBool aClean )
       
   667 	{
       
   668     if ( aContentId == EAiDeviceStatusContentNetworkIdentity )
       
   669         {
       
   670         iSuspended = EFalse;
       
   671         
       
   672    	    RefreshL( aClean );
       
   673    	    
       
   674    	    if ( iSuccess )
       
   675    	        {
       
   676    	        return ETrue;
       
   677    	        }
       
   678     	}
       
   679 
       
   680     return EFalse;
       
   681 	}
       
   682 
       
   683 TBool CAiOperatorNamePublisher::SuspendL( TInt aContentId, TBool /*aClean*/ )
       
   684     {
       
   685     if ( aContentId == EAiDeviceStatusContentNetworkIdentity )
       
   686         {
       
   687         iSuspended = ETrue;
       
   688         iPeriodic->Cancel();
       
   689         return ETrue;
       
   690         }
       
   691 
       
   692     return EFalse;    
       
   693     }
       
   694 
       
   695 TBool CAiOperatorNamePublisher::RefreshContentWithPriorityL(
       
   696                                             TInt aContentId,
       
   697                                             TInt aPriority )
       
   698 	{
       
   699 	if( aContentId == EAiDeviceStatusContentNetworkIdentity && aPriority == EAiServiceProviderName )
       
   700         {
       
   701 	    RefreshL( EFalse );
       
   702 	    if( iSuccess )
       
   703    	        {
       
   704    	        return ETrue;
       
   705    	        }
       
   706         }
       
   707     return EFalse;
       
   708 	}
       
   709 
       
   710 
       
   711 TBool CAiOperatorNamePublisher::OperatorNamePriority( TInt& aPriority )
       
   712 	{
       
   713 	TBool succeeded = ETrue;
       
   714 
       
   715 	const TNWInfo& nwInfo = iListener->NetworkInfo();
       
   716 
       
   717     switch ( nwInfo.iOperatorNameInfo.iType )
       
   718     	{
       
   719         case RMmCustomAPI::EOperatorNameFlexiblePlmn:
       
   720         	aPriority = EAiFlexiblePLMN;
       
   721             break;
       
   722 
       
   723        	case RMmCustomAPI::EOperatorNameNitzFull:
       
   724             aPriority = EAiNITZ;
       
   725             break;
       
   726 
       
   727         case RMmCustomAPI::EOperatorNameNitzShort:
       
   728             aPriority = EAiNITZ;
       
   729             break;
       
   730 
       
   731         case RMmCustomAPI::EOperatorNameProgrammableUcs2:
       
   732             aPriority = EAiUnicodeOperatorName;
       
   733             break;
       
   734 
       
   735         case RMmCustomAPI::EOperatorNameProgrammableLatin:
       
   736             aPriority = EAiLatinOperatorName;
       
   737             break;
       
   738 
       
   739         case RMmCustomAPI::EOperatorNameHardcodedUcs2:
       
   740             aPriority = EAiUnicodeOperatorName;
       
   741             break;
       
   742 
       
   743         case RMmCustomAPI::EOperatorNameHardcodedLatin:
       
   744             aPriority = EAiLatinOperatorName;
       
   745             break;
       
   746 
       
   747         case RMmCustomAPI::EOperatorNameCountryMcn:
       
   748             aPriority = EAiCountryMNC;
       
   749             break;
       
   750 
       
   751         case RMmCustomAPI::EOperatorNameMccMnc:
       
   752             aPriority = EAiMCC_MCN;
       
   753             break;
       
   754 
       
   755         default:
       
   756         	aPriority = EAiInvalidPriority;
       
   757         	succeeded = EFalse;
       
   758             break;
       
   759        	}
       
   760     return succeeded;
       
   761 	}
       
   762 
       
   763 TBool CAiOperatorNamePublisher::IsKeyLockEnabled()
       
   764 	{
       
   765     TInt value;
       
   766     TInt err = RProperty::Get(KPSUidAvkonDomain, KAknKeyguardStatus, value);
       
   767     if ( err != KErrNone ) 
       
   768     	return EFalse;
       
   769     switch( value ) 
       
   770     	{
       
   771         case EKeyguardLocked:
       
   772         case EKeyguardAutolockEmulation:
       
   773         	return ETrue;
       
   774         case EKeyguardNotActive:
       
   775         default:
       
   776         	return EFalse;
       
   777        	}
       
   778   	}
       
   779 
       
   780 void CAiOperatorNamePublisher::HandleProfileActivatedL( TInt /*aProfileId*/ )
       
   781     {
       
   782     RefreshL( EFalse );
       
   783     }
       
   784