pkiutilities/SecModUI/src/SecModUIViewSignature.cpp
changeset 0 164170e6151a
child 5 3b17fc5c9564
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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:   Implementation of the CSecModUIViewSignature class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include  "secmodui.hrh"
       
    21 #include  "SecModUIViewSignature.h"
       
    22 #include  "SecModUIContainerSignature.h" 
       
    23 #include  "SecModUIModel.h"
       
    24 #include  "SecModUISyncWrapper.h"
       
    25 #include  <aknViewAppUi.h>
       
    26 #include  <avkon.hrh>
       
    27 #include  <SecModUI.rsg>
       
    28 #include  <aknlists.h>
       
    29 #include  <eikmenup.h>
       
    30 #include  <featmgr.h>
       
    31 
       
    32 // ================= MEMBER FUNCTIONS =======================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CSecModUIViewMain::CSecModUIViewMain
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CSecModUIViewSignature::CSecModUIViewSignature(CSecModUIModel& aModel):CSecModUIViewBase(aModel)
       
    41     {
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------
       
    45 // CSecModUIViewSignature::ConstructL(const TRect& aRect)
       
    46 // EPOC two-phased constructor
       
    47 // ---------------------------------------------------------
       
    48 //
       
    49 void CSecModUIViewSignature::ConstructL()
       
    50     {
       
    51     BaseConstructL( R_SECMODUI_VIEW_SIGNATURE );
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------
       
    55 // CSecModUIViewSignature::~CSecModUIViewSignature()
       
    56 // destructor
       
    57 // ---------------------------------------------------------
       
    58 //
       
    59 CSecModUIViewSignature::~CSecModUIViewSignature()
       
    60     {
       
    61    
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CSecModUIViewSignature::NewLC
       
    66 // Two-phased constructor.
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 CSecModUIViewSignature* CSecModUIViewSignature::NewLC(CSecModUIModel& aModel)
       
    70     {
       
    71     CSecModUIViewSignature* self = new (ELeave) CSecModUIViewSignature(aModel);
       
    72     CleanupStack::PushL(self);
       
    73     self->ConstructL();
       
    74     return self;
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------
       
    78 // void CSecModUIViewSignature::CreateContainerL()
       
    79 // Creates container
       
    80 // ---------------------------------------------------------
       
    81 //
       
    82 void CSecModUIViewSignature::CreateContainerL()
       
    83     {
       
    84     iContainer = new (ELeave) CSecModUIContainerSignature(iModel, this);
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------
       
    88 // CSecModUIViewSignature::AddNavipaneLabelL()
       
    89 // Default implementation is empty
       
    90 // ---------------------------------------------------------
       
    91 //
       
    92 void CSecModUIViewSignature::AddNaviPaneLabelL()
       
    93     { 
       
    94     DoAddNaviPaneL(R_NAVIPANE_SIGNATURE_TEXT);   
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------
       
    98 // TUid CSecModUIViewSignature::Id()
       
    99 //
       
   100 // ---------------------------------------------------------
       
   101 //
       
   102 TUid CSecModUIViewSignature::Id() const
       
   103     {
       
   104     return KSecModUIViewSignatureId;
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------
       
   108 // CSecModUIViewSignature::HandleCommandL(TInt aCommand)
       
   109 // takes care of view command handling
       
   110 // ---------------------------------------------------------
       
   111 //
       
   112 void CSecModUIViewSignature::HandleCommandL(TInt aCommand)
       
   113     {
       
   114     if (iModel.Wrapper().IsActive())
       
   115         {
       
   116         return;
       
   117         }  
       
   118     switch ( aCommand )
       
   119         {
       
   120         case ESecModUICmdChange:
       
   121             {
       
   122             iModel.ChangePinNrL(iContainer->ListBox().CurrentItemIndex());
       
   123             iModel.LoadPinNRLabelsL(iContainer->ListBox(), EFalse);
       
   124             iContainer->DrawNow();
       
   125             UpdateCbaL(iContainer->ListBox().CurrentItemIndex());
       
   126             break;
       
   127             }            
       
   128         case ESecModUICmdUnblock:
       
   129             {
       
   130             iModel.UnblockPinNrL(iContainer->ListBox().CurrentItemIndex());
       
   131             iModel.LoadPinNRLabelsL(iContainer->ListBox(), EFalse);
       
   132             iContainer->DrawNow();
       
   133             UpdateCbaL(iContainer->ListBox().CurrentItemIndex());
       
   134             break;
       
   135             }
       
   136         case EAknSoftkeyChange:
       
   137             {
       
   138             iModel.ChangePinNrL(iContainer->ListBox().CurrentItemIndex());
       
   139             iModel.LoadPinNRLabelsL(iContainer->ListBox(), EFalse);
       
   140             iContainer->DrawNow();
       
   141             UpdateCbaL(iContainer->ListBox().CurrentItemIndex());	
       
   142             break;	
       
   143             }
       
   144         case EAknSoftkeyUnlock:
       
   145             {
       
   146             iModel.UnblockPinNrL(iContainer->ListBox().CurrentItemIndex());
       
   147             iModel.LoadPinNRLabelsL(iContainer->ListBox(), EFalse);
       
   148             iContainer->DrawNow();
       
   149             UpdateCbaL(iContainer->ListBox().CurrentItemIndex());
       
   150             break;	
       
   151             }
       
   152         default:
       
   153             {
       
   154             CSecModUIViewBase::HandleCommandL( aCommand );
       
   155             break;
       
   156             }
       
   157         }
       
   158     
       
   159     }
       
   160 
       
   161 
       
   162 // ---------------------------------------------------------
       
   163 // TUid CSecModUIViewSignature::DynInitMenuPaneL(
       
   164 //      TInt aResourceId, CEikMenuPane* aMenuPane)
       
   165 //
       
   166 // ---------------------------------------------------------
       
   167 //
       
   168 void CSecModUIViewSignature::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
       
   169     {
       
   170     TInt currentItem = iContainer->ListBox().CurrentItemIndex();
       
   171     switch(aResourceId)
       
   172         {
       
   173         case R_SECMODUI_VIEW_SIGNATURE_MENU:
       
   174             {
       
   175             if( aResourceId == !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   176                 {
       
   177                 aMenuPane->DeleteMenuItem( EAknCmdHelp ); //remove help
       
   178                 } 
       
   179             // The security module list is empty.  
       
   180             // All except Exit and Help is dimmed.
       
   181             if (!iModel.PinNrChangeable(currentItem))
       
   182                 {
       
   183                 aMenuPane->SetItemDimmed( ESecModUICmdChange, ETrue );
       
   184                 }
       
   185             if (!iModel.PinNrUnblockable(currentItem))
       
   186                 {
       
   187                 aMenuPane->SetItemDimmed( ESecModUICmdUnblock, ETrue );
       
   188                 }
       
   189             break;
       
   190             }
       
   191         default:
       
   192             {
       
   193             break;
       
   194             }    
       
   195         }  
       
   196     }
       
   197 
       
   198 // ---------------------------------------------------------
       
   199 // CSecModUIViewSignature::HandleListBoxEventL(
       
   200 //     CEikListBox* aListBox, TListBoxEvent aEventType)
       
   201 // ---------------------------------------------------------
       
   202 //     
       
   203 void CSecModUIViewSignature::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
       
   204     {
       
   205     if(iModel.Wrapper().IsActive())
       
   206         {
       
   207         return;	
       
   208         }
       
   209         
       
   210     switch( aEventType )
       
   211 		{
       
   212 		case EEventEnterKeyPressed:
       
   213 		case EEventItemDoubleClicked:
       
   214 		case EEventItemSingleClicked:
       
   215 			{			
       
   216 			iModel.ChangeOrUnblockPinNrL(aListBox->CurrentItemIndex());
       
   217 			iModel.LoadPinNRLabelsL(iContainer->ListBox(), EFalse);
       
   218             iContainer->DrawNow();
       
   219             UpdateCbaL(aListBox->CurrentItemIndex());
       
   220             break;
       
   221 			}
       
   222         default:
       
   223             {
       
   224 			break;
       
   225             }
       
   226 		}           
       
   227     }
       
   228 
       
   229 
       
   230 // ---------------------------------------------------------
       
   231 // CSecModUIViewSignature::UpdateCbaL()
       
   232 //     
       
   233 // ---------------------------------------------------------
       
   234 //
       
   235 void CSecModUIViewSignature::UpdateCbaL( TInt aIndex )
       
   236     {
       
   237     if( iModel.PinNrChangeable(aIndex) )
       
   238         {
       
   239         SetCbaL(R_SECMODUI_SOFTKEYS_OPTIONS_BACK_CHANGE);
       
   240         }
       
   241     else
       
   242         {
       
   243         if( !iModel.PinNrUnblockable(aIndex) )
       
   244             {
       
   245             SetCbaL(R_SECMODUI_SOFTKEYS_OPTIONS_BACK);
       
   246             } 
       
   247         else
       
   248             {
       
   249             SetCbaL(R_SECMODUI_SOFTKEYS_OPTIONS_BACK_UNBLOCK);	
       
   250             }     
       
   251         }    	
       
   252     }
       
   253 
       
   254 
       
   255 // ---------------------------------------------------------
       
   256 // CSecModUIViewSignature::SetCbaL()
       
   257 //     
       
   258 // ---------------------------------------------------------
       
   259 // 
       
   260 void CSecModUIViewSignature::SetCbaL( TInt aCbaResourceId )
       
   261     {
       
   262 	CEikButtonGroupContainer*  cba = Cba();
       
   263     cba->SetCommandSetL(aCbaResourceId);
       
   264     cba->DrawNow();
       
   265     }
       
   266 
       
   267 
       
   268 // ---------------------------------------------------------
       
   269 // CSecModUIViewSignature::DoActivateL()
       
   270 //     
       
   271 // ---------------------------------------------------------
       
   272 //     
       
   273 void CSecModUIViewSignature::DoActivateL(
       
   274    const TVwsViewId& aPrevViewId,TUid /*aCustomMessageId*/,
       
   275    const TDesC8& /*aCustomMessage*/)
       
   276     {
       
   277   
       
   278     if (KNullUid == iPrevViewId.iViewUid)
       
   279         {
       
   280         iPrevViewId = aPrevViewId;
       
   281         }
       
   282     SetTitlePaneL();
       
   283     AddNaviPaneLabelL();
       
   284                     
       
   285     if (!iContainer)
       
   286         {
       
   287         CreateContainerL();
       
   288         iContainer->SetMopParent(this);
       
   289         iContainer->ConstructL(ClientRect());
       
   290         iContainer->ListBox().SetListBoxObserver(this);
       
   291         AppUi()->AddToStackL(*this, iContainer);
       
   292         }         
       
   293    iContainer->MakeVisible(ETrue);
       
   294    iContainer->SetRect(ClientRect());
       
   295    iContainer->ActivateL();
       
   296    
       
   297    UpdateCbaL(iContainer->ListBox().CurrentItemIndex());
       
   298        
       
   299    }
       
   300 
       
   301 // ---------------------------------------------------------
       
   302 // CSecModUIViewSignature::DoDeactivate()
       
   303 // 
       
   304 // ---------------------------------------------------------
       
   305 //
       
   306 void CSecModUIViewSignature::DoDeactivate()
       
   307     {
       
   308  
       
   309     if ( iContainer )
       
   310         {
       
   311         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   312         }
       
   313     
       
   314     delete iContainer;
       
   315     iContainer = NULL;
       
   316         
       
   317     }  
       
   318            
       
   319 // End of File
       
   320