browserutilities/browserdialogsprovider/Src/BrowserAuthenticationDialog.cpp
changeset 0 dd21522fd290
child 68 92a765b5b3e7
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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 *      Password dialog
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include <EIKSECED.H>
       
    24 #include <avkon.hrh>
       
    25 
       
    26 #include "BrowserAuthenticationDialog.h"
       
    27 #include "BrowserDialogsProvider.hrh"
       
    28 
       
    29 // ================= MEMBER FUNCTIONS =======================
       
    30 
       
    31 // ---------------------------------------------------------
       
    32 // CBrowserAuthenticationDialog::NewL
       
    33 // 2 phase constructor
       
    34 // ---------------------------------------------------------
       
    35 //
       
    36 CBrowserAuthenticationDialog*
       
    37     CBrowserAuthenticationDialog::NewL( TDes& aUsername, 
       
    38                                         TDes& aPassword )
       
    39     {
       
    40     CBrowserAuthenticationDialog* dlg = 
       
    41                                 new (ELeave) CBrowserAuthenticationDialog();
       
    42     CleanupStack::PushL( dlg );
       
    43 
       
    44     dlg->ConstructL( &aUsername, &aPassword );
       
    45     dlg->SetDataL( aUsername, aPassword );
       
    46 
       
    47     CleanupStack::Pop( dlg );
       
    48     return dlg;
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------
       
    52 // CBrowserAuthenticationDialog::CBrowserAuthenticationDialog
       
    53 //
       
    54 // C++ default constructor can NOT contain any code, that
       
    55 // might leave.
       
    56 // ---------------------------------------------------------
       
    57 //
       
    58 CBrowserAuthenticationDialog::CBrowserAuthenticationDialog()
       
    59     : CAknMultiLineDataQueryDialog( CAknQueryDialog::ENoTone )
       
    60     , iEmptyName( ETrue )
       
    61     , iEmptyPassword( ETrue )
       
    62     , iUsername( NULL )
       
    63     , iPassword( NULL )
       
    64     {
       
    65     }
       
    66 
       
    67 void CBrowserAuthenticationDialog::ConstructL( TDes* aUsername, 
       
    68                                                TDes* aPassword )
       
    69     {
       
    70     iUsername = aUsername;
       
    71     iPassword = aPassword;
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------
       
    75 // CBrowserAuthenticationDialog::PreLayoutDynInitL
       
    76 // ---------------------------------------------------------
       
    77 //
       
    78 void  CBrowserAuthenticationDialog::PreLayoutDynInitL()
       
    79     {
       
    80     
       
    81     CAknMultiLineDataQueryDialog::PreLayoutDynInitL();
       
    82 
       
    83     SetEditableL( ETrue );
       
    84 
       
    85     FirstControl()->SetQueryControlObserver( this );
       
    86     SecondControl()->SetQueryControlObserver( this );
       
    87     
       
    88     iEmptyName = ( !FirstControl()->GetTextLength() );
       
    89     // password is always empty. Confirmation softkey depends on name.
       
    90     MakeLeftSoftkeyVisible( !iEmptyName );
       
    91     } 
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // CBrowserAuthenticationDialog::OkToExitL
       
    95 // ---------------------------------------------------------
       
    96 //
       
    97 TBool CBrowserAuthenticationDialog::OkToExitL( TInt aKeycode )
       
    98     {
       
    99     TBool ret = CAknMultiLineDataQueryDialog::OkToExitL( aKeycode );    
       
   100     if ( aKeycode == EAknSoftkeyOk )
       
   101         {
       
   102         FirstControl()->GetText( *iUsername );
       
   103         SecondControl()->GetText( *iPassword );
       
   104         }
       
   105     return ret;
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------
       
   109 // CBrowserAuthenticationDialog::SetInitialCurrentLineL
       
   110 // ---------------------------------------------------------
       
   111 //
       
   112 void CBrowserAuthenticationDialog::SetInitialCurrentLineL()
       
   113     {   
       
   114     CAknMultiLineDataQueryDialog::SetInitialCurrentLine();
       
   115 
       
   116     if( FirstControl()->GetTextLength() > 0 )
       
   117         {
       
   118         TryChangeFocusToL( EMultilineSecondLine );
       
   119         }
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------
       
   123 // CBrowserAuthenticationDialog::HandleQueryEditorStateEventL
       
   124 //
       
   125 // This code is base on AknQueryDialog.cpp
       
   126 // ---------------------------------------------------------
       
   127 //
       
   128 TBool CBrowserAuthenticationDialog::HandleQueryEditorStateEventL(
       
   129                 CAknQueryControl* aQueryControl, 
       
   130                 TQueryControlEvent /*aEventType*/, 
       
   131                 TQueryValidationStatus aStatus )
       
   132     {
       
   133     if( aQueryControl == FirstControl() )
       
   134         {
       
   135         iEmptyName = aStatus == EEditorEmpty;
       
   136         }
       
   137     else
       
   138         {
       
   139         iEmptyPassword = aStatus == EEditorEmpty;
       
   140         }
       
   141 
       
   142     MakeLeftSoftkeyVisible( !iEmptyName  || !iEmptyPassword );
       
   143 
       
   144     return EFalse;
       
   145     }
       
   146 
       
   147 //  End of File