idlefw/plugins/devicestatus/src/aisimregpublisher.cpp
changeset 0 79c6a41cd166
child 9 d0529222e3f0
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     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:  SIM registration status publisher
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "aisimregpublisher.h"
       
    20 #include "aicontentobserver.h"
       
    21 #include "ainetworkinfolistener.h"
       
    22 #include <activeidle2domainpskeys.h>
       
    23 #include <e32property.h>
       
    24 
       
    25 #include <startupdomainpskeys.h>
       
    26 
       
    27 // ======== LOCAL FUNCTIONS =======
       
    28 
       
    29 TBool AllowedToShowSimRegFailed()
       
    30     {
       
    31     TInt simCardStatus = ESimStatusUninitialized;
       
    32     TInt err = RProperty::Get( KPSUidStartup, KPSSimStatus, simCardStatus );
       
    33 
       
    34     // Show note only when the SIM is usable
       
    35     if( err == KErrNone && simCardStatus == ESimUsable )
       
    36         {
       
    37         return ETrue;
       
    38         }
       
    39     return EFalse;
       
    40     }
       
    41 
       
    42 
       
    43 // ======== MEMBER FUNCTIONS ========
       
    44 
       
    45 CAiSimRegPublisher::CAiSimRegPublisher()
       
    46     {
       
    47     }
       
    48 
       
    49 
       
    50 void CAiSimRegPublisher::ConstructL()
       
    51     {
       
    52     iListener = CAiNetworkInfoListener::InstanceL();
       
    53     }
       
    54 
       
    55 
       
    56 CAiSimRegPublisher* CAiSimRegPublisher::NewL()
       
    57     {
       
    58     CAiSimRegPublisher* self = new( ELeave ) CAiSimRegPublisher;
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL();
       
    61     CleanupStack::Pop( self );
       
    62     return self;
       
    63     }
       
    64 
       
    65 
       
    66 CAiSimRegPublisher::~CAiSimRegPublisher()
       
    67     {
       
    68     if( iListener )
       
    69         {
       
    70         iListener->RemoveObserver( *this );
       
    71         iListener->Release();
       
    72         }
       
    73     }
       
    74 
       
    75 
       
    76 void CAiSimRegPublisher::ResumeL()
       
    77     {
       
    78     iListener->AddObserverL( *this );
       
    79     }
       
    80 
       
    81 
       
    82 void CAiSimRegPublisher::Subscribe( MAiContentObserver& aObserver,
       
    83 								    MAiPropertyExtension& aExtension,
       
    84                                     MAiPublishPrioritizer& /*aPrioritizer*/,
       
    85                                     MAiPublisherBroadcaster& /*aBroadcaster*/ )
       
    86     {
       
    87     iContentObserver = &aObserver;
       
    88     iExtension = &aExtension;
       
    89     }
       
    90 
       
    91 
       
    92 void CAiSimRegPublisher::RefreshL( TBool /*aClean*/ )
       
    93     {
       
    94     TInt status = EPSSimRegFailedMessageNotReceived;
       
    95     RProperty::Get(
       
    96 	    KPSUidAiInformation,
       
    97         KActiveIdleSimRegFailedReceived,
       
    98         status );
       
    99     //this cannot be refreshed
       
   100     switch( iListener->NetworkInfo().iRegistrationStatus )
       
   101         {
       
   102         case ENWRegistrationUnknown:
       
   103         case ENWNotRegisteredNoService:
       
   104         case ENWNotRegisteredEmergencyOnly:
       
   105         case ENWRegistrationDenied: // fallthrough
       
   106             {
       
   107             if( status == EPSSimRegFailedMessageReceived &&
       
   108                 ::AllowedToShowSimRegFailed() )
       
   109             	{
       
   110             	iContentObserver->Publish( *iExtension,
       
   111             	        EAiDeviceStatusContentSIMRegStatus,
       
   112             	        EAiDeviceStatusResourceSIMRegFail,
       
   113             	        0 );
       
   114             	}
       
   115             break;
       
   116             }
       
   117         case ENWRegisteredOnHomeNetwork:
       
   118         case ENWRegisteredRoaming:
       
   119         case ENWRegisteredBusy: // fallthrough
       
   120             {
       
   121             if( status == EPSSimRegFailedMessageReceived )
       
   122                 {
       
   123                 iContentObserver->Clean( *iExtension,
       
   124                 	EAiDeviceStatusContentSIMRegStatus,
       
   125                 	0 );
       
   126                 }
       
   127             break;
       
   128             }
       
   129         default:
       
   130             {
       
   131             // no op
       
   132             break;
       
   133             }
       
   134         }
       
   135     }
       
   136 
       
   137 
       
   138 void CAiSimRegPublisher::HandleNetworkInfoChange(
       
   139 							const MNWMessageObserver::TNWMessages& aMessage,
       
   140 							const TNWInfo& aInfo,
       
   141 							const TBool /*aShowOpInd*/ )
       
   142     {
       
   143     if ( aMessage ==
       
   144     		MNWMessageObserver::ENWMessageNetworkConnectionFailure &&
       
   145     		::AllowedToShowSimRegFailed())
       
   146         {
       
   147 
       
   148         // SIM registration failed. Publish SIM registration status.
       
   149         iContentObserver->Publish( *iExtension,
       
   150                 EAiDeviceStatusContentSIMRegStatus,
       
   151                 EAiDeviceStatusResourceSIMRegFail,
       
   152                 0 );
       
   153         RProperty::Set(
       
   154                 KPSUidAiInformation,
       
   155                 KActiveIdleSimRegFailedReceived,
       
   156                 EPSSimRegFailedMessageReceived );
       
   157         }
       
   158 
       
   159     else if ( aMessage ==
       
   160     		MNWMessageObserver::ENWMessageNetworkRegistrationStatusChange )
       
   161         {
       
   162         switch ( aInfo.iRegistrationStatus )
       
   163             {
       
   164             case ENWRegisteredOnHomeNetwork:
       
   165             case ENWRegisteredRoaming:
       
   166             case ENWRegisteredBusy:
       
   167                 {
       
   168 				//Call clean if registration is fine.
       
   169                 iContentObserver->Clean( *iExtension,
       
   170                 			EAiDeviceStatusContentSIMRegStatus,
       
   171                 			0 );
       
   172                 break;
       
   173                 }
       
   174             default:
       
   175                 break;
       
   176             }
       
   177         }
       
   178     }
       
   179 
       
   180 
       
   181 TBool CAiSimRegPublisher::RefreshL( TInt aContentId, TBool aClean )
       
   182 	{
       
   183     if( aContentId == EAiDeviceStatusContentSIMRegStatus )
       
   184         {
       
   185    	    RefreshL( aClean );
       
   186    	    return ETrue;
       
   187     	}
       
   188 
       
   189     return EFalse;
       
   190 	}