pkiutilities/CertmanUi/SRC/CertmanuiviewDevice.cpp
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2003-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 class CCertManUIViewDevice
       
    15 *                Updates Options list depending of the number of
       
    16 *                marked and unmarked certificates in the listbox.
       
    17 *                Handles softkey and Option list commands.
       
    18 *                Handles certificate deletion including confirmation and
       
    19 *                read-only notes.
       
    20 *                Shows certificate details view with appropriate
       
    21 *                warning notes if certificate is corrupted/expired/not valid.
       
    22 *
       
    23 */
       
    24 
       
    25 
       
    26 // INCLUDE FILES
       
    27 #include <aknmessagequerydialog.h>
       
    28 #include <aknnotewrappers.h>            // for warning & information notes
       
    29 #include <X509CertNameParser.h>
       
    30 #include <ErrorUI.h>
       
    31 #include <x509cert.h>
       
    32 #include <pkixcertchain.h>              //for validation
       
    33 #include <certmanui.rsg>
       
    34 #include "CertmanuiCertificateHelper.h"
       
    35 #include "CertmanuiKeeper.h"
       
    36 #include "CertmanuiviewDevice.h"
       
    37 #include "CertmanuicontainerDevice.h"
       
    38 #include "Certmanui.hrh"
       
    39 #include "Certmanuitrustids.h"
       
    40 #include "CertmanuiSyncWrapper.h"
       
    41 #include "CertmanuiCommon.h"
       
    42 #include "CertManUILogger.h"
       
    43 
       
    44 #include    <hlplch.h>                  // For HlpLauncher
       
    45 #include    <featmgr.h>                 // For FeatureManager
       
    46 
       
    47 // ================= MEMBER FUNCTIONS =======================
       
    48 
       
    49 // ---------------------------------------------------------
       
    50 // CCertManUIViewDevice::CCertManUIViewDevice(CCertManUIKeeper& aKeeper)
       
    51 // : iKeeper(aKeeper), iCrMgr(iKeeper.CertManager())
       
    52 // Constructor
       
    53 // ---------------------------------------------------------
       
    54 //
       
    55 CCertManUIViewDevice::CCertManUIViewDevice( CCertManUIKeeper& aKeeper )
       
    56     : iKeeper( aKeeper )
       
    57     {
       
    58     CERTMANUILOGGER_WRITE_TIMESTAMP(
       
    59         "CCertManUIViewDevice::CCertManUIViewDevice" );
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // CCertManUIViewDevice::~CCertManUIViewDevice()
       
    64 // Destructor
       
    65 // ---------------------------------------------------------
       
    66 //
       
    67 CCertManUIViewDevice::~CCertManUIViewDevice()
       
    68     {
       
    69     CERTMANUILOGGER_ENTERFN( " CCertManUIViewDevice::~CCertManUIViewDevice" );
       
    70 
       
    71     if ( iContainerDevice )
       
    72         {
       
    73         AppUi()->RemoveFromViewStack( *this, iContainerDevice );
       
    74         delete iContainerDevice;
       
    75         }
       
    76 
       
    77     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewDevice::~CCertManUIViewDevice" );
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------
       
    81 // CCertManUIViewDevice* CCertManUIViewDevice::NewL(
       
    82 //      const TRect& /*aRect*/, CCertManUIKeeper& aKeeper)
       
    83 // ---------------------------------------------------------
       
    84 //
       
    85 CCertManUIViewDevice* CCertManUIViewDevice::NewL(
       
    86     const TRect& /*aRect*/, CCertManUIKeeper& aKeeper )
       
    87     {
       
    88     CCertManUIViewDevice* self =
       
    89         new ( ELeave ) CCertManUIViewDevice( aKeeper );
       
    90     CleanupStack::PushL( self );
       
    91     self->ConstructL();
       
    92     CleanupStack::Pop();
       
    93     return self;
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------
       
    97 // CCertManUIViewDevice* CCertManUIViewDevice::NewLC(
       
    98 //  const TRect& /*aRect*/, CCertManUIKeeper& aKeeper)
       
    99 // ---------------------------------------------------------
       
   100 //
       
   101 CCertManUIViewDevice* CCertManUIViewDevice::NewLC(
       
   102     const TRect& /*aRect*/, CCertManUIKeeper& aKeeper )
       
   103     {
       
   104     CCertManUIViewDevice* self =
       
   105         new ( ELeave ) CCertManUIViewDevice( aKeeper );
       
   106     CleanupStack::PushL( self );
       
   107     self->ConstructL();
       
   108     return self;
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------
       
   112 // CCertManUIViewDevice::ConstructL()
       
   113 // EPOC two-phased constructor
       
   114 // ---------------------------------------------------------
       
   115 //
       
   116 void CCertManUIViewDevice::ConstructL()
       
   117     {
       
   118     CERTMANUILOGGER_ENTERFN( " CCertManUIViewDevice::ConstructL" );
       
   119 
       
   120     BaseConstructL( R_CERTMANUI_VIEW_MAIN_DEVICE );
       
   121 
       
   122     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewDevice::ConstructL" );
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------
       
   126 // CCertManUIViewDevice::DynInitMenuPaneL(
       
   127 //      TInt aResourceId,CEikMenuPane* aMenuPane)
       
   128 // Updates Options list with correct items depending on
       
   129 // whether the listbox is empty or if it has any marked items
       
   130 // ---------------------------------------------------------
       
   131 //
       
   132 void CCertManUIViewDevice::DynInitMenuPaneL(
       
   133     TInt aResourceId, CEikMenuPane* aMenuPane )
       
   134     {
       
   135     CERTMANUILOGGER_ENTERFN( " CCertManUIViewDevice::DynInitMenuPaneL" );
       
   136 
       
   137     if (( iKeeper.iWrapper->IsActive()) ||
       
   138         ( iContainerDevice->iListBox->CurrentItemIndex() >= iKeeper.iDeviceLabelEntries.Count()))
       
   139         {
       
   140         return;
       
   141         }
       
   142 
       
   143     const CListBoxView::CSelectionIndexArray* selections =
       
   144             iContainerDevice->iListBox->SelectionIndexes();
       
   145     const TInt markedCount = selections->Count();
       
   146     const TInt currentItemIndex = iContainerDevice->iListBox->CurrentItemIndex();
       
   147 
       
   148     switch ( aResourceId )
       
   149         {
       
   150         case R_CERTMANUI_VIEW_MENU_DEVICE:
       
   151             {
       
   152             if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   153                 {
       
   154                 aMenuPane->DeleteMenuItem( EAknCmdHelp );
       
   155                 }
       
   156 
       
   157             // the certificate list is empty, all except Exit are dimmed
       
   158             if ( currentItemIndex == -1 )
       
   159                 {
       
   160                 aMenuPane->SetItemDimmed( ECertManUICmdAppViewDtls, ETrue );
       
   161                 aMenuPane->SetItemDimmed( ECertManUICmdAppDelete, ETrue );
       
   162                 aMenuPane->SetItemDimmed( ECertManUICmdMoveToPersonal, ETrue );
       
   163                 aMenuPane->SetItemDimmed( ECertManUICmdMarkUnmark, ETrue );
       
   164                 }
       
   165             else
       
   166                 {
       
   167                 if ( markedCount == 1 )
       
   168                     {
       
   169                     aMenuPane->SetItemDimmed( ECertManUICmdAppViewDtls, ETrue );
       
   170                     }
       
   171 
       
   172                 if ( markedCount > 1 )
       
   173                     {
       
   174                     aMenuPane->SetItemDimmed( ECertManUICmdAppViewDtls, ETrue );
       
   175                     aMenuPane->SetItemDimmed( ECertManUICmdMoveToPersonal, ETrue );
       
   176                     }
       
   177 
       
   178                 if ( !iKeeper.iCertificateHelper->IsOneMarkedCertificateDeletable(
       
   179                         iContainerDevice->iListBox, KCertTypeDevice ) )
       
   180                     {
       
   181                     aMenuPane->SetItemDimmed( ECertManUICmdAppDelete, ETrue );
       
   182                     aMenuPane->SetItemDimmed( ECertManUICmdMoveToPersonal, ETrue );
       
   183                     }
       
   184                 }
       
   185             break;
       
   186             }
       
   187 
       
   188         case R_CERTMANUI_MENUPANE_OPTIONS_MARKED:
       
   189             {
       
   190             if ( markedCount > 1 )
       
   191                 {
       
   192                 aMenuPane->SetItemDimmed( ECertManUICmdMoveToPersonal, ETrue );
       
   193                 }
       
   194 
       
   195             if ( !iKeeper.iCertificateHelper->IsOneMarkedCertificateDeletable(
       
   196                     iContainerDevice->iListBox, KCertTypeDevice ) )
       
   197                 {
       
   198                 aMenuPane->SetItemDimmed( ECertManUICmdAppDelete, ETrue );
       
   199                 }
       
   200 
       
   201             // not available for device certificates
       
   202             aMenuPane->SetItemDimmed( ECertManUICmdMoveToDevice, ETrue );
       
   203             }
       
   204             // FALLTHROUGH
       
   205 
       
   206         case R_CERTMANUI_MENU_PANE_MARK_UNMARK:
       
   207             {
       
   208             TInt index = 0;
       
   209             TKeyArrayFix key( 0, ECmpTInt );
       
   210             if ( selections->Find( currentItemIndex, key, index ) )
       
   211                 {   // focus is on unmarked item
       
   212                 aMenuPane->SetItemDimmed( ECertManUICmdUnmark, ETrue );
       
   213                 }
       
   214             else
       
   215                 {   // focus is on marked item
       
   216                 aMenuPane->SetItemDimmed( ECertManUICmdMark, ETrue );
       
   217                 }
       
   218 
       
   219             // if all items are marked, dim "mark all" option
       
   220             if ( markedCount == iContainerDevice->iListBox->Model()->NumberOfItems() )
       
   221                 {
       
   222                 aMenuPane->SetItemDimmed( ECertManUICmdMarkAll, ETrue );
       
   223                 }
       
   224 
       
   225             // if no items are marked, dim "unmark all" option
       
   226             if ( markedCount == 0 )
       
   227                 {
       
   228                 aMenuPane->SetItemDimmed( ECertManUICmdUnmarkAll, ETrue );
       
   229                 }
       
   230             break;
       
   231             }
       
   232 
       
   233         default:
       
   234             break;
       
   235         }
       
   236 
       
   237     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewDevice::DynInitMenuPaneL" );
       
   238     }
       
   239 
       
   240 // ---------------------------------------------------------
       
   241 // CCertManUIViewDevice::Id() const
       
   242 // Returns Authority view id
       
   243 // ---------------------------------------------------------
       
   244 //
       
   245 TUid CCertManUIViewDevice::Id() const
       
   246     {
       
   247     return KCertManUIViewDeviceId;
       
   248     }
       
   249 
       
   250 // ---------------------------------------------------------
       
   251 // CCertManUIViewDevice::HandleCommandL(TInt aCommand)
       
   252 // Handles Softkey and Options list commands
       
   253 // ---------------------------------------------------------
       
   254 //
       
   255 void CCertManUIViewDevice::HandleCommandL( TInt aCommand )
       
   256     {
       
   257     CERTMANUILOGGER_ENTERFN( " CCertManUIViewDevice::HandleCommandL" );
       
   258 
       
   259     if (( iKeeper.iWrapper->IsActive() ) ||
       
   260         ( iContainerDevice->iListBox->CurrentItemIndex() >= iKeeper.iDeviceLabelEntries.Count() ))
       
   261         {
       
   262         return;
       
   263         }
       
   264 
       
   265     switch ( aCommand )
       
   266         {
       
   267         case EAknSoftkeyBack:
       
   268             {
       
   269             // Activate main view
       
   270             AppUi()->ActivateLocalViewL( KCertManUIViewMainId );
       
   271             break;
       
   272             }
       
   273         // put the view specific menu commands here
       
   274         case EAknCmdExit:
       
   275             {
       
   276             ((CAknViewAppUi*)iAvkonAppUi)->HandleCommandL( EAknCmdExit );
       
   277             break;
       
   278             }
       
   279         case ECertManUICmdAppViewDtls:
       
   280             {
       
   281             iKeeper.iCertificateHelper->MessageQueryViewDetailsL(
       
   282                 iContainerDevice->iListBox->CurrentItemIndex(),
       
   283                 KCertTypeDevice, iEikonEnv );
       
   284             break;
       
   285             }
       
   286         case ECertManUICmdAppDelete:
       
   287             {
       
   288             if ( iKeeper.iCertificateHelper->ConfirmationQueryDeleteCertL( KCertTypeDevice,
       
   289                                                     iContainerDevice->iListBox) )
       
   290                 {
       
   291                 // goes here if at least one certificate is deleted
       
   292                 iCurrentPosition = iContainerDevice->iListBox->CurrentItemIndex();
       
   293                 iTopItem = iContainerDevice->iListBox->TopItemIndex();
       
   294 
       
   295                 iContainerDevice->DrawListBoxL(iCurrentPosition, iTopItem );
       
   296                 TRAPD( error, iKeeper.RefreshDeviceCertEntriesL() );
       
   297                 if ( error != KErrNone )
       
   298                     {
       
   299                     if ( error == KErrCorrupt )
       
   300                         {
       
   301                         iKeeper.ShowErrorNoteL( error );
       
   302                         User::Exit( KErrNone );
       
   303                         }
       
   304                     else
       
   305                         {
       
   306                         // have to call straight away the Exit
       
   307                         // showing any error notes would corrupt the display
       
   308                         User::Exit( error );
       
   309                         }
       
   310                     }
       
   311                 UpdateMenuBar();
       
   312                 }
       
   313             break;
       
   314             }
       
   315        case ECertManUICmdMoveToPersonal:
       
   316             {
       
   317             HBufC* prompt = StringLoader::LoadLC(
       
   318                         R_QTN_CM_CONF_MOVE_TO_PERSONAL );
       
   319             TInt selection = iKeeper.iCertificateHelper->DisplayConfirmationLD(prompt);
       
   320             if ( selection )
       
   321                 {
       
   322                 TInt focusPosition = 0;
       
   323                 
       
   324                 const CArrayFix<TInt>* array = iContainerDevice->iListBox->SelectionIndexes();
       
   325                 
       
   326                 if ( array->Count() == 1 )
       
   327                     {
       
   328                     // item is marked
       
   329                     focusPosition = array->At( 0 );
       
   330                     }
       
   331                 else
       
   332                     {
       
   333                     // There is no marked item. Select higlighted item 
       
   334                     focusPosition = iContainerDevice->iListBox->CurrentItemIndex();
       
   335                     }
       
   336                                                         
       
   337                 CCTCertInfo* entry = iKeeper.iDeviceLabelEntries[ focusPosition ]->iDeviceEntry;
       
   338 
       
   339                 // Move key first
       
   340                 TCTKeyAttributeFilter keyFilter;
       
   341                 keyFilter.iKeyId = entry->SubjectKeyId();
       
   342                 keyFilter.iPolicyFilter =  TCTKeyAttributeFilter::EAllKeys;
       
   343 
       
   344                 TRAPD( error, iKeeper.iCertificateHelper->MoveKeyL( keyFilter,
       
   345                                 KCMDeviceKeyStoreTokenUid, KCMFileKeyStoreTokenUid ));
       
   346 
       
   347                 if ( error == KErrNone )
       
   348                     {
       
   349                     iKeeper.iCertificateHelper->MoveCertL(
       
   350                                                       *entry,
       
   351                                                       focusPosition,
       
   352                                                       iContainerDevice->iListBox,
       
   353                                                       KCMDeviceCertStoreTokenUid,
       
   354                                                       KCMFileCertStoreTokenUid );
       
   355 
       
   356                     TRAP( error, iKeeper.RefreshDeviceCertEntriesL() );
       
   357                     if ( error != KErrNone )
       
   358                         {
       
   359                         if ( error == KErrCorrupt )
       
   360                             {
       
   361                             iKeeper.ShowErrorNoteL( error );
       
   362                             User::Exit( KErrNone );
       
   363                             }
       
   364                         else
       
   365                             {
       
   366                             // have to call straight away the Exit
       
   367                             // showing any error notes would corrupt the display
       
   368                             User::Exit( error );
       
   369                             }
       
   370                         }
       
   371 
       
   372                     MDesCArray* itemList = iContainerDevice->iListBox->Model()->ItemTextArray();
       
   373                     CDesCArray* itemArray = ( CDesCArray* )itemList;
       
   374                     if (( itemArray != NULL ) && ( itemArray->Count() == 0 ))
       
   375                         {
       
   376                         iCurrentPosition = 0;
       
   377                         iTopItem = 0;
       
   378                         iContainerDevice->UpdateListBoxL( iCurrentPosition, iTopItem );
       
   379                         }
       
   380                      else
       
   381                         {
       
   382                         iCurrentPosition = iContainerDevice->iListBox->CurrentItemIndex();
       
   383                         iTopItem = iContainerDevice->iListBox->TopItemIndex();
       
   384                         }
       
   385 
       
   386                     iContainerDevice->DrawListBoxL(iCurrentPosition, iTopItem );
       
   387 
       
   388                     UpdateMenuBar();
       
   389                     }
       
   390                 }
       
   391             break;
       
   392             }
       
   393         case ECertManUICmdMark:
       
   394         case ECertManUICmdUnmark:
       
   395         case ECertManUICmdMarkAll:
       
   396         case ECertManUICmdUnmarkAll:
       
   397             {
       
   398             // Gets pointer of current listbox.
       
   399             CEikListBox* listbox = iContainerDevice->iListBox;
       
   400             if ( listbox )
       
   401                 {
       
   402                 AknSelectionService::HandleMarkableListProcessCommandL(
       
   403                     aCommand, listbox );
       
   404 
       
   405                 iKeeper.iCertificateHelper->
       
   406                                     HandleMarkableListCommandL(
       
   407                                                               aCommand,
       
   408                                                               iContainerDevice->iListBox
       
   409                                                               );
       
   410 
       
   411                 UpdateMenuBar();
       
   412                 }
       
   413             break;
       
   414             }
       
   415         case EAknCmdHelp:
       
   416             {
       
   417             if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   418                 {
       
   419                 HlpLauncher::LaunchHelpApplicationL(
       
   420                    iEikonEnv->WsSession(), AppUi()->AppHelpContextL() );
       
   421                 }
       
   422 
       
   423             break;
       
   424             }
       
   425 
       
   426         default:
       
   427             {
       
   428             AppUi()->HandleCommandL( aCommand );
       
   429             break;
       
   430             }
       
   431         }
       
   432 
       
   433     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewDevice::HandleCommandL" );
       
   434     }
       
   435 
       
   436 // ---------------------------------------------------------
       
   437 // CCertManUIViewDevice::HandleClientRectChange()
       
   438 // ---------------------------------------------------------
       
   439 //
       
   440 void CCertManUIViewDevice::HandleClientRectChange()
       
   441     {
       
   442     if ( iContainerDevice )
       
   443         {
       
   444         iContainerDevice->SetRect( ClientRect() );
       
   445         }
       
   446     }
       
   447 
       
   448 // ---------------------------------------------------------
       
   449 // CCertManUIViewDevice::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
       
   450 //      TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
       
   451 // Updates the view when opening it
       
   452 // ---------------------------------------------------------
       
   453 //
       
   454 void CCertManUIViewDevice::DoActivateL(
       
   455     const TVwsViewId& aPrevViewId,
       
   456     TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
       
   457     {
       
   458      CERTMANUILOGGER_ENTERFN( " CCertManUIViewDevice::DoActivateL" );
       
   459 
       
   460      iKeeper.StartWaitDialogL( ECertmanUiWaitDialog );
       
   461      CleanupCloseWaitDialogPushL( iKeeper );
       
   462 
       
   463      TRAPD ( error, iKeeper.RefreshDeviceCertEntriesL() );
       
   464      if ( error != KErrNone )
       
   465          {
       
   466          if ( error == KErrCorrupt )
       
   467              {
       
   468              iKeeper.ShowErrorNoteL( error );
       
   469              User::Exit( KErrNone );
       
   470              }
       
   471          else
       
   472              {
       
   473              // have to call straight away the Exit
       
   474              // showing any error notes would corrupt the display
       
   475              User::Exit( error );
       
   476              }
       
   477          }
       
   478 
       
   479     // If this view is being activated from main view,
       
   480     // current position is 0. The declaration of KCertManUIViewMainId is
       
   481     // located in certmanuiviewid.h which is not public header --> constant
       
   482     // is being used.
       
   483     if( aPrevViewId.iViewUid == KCertManUIViewMainId )
       
   484         {
       
   485         iCurrentPosition = 0;
       
   486         }
       
   487 
       
   488     if ( iContainerDevice )
       
   489         {
       
   490         ((CAknViewAppUi*)iAvkonAppUi)->RemoveFromViewStack(
       
   491             *this, iContainerDevice );
       
   492 
       
   493         delete iContainerDevice;
       
   494         iContainerDevice = NULL;
       
   495         }
       
   496 
       
   497     iContainerDevice = new (ELeave) CCertManUIContainerDevice(
       
   498         *this, iKeeper );
       
   499 
       
   500     iContainerDevice->SetMopParent( this );
       
   501     iContainerDevice->ConstructL(
       
   502         ClientRect(), iCurrentPosition, iTopItem );
       
   503 
       
   504     if ( !iKeeper.iCertsDatOK )
       
   505         {
       
   506         iCurrentPosition = 0;
       
   507         iTopItem = 0;
       
   508         }
       
   509 
       
   510     iKeeper.ActivateTitleL( KViewTitleCertManUIDevice );
       
   511 
       
   512     iContainerDevice->DrawListBoxL( iCurrentPosition, iTopItem );
       
   513     ((CAknViewAppUi*)iAvkonAppUi)->AddToStackL( *this, iContainerDevice );
       
   514 
       
   515     UpdateMenuBar();
       
   516 
       
   517     CleanupStack::PopAndDestroy();    // closes wait dialog
       
   518 
       
   519     iKeeper.iStartup = EFalse;
       
   520 
       
   521      CERTMANUILOGGER_LEAVEFN( " CCertManUIViewDevice::DoActivateL" );
       
   522     }
       
   523 
       
   524 // ---------------------------------------------------------
       
   525 // CCertManUIViewDevice::DoDeactivate()
       
   526 // Saves focus position when closing view
       
   527 // ---------------------------------------------------------
       
   528 //
       
   529 void CCertManUIViewDevice::DoDeactivate()
       
   530     {
       
   531      CERTMANUILOGGER_ENTERFN( " CCertManUIViewDevice::DoDeactivate" );
       
   532 
       
   533     if ( iKeeper.iCertsDatOK )
       
   534         {
       
   535         iCurrentPosition = iContainerDevice->iListBox->CurrentItemIndex();
       
   536         iTopItem = iContainerDevice->iListBox->TopItemIndex();
       
   537         }
       
   538     else
       
   539         {
       
   540         iCurrentPosition = 0;
       
   541         iTopItem = 0;
       
   542         }
       
   543 
       
   544      CERTMANUILOGGER_LEAVEFN( " CCertManUIViewDevice::DoDeactivate" ); //lint !e539
       
   545     }
       
   546 
       
   547 // ---------------------------------------------------------
       
   548 // CCertManUIViewDevice::Container()
       
   549 // Returns iContainerDevice to be used in CertManUiContainerDevice
       
   550 // ---------------------------------------------------------
       
   551 //
       
   552 CCoeControl* CCertManUIViewDevice::Container()
       
   553     {
       
   554     return iContainerDevice;
       
   555     }
       
   556 
       
   557 // ---------------------------------------------------------
       
   558 // CCertManUIViewDevice::UpdateMenuBar()
       
   559 // Updates the menu bar
       
   560 // ---------------------------------------------------------
       
   561 //
       
   562 void CCertManUIViewDevice::UpdateMenuBar()
       
   563     {
       
   564     CEikButtonGroupContainer*  cba = Cba();
       
   565 
       
   566     if ( cba == NULL )
       
   567         {
       
   568         return;
       
   569         }
       
   570 
       
   571     if ( iKeeper.iDeviceLabelEntries.Count() == 0 )
       
   572         {
       
   573         // No certificate. Don't show MSK
       
   574         UpdateCba( R_CERTMANUI_OPTIONS_OPEN_BACK );
       
   575         cba->MakeCommandVisible( ECertManUICmdAppViewDtls, EFalse );
       
   576         }
       
   577     else
       
   578         {
       
   579         if ( iContainerDevice->iListBox->SelectionIndexes()->Count() > 0 )
       
   580             {
       
   581             MenuBar()->SetContextMenuTitleResourceId( R_CERTMANUI_MENUBAR_OPTIONS_MARKED );
       
   582             UpdateCba( R_CERTMANUI_OPTIONS_CONTEXT_BACK );
       
   583             }
       
   584         else
       
   585             {
       
   586             MenuBar()->SetMenuTitleResourceId( R_CERTMANUI_MENUBAR_VIEW_DEVICE );
       
   587             UpdateCba( R_CERTMANUI_OPTIONS_OPEN_BACK );
       
   588             }
       
   589          cba->MakeCommandVisible( ECertManUICmdAppViewDtls, ETrue );
       
   590          }
       
   591     }
       
   592 
       
   593 // ---------------------------------------------------------
       
   594 // CCertManUIViewDevice::UpdateCba( TInt aCbaResourceId )
       
   595 // Updates cba
       
   596 // ---------------------------------------------------------
       
   597 //
       
   598 void CCertManUIViewDevice::UpdateCba( TInt aCbaResourceId )
       
   599     {
       
   600     CEikButtonGroupContainer*  cba = Cba();
       
   601 
       
   602     if ( cba )
       
   603         {
       
   604         cba->SetCommandSetL( aCbaResourceId );
       
   605         cba->DrawNow();
       
   606         }
       
   607     }
       
   608 
       
   609 // End of File
       
   610 
       
   611 
       
   612