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