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