sysstatemgmt/systemstatereferenceplugins/clayer/src/ssmsecuritynotecontroller.cpp
changeset 0 4e1aa6a622a0
child 3 a811597961f0
child 12 e978f818f9bd
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        : strtsecuritynotecontroller.cpp
       
    15 // Part of     : System Startup / StrtSecObs
       
    16 // Implementation of CStrtSecurityNoteController 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 // File renamed from strtsecuritynotecontroller.cpp to ssmsecuritynotecontroller.cpp as part of Core OS transfer.
       
    28 //
       
    29 
       
    30 
       
    31 
       
    32 #include "strtsecnoterequestqueue.h"
       
    33 #include "ssmsecuritynotecontroller.h"
       
    34 #include "ssmsecuritychecknotifier.h"
       
    35 #include "ssmdebug.h"
       
    36 
       
    37 CStrtSecurityNoteController* CStrtSecurityNoteController::NewL()
       
    38     {
       
    39     CStrtSecurityNoteController* self = new( ELeave ) CStrtSecurityNoteController;
       
    40     CleanupStack::PushL( self );
       
    41     self->ConstructL();
       
    42     CleanupStack::Pop( self );
       
    43     return self;
       
    44     }
       
    45 
       
    46 CStrtSecurityNoteController::~CStrtSecurityNoteController()
       
    47     {
       
    48     Cancel();
       
    49     delete iSecurityNote;
       
    50     delete iQueue;
       
    51     }
       
    52 
       
    53 TInt CStrtSecurityNoteController::SecurityNoteRequested(
       
    54     const TStrtSecurityNoteType aNoteType )
       
    55     {
       
    56     TInt errorCode = iQueue->Add(aNoteType);
       
    57     if(KErrNone != errorCode)
       
    58     	{
       
    59     	DEBUGPRINT2A("Failed to add security note request to the queue "
       
    60     			"with error %d", errorCode);
       
    61     	}
       
    62 
       
    63     if ((errorCode == KErrNone) && !IsActive())
       
    64         {
       
    65         CompleteSelf(); // Jump to RunL
       
    66         }
       
    67     return errorCode;
       
    68     }
       
    69 
       
    70 void CStrtSecurityNoteController::SecurityCodeVerified(
       
    71     const TStrtSecurityNoteType aNoteType )
       
    72     {
       
    73     iQueue->Remove( aNoteType );
       
    74     // No need to care about the security code which is currently being
       
    75     // requested, SecurityNotifier completes that request.
       
    76     }
       
    77 
       
    78 void CStrtSecurityNoteController::DoCancel()
       
    79     {
       
    80     iSecurityNote->Cancel();
       
    81     }
       
    82 
       
    83 void CStrtSecurityNoteController::RunL()
       
    84     {
       
    85     TStrtSecurityNoteType code = iQueue->GetFirst();
       
    86     if ( code != ESecNoteNone )
       
    87         {
       
    88         iSecurityNote->ShowNoteL(code, iStatus );
       
    89         SetActive();
       
    90         }
       
    91     }
       
    92 
       
    93 CStrtSecurityNoteController::CStrtSecurityNoteController()
       
    94   : CActive( EPriorityStandard ),    
       
    95     iQueue( NULL ),
       
    96     iSecurityNote( NULL )
       
    97     {
       
    98     CActiveScheduler::Add( this );
       
    99     }
       
   100 
       
   101 void CStrtSecurityNoteController::ConstructL()
       
   102     {
       
   103     iQueue = CStrtSecNoteRequestQueue::NewL();
       
   104     iSecurityNote = CSsmSecurityCheckNotifier::NewL();
       
   105     }
       
   106 
       
   107 void CStrtSecurityNoteController::CompleteSelf()
       
   108     {
       
   109     iStatus = KRequestPending;
       
   110     TRequestStatus* status = &iStatus;
       
   111     User::RequestComplete( status, KErrNone );
       
   112     SetActive();
       
   113     }