convergedconnectionhandler/cchserver/src/cchstartupcounter.cpp
changeset 0 a4daefaec16c
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2008 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:  CCchStartupCounter implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cchlogger.h"
       
    21 #include "cchstartupcounter.h"
       
    22 #include "cchserverbase.h"
       
    23 #include "cchspshandler.h"
       
    24 #include "cchservicehandler.h"
       
    25 #include "cchprivatecrkeys.h"
       
    26 #include <centralrepository.h>
       
    27 
       
    28 // EXTERNAL DATA STRUCTURES
       
    29 // None
       
    30 
       
    31 // EXTERNAL FUNCTION PROTOTYPES
       
    32 // None
       
    33 
       
    34 // CONSTANTS
       
    35 // Some critical process has crashed three times during startup registration
       
    36 // to avoid bootlock situation set startup flag to OFF after max count
       
    37 const TInt KCCHMaxStartupCount = 3;
       
    38 
       
    39 // MACROS
       
    40 // None
       
    41 
       
    42 // LOCAL CONSTANTS AND MACROS
       
    43 // None
       
    44 
       
    45 // MODULE DATA STRUCTURES
       
    46 // None
       
    47 
       
    48 // LOCAL FUNCTION PROTOTYPES
       
    49 // None
       
    50 
       
    51 // FORWARD DECLARATIONS
       
    52 // None
       
    53 
       
    54 // ============================= LOCAL FUNCTIONS =============================
       
    55 
       
    56 // ============================ MEMBER FUNCTIONS =============================
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CCchStartupCounter::CCchStartupCounter
       
    60 // C++ default constructor can NOT contain any code, that might leave.
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CCchStartupCounter::CCchStartupCounter( CCCHServerBase& aServer ) 
       
    64     : iServer( aServer )
       
    65     {
       
    66     // No implementation required
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CCchStartupCounter::ConstructL
       
    71 // Symbian 2nd phase constructor can leave.
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 void CCchStartupCounter::ConstructL()
       
    75     {
       
    76     iStartupRepository = CRepository::NewL( KCRUidCch );
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CCchStartupCounter::NewL
       
    81 // Two-phased constructor.
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 CCchStartupCounter* CCchStartupCounter::NewL( CCCHServerBase& aServer )
       
    85     {
       
    86     CCchStartupCounter* self = new (ELeave) CCchStartupCounter( aServer );
       
    87     CleanupStack::PushL( self );
       
    88     self->ConstructL();
       
    89     CleanupStack::Pop( self );
       
    90     return self;
       
    91     }
       
    92 
       
    93 // Destructor
       
    94 CCchStartupCounter::~CCchStartupCounter()
       
    95     {
       
    96     delete iStartupRepository;
       
    97     }
       
    98     
       
    99 // ---------------------------------------------------------------------------
       
   100 // CCchStartupCounter::StartupOccuredL
       
   101 // 
       
   102 // (other items were commented in a header).
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 void CCchStartupCounter::StartupOccuredL()
       
   106     {
       
   107     CCHLOGSTRING( "CCchStartupCounter::StartupOccuredL IN" );
       
   108     
       
   109     TInt startupCounter( KErrNone );
       
   110     User::LeaveIfError( iStartupRepository->Get( 
       
   111         KCCHStartupCounter, startupCounter ) );
       
   112             
       
   113     startupCounter++;
       
   114     CCHLOGSTRING2( 
       
   115         "CCchStartupCounter -> startup counter: %d", startupCounter );
       
   116             
       
   117     if ( startupCounter >= KCCHMaxStartupCount )
       
   118         {
       
   119         CCHLOGSTRING( "CCchStartupCounter -> set startup flag to OFF" );
       
   120         // Some critical process has crashed three times during startup registration..
       
   121         startupCounter = 0;
       
   122         // ..to avoid bootlock situation set startup flag to OFF
       
   123         HandleStartupExceptionsL(); 
       
   124         }
       
   125             
       
   126     User::LeaveIfError( iStartupRepository->Set( 
       
   127         KCCHStartupCounter, startupCounter ) );
       
   128                         
       
   129     CCHLOGSTRING( "CCchStartupCounter::StartupOccuredL OUT" );
       
   130     }
       
   131       
       
   132 // ---------------------------------------------------------------------------
       
   133 // CCchStartupCounter::HandleStartupExceptionsL
       
   134 // 
       
   135 // (other items were commented in a header).
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 void CCchStartupCounter::HandleStartupExceptionsL()
       
   139     {
       
   140     CCHLOGSTRING( "CCchStartupCounter::HandleStartupExceptionsL IN" );
       
   141     
       
   142     RArray<TUint> serviceIds;
       
   143     CleanupClosePushL( serviceIds );
       
   144     RArray<TCCHSubserviceType> subserviceTypes;
       
   145     CleanupClosePushL( subserviceTypes );
       
   146                 
       
   147     iServer.SPSHandler().GetServiceIdsL( serviceIds );
       
   148     for ( TInt i( 0 ); i < serviceIds.Count(); i++ )
       
   149         {
       
   150         iServer.ServiceHandler().GetSubserviceTypesL( 
       
   151             serviceIds[ i ], subserviceTypes );
       
   152             
       
   153         for ( TInt j( 0 ); j < subserviceTypes.Count(); j++ )
       
   154             {
       
   155             iServer.ServiceHandler().SetStartupFlag( TServiceSelection( 
       
   156                 serviceIds[ i ], subserviceTypes[ j ] ), EFalse );
       
   157             iServer.SPSHandler().SetLoadAtStartUpL(
       
   158                 serviceIds[ i ], subserviceTypes[ j ], EFalse );
       
   159             }
       
   160         }
       
   161     
       
   162     CleanupStack::PopAndDestroy( &subserviceTypes );
       
   163     CleanupStack::PopAndDestroy( &serviceIds ); 
       
   164             
       
   165     CCHLOGSTRING( "CCchStartupCounter::HandleStartupExceptionsL OUT" );
       
   166     }
       
   167 
       
   168 // ---------------------------------------------------------------------------
       
   169 // CCchStartupCounter::ResetStartupCounter
       
   170 // 
       
   171 // (other items were commented in a header).
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 void CCchStartupCounter::ResetStartupCounter()
       
   175     {
       
   176     CCHLOGSTRING( "CCchStartupCounter::ResetStartupCounter IN" );
       
   177     
       
   178     iStartupRepository->Set( 
       
   179         KCCHStartupCounter, KErrNone );
       
   180     
       
   181     CCHLOGSTRING( "CCchStartupCounter::ResetStartupCounter OUT" );
       
   182     }
       
   183 
       
   184 // ========================== OTHER EXPORTED FUNCTIONS =======================
       
   185 
       
   186 //  End of File