startupservices/Startup/src/StartupPubSubObserver.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Implementation of CStartupPubSubObserver class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // SYSTEM INCLUDES
       
    20 #include "startupappinternalpskeys.h"
       
    21 #include <featmgr.h>
       
    22 
       
    23 // USER INCLUDES
       
    24 #include "StartupPubSubObserver.h"
       
    25 #include "StartupSubscriber.h"
       
    26 #include "startupappprivatepskeys.h"
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 
       
    30 // ----------------------------------------------------
       
    31 // StartupPubSubObserver::StartupPubSubObserver( CStartupAppUi* aStartupAppUi )
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // ----------------------------------------------------
       
    35 CStartupPubSubObserver::CStartupPubSubObserver( CStartupAppUi* aStartupAppUi ) :
       
    36     iStartupAppUi( aStartupAppUi )
       
    37 #if defined (RD_SCALABLE_UI_V2) && !defined(RD_STARTUP_ANIMATION_CUSTOMIZATION)
       
    38     , iTouchScreenCalibSupport( EFalse )
       
    39 #endif // RD_SCALABLE_UI_V2 && !RD_STARTUP_ANIMATION_CUSTOMIZATION
       
    40     {
       
    41     }
       
    42 
       
    43 // ----------------------------------------------------
       
    44 // CStartupPubSubObserver::ConstructL()
       
    45 // ----------------------------------------------------
       
    46 void CStartupPubSubObserver::ConstructL()
       
    47     {
       
    48     TRACES("CStartupPubSubObserver::ConstructL()");
       
    49 
       
    50     iGlobalSystemStateSubscriber = CStartupSubscriber::NewL( *this,
       
    51                                                              KPSUidStartup,
       
    52                                                              KPSGlobalSystemState );
       
    53     iGlobalSystemStateSubscriber->Subscribe();
       
    54 
       
    55     TInt globalSystemState;
       
    56     User::LeaveIfError( RProperty::Get (
       
    57         KPSUidStartup, KPSGlobalSystemState, globalSystemState ) );
       
    58 
       
    59     TRACES1("CStartupPubSubObserver::ConstructL(): globalSystemState: %d",globalSystemState );
       
    60 
       
    61     // If critical phase in Starter has ended
       
    62     if ( globalSystemState == ESwStateNormalRfOn ||
       
    63          globalSystemState == ESwStateNormalRfOff ||
       
    64          globalSystemState == ESwStateNormalBTSap ||
       
    65          globalSystemState == ESwStateCriticalPhaseOK ||
       
    66          globalSystemState == ESwStateEmergencyCallsOnly )
       
    67         {
       
    68         iStartupAppUi->SetCriticalBlockEndedL();
       
    69         }
       
    70 
       
    71     else if ( globalSystemState == ESwStateFatalStartupError )
       
    72         {
       
    73         iStartupAppUi->SwStateFatalStartupErrorL( EFalse ); // property changed = EFalse
       
    74         }
       
    75 
       
    76     iStartupPhaseSubscriber = CStartupSubscriber::NewL( *this,
       
    77                                                         KPSUidStartupApp,
       
    78                                                         KPSStartupAppState );
       
    79     iStartupPhaseSubscriber->Subscribe();
       
    80 
       
    81     TInt startupPhase;
       
    82     User::LeaveIfError( RProperty::Get (
       
    83         KPSUidStartupApp, KPSStartupAppState, startupPhase ) );
       
    84 
       
    85     TRACES1("CStartupPubSubObserver::ConstructL(): startupPhase: %d", startupPhase );
       
    86 
       
    87     if ( startupPhase == EStartupAppStateStartAnimations )
       
    88         {
       
    89         iStartupAppUi->SetWaitingStartupAnimationStartL();
       
    90         }
       
    91 
       
    92 #if defined (RD_SCALABLE_UI_V2) && !defined(RD_STARTUP_ANIMATION_CUSTOMIZATION)
       
    93     FeatureManager::InitializeLibL();
       
    94     if ( FeatureManager::FeatureSupported(KFeatureIdPenSupport) &&
       
    95          FeatureManager::FeatureSupported(KFeatureIdPenSupportCalibration) )
       
    96         {
       
    97         iTouchScreenCalibSupport = ETrue;
       
    98 
       
    99         iTouchScreenCalibSyncSubscriber = CStartupSubscriber::NewL( *this,
       
   100                                                          KPSUidStartup,
       
   101                                                          KPSTouchScreenCalibration );
       
   102         iTouchScreenCalibSyncSubscriber->Subscribe();
       
   103 
       
   104         TInt touchScreenCalibrationState;
       
   105         RProperty::Get( KPSUidStartup, KPSTouchScreenCalibration, touchScreenCalibrationState );
       
   106         if ( touchScreenCalibrationState == ETouchScreenCalibrationOk )
       
   107             {
       
   108             iStartupAppUi->TouchScreenCalibrationDoneL();
       
   109             }
       
   110         }
       
   111     FeatureManager::UnInitializeLib();
       
   112 #endif // RD_SCALABLE_UI_V2 && !RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   113 
       
   114     TRACES("CStartupPubSubObserver::ConstructL(): End");
       
   115     }
       
   116 
       
   117 // ----------------------------------------------------------------------------
       
   118 // CStartupPubSubObserver::HandlePropertyChangedL()
       
   119 // ----------------------------------------------------------------------------
       
   120 void CStartupPubSubObserver::HandlePropertyChangedL( const TUid& /*aCategory*/, TUint aKey )
       
   121     {
       
   122     TRACES("CStartupPubSubObserver::HandlePropertyChangedL()");
       
   123     TRACES1("CStartupPubSubObserver::HandlePropertyChangedL(): aKey: %d",aKey );
       
   124 
       
   125     TInt eventState( 0 );
       
   126 
       
   127     switch ( aKey )
       
   128         {
       
   129         case KPSGlobalSystemState:
       
   130             {
       
   131             TRACES("CStartupPubSubObserver::HandlePropertyChangedL(): key == KPSGlobalSystemState");
       
   132             User::LeaveIfError( RProperty::Get ( KPSUidStartup,
       
   133                                                  KPSGlobalSystemState,
       
   134                                                  eventState ) );
       
   135             if( eventState == ESwStateCriticalPhaseOK ||
       
   136             		eventState == ESwStateNormalRfOn ||
       
   137             		eventState == ESwStateNormalRfOff ||
       
   138             		eventState == ESwStateNormalBTSap )
       
   139                 {
       
   140                 TRACES("CStartupPubSubObserver::HandlePropertyChangedL(): eventState == ESwStateCriticalPhaseOK");
       
   141                 iStartupAppUi->SetCriticalBlockEndedL();
       
   142                 }
       
   143             else if( eventState == ESwStateEmergencyCallsOnly )
       
   144                 {
       
   145                 TRACES("CStartupPubSubObserver::HandlePropertyChangedL(): eventState == ESwStateEmergencyCallsOnly");
       
   146                 iStartupAppUi->SetEmergencyCallsOnlyL();
       
   147                 }
       
   148             else if (eventState == ESwStateFatalStartupError )
       
   149                 {
       
   150                 TRACES("CStartupPubSubObserver::HandlePropertyChangedL(): eventState == ESwStateFatalStartupError");
       
   151                 iStartupAppUi->SwStateFatalStartupErrorL( ETrue ); // property changed = ETrue
       
   152                 }
       
   153 #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   154             else if ( eventState == ESwStateChargingToNormal ||
       
   155                       eventState == ESwStateAlarmToNormal )
       
   156                 {
       
   157                 TRACES("CStartupPubSubObserver::HandlePropertyChangedL(): eventState == ESwStateAlarm/ChargingToNormal");
       
   158                 iStartupAppUi->TryPreLoadAnimation();
       
   159                 }
       
   160 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   161             }
       
   162             break;
       
   163         case KPSStartupAppState:
       
   164             {
       
   165             TRACES("CStartupPubSubObserver::HandlePropertyChangedL(): key == KPSStartupAppState");
       
   166             User::LeaveIfError( RProperty::Get ( KPSUidStartupApp,
       
   167                                                  KPSStartupAppState,
       
   168                                                  eventState ) );
       
   169             
       
   170             TRACES1("CStartupPubSubObserver::HandlePropertyChangedL(): eventState = %d", eventState);
       
   171             
       
   172             if ( eventState == EStartupAppStateStartAnimations )
       
   173                 {                
       
   174                 iStartupAppUi->SetWaitingStartupAnimationStartL();
       
   175                 }            
       
   176             }
       
   177             break;
       
   178 #if defined (RD_SCALABLE_UI_V2) && !defined(RD_STARTUP_ANIMATION_CUSTOMIZATION)
       
   179         case KPSTouchScreenCalibration:
       
   180             {
       
   181             TInt state;
       
   182 
       
   183             RProperty::Get( KPSUidStartup, KPSTouchScreenCalibration, state );
       
   184             if ( state == ETouchScreenCalibrationOk )
       
   185                 {
       
   186                 iStartupAppUi->TouchScreenCalibrationDoneL();
       
   187                 }
       
   188             }
       
   189             break;
       
   190 #endif // RD_SCALABLE_UI_V2 && !RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   191         default:
       
   192             TRACES("CStartupPubSubObserver::HandlePropertyChangedL(): key is unsupported");
       
   193             break;
       
   194         }//End of switch-clause
       
   195 
       
   196     TRACES("CStartupPubSubObserver::HandlePropertyChangedL(): End");
       
   197     }
       
   198 
       
   199 // ----------------------------------------------------
       
   200 // CStartupPubSubObserver::NewL( CStartupAppUi* aStartupAppUi )
       
   201 // ----------------------------------------------------
       
   202 CStartupPubSubObserver* CStartupPubSubObserver::NewL( CStartupAppUi* aStartupAppUi )
       
   203     {
       
   204     TRACES("CStartupPubSubObserver::NewL()");
       
   205     CStartupPubSubObserver* self = new (ELeave) CStartupPubSubObserver( aStartupAppUi );
       
   206 
       
   207     CleanupStack::PushL( self );
       
   208     self->ConstructL();
       
   209     CleanupStack::Pop(); // self
       
   210 
       
   211     TRACES("CStartupPubSubObserver::NewL(): End");
       
   212     return self;
       
   213     }
       
   214 
       
   215 // ----------------------------------------------------
       
   216 // CStartupPubSubObserver::~CStartupPubSubObserver()
       
   217 // ----------------------------------------------------
       
   218 CStartupPubSubObserver::~CStartupPubSubObserver()
       
   219     {
       
   220     TRACES("CStartupPubSubObserver::~CStartupPubSubObserver()");
       
   221 
       
   222     delete iGlobalSystemStateSubscriber;
       
   223     delete iStartupPhaseSubscriber;
       
   224 #if defined (RD_SCALABLE_UI_V2) && !defined(RD_STARTUP_ANIMATION_CUSTOMIZATION)
       
   225     if (iTouchScreenCalibSupport)
       
   226         {
       
   227         delete iTouchScreenCalibSyncSubscriber;
       
   228         }
       
   229 #endif // RD_SCALABLE_UI_V2 && !RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   230 
       
   231     TRACES("CStartupPubSubObserver::~CStartupPubSubObserver(): End");
       
   232     }
       
   233 //  End of File