pkiutilities/CertmanUi/SRC/CertmanuiviewTrust.cpp
changeset 0 164170e6151a
child 12 a005fc61b02a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2003-2007 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 CCertManUIViewTrust
       
    15 *                Updates Options list depending on the status of the
       
    16 *                trusted clients (unavailable, located in WIM).
       
    17 *                Handles Softkey and Options list commands.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <certificateapps.h>
       
    24 #include <certmanui.rsg>
       
    25 #include "CertmanuiKeeper.h"
       
    26 #include "CertmanuiviewTrust.h"
       
    27 #include "CertmanuicontainerTrust.h"
       
    28 #include "CertmanuicontainerAuthority.h"
       
    29 #include "CertmanuiSyncWrapper.h"
       
    30 #include "Certmanuitrustids.h"
       
    31 #include "Certmanui.hrh"
       
    32 #include "CertmanuiCommon.h"
       
    33 #include "CertManUILogger.h"
       
    34 #include "securityuisvariant.hrh"
       
    35 #include "CertmanuiCertificateHelper.h"
       
    36 
       
    37 #include    <hlplch.h>            // For HlpLauncher
       
    38 #include    <featmgr.h>           // For FeatureManager
       
    39 
       
    40 
       
    41 
       
    42 // ================= MEMBER FUNCTIONS =======================
       
    43 
       
    44 // ---------------------------------------------------------
       
    45 // CCertManUIViewTrust::CCertManUIViewTrust(CCertManUIKeeper& aKeeper)
       
    46 // Constructor
       
    47 // ---------------------------------------------------------
       
    48 //
       
    49 CCertManUIViewTrust::CCertManUIViewTrust( CCertManUIKeeper& aKeeper )
       
    50     : iKeeper( aKeeper )
       
    51     {
       
    52     CERTMANUILOGGER_WRITE_TIMESTAMP(
       
    53         "CCertManUIViewTrust::CCertManUIViewTrust" );
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------
       
    57 // CCertManUIViewTrust::~CCertManUIViewTrust()
       
    58 // Destructor
       
    59 // ---------------------------------------------------------
       
    60 //
       
    61 CCertManUIViewTrust::~CCertManUIViewTrust()
       
    62     {
       
    63     CERTMANUILOGGER_ENTERFN( " CCertManUIViewTrust::~CCertManUIViewTrust" );
       
    64 
       
    65     if ( iContainerTrust )
       
    66         {
       
    67         AppUi()->RemoveFromViewStack( *this, iContainerTrust );
       
    68         delete iContainerTrust;
       
    69         }
       
    70 
       
    71     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewTrust::~CCertManUIViewTrust" );
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------
       
    75 // CCertManUIViewTrust* CCertManUIViewTrust::NewL(const TRect& /*aRect*/,
       
    76 //      CCertManUIKeeper& aKeeper)
       
    77 // ---------------------------------------------------------
       
    78 //
       
    79 CCertManUIViewTrust* CCertManUIViewTrust::NewL(
       
    80     const TRect& /*aRect*/, CCertManUIKeeper& aKeeper )
       
    81     {
       
    82     CCertManUIViewTrust* self = new (ELeave) CCertManUIViewTrust( aKeeper );
       
    83     CleanupStack::PushL( self );
       
    84     self->ConstructL();
       
    85     CleanupStack::Pop();
       
    86     return self;
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------
       
    90 // CCertManUIViewTrust* CCertManUIViewTrust::NewLC(const TRect& /*aRect*/,
       
    91 //      CCertManUIKeeper& aKeeper)
       
    92 // ---------------------------------------------------------
       
    93 //
       
    94 CCertManUIViewTrust* CCertManUIViewTrust::NewLC(const TRect& /*aRect*/,
       
    95     CCertManUIKeeper& aKeeper)
       
    96     {
       
    97     CCertManUIViewTrust* self = new (ELeave) CCertManUIViewTrust(aKeeper);
       
    98     CleanupStack::PushL( self );
       
    99     self->ConstructL();
       
   100     return self;
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------
       
   104 // CCertManUIViewTrust::ConstructL()
       
   105 // EPOC two-phased constructor
       
   106 // ---------------------------------------------------------
       
   107 //
       
   108 void CCertManUIViewTrust::ConstructL()
       
   109     {
       
   110     CERTMANUILOGGER_ENTERFN( " CCertManUIViewTrust::ConstructL" );
       
   111 
       
   112     BaseConstructL( R_CERTMANUI_VIEW_TRUST );
       
   113 
       
   114     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewTrust::ConstructL" );
       
   115   }
       
   116 
       
   117 // ---------------------------------------------------------
       
   118 // CCertManUIViewTrust::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
   119 // Updates Options list with correct items depending on
       
   120 // whether the listbox is empty or if the trust can be changed
       
   121 // Change trust is not shown if certificate location is not supported
       
   122 // unsupported certificate locations are ECrCertLocationWIMCard,
       
   123 //                    ECrCertLocationWIMURL,
       
   124 //                    ECrCertLocationPhoneMemory,
       
   125 //                    ECrCertLocationPhoneMemoryURL
       
   126 // Change trust is not shown if certificate format is not supported
       
   127 // unsupported certificate formats are ECrX968Certificate
       
   128 //                    ECrCertificateURL
       
   129 // ---------------------------------------------------------
       
   130 //
       
   131 void CCertManUIViewTrust::DynInitMenuPaneL(
       
   132     TInt aResourceId, CEikMenuPane* aMenuPane )
       
   133     {
       
   134     CERTMANUILOGGER_ENTERFN( " CCertManUIViewTrust::DynInitMenuPaneL" );
       
   135 
       
   136     if ( aResourceId == R_CERTMANUI_VIEW_TRUST_MENU )
       
   137         {
       
   138         if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   139              {
       
   140              aMenuPane->DeleteMenuItem( EAknCmdHelp );
       
   141              }
       
   142 
       
   143         TInt currentItemTrust = iContainerTrust->iListBox->CurrentItemIndex();
       
   144         if ( currentItemTrust == -1 )
       
   145             {
       
   146             aMenuPane->SetItemDimmed( ECertManUICmdAppChangeTrust, ETrue );
       
   147             }
       
   148 
       
   149         CCertManUIViewAuthority* authorityView = STATIC_CAST(
       
   150             CCertManUIViewAuthority*, AppUi()->View( KCertManUIViewAuthorityId ) );
       
   151         TInt currentItem = authorityView->
       
   152             iContainerAuthority->iListBox->CurrentItemIndex();
       
   153         CCTCertInfo& entry = *( iKeeper.iCALabelEntries[ currentItem ]->iCAEntry );
       
   154 
       
   155         if ( !iKeeper.iCertificateHelper->IsOneMarkedCertificateDeletable(
       
   156                 authorityView->iContainerAuthority->iListBox, KCertTypeAuthority ) )
       
   157                 {
       
   158                 LOG_WRITE( "Read only Certificate" );
       
   159                 aMenuPane->SetItemDimmed( ECertManUICmdAppChangeTrust, ETrue );
       
   160                 }
       
   161 
       
   162         if ( currentItem >= 0 )
       
   163             {
       
   164             if( KCertManUIViewTrustApplicationControllerId ==
       
   165                 iContainerTrust->iClientUids[ currentItemTrust ] &&
       
   166                 iKeeper.IsLocalFeatureSupported( KSecurityUIsNoNativeAppTrustSettingChange ) )
       
   167                 {
       
   168                 aMenuPane->SetItemDimmed( ECertManUICmdAppChangeTrust, ETrue );
       
   169                 }
       
   170             }
       
   171         }
       
   172 
       
   173     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewTrust::DynInitMenuPaneL" );
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------
       
   177 // CCertManUIViewTrust::Id() const
       
   178 // Returns Trust view id
       
   179 // ---------------------------------------------------------
       
   180 //
       
   181 TUid CCertManUIViewTrust::Id() const
       
   182     {
       
   183     return KCertManUIViewTrustId;
       
   184     }
       
   185 
       
   186 // ---------------------------------------------------------
       
   187 // CCertManUIViewTrust::HandleCommandL(TInt aCommand)
       
   188 // Handles Softkey and Options list commands
       
   189 // ---------------------------------------------------------
       
   190 //
       
   191 void CCertManUIViewTrust::HandleCommandL( TInt aCommand )
       
   192     {
       
   193     CERTMANUILOGGER_ENTERFN( " CCertManUIViewTrust::HandleCommandL" );
       
   194 
       
   195     if ( iKeeper.iWrapper->IsActive() )
       
   196         {
       
   197         return;
       
   198         }
       
   199 
       
   200     switch ( aCommand )
       
   201         {
       
   202         case EAknSoftkeyBack:
       
   203             {
       
   204             AppUi()->ActivateLocalViewL( KCertManUIViewAuthorityId );
       
   205             break;
       
   206             }
       
   207         // put the view specific menu commands here
       
   208         case EAknCmdExit:
       
   209             {
       
   210             ((CAknViewAppUi*)iAvkonAppUi)->HandleCommandL( EAknCmdExit );
       
   211             break;
       
   212             }
       
   213         case ECertManUICmdAppChangeTrust:
       
   214             {
       
   215             PopupTrustChangeSettingPageL();
       
   216             break;
       
   217             }
       
   218 
       
   219         case EAknCmdHelp:
       
   220             {
       
   221             if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   222                 {
       
   223                 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   224                     AppUi()->AppHelpContextL() );
       
   225                 }
       
   226             break;
       
   227             }
       
   228 
       
   229         default:
       
   230             {
       
   231             AppUi()->HandleCommandL( aCommand );
       
   232             break;
       
   233             }
       
   234         }
       
   235 
       
   236     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewTrust::HandleCommandL" );
       
   237     }
       
   238 
       
   239 // ---------------------------------------------------------
       
   240 // CCertManUIViewTrust::HandleClientRectChange()
       
   241 // ---------------------------------------------------------
       
   242 //
       
   243 void CCertManUIViewTrust::HandleClientRectChange()
       
   244     {
       
   245     if ( iContainerTrust )
       
   246         {
       
   247         iContainerTrust->SetRect( ClientRect() );
       
   248         }
       
   249     }
       
   250 
       
   251 // ---------------------------------------------------------
       
   252 // CCertManUIViewTrust::DoActivateL(
       
   253 //      const TVwsViewId& /*aPrevViewId*/,
       
   254 //      TUid aCustomMessageId, const TDesC8& /*aCustomMessage*/)
       
   255 // Updates the view when opening it
       
   256 // ---------------------------------------------------------
       
   257 //
       
   258 void CCertManUIViewTrust::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
       
   259     TUid aCustomMessageId, const TDesC8& /*aCustomMessage*/ )
       
   260     {
       
   261     CERTMANUILOGGER_ENTERFN( " CCertManUIViewTrust::DoActivateL" );
       
   262 
       
   263     if ( iContainerTrust )
       
   264         {
       
   265         ((CAknViewAppUi*)iAvkonAppUi)->RemoveFromViewStack(
       
   266             *this, iContainerTrust );
       
   267         delete iContainerTrust;
       
   268         iContainerTrust = NULL;
       
   269         }
       
   270 
       
   271     TInt trustViewItem = STATIC_CAST( TInt, aCustomMessageId.iUid );
       
   272     iContainerTrust = new(ELeave) CCertManUIContainerTrust( *this, iKeeper );
       
   273     // to fix problem of focus if trust view has more than one item
       
   274     TInt currentPosition = 0;
       
   275     TInt topItem = 0;
       
   276     iContainerTrust->SetMopParent( this );
       
   277     iContainerTrust->ConstructL( ClientRect());
       
   278 
       
   279     UpdateMenuBar();
       
   280 
       
   281     UpdateNaviPaneL();
       
   282 
       
   283     iContainerTrust->DrawListBoxL( currentPosition, topItem, trustViewItem );
       
   284     ((CAknViewAppUi*)iAvkonAppUi)->AddToStackL( *this, iContainerTrust );
       
   285 
       
   286     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewTrust::DoActivateL" );
       
   287     }
       
   288 
       
   289 // ---------------------------------------------------------
       
   290 // CCertManUIViewTrust::DoDeactivate()
       
   291 // ---------------------------------------------------------
       
   292 //
       
   293 void CCertManUIViewTrust::DoDeactivate()
       
   294     {
       
   295     CERTMANUILOGGER_ENTERFN( " CCertManUIViewTrust::DoDeactivate" );
       
   296 
       
   297     if ( iContainerTrust )
       
   298         {
       
   299         ((CAknViewAppUi*)iAvkonAppUi)->RemoveFromViewStack( *this, iContainerTrust );
       
   300         delete iContainerTrust;
       
   301         iContainerTrust = NULL;
       
   302         }
       
   303 
       
   304     RemoveNaviPane();
       
   305 
       
   306     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewTrust::DoDeactivate" );
       
   307     }
       
   308 
       
   309 // ---------------------------------------------------------
       
   310 // CCertManUIViewTrust::Container()
       
   311 // Returns iContainerTrust
       
   312 // ---------------------------------------------------------
       
   313 //
       
   314 CCoeControl* CCertManUIViewTrust::Container()
       
   315     {
       
   316     return iContainerTrust;
       
   317     }
       
   318 
       
   319 // ---------------------------------------------------------
       
   320 // CCertManUIViewTrust::ChangeTrustL()
       
   321 // Calls Change trust method UpdateTrustSettingsViewL in certmanuicontainertrust
       
   322 // for not supported certificate formats ECrX968Certificate and ECrCertificateURL
       
   323 // and for not supported certificate locations  ECrCertLocationWIMCard, ECrCertLocationWIMURL,
       
   324 // ECrCertLocationPhoneMemory, ECrCertLocationPhoneMemoryURL UpdateTrustSettingsViewL is not called
       
   325 // also UpdateTrustSettingsViewL is not called if there are no clients in Trust view.
       
   326 // This function is called when user presses joystick key in trusters list.
       
   327 // ---------------------------------------------------------
       
   328 //
       
   329 void CCertManUIViewTrust::ChangeTrustL()
       
   330     {
       
   331     CERTMANUILOGGER_ENTERFN( " CCertManUIViewTrust::ChangeTrustL" );
       
   332     CCertManUIViewAuthority* authorityView = STATIC_CAST(
       
   333             CCertManUIViewAuthority*, AppUi()->View(KCertManUIViewAuthorityId) );
       
   334     // Policy decision: Trusters of read-only certs cannot be changed
       
   335     if ( iKeeper.iCertificateHelper->IsOneMarkedCertificateDeletable(
       
   336                 authorityView->iContainerAuthority->iListBox, KCertTypeAuthority ) )
       
   337 
       
   338         {
       
   339         TInt currentItem = authorityView->
       
   340             iContainerAuthority->iListBox->CurrentItemIndex();
       
   341 
       
   342         CCTCertInfo& entry = *( iKeeper.iCALabelEntries[ currentItem ]->iCAEntry );
       
   343 
       
   344         TInt currentTruster = iContainerTrust->iListBox->CurrentItemIndex();
       
   345 
       
   346         if ( currentItem >= 0 )
       
   347             {
       
   348             TUid uid = iContainerTrust->iClientUids[ currentTruster ];
       
   349 
       
   350             iContainerTrust->ChangeTrustValueL( entry, uid );
       
   351             iContainerTrust->UpdateTrustListboxItemL( entry, currentTruster );
       
   352             }
       
   353         }
       
   354 
       
   355     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewTrust::ChangeTrustL" );
       
   356     }
       
   357 
       
   358 // ---------------------------------------------------------
       
   359 // CCertManUIViewTrust::PopupTrustChangeSettingPageL()
       
   360 // ---------------------------------------------------------
       
   361 //
       
   362 void CCertManUIViewTrust::PopupTrustChangeSettingPageL()
       
   363     {
       
   364     CCertManUIViewAuthority* authorityView =
       
   365     STATIC_CAST( CCertManUIViewAuthority*,
       
   366             AppUi()->View( KCertManUIViewAuthorityId ) );
       
   367     TInt helpIndex3 = authorityView->
       
   368             iContainerAuthority->iListBox->CurrentItemIndex();
       
   369     iContainerTrust->PopupTrustChangeSettingPageL( helpIndex3 );
       
   370     }
       
   371 
       
   372 // ---------------------------------------------------------
       
   373 // CCertManUIViewTrust::UpdateMenuBar()
       
   374 // Updates the menu bar
       
   375 // ---------------------------------------------------------
       
   376 //
       
   377 void CCertManUIViewTrust::UpdateMenuBar()
       
   378     {
       
   379     CERTMANUILOGGER_ENTERFN( " CCertManUIViewTrust::UpdateMenuBar" );
       
   380 
       
   381     CCertManUIViewAuthority* authorityView = STATIC_CAST(
       
   382             CCertManUIViewAuthority*, AppUi()->View(KCertManUIViewAuthorityId) );
       
   383 
       
   384     CEikButtonGroupContainer*  cba = Cba();
       
   385 
       
   386     if (( cba == NULL ) || ( authorityView == NULL ))
       
   387         {
       
   388         return;
       
   389         }
       
   390 
       
   391     if ( !iKeeper.iCertificateHelper->IsOneMarkedCertificateDeletable(
       
   392                 authorityView->iContainerAuthority->iListBox, ETrue ))
       
   393         {
       
   394         // Read-only certificate
       
   395         cba->MakeCommandVisible( ECertManUICmdAppChangeTrust, EFalse );
       
   396         }
       
   397     else
       
   398        {
       
   399        cba->MakeCommandVisible( ECertManUICmdAppChangeTrust, ETrue );
       
   400        }
       
   401 
       
   402     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewTrust::UpdateMenuBar" );
       
   403     }
       
   404 
       
   405 // ---------------------------------------------------------
       
   406 // CCertManUIViewTrust::UpdateNaviPaneL()
       
   407 // Updates navi pane
       
   408 // ---------------------------------------------------------
       
   409 //
       
   410 void CCertManUIViewTrust::UpdateNaviPaneL()
       
   411     {
       
   412     CERTMANUILOGGER_ENTERFN( " CCertManUIViewTrust::UpdateNaviPaneL" );
       
   413 
       
   414     CEikStatusPane* sp = STATIC_CAST(
       
   415         CAknAppUi*, iEikonEnv->EikAppUi())->StatusPane();
       
   416 
       
   417     iNaviPane = STATIC_CAST(CAknNavigationControlContainer*,
       
   418         sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
       
   419 
       
   420     TResourceReader reader;
       
   421     iCoeEnv->CreateResourceReaderLC( reader, R_CM_NAVI_PANE_TRUST_SETTINGS );
       
   422     iTrustSettingsNaviPane = iNaviPane->CreateMessageLabelL( reader );
       
   423     CleanupStack::PopAndDestroy();  // reader
       
   424 
       
   425     iNaviPane->PushL( *iTrustSettingsNaviPane );
       
   426 
       
   427     CERTMANUILOGGER_LEAVEFN( " CCertManUIViewTrust::UpdateNaviPaneL" );
       
   428     }
       
   429 
       
   430 // ---------------------------------------------------------
       
   431 // CCertManUIViewTrust::RemoveNaviPane()
       
   432 // Removes navi pane
       
   433 // ---------------------------------------------------------
       
   434 //
       
   435 void CCertManUIViewTrust::RemoveNaviPane()
       
   436   {
       
   437   CERTMANUILOGGER_ENTERFN( " CCertManUIViewTrust::RemoveNaviPane" );
       
   438 
       
   439   if ( iNaviPane )
       
   440     {
       
   441     iNaviPane->Pop( iTrustSettingsNaviPane );
       
   442     }
       
   443 
       
   444   delete iTrustSettingsNaviPane;
       
   445   iTrustSettingsNaviPane = NULL;
       
   446 
       
   447   CERTMANUILOGGER_LEAVEFN( " CCertManUIViewTrust::RemoveNaviPane" );
       
   448   }
       
   449 
       
   450 
       
   451 // End of File
       
   452