sysstatemgmt/systemstatereferenceplugins/clayer/src/strtsecphaseobserver.cpp
changeset 0 4e1aa6a622a0
child 7 1a73e8f1b64d
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name        : strtsecphaseobserver.cpp
       
    15 // Part of     : System Startup / StrtSecObs
       
    16 // Implementation of CStrtSecPhaseObserver class
       
    17 // Version     : %version: 1 % << Don't touch! Updated by Synergy at check-out.
       
    18 // This material, including documentation and any related computer
       
    19 // programs, is protected by copyright controlled by Nokia.  All
       
    20 // rights are reserved.  Copying, including reproducing, storing,
       
    21 // adapting or translating, any or all of this material requires the
       
    22 // prior written consent of Nokia.  This material also contains
       
    23 // confidential information which may not be disclosed to others
       
    24 // without the prior written consent of Nokia.
       
    25 // Template version: 4.1.1
       
    26 // Nokia Core OS *
       
    27 //
       
    28 
       
    29 
       
    30 
       
    31 #include "strtsecphaseobserver.h"
       
    32 #include "ssmdebug.h"
       
    33 #include "ssmrefcustomcmdcommon.h"
       
    34 #include <ssm/ssmuiproviderdll.h>
       
    35 
       
    36 // ======== MEMBER FUNCTIONS ========
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CStrtSecPhaseObserver::NewL
       
    40 //
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 CStrtSecPhaseObserver* CStrtSecPhaseObserver::NewL()
       
    44     {
       
    45     CStrtSecPhaseObserver* self = new( ELeave ) CStrtSecPhaseObserver;
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL();
       
    48     CleanupStack::Pop( self );
       
    49     return self;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CStrtSecPhaseObserver::~CStrtSecPhaseObserver
       
    54 //
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 CStrtSecPhaseObserver::~CStrtSecPhaseObserver()
       
    58     {
       
    59     Cancel();
       
    60     iProperty.Close();
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CStrtSecPhaseObserver::IsSecurityPhaseSimOk
       
    65 //
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 TBool CStrtSecPhaseObserver::IsSecurityPhaseSimOk() const
       
    69     {
       
    70     return ( iValue == EStarterSecurityPhaseSimOk ||
       
    71              iValue == EStarterSecurityPhaseSecOk ||
       
    72              iValue == EStarterSecurityPhaseSecNok );
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CStrtSecPhaseObserver::IsSecurityPhaseSecOk
       
    77 //
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 TBool CStrtSecPhaseObserver::IsSecurityPhaseSecOk() const
       
    81     {
       
    82     return iValue == EStarterSecurityPhaseSecOk;
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CStrtSecPhaseObserver::DoCancel
       
    87 //
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CStrtSecPhaseObserver::DoCancel()
       
    91     {
       
    92     iProperty.Cancel();
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CStrtSecPhaseObserver::RunL
       
    97 //
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 void CStrtSecPhaseObserver::RunL()
       
   101     {
       
   102     TInt errorCode = iStatus.Int();
       
   103     if ( errorCode == KErrNone )
       
   104         {
       
   105         IssueRequest();
       
   106 
       
   107         TInt val( 0 );
       
   108         errorCode = iProperty.Get( CSsmUiSpecific::StarterPSUid(), KStarterSecurityPhase, val );
       
   109         if (KErrNone == errorCode)
       
   110             {
       
   111             iValue = val;
       
   112             }
       
   113         else
       
   114         	{
       
   115         	DEBUGPRINT2A("Failed to get value of Starter Security Phase property: %d", errorCode);
       
   116         	}
       
   117         }
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CStrtSecPhaseObserver::CStrtSecPhaseObserver
       
   122 // C++ default constructor can NOT contain any code, that might leave.
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 CStrtSecPhaseObserver::CStrtSecPhaseObserver() : CActive( EPriorityStandard )
       
   126     {
       
   127     CActiveScheduler::Add( this );
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CStrtSecPhaseObserver::ConstructL
       
   132 // Symbian 2nd phase constructor can leave.
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void CStrtSecPhaseObserver::ConstructL()
       
   136     {
       
   137     // Attach can only return error in oom-situation.
       
   138     User::LeaveIfError( iProperty.Attach( CSsmUiSpecific::StarterPSUid(), KStarterSecurityPhase ) );
       
   139     IssueRequest();
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CStrtSecPhaseObserver::IssueRequest
       
   144 //
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 void CStrtSecPhaseObserver::IssueRequest()
       
   148     {
       
   149     iProperty.Subscribe( iStatus );
       
   150     SetActive();
       
   151     }