sysstatemgmt/systemstatereferenceplugins/custcmd/src/securitynoteobserver.cpp
changeset 0 4e1aa6a622a0
child 7 1a73e8f1b64d
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-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        : strtsecuritynoteobserver.cpp
       
    15 // Part of     : System Startup / Starter
       
    16 // Implementation of CStrtSecurityNoteObserver class.
       
    17 // Version     : %version: 3 %
       
    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
       
    26 // Nokia Core OS *
       
    27 // File renamed from strtsecuritynoteobserver.cpp to securitynoteobserver.cpp as part of Core OS transfer.
       
    28 //
       
    29 
       
    30 
       
    31 
       
    32 
       
    33 /**
       
    34  @file
       
    35  @internalComponent
       
    36  @released
       
    37 */
       
    38 
       
    39 #include "startupdomainpskeys.h"
       
    40 #include "securitynoteobserver.h"
       
    41 #include "ssmuiproviderdll.h"
       
    42 #include <e32property.h>
       
    43 
       
    44 CSecurityNoteObserver* CSecurityNoteObserver::NewL()
       
    45 	{
       
    46 	CSecurityNoteObserver* self = new (ELeave) CSecurityNoteObserver(CSsmUiSpecific::StartupPSUid(), KStartupSecurityCodeQueryStatus);
       
    47 
       
    48 	CleanupStack::PushL( self );
       
    49 	self->StartL();
       
    50 	CleanupStack::Pop( self );
       
    51 
       
    52 	return self;
       
    53 	}
       
    54 
       
    55 CSecurityNoteObserver::CSecurityNoteObserver(const TUid& aCategory,
       
    56 						const TUint aKey ): CActive( EPriorityStandard ),
       
    57 						iCategory( aCategory ), iKey( aKey )
       
    58 	{
       
    59 	CActiveScheduler::Add(this);
       
    60 	}
       
    61 
       
    62 CSecurityNoteObserver::~CSecurityNoteObserver()
       
    63 	{
       
    64 	if(IsAdded())
       
    65 		{
       
    66 		Deque();
       
    67 		}
       
    68 	iProperty.Close();
       
    69 	}
       
    70 
       
    71 void CSecurityNoteObserver::StartL()
       
    72 	{
       
    73     // Attach can only return error in oom-situation.
       
    74     User::LeaveIfError(iProperty.Attach(iCategory, iKey));
       
    75     Activate();
       
    76     }
       
    77 
       
    78 void CSecurityNoteObserver::DoCancel()
       
    79 	{
       
    80 	iProperty.Cancel();
       
    81 	}
       
    82 
       
    83 TBool CSecurityNoteObserver::PropertyChanged(const TInt aCurrentValue )
       
    84 	{
       
    85 	TBool continueObserving = EFalse;
       
    86 	if (aCurrentValue == ESecurityQueryActive)
       
    87 		{
       
    88 		RProperty::Set(CSsmUiSpecific::StartupPSUid(),KPSSplashShutdown, ESplashShutdown );
       
    89 		continueObserving = ETrue;
       
    90 		}
       
    91 	return continueObserving;
       
    92 	}
       
    93 
       
    94 void CSecurityNoteObserver::RunL()
       
    95 	{
       
    96 	if (KErrNone  == iStatus.Int())
       
    97 		{
       
    98 		TInt currentValue = 0;
       
    99 		TInt errorCode = iProperty.Get( iCategory, iKey, currentValue );
       
   100 		if ( errorCode == KErrNone )
       
   101 			{
       
   102 			TBool continueObserving = PropertyChanged( currentValue );
       
   103 			if ( continueObserving )
       
   104 				{
       
   105 				Activate();
       
   106 				}
       
   107 			else
       
   108 				{
       
   109 				iProperty.Close();
       
   110 				}
       
   111 			}
       
   112 		else
       
   113 			{
       
   114 			Activate();
       
   115 			}
       
   116 		}
       
   117 	else
       
   118 		{
       
   119 		Activate();
       
   120 		}
       
   121 	}
       
   122 
       
   123 void CSecurityNoteObserver::Activate()
       
   124 	{
       
   125 	iProperty.Subscribe(iStatus);
       
   126 	SetActive();
       
   127 	}