phoneclientserver/EnPolicy/Src/SosEnPolicy/CSosEnPolicySatRefresh.cpp
changeset 0 ff3b6d0fd310
child 18 594d59766373
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2002-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:  This module contains the implementation of CSosEnPolicySatRefresh
       
    15 *                class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include  <e32std.h>
       
    23 #include "CSOSEmergencyNumberPolicyHandler.h"
       
    24 #include "CSosEnPolicySatRefresh.h"
       
    25 
       
    26 #include <RSatRefresh.h>
       
    27 #include <RSatSession.h>
       
    28 
       
    29 #include  <startupdomainpskeys.h> // Property values
       
    30 
       
    31 // Constants
       
    32 _LIT( KENPolicyPanicCategory, "ENPolicyFault" );
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS ===============================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CSosEnPolicySatRefresh::CSosEnPolicySatRefresh
       
    38 // C++ default constructor can NOT contain any code, that
       
    39 // might leave.
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CSosEnPolicySatRefresh::CSosEnPolicySatRefresh( CSosEmergencyNumberPolicyHandler& aCSosEmergencyNumberPolicyHandler ): 
       
    43 	CActive( EPriorityStandard ), iCSosEmergencyNumberPolicyHandler ( aCSosEmergencyNumberPolicyHandler )
       
    44     {
       
    45     CActiveScheduler::Add( this );
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CSosEnPolicySatRefresh::ConstructL
       
    50 // Symbian 2nd phase constructor can leave.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 void CSosEnPolicySatRefresh::ConstructL()
       
    54     {
       
    55     TInt err = KErrNotSupported;
       
    56     iSatSession = new ( ELeave ) RSatSession;
       
    57     iSatRefresh = new ( ELeave ) RSatRefresh( *this );
       
    58  
       
    59     err = iProperty.Attach( KPSUidStartup, KPSGlobalSystemState );
       
    60     __ASSERT_ALWAYS( err == KErrNone, User::Panic( 
       
    61         KENPolicyPanicCategory, EEnPolicyPanicCentralRepositoryConnectionFailure ) );
       
    62     IssueRequest();
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CSosEnPolicySatRefresh::NewL
       
    67 // Two-phased constructor.
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 CSosEnPolicySatRefresh* CSosEnPolicySatRefresh::NewL( CSosEmergencyNumberPolicyHandler& aCSosEmergencyNumberPolicyHandler )
       
    71     {    
       
    72     CSosEnPolicySatRefresh* self = new (ELeave) CSosEnPolicySatRefresh( aCSosEmergencyNumberPolicyHandler );
       
    73     CleanupStack::PushL( self );
       
    74     self->ConstructL();
       
    75     CleanupStack::Pop( self );
       
    76     return self;
       
    77     }
       
    78 
       
    79 // Destructor
       
    80 CSosEnPolicySatRefresh::~CSosEnPolicySatRefresh()
       
    81     {
       
    82     if ( iSatRefresh )
       
    83         {
       
    84         // Cancel notifications.
       
    85         iSatRefresh->Cancel();	
       
    86         // Close SubSession.
       
    87         iSatRefresh->Close();
       
    88         }
       
    89 	delete iSatRefresh;
       
    90 	
       
    91 	if ( iSatSession )
       
    92 		{
       
    93 		iSatSession->Close();
       
    94 		}
       
    95 	  delete iSatSession;
       
    96 
       
    97     Cancel();
       
    98     iProperty.Close();
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CSosEnPolicySatRefresh::AllowRefresh
       
   103 // Refresh query. Determines whether it allow the refresh to happen. 
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 TBool CSosEnPolicySatRefresh::AllowRefresh( TSatRefreshType /*aType*/, const TSatRefreshFiles& /*aFiles*/ )
       
   107  	{
       
   108  	// Refresh is always allowed
       
   109 	return ETrue;
       
   110     }
       
   111  
       
   112 // -----------------------------------------------------------------------------
       
   113 // CSosEnPolicySatRefresh::Refresh
       
   114 // Notification of refresh. In this method the client should not close 
       
   115 // or cancel the RSatRefresh subsession. 
       
   116 // -----------------------------------------------------------------------------
       
   117 //     
       
   118 void CSosEnPolicySatRefresh::Refresh( TSatRefreshType /*aType*/, const TSatRefreshFiles& /*aFiles*/ )
       
   119 	{
       
   120 	// Reload SIM Topics in case of refresh     		
       
   121     iCSosEmergencyNumberPolicyHandler.CpsssmHandleSimStatusEvent( CSosEmergencyNumberPolicyHandler::ESosEnPolicySimEmergencyNumberRead );
       
   122     iSatRefresh->RefreshEFRead( EFalse );
       
   123 	}
       
   124 	
       
   125     
       
   126 // -----------------------------------------------------------------------------
       
   127 // CSosEnPolicySimStatusMonitor::IssueRequest
       
   128 // 
       
   129 // Issue notify request to System agent.
       
   130 // -----------------------------------------------------------------------------
       
   131 //        
       
   132 void CSosEnPolicySatRefresh::IssueRequest()
       
   133     {
       
   134     iProperty.Subscribe( iStatus );
       
   135     SetActive();
       
   136     }
       
   137     
       
   138 // -----------------------------------------------------------------------------
       
   139 // CSosEnPolicySatRefresh::RunL
       
   140 // 
       
   141 // Property event occurred.
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 void CSosEnPolicySatRefresh::RunL()
       
   145     {
       
   146     TInt value;
       
   147     iProperty.Get( KPSUidStartup, KPSGlobalSystemState, value );
       
   148     if ( ESwStateNormalRfOn == value || ESwStateNormalRfOff == value  ) 
       
   149         {
       
   150         switch ( iStatus.Int() )
       
   151             {
       
   152             case KErrNotSupported:
       
   153             case KErrCancel:
       
   154                 return;
       
   155             case KErrNone:
       
   156                 {
       
   157                 iSatSession->ConnectL();
       
   158                 iSatRefresh->OpenL( *iSatSession );   	
       
   159                 TSatRefreshFiles file;
       
   160                 file.Append( KEccEf );
       
   161                 iSatRefresh->NotifyFileChangeL( file );
       
   162                 break;	
       
   163                 }
       
   164             default:
       
   165                 break;
       
   166             }
       
   167         }
       
   168     else
       
   169         {
       
   170         IssueRequest();	
       
   171         }
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 //CSosEnPolicySatRefresh::DoCancel
       
   176 // 
       
   177 //  Cancellation of notify.
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 void CSosEnPolicySatRefresh::DoCancel()
       
   181     {
       
   182     iProperty.Cancel();
       
   183     }
       
   184     
       
   185 
       
   186 //  End of File