sysstatemgmt/systemstatereferenceplugins/clayer/src/strtsecnoterequestqueue.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        : strtsecnoterequestqueue.cpp
       
    15 // Part of     : System Startup / StrtSecObs
       
    16 // Implementation of CStrtSecNoteRequestQueue 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 "strtsecnoterequestqueue.h"
       
    32 #include "ssmdebug.h"
       
    33 #include "clayerpanic.h"
       
    34 
       
    35 // Allocate queue space for this many items in advance.
       
    36 const TInt KPreallocatedQueueSize = 8;
       
    37 
       
    38 // ======== MEMBER FUNCTIONS ========
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CStrtSecNoteRequestQueue::NewL
       
    42 //
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CStrtSecNoteRequestQueue* CStrtSecNoteRequestQueue::NewL()
       
    46     {
       
    47     CStrtSecNoteRequestQueue* self = new( ELeave ) CStrtSecNoteRequestQueue;
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL();
       
    50     CleanupStack::Pop( self );
       
    51     return self;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // CStrtSecNoteRequestQueue::~CStrtSecNoteRequestQueue
       
    56 //
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CStrtSecNoteRequestQueue::~CStrtSecNoteRequestQueue()
       
    60     {
       
    61     iArray.Close();
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CStrtSecNoteRequestQueue::Add
       
    66 //
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 TInt CStrtSecNoteRequestQueue::Add( const TStrtSecurityNoteType aItem )
       
    70     {
       
    71 	DEBUGPRINT2A("Item to add: %d", aItem);
       
    72 	__ASSERT_DEBUG(aItem >= ESecCodePIN1 && aItem < ESecNoteTypeLimit, CLAYER_PANIC(ECLayerInvalidNoteType));
       
    73 
       
    74     TInt errorCode = iArray.Find( aItem );
       
    75     if ( errorCode == KErrNotFound )
       
    76         {
       
    77         errorCode = iArray.Append( aItem );
       
    78         }
       
    79     return errorCode;
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CStrtSecNoteRequestQueue::Remove
       
    84 //
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CStrtSecNoteRequestQueue::Remove( const TStrtSecurityNoteType aItem )
       
    88     {
       
    89 	DEBUGPRINT2A("Item to remove: %d", aItem);
       
    90     TInt idx = iArray.Find( aItem );
       
    91     
       
    92     if ( idx >= 0 && idx < iArray.Count() )
       
    93         {
       
    94         iArray.Remove( idx );
       
    95         }
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CStrtSecNoteRequestQueue::GetFirst
       
   100 //
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 TStrtSecurityNoteType CStrtSecNoteRequestQueue::GetFirst()
       
   104     {
       
   105     TStrtSecurityNoteType item = ESecNoteNone;
       
   106     if ( iArray.Count() > 0 )
       
   107         {
       
   108         item = iArray[0];
       
   109         iArray.Remove( 0 );
       
   110         }
       
   111     return item;
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CStrtSecNoteRequestQueue::CStrtSecNoteRequestQueue
       
   116 //
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 CStrtSecNoteRequestQueue::CStrtSecNoteRequestQueue()
       
   120     {
       
   121     
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CStrtSecNoteRequestQueue::ConstructL
       
   126 //
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 void CStrtSecNoteRequestQueue::ConstructL()
       
   130     {
       
   131     iArray.ReserveL( KPreallocatedQueueSize );
       
   132     }