messagingapp/msgsettings/msginit/src/startupmonitor.cpp
changeset 23 238255e8b033
equal deleted inserted replaced
5:4697dfb2d7ad 23:238255e8b033
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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:  
       
    15 *       CStartUpMonitor implementation file
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <startupdomainpskeys.h>
       
    22 #include "simscnumberdetector.h"
       
    23 #include "startupmonitor.h"
       
    24 
       
    25 // CONSTANTS
       
    26 
       
    27 // ================= MEMBER FUNCTIONS =======================
       
    28 
       
    29 // ---------------------------------------------------------
       
    30 // CStartUpMonitor::CStartUpMonitor
       
    31 //
       
    32 // C++ constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // ---------------------------------------------------------
       
    35 //
       
    36 CStartUpMonitor::CStartUpMonitor( CMsgSimOperation* aWatcher )
       
    37     : CActive( CActive::EPriorityStandard ),
       
    38     iWatcher( aWatcher )
       
    39     {    
       
    40     CActiveScheduler::Add( this );
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------
       
    44 // CStartUpMonitor::ConstructL()
       
    45 //
       
    46 // Symbian OS default constructor can leave.
       
    47 // ---------------------------------------------------------
       
    48 //
       
    49 void CStartUpMonitor::ConstructL()
       
    50     {
       
    51   
       
    52     User::LeaveIfError( iStartupProperty.Attach( KPSUidStartup, KPSGlobalSystemState ) );
       
    53     // Complete self
       
    54     iStatus = KRequestPending;
       
    55     TRequestStatus* pStatus = &iStatus;
       
    56     SetActive();
       
    57     User::RequestComplete( pStatus, KErrNone );
       
    58   
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------
       
    62 // CStartUpMonitor::NewL
       
    63 //
       
    64 // Two-phased constructor.
       
    65 // ---------------------------------------------------------
       
    66 //
       
    67 CStartUpMonitor* CStartUpMonitor::NewL( CMsgSimOperation* aWatcher )
       
    68     {
       
    69     
       
    70     CStartUpMonitor* self = new ( ELeave )
       
    71         CStartUpMonitor( aWatcher );
       
    72     
       
    73     CleanupStack::PushL( self );
       
    74     self->ConstructL();
       
    75     CleanupStack::Pop();
       
    76 
       
    77     return self;
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------
       
    81 // CStartUpMonitor::~CStartUpMonitor
       
    82 //
       
    83 // Destructor
       
    84 // ---------------------------------------------------------
       
    85 //
       
    86 CStartUpMonitor::~CStartUpMonitor()
       
    87     {
       
    88     Cancel();
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------
       
    92 // CStartUpMonitor::DoCancel
       
    93 //
       
    94 // From active object framework
       
    95 // ---------------------------------------------------------
       
    96 //
       
    97 void CStartUpMonitor::DoCancel()
       
    98     {
       
    99     iStartupProperty.Cancel();
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------
       
   103 // CStartUpMonitor::RunL
       
   104 //
       
   105 // From active object framework
       
   106 // ---------------------------------------------------------
       
   107 //
       
   108 void CStartUpMonitor::RunL()
       
   109     {
       
   110 
       
   111     TInt startupState = 0;
       
   112     iStartupProperty.Get( startupState );
       
   113 
       
   114     if ( startupState == ESwStateNormalRfOn ||
       
   115         startupState == ESwStateNormalRfOff ||
       
   116         startupState == ESwStateNormalBTSap )
       
   117         {
       
   118         iWatcher->HandleStartupReadyL();       
       
   119         }
       
   120     else
       
   121         {
       
   122         iStatus = KRequestPending;
       
   123         iStartupProperty.Subscribe( iStatus );
       
   124         SetActive();
       
   125         }
       
   126 
       
   127     }
       
   128 
       
   129 //  End of File