pkiutilities/CTSecurityDialogs/NotifSrc/CTNoTrustQuery.cpp
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2006-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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include "CTNoTrustQuery.h"
       
    23 #include "CTSecurityDialogsAO.h"
       
    24 #include "CTCertificateQuery.h"
       
    25 #include <aknlists.h>
       
    26 #include <CTSecDlgs.rsg>
       
    27 #include <uikon/eiksrvui.h>
       
    28 #include <StringLoader.h>
       
    29 
       
    30 
       
    31 // ================= MEMBER FUNCTIONS ==========================================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CSecNotNoTrustQuery::CCTNoTrustQuery()
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CCTNoTrustQuery::CCTNoTrustQuery(
       
    38     CCTSecurityDialogsAO& aNotifier,
       
    39     TBool& aRetVal,
       
    40     TRequestStatus& aClientStatus,
       
    41     HBufC* aServerName,
       
    42     TBool aShowPermAccept,
       
    43     TBool& aIsDeleted ):
       
    44     CAknQueryDialog( CAknQueryDialog::ENoTone ),
       
    45     iNotifier( aNotifier ),
       
    46     iRetVal( aRetVal ),
       
    47     iClientStatus( &aClientStatus ),
       
    48     iServerName( aServerName ),
       
    49     iShowPermAccept( aShowPermAccept ),
       
    50     iDeleted( aIsDeleted )
       
    51     {
       
    52     iDeleted = EFalse;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CSecNotNoTrustQuery::~CCTNoTrustQuery()
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CCTNoTrustQuery::~CCTNoTrustQuery()
       
    60     {
       
    61     // Allow application switching again
       
    62     CEikonEnv* eikonEnv = CEikonEnv::Static();
       
    63     if( eikonEnv )
       
    64         {
       
    65         CEikServAppUi* eikServAppUi = static_cast<CEikServAppUi*>( eikonEnv->EikAppUi() );
       
    66         if( eikServAppUi )
       
    67             {
       
    68             eikServAppUi->SuppressAppSwitching( EFalse );
       
    69             }
       
    70         }
       
    71 
       
    72     // Complete the client request
       
    73     if( iClientStatus && *iClientStatus == KRequestPending )
       
    74         {
       
    75         iRetVal = EFalse;
       
    76         User::RequestComplete( iClientStatus, KErrNone );
       
    77         }
       
    78     
       
    79     // Notify that the dialog has been deleted
       
    80     iDeleted = ETrue;
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CSecNotNoTrustQuery::OkToExitL()
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 TBool CCTNoTrustQuery::OkToExitL( TInt aButtonId )
       
    88     {
       
    89     if ( aButtonId == EAknSoftkeyOptions || aButtonId == EAknSoftkeyOk )
       
    90         {
       
    91         return OptionsMenuL();
       
    92         }
       
    93     else
       
    94         {
       
    95         iRetVal = EFalse;
       
    96         User::RequestComplete( iClientStatus, KErrNone );
       
    97         }
       
    98     return ETrue;
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CCTNoTrustQuery::PostLayoutDynInitL()
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CCTNoTrustQuery::PostLayoutDynInitL()
       
   106     {
       
   107     CAknQueryControl* control = QueryControl();
       
   108     if (control)
       
   109         control->StartAnimationL();
       
   110     ((CEikServAppUi*)(CEikonEnv::Static())->EikAppUi())->SuppressAppSwitching( ETrue );
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CCTNoTrustQuery::OptionsMenuL()
       
   115 // -----------------------------------------------------------------------------
       
   116 TBool CCTNoTrustQuery::OptionsMenuL()
       
   117     {
       
   118     TBool ret = EFalse;
       
   119     CAknSinglePopupMenuStyleListBox* list =
       
   120         new( ELeave ) CAknSinglePopupMenuStyleListBox;
       
   121     CleanupStack::PushL( list );
       
   122     CAknPopupList* popupList = CAknPopupList::NewL(
       
   123         list, R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, AknPopupLayouts::EMenuWindow );
       
   124     CleanupStack::PushL( popupList );
       
   125     list->ConstructL( popupList, CEikListBox::ELeftDownInViewRect );
       
   126     list->CreateScrollBarFrameL( ETrue );
       
   127     list->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   128         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   129 
       
   130     TInt resourceid;
       
   131 
       
   132     if ( iShowPermAccept )
       
   133         {
       
   134         resourceid = R_NOTRUST_MENUPANE;
       
   135         }
       
   136     else
       
   137         {
       
   138         resourceid = R_NOTRUST_MENUPANE_NO_PERM;
       
   139         }
       
   140 
       
   141      CDesCArrayFlat* items =
       
   142             CEikonEnv::Static()->ReadDesCArrayResourceL( resourceid );
       
   143 
       
   144     CTextListBoxModel* model = list->Model();
       
   145     model->SetOwnershipType( ELbmOwnsItemArray );
       
   146     model->SetItemTextArray( items );
       
   147 
       
   148     CleanupStack::Pop( popupList ); //popupList
       
   149     if ( popupList->ExecuteLD() )
       
   150         {
       
   151         if( !iDeleted )
       
   152             {
       
   153             TInt index = list->CurrentItemIndex();
       
   154             if ( index == 0 )       // Accept now
       
   155                 {
       
   156                 iRetVal = EServerCertAcceptedTemporarily;
       
   157                 User::RequestComplete(iClientStatus, KErrNone);
       
   158                 ret = ETrue;
       
   159                 }
       
   160             else if (( index == 1 ) && ( resourceid == R_NOTRUST_MENUPANE ))  // Accept permanently
       
   161                 {
       
   162     
       
   163                 HBufC* prompt = StringLoader::LoadLC( R_QTN_HTTPSEC_QUERY_PERM_ACCEPT_TEXT, *iServerName );
       
   164     
       
   165                 CAknMessageQueryDialog* note = CAknMessageQueryDialog::NewL( *prompt );
       
   166     
       
   167                 note->PrepareLC( R_HTTPSEC_QUERY_PERM_ACCEPT );
       
   168                 note->SetPromptL( *prompt );
       
   169     
       
   170                 if ( note->RunLD() )
       
   171                     {
       
   172                     iRetVal = EServerCertAcceptedPermanently;
       
   173                     User::RequestComplete( iClientStatus, KErrNone );
       
   174                     ret = ETrue;
       
   175                     }
       
   176                 else
       
   177                     {
       
   178                     ret = EFalse;
       
   179                     }
       
   180     
       
   181                 CleanupStack::PopAndDestroy( prompt );
       
   182                 }
       
   183             else if ((( index == 2 ) && ( resourceid == R_NOTRUST_MENUPANE ))  ||
       
   184                      (( index == 1 ) && ( resourceid == R_NOTRUST_MENUPANE_NO_PERM )) ) // Details
       
   185                 {
       
   186                 // We need to delay this implementation in other releases, because
       
   187                 // separate ICD was taken to 3.0.
       
   188                 CCTCertificateQuery* query =
       
   189                 CCTCertificateQuery::NewL( iNotifier );
       
   190                 query->ExecuteLD( R_NOTRUST_CERTIFICATE_QUERY );
       
   191                 ret = EFalse;
       
   192                 }
       
   193             else
       
   194                 {
       
   195                 iRetVal = EServerCertNotAccepted;
       
   196                 User::RequestComplete( iClientStatus, KErrNone );
       
   197                 ret = ETrue;
       
   198                 }
       
   199             }
       
   200         else
       
   201             {
       
   202             ret = EFalse;
       
   203             }
       
   204         }
       
   205     else
       
   206         {
       
   207         ret = EFalse;
       
   208         }
       
   209     CleanupStack::PopAndDestroy( list );  // list
       
   210     return ret;
       
   211     }
       
   212