coreapplicationuis/SysAp/Src/SysApSimChanged.cpp
changeset 0 2e3d3ce01487
child 19 924385140d98
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Implementation of CSysApSimChanged
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "SysApSimChanged.h"
       
    21 #include "SysApAppUi.h"
       
    22 #include <settingsinternalcrkeys.h>
       
    23 #include <LogsDomainCRKeys.h>
       
    24 #include <logcli.h>
       
    25 #include <centralrepository.h>
       
    26 const TInt KPSetDefaultCFTimer = 30;
       
    27 #include <RSSSettings.h>
       
    28 #include <startupdomainpskeys.h>
       
    29 #include <PSVariables.h>
       
    30 #include "SysAp.hrh"
       
    31 //  LOCAL CONSTANTS AND MACROS  
       
    32 
       
    33    
       
    34 // ============================ MEMBER FUNCTIONS ===============================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CSysApSimChanged::NewL
       
    38 //
       
    39 // Two-phased constructor.
       
    40 // -----------------------------------------------------------------------------
       
    41 
       
    42 CSysApSimChanged* CSysApSimChanged::NewL( CSysApAppUi& aSysApAppUi, RFs& aFs )
       
    43     {
       
    44     TRACES( RDebug::Print( _L("CSysApSimChanged::NewL()") ) );
       
    45     CSysApSimChanged* self = new(ELeave) CSysApSimChanged(aSysApAppUi, aFs );
       
    46     return self;
       
    47     }
       
    48 
       
    49 // ----------------------------------------------------------------------------
       
    50 // CSysApSimChanged::CSysApSimChanged( CSysApAppUi& aSysApAppUi )
       
    51 // ----------------------------------------------------------------------------
       
    52 
       
    53 CSysApSimChanged::CSysApSimChanged( CSysApAppUi& aSysApAppUi, RFs& aFs ) :
       
    54     iSysApAppUi( aSysApAppUi ),
       
    55     iFs( aFs )
       
    56     {
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // Destructor
       
    61 // -----------------------------------------------------------------------------
       
    62 
       
    63 CSysApSimChanged::~CSysApSimChanged()
       
    64     {
       
    65     TRACES( RDebug::Print( _L("CSysApSimChanged::~CSysApSimChanged()") ) );
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CSysApSimChanged::ClearRepositoriesL()
       
    70 // -----------------------------------------------------------------------------
       
    71 
       
    72 void CSysApSimChanged::ClearRepositoriesL()
       
    73     {
       
    74     TRACES( RDebug::Print( _L("CSysApSimChanged::ClearRepositoriesL(): opening KCRUidCallForwarding") ) );
       
    75     
       
    76     CRepository* repository = CRepository::NewL( KCRUidCallForwarding );
       
    77     
       
    78     repository->Set( KSettingsCFDefaultNumber1, KNullDesC );
       
    79     repository->Set( KSettingsCFDefaultNumber2, KNullDesC );
       
    80     repository->Set( KSettingsCFDefaultNumber3, KNullDesC );
       
    81     repository->Set( KSettingsCFDefaultNumberAls1, KNullDesC );
       
    82     repository->Set( KSettingsCFDefaultNumberAls2, KNullDesC );
       
    83     repository->Set( KSettingsCFDefaultNumberAls3, KNullDesC );
       
    84     repository->Set( KSettingsCFUsedFaxNumber, KNullDesC );
       
    85     repository->Set( KSettingsCFUsedDataNumber, KNullDesC );
       
    86     repository->Set( KSettingsCFTimerValue, KPSetDefaultCFTimer );
       
    87     repository->Set( KSettingsCFTimerValueAls, KPSetDefaultCFTimer );
       
    88     
       
    89     delete repository;
       
    90     
       
    91     TRACES( RDebug::Print( _L("CSysApSimChanged::ClearRepositoriesL(): opening KCRUidLogs") ) );
       
    92     repository = CRepository::NewL( KCRUidLogs );
       
    93     
       
    94     repository->Set( KLogsNewMissedCalls, 0 );
       
    95 
       
    96     delete repository;
       
    97     }
       
    98 // -----------------------------------------------------------------------------
       
    99 // CSysApSimChanged::ClearLogsL()
       
   100 // -----------------------------------------------------------------------------
       
   101 
       
   102 void CSysApSimChanged::ClearLogsL()
       
   103     {
       
   104     TRACES( RDebug::Print( _L("CSysApSimChanged::ClearLogsL()") ) );
       
   105     // Clear the event log.
       
   106     CShareActive* active = new (ELeave) CShareActive;
       
   107     CleanupStack::PushL( active );
       
   108     active->StartL();
       
   109     
       
   110     TDateTime dateTime;
       
   111     dateTime.Set( 2100, EJanuary, 1, 0, 0, 0, 0 );
       
   112     TTime date(dateTime);
       
   113     
       
   114     TRACES( RDebug::Print( _L("CSysApSimChanged::ClearLogsL(): trying CLogClient::NewL") ) );
       
   115     CLogClient* logClient = CLogClient::NewL( iFs );    
       
   116     logClient->ClearLog( date, active->iStatus );
       
   117     
       
   118     CActiveScheduler::Start();
       
   119 
       
   120     delete logClient;
       
   121     CleanupStack::PopAndDestroy( active );
       
   122     }
       
   123     
       
   124 // -----------------------------------------------------------------------------
       
   125 // CSysApSimChanged::ClearSsSettingsL()
       
   126 // -----------------------------------------------------------------------------
       
   127 
       
   128 void CSysApSimChanged::ClearSsSettingsL()
       
   129     {
       
   130     TRACES( RDebug::Print( _L("CSysApSimChanged::ClearSsSettingsL()") ) );
       
   131     
       
   132     // Reset SSSettings values
       
   133     RSSSettings ssSettings;
       
   134     User::LeaveIfError( ssSettings.Open( iSysApAppUi.GetTelServer() ) );
       
   135     
       
   136     TRACES( RDebug::Print( _L("CSysApSimChanged::ClearSsSettingsL(): trying RSSSettings::HandleSIMChanged") ) );
       
   137     TInt err = ssSettings.HandleSIMChanged();
       
   138     ssSettings.Close();    
       
   139     
       
   140     User::LeaveIfError( err );
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CSysApSimChanged::HandleSimChangedL()
       
   145 // -----------------------------------------------------------------------------
       
   146     
       
   147 void CSysApSimChanged::HandleSimChangedL()
       
   148     {
       
   149     TBool simChanged;
       
   150     TBool simNotOwned;
       
   151 
       
   152     simChanged = ( iSysApAppUi.StateOfProperty( KPSUidStartup, KPSSimChanged ) == ESimChanged );
       
   153     simNotOwned = ( iSysApAppUi.StateOfProperty( KPSUidStartup, KPSSimOwned ) == ESimNotOwned );
       
   154     
       
   155     TRACES( RDebug::Print( _L("CSysApSimChanged::HandleSimChangedL(): simChanged=%d, simNotOwned=%d"), simChanged, simNotOwned ) );
       
   156 
       
   157     // Supplementary settings are always cleared when SIM has been changed, regardless whether SIM is known or not
       
   158     if ( simChanged || simNotOwned )
       
   159         {
       
   160         ClearSsSettingsL();
       
   161         }
       
   162     
       
   163     // Other repositories are cleared only if an unknown SIM has been inserted    
       
   164     if ( simNotOwned )
       
   165         {
       
   166         ClearRepositoriesL();
       
   167         ClearLogsL();
       
   168         }
       
   169     }
       
   170 // =============== CShareActive MEMBER FUNCTIONS ===============================
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // These are needed for ClogClient.
       
   174 // -----------------------------------------------------------------------------
       
   175 
       
   176 CShareActive::CShareActive() : CActive(0)
       
   177     {
       
   178     CActiveScheduler::Add(this);
       
   179     }
       
   180 
       
   181 CShareActive::~CShareActive()
       
   182     {
       
   183     Cancel();
       
   184     }
       
   185 
       
   186 void CShareActive::DoCancel()
       
   187     {
       
   188     TRequestStatus* s=&iStatus;
       
   189     User::RequestComplete(s, KErrNone);
       
   190     }
       
   191 
       
   192 void CShareActive::StartL()
       
   193     {
       
   194     SetActive();
       
   195     }
       
   196 
       
   197 void CShareActive::RunL() 
       
   198     {
       
   199     TRACES( RDebug::Print( _L("CSysApSimChanged::CShareActive::RunL: iStatus=%d"), iStatus.Int() ) );
       
   200     CActiveScheduler::Stop();
       
   201     }
       
   202 
       
   203 //  End of File
       
   204 
       
   205 
       
   206