uifw/AvKon/src/AknPasswordSettingPage.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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 "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 *	Implementation of CAknPasswordSettingPage, (pure virtual) and its descendants,
       
    16 *	CAknAlphaPasswordSettingPage and CAknNumericPasswordSettingPage
       
    17 *   
       
    18 *
       
    19 */
       
    20 
       
    21 //////////////////////////////////////////////////////////////////////
       
    22 //
       
    23 // AknPasswordSettingPage.cpp
       
    24 //
       
    25 //////////////////////////////////////////////////////////////////////
       
    26 
       
    27 #include "aknpasswordsettingpage.h"
       
    28 #include "aknsettingpage.h"
       
    29 #include "aknnotedialog.h"
       
    30 
       
    31 //For TResourceReader
       
    32 #include <barsread.h>
       
    33 
       
    34 #include <coemain.h>
       
    35 #include <coecntrl.h>
       
    36 #include <coecobs.h>
       
    37 
       
    38 //For CEikEnv
       
    39 #include <eikenv.h>
       
    40 
       
    41 // For queries
       
    42 #include <AknQueryDialog.h>
       
    43 
       
    44 //For the different layout definitions
       
    45 #include <avkon.hrh>                                             
       
    46 #include <aknlayoutscalable_avkon.cdl.h>
       
    47 
       
    48 
       
    49 #include <AknTasHook.h>
       
    50 
       
    51 //////////////////////////////////////////////////////////////////////
       
    52 //
       
    53 //  PASSWORD SETTING PAGE BASE CLASS
       
    54 //
       
    55 // This class holds the main data model for the password setting pages.
       
    56 // It also does the drawing and other functions.
       
    57 //
       
    58 //////////////////////////////////////////////////////////////////////
       
    59 
       
    60 /**
       
    61  *
       
    62  * Constructor from setting page resource id: Pass through to base class 
       
    63  *
       
    64  */
       
    65 EXPORT_C CAknPasswordSettingPage::CAknPasswordSettingPage(
       
    66 	TInt aResourceId, 
       
    67 	TDes& aNewPassword, 
       
    68 	const TDesC& aOldPassword )
       
    69 		:	CAknSettingPage( aResourceId), 
       
    70 			iNewPassword(aNewPassword),
       
    71 			iOldPassword(aOldPassword)
       
    72 	{
       
    73 	SetMatchingMode( ECaseSensitive );
       
    74 	AKNTASHOOK_ADD( this, "CAknPasswordSettingPage" );
       
    75 	}
       
    76 
       
    77 
       
    78 EXPORT_C CAknPasswordSettingPage::CAknPasswordSettingPage(	
       
    79 								const TDesC* aSettingText, 
       
    80 								TInt aSettingNumber, 
       
    81 								TInt aControlType,
       
    82 								TInt aEditorResourceId, 
       
    83 								TInt aSettingPageResourceId, 
       
    84 								TDes& aNewPassword, 
       
    85 								const TDesC& aOldPassword )
       
    86 								:	CAknSettingPage( 
       
    87 									aSettingText, 
       
    88 									aSettingNumber, 
       
    89 									aControlType, 
       
    90 									aEditorResourceId, 
       
    91 									aSettingPageResourceId) , 
       
    92 									iNewPassword( aNewPassword ),
       
    93 									iOldPassword( aOldPassword )
       
    94 	{
       
    95 	SetMatchingMode( ECaseSensitive );
       
    96 	AKNTASHOOK_ADD( this, "CAknPasswordSettingPage" );
       
    97 	}
       
    98 
       
    99 /**
       
   100  * Acts upon changes in the hosted control's state. 
       
   101  *
       
   102  * @param	aControl	The control changing its state (not used)
       
   103  * @param	aEventType	The type of control event 
       
   104  */
       
   105 EXPORT_C void CAknPasswordSettingPage::HandleControlEventL(CCoeControl* /*aControl*/,
       
   106 				 MCoeControlObserver::TCoeEvent aEventType)
       
   107 	{
       
   108 	// This event is used as it is called at least every time an edit is made to 
       
   109 	// the editor
       
   110 	if ( aEventType == EEventStateChanged && iUpdateMode == EUpdateWhenChanged)
       
   111 		{
       
   112 		UpdateSettingL();
       
   113 		}
       
   114 	}
       
   115 
       
   116 /**
       
   117  *
       
   118  * Routine to set up the resources for old password confirmation. 
       
   119  *
       
   120  */
       
   121 EXPORT_C void CAknPasswordSettingPage::SetOldPasswordConfirmationResourceId( TInt aConfirmationResourceId )
       
   122 	{
       
   123 	iOldPasswordConfirmationResourceId = aConfirmationResourceId;
       
   124 	}
       
   125 /**
       
   126  *
       
   127  * Routine to set up the resources for new password confirmation. 
       
   128  *
       
   129  */
       
   130 EXPORT_C void CAknPasswordSettingPage::SetNewPasswordConfirmationResourceId( TInt aConfirmationResourceId )
       
   131 	{
       
   132 	iNewPasswordConfirmationResourceId = aConfirmationResourceId;
       
   133 	}
       
   134 
       
   135 /**
       
   136  *
       
   137  * Access routine for the confirmation resource structure 
       
   138  *
       
   139  */
       
   140 EXPORT_C TInt CAknPasswordSettingPage::OldPasswordConfirmationResourceId() const
       
   141 	{
       
   142 	return iOldPasswordConfirmationResourceId;
       
   143 	}
       
   144 /**
       
   145  *
       
   146  * Access routine for the confirmation resource structure 
       
   147  *
       
   148  */
       
   149 EXPORT_C TInt CAknPasswordSettingPage::NewPasswordConfirmationResourceId() const
       
   150 	{
       
   151 	return iNewPasswordConfirmationResourceId;
       
   152 	}
       
   153 
       
   154 /**
       
   155  * Sets the mode for the matching that will be performed
       
   156  *
       
   157  */
       
   158 EXPORT_C void CAknPasswordSettingPage::SetMatchingMode( TAknPasswordMatchingMode aMode )
       
   159 	{
       
   160 	iMatchingMode = aMode;
       
   161 	}
       
   162 /**
       
   163  * Access method for the matching mode
       
   164  *
       
   165  */
       
   166 EXPORT_C CAknPasswordSettingPage::TAknPasswordMatchingMode CAknPasswordSettingPage::MatchingMode()
       
   167 	{
       
   168 	return iMatchingMode;
       
   169 	}
       
   170 
       
   171 /**
       
   172  * Sets the maximum number of characters that will be allowed to enter or to match
       
   173  *
       
   174  */
       
   175 EXPORT_C void CAknPasswordSettingPage::SetMaxPasswordLength( TInt aMaxLength )
       
   176 	{
       
   177 	iMaxPasswordLength = aMaxLength;
       
   178 	}
       
   179 /**
       
   180  * Access method for the maximum password length
       
   181  *
       
   182  *
       
   183  */
       
   184 EXPORT_C TInt CAknPasswordSettingPage::MaxPasswordLength() const
       
   185 	{
       
   186 	return iMaxPasswordLength;
       
   187 	}
       
   188 
       
   189 /**
       
   190  * Access method for the new password
       
   191  *
       
   192  */
       
   193 EXPORT_C TDes& CAknPasswordSettingPage::NewPassword() const
       
   194 	{
       
   195 	return iNewPassword;
       
   196 	}
       
   197 
       
   198 /**
       
   199  * Access method for the old password
       
   200  *
       
   201  */
       
   202 EXPORT_C const TDesC& CAknPasswordSettingPage::OldPassword() const
       
   203 	{
       
   204 	return iOldPassword;
       
   205 	}
       
   206 
       
   207 /**
       
   208  *
       
   209  * This routine is called when the a change is detected in the editor.
       
   210  * The text is copied out to the referenced descriptor using a utility routine.
       
   211  *
       
   212  */
       
   213 EXPORT_C void CAknPasswordSettingPage::UpdateSettingL()
       
   214 	{
       
   215 	UpdateTextL();
       
   216 
       
   217 	if( iSettingPageObserver )
       
   218 		iSettingPageObserver->HandleSettingPageEventL(this, MAknSettingPageObserver::EEventSettingChanged);	
       
   219 
       
   220 	}
       
   221 
       
   222 
       
   223 /**
       
   224  * Checks if it OK to exit. This implementation performs a new password confirmation if the resource is defined
       
   225  * If there is no confirmation resource defined, then we exit.
       
   226  * If there is, then a confirmation query is put up.  Upon exit, if the match is OK, then we exit 
       
   227  * 
       
   228  * Returns ETrue if the dialog is ready to exit. Returns ETrue by default.
       
   229  */
       
   230 EXPORT_C TBool CAknPasswordSettingPage::OkToExitL(TBool aAccept )
       
   231     {
       
   232 	 if ( aAccept )
       
   233 		{
       
   234 		return ExecuteNewPasswordConfirmationL( NewPassword(), NewPasswordConfirmationResourceId() ) ;
       
   235 		// SetFocusToEditor();   // Should the focus be changed somewhere else?
       
   236 		}
       
   237 	 else
       
   238 	    return(ETrue); 
       
   239     }
       
   240 
       
   241 
       
   242 /**
       
   243  *
       
   244  * The value is copied out and the call back called if there is an observer
       
   245  *
       
   246  */
       
   247 EXPORT_C void CAknPasswordSettingPage::AcceptSettingL()
       
   248 	{
       
   249 	UpdateTextL();
       
   250 	}
       
   251 
       
   252 /**
       
   253  * Reads in the resource structure associated with a password confirmation (old or new)
       
   254  *
       
   255  */
       
   256 EXPORT_C void CAknPasswordSettingPage::ReadConfirmationResourceL( TInt aResourceId, SAknConfirmationResource& resources )
       
   257 	{
       
   258 	TResourceReader reader;
       
   259 	iCoeEnv->CreateResourceReaderLC( reader,aResourceId );
       
   260 
       
   261 	resources.iEntryQueryResourceId = reader.ReadInt32();
       
   262 	resources.iSuccessNoteResourceId = reader.ReadInt32();
       
   263 	resources.iFailureNoteResourceId = reader.ReadInt32();
       
   264 
       
   265 	CleanupStack::PopAndDestroy(); //reader	
       
   266 
       
   267 	}
       
   268 
       
   269 /**
       
   270  * Activity to run after the setting page is displayed
       
   271  *
       
   272  */
       
   273  
       
   274 EXPORT_C void CAknPasswordSettingPage::PostDisplayInitL()
       
   275 	 {}
       
   276 
       
   277 EXPORT_C TBool CAknPasswordSettingPage::PostDisplayCheckL()
       
   278 	{
       
   279 	return ExecuteOldPasswordConfirmationL( OldPassword(), OldPasswordConfirmationResourceId() ) ;
       
   280 	}
       
   281 
       
   282 /**
       
   283  * Base implementation of this framework method. Just call the generic Do.. routine
       
   284  * This implementation does not use "tries" but this may be a useful piece of information
       
   285  */
       
   286 EXPORT_C TBool CAknPasswordSettingPage::ExecuteOldPasswordConfirmationL(const TDesC& aPassword, TInt aPasswordConfirmationResourceId )
       
   287 	{
       
   288 	// This check is done internally to allow completely different derivation of the resources
       
   289 	if ( aPasswordConfirmationResourceId )
       
   290 		{
       
   291 		TInt tries;
       
   292 		return DoPasswordConfirmationL(aPassword, aPasswordConfirmationResourceId, MatchingMode(), tries);
       
   293 		}
       
   294 	else
       
   295 		return ETrue; // because no check has been defined
       
   296 	}
       
   297 
       
   298 /**
       
   299  * Base implementation of this framework method. Just call the generic Do.. routine
       
   300  *
       
   301  */
       
   302 EXPORT_C TBool CAknPasswordSettingPage::ExecuteNewPasswordConfirmationL(const TDesC& aPassword, TInt aPasswordConfirmationResourceId )
       
   303 	{
       
   304 	// This check is done internally to allow completely different derivation of the resources
       
   305 	if ( aPasswordConfirmationResourceId )
       
   306 		{
       
   307 		TInt tries;
       
   308 		return DoPasswordConfirmationL(aPassword, aPasswordConfirmationResourceId, MatchingMode(), tries );
       
   309 		}
       
   310 	else
       
   311 		return ETrue; // No check defined
       
   312 	}
       
   313 
       
   314 /**
       
   315  *  Default implementation of a password confirmation procedure
       
   316  *
       
   317  */
       
   318 EXPORT_C TBool CAknPasswordSettingPage::DoPasswordConfirmationL(const TDesC& aPassword, TInt aPasswordConfirmationResourceId, TAknPasswordMatchingMode aMatchMode, TInt& aTries )
       
   319 	{
       
   320 	TBool retVal = EFalse;
       
   321 
       
   322 	// zero the number of tries
       
   323 	aTries = 0;
       
   324 
       
   325 	// 
       
   326 	// Read the resource for the dialogs
       
   327 	//
       
   328 	SAknConfirmationResource confResources;
       
   329 	ReadConfirmationResourceL( aPasswordConfirmationResourceId, confResources );
       
   330 
       
   331 	if (confResources.iEntryQueryResourceId )
       
   332 		{
       
   333 		// Put up a query note for the password entry
       
   334 		// Produce candidate text descriptor
       
   335 		HBufC* aEnteredTextBuf = HBufC::NewLC( MaxPasswordLength() );
       
   336 		TPtr aEnteredTextPtr = aEnteredTextBuf->Des();
       
   337 
       
   338 		CAknTextQueryDialog* dlgQuery = CAknTextQueryDialog::NewL(aEnteredTextPtr, CAknQueryDialog::ENoTone);
       
   339 
       
   340 		if ( dlgQuery->ExecuteLD( confResources.iEntryQueryResourceId ) )
       
   341 			{
       
   342 			// Increment the tries
       
   343 			aTries++;
       
   344 
       
   345 			if ( ComparePasswords( aPassword, aEnteredTextPtr, aMatchMode ) == 0 )
       
   346 				{
       
   347 				// put up success note if specified
       
   348 				if ( confResources.iSuccessNoteResourceId )
       
   349 					{
       
   350 					CAknNoteDialog* dlgSuccessNote = new (ELeave) CAknNoteDialog(CAknNoteDialog::ENoTone,CAknNoteDialog::ELongTimeout);
       
   351 					dlgSuccessNote->PrepareLC(confResources.iSuccessNoteResourceId);
       
   352 					dlgSuccessNote->RunLD();
       
   353 					}
       
   354 				// nothing otherwise
       
   355 				retVal = ETrue;
       
   356 				}
       
   357 			else
       
   358 				{
       
   359 				// failure note
       
   360 				if ( confResources.iFailureNoteResourceId )
       
   361 					{
       
   362 					CAknNoteDialog* dlgFailureNote = new (ELeave) CAknNoteDialog(CAknNoteDialog::ENoTone,CAknNoteDialog::ELongTimeout);
       
   363 					dlgFailureNote->PrepareLC(confResources.iFailureNoteResourceId);
       
   364 					dlgFailureNote->RunLD();
       
   365 					}
       
   366 				// nothing otherwise
       
   367 				retVal = EFalse;
       
   368 		
       
   369 				}
       
   370 			}
       
   371 		CleanupStack::PopAndDestroy(); //  aEnteredTextBuf 
       
   372 
       
   373 		}
       
   374 
       
   375 	return (retVal);
       
   376 	}
       
   377 
       
   378 EXPORT_C TInt CAknPasswordSettingPage::ComparePasswords( const TDesC& aRefPassword, const TDesC& aCandidatePassword, enum CAknPasswordSettingPage::TAknPasswordMatchingMode /*aMode*/) const
       
   379 	{
       
   380 	// This comparison needs changing for mode. 
       
   381 	return aRefPassword.Compare( aCandidatePassword );
       
   382 	}
       
   383 
       
   384 EXPORT_C void CAknPasswordSettingPage::SizeChanged()
       
   385 	{
       
   386 	StandardSettingPageLayout();  // Must be part of any re-implementation
       
   387 	
       
   388     iSecretEditorLayoutRect.LayoutRect( 
       
   389             CAknSettingPage::SettingItemContentRect( EFalse ),
       
   390             AknLayoutScalable_Avkon::setting_code_pane_copy1() );
       
   391 
       
   392     TRect editorRect = iSecretEditorLayoutRect.Rect();
       
   393 
       
   394 	iHorizontalShadow.LayoutRect(editorRect, 
       
   395 		AKN_LAYOUT_WINDOW_Code_time_and_date_entry_pane_elements_Line_1);
       
   396 	iVerticalShadow.LayoutRect(editorRect, 
       
   397 		AKN_LAYOUT_WINDOW_Code_time_and_date_entry_pane_elements_Line_2);
       
   398 	iOutlineFrame.LayoutRect(editorRect, 
       
   399 		AKN_LAYOUT_WINDOW_Code_time_and_date_entry_pane_elements_Line_3);
       
   400 
       
   401     AknLayoutUtils::LayoutSecretEditor( ( CEikSecretEditor * )EditorControl(), 
       
   402     editorRect, AknLayoutScalable_Avkon::setting_code_pane_t1_copy1() );
       
   403 
       
   404 	TRAP_IGNORE(((CEikSecretEditor*)EditorControl())->SetSkinTextColorL(EAknsCIQsnTextColorsCG26));
       
   405 
       
   406     TAknLayoutRect layoutRect;
       
   407     layoutRect.LayoutRect(
       
   408         editorRect,
       
   409         AknLayoutScalable_Avkon::input_focus_pane_cp2_copy1() );
       
   410     TRect editorFrameRect( layoutRect.Rect() );
       
   411     
       
   412     layoutRect.LayoutRect(
       
   413         editorFrameRect,
       
   414         AknLayoutScalable_Avkon::set_opt_bg_pane_g1_copy1() );
       
   415     
       
   416     SetEditedItemFrameRects( editorFrameRect, layoutRect.Rect() );
       
   417     
       
   418     layoutRect.LayoutRect(
       
   419         editorRect,
       
   420         AknLayoutScalable_Avkon::indicator_popup_pane_cp6() );
       
   421     SetEditorIndicatorRect( layoutRect.Rect() );
       
   422 	}
       
   423 
       
   424 /**
       
   425  * All password setting pages containing edwins will have the same draw code
       
   426  *
       
   427  */
       
   428 EXPORT_C void CAknPasswordSettingPage::Draw(const TRect& aRect) const
       
   429 	{
       
   430 	BaseDraw( aRect );
       
   431 	// Suppress this legacy frame drawing if skins is performing it
       
   432 	if ( !IsSkinsHandlingEditorFrameDrawing() )
       
   433 		{
       
   434 		CWindowGc& gc=SystemGc(); 
       
   435 		iSecretEditorLayoutRect.DrawRect( gc );
       
   436 		iHorizontalShadow.DrawRect( gc );
       
   437 		iVerticalShadow.DrawRect( gc );
       
   438 		iOutlineFrame.DrawOutLineRect( gc );
       
   439 		}
       
   440 	}
       
   441 
       
   442 /**
       
   443  * Writes the internal state of the control and its components to aStream.
       
   444  * Does nothing in release mode.
       
   445  * Designed to be overidden and base called by subclasses.
       
   446  */
       
   447 #ifndef _DEBUG
       
   448 EXPORT_C void CAknPasswordSettingPage::WriteInternalStateL(RWriteStream& /*aWriteStream*/) const
       
   449 	{}
       
   450 #else
       
   451 EXPORT_C void CAknPasswordSettingPage::WriteInternalStateL(RWriteStream& aWriteStream) const
       
   452 	{
       
   453 	CAknSettingPage::WriteInternalStateL(aWriteStream);
       
   454 	}
       
   455 #endif
       
   456 
       
   457 EXPORT_C void CAknPasswordSettingPage::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
   458     { 
       
   459     CAknSettingPage::HandlePointerEventL(aPointerEvent); 
       
   460     }
       
   461 
       
   462 EXPORT_C void* CAknPasswordSettingPage::ExtensionInterface( TUid /*aInterface*/ ) 
       
   463     { 
       
   464     return NULL;
       
   465     }
       
   466 
       
   467 /**
       
   468  *	Reserved method derived from CCoeControl
       
   469  */
       
   470 EXPORT_C void CAknPasswordSettingPage::Reserved_2()
       
   471 	{
       
   472 	}
       
   473 
       
   474 /**
       
   475 * Setting Page reserved methods 
       
   476 */ 
       
   477 EXPORT_C void CAknPasswordSettingPage::CAknSettingPage_Reserved_1()
       
   478 	{
       
   479 	}
       
   480 EXPORT_C void CAknPasswordSettingPage::CAknSettingPage_Reserved_2()
       
   481 	{
       
   482 	}
       
   483 //////////////////////////////////////////////////////////////////////
       
   484 //
       
   485 //  ALPHA PASSWORD SETTING PAGE
       
   486 //
       
   487 //////////////////////////////////////////////////////////////////////
       
   488 
       
   489 /**
       
   490  *
       
   491  * Constructor from setting page resource id + referenced passwords.
       
   492  *
       
   493  */
       
   494 EXPORT_C CAknAlphaPasswordSettingPage::CAknAlphaPasswordSettingPage( 
       
   495 	TInt aResourceId, 
       
   496 	TDes& aNewPassword, 
       
   497 	const TDesC& aOldPassword ):
       
   498 	CAknPasswordSettingPage(aResourceId, aNewPassword, aOldPassword)
       
   499 	{
       
   500 	SetMaxPasswordLength( KDefaultAlphaPasswordLength );
       
   501 	AKNTASHOOK_ADD( this, "CAknAlphaPasswordSettingPage" );
       
   502 	}
       
   503 
       
   504 EXPORT_C CAknAlphaPasswordSettingPage::CAknAlphaPasswordSettingPage(	
       
   505 								const TDesC* aSettingText, 
       
   506 								TInt aSettingNumber, 
       
   507 								TInt aControlType,
       
   508 								TInt aEditorResourceId, 
       
   509 								TInt aSettingPageResourceId, 
       
   510 								TDes& aNewPassword, 
       
   511 								const TDesC& aOldPassword )
       
   512 								:	CAknPasswordSettingPage( 
       
   513 									aSettingText, 
       
   514 									aSettingNumber, 
       
   515 									aControlType, 
       
   516 									aEditorResourceId, 
       
   517 									aSettingPageResourceId,
       
   518 									aNewPassword, 
       
   519 									aOldPassword )
       
   520 	{
       
   521 	SetMaxPasswordLength( KDefaultAlphaPasswordLength );
       
   522 	AKNTASHOOK_ADD( this, "CAknAlphaPasswordSettingPage" );
       
   523 	}
       
   524 
       
   525 /**
       
   526  * Destructor
       
   527  *
       
   528  */
       
   529 EXPORT_C CAknAlphaPasswordSettingPage::~CAknAlphaPasswordSettingPage()
       
   530 	{
       
   531 	AKNTASHOOK_REMOVE();
       
   532 	}
       
   533 
       
   534 
       
   535 /** 
       
   536  *
       
   537  * The 2nd stage construction. Stored internal resource is used to perform the
       
   538  * construction.
       
   539  * Secret editor is reset to zero length.
       
   540  *
       
   541  */
       
   542 EXPORT_C void CAknAlphaPasswordSettingPage::ConstructL()
       
   543 	{
       
   544 	BaseConstructL();
       
   545 	AlphaPasswordEditor()->SetBorder( TGulBorder::ENone );
       
   546 	AlphaPasswordEditor()->Reset();
       
   547 	// Construct an appropriate control context for the contained editor areas.
       
   548 	// Context produced is owned by CAknSettingPage. 
       
   549     SetEditedItemFrameIID( KAknsIIDQsnFrInput, KAknsIIDQsnFrInputCenter );
       
   550 	}
       
   551 
       
   552 /**
       
   553  * Soak up function to do the safe copying of the editor to the referenced value
       
   554  *
       
   555  */
       
   556 EXPORT_C void CAknAlphaPasswordSettingPage::UpdateTextL()
       
   557 	{
       
   558 	AlphaPasswordEditor()->GetText( NewPassword() );
       
   559 	}
       
   560 
       
   561 /**
       
   562  * Compares the given passwords.
       
   563  * Supports folding matching.
       
   564  */
       
   565 EXPORT_C TInt CAknAlphaPasswordSettingPage::ComparePasswords( const TDesC& aRefPassword, const TDesC& aCandidatePassword, enum CAknPasswordSettingPage::TAknPasswordMatchingMode aMode) const
       
   566 	{
       
   567 	TBool retVal(EFalse);
       
   568 
       
   569     if ( aMode == ECaseSensitive )
       
   570         retVal = aRefPassword.Compare( aCandidatePassword );
       
   571     else
       
   572         retVal = aRefPassword.CompareF( aCandidatePassword );
       
   573         
       
   574     return retVal;
       
   575 	}
       
   576 
       
   577 /** 
       
   578  *
       
   579  * Type-specific access to the alpha password editor control
       
   580  *
       
   581  */
       
   582 EXPORT_C CEikSecretEditor* CAknAlphaPasswordSettingPage::AlphaPasswordEditor()
       
   583 	{
       
   584 	return STATIC_CAST( CEikSecretEditor*, EditorControl());
       
   585 	}
       
   586 
       
   587 /**
       
   588  * Writes the internal state of the control and its components to aStream.
       
   589  * Does nothing in release mode.
       
   590  * Designed to be overidden and base called by subclasses.
       
   591  */
       
   592 #ifndef _DEBUG
       
   593 EXPORT_C void CAknAlphaPasswordSettingPage::WriteInternalStateL(RWriteStream& /*aWriteStream*/) const
       
   594 	{}
       
   595 #else
       
   596 EXPORT_C void CAknAlphaPasswordSettingPage::WriteInternalStateL(RWriteStream& aWriteStream) const
       
   597 	{
       
   598 	CAknPasswordSettingPage::WriteInternalStateL(aWriteStream);
       
   599 	}
       
   600 #endif
       
   601 
       
   602 EXPORT_C void CAknAlphaPasswordSettingPage::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
   603     { 
       
   604     CAknPasswordSettingPage::HandlePointerEventL(aPointerEvent); 
       
   605     }
       
   606 
       
   607 EXPORT_C void* CAknAlphaPasswordSettingPage::ExtensionInterface( TUid /*aInterface*/ ) 
       
   608     { 
       
   609     return NULL;
       
   610     }
       
   611 
       
   612 /**
       
   613  *	Reserved method derived from CCoeControl
       
   614  */
       
   615 EXPORT_C void CAknAlphaPasswordSettingPage::Reserved_2()
       
   616 	{
       
   617 	}
       
   618 
       
   619 /**
       
   620 * Setting Page reserved methods 
       
   621 */ 
       
   622 EXPORT_C void CAknAlphaPasswordSettingPage::CAknSettingPage_Reserved_1()
       
   623 	{
       
   624 	}
       
   625 EXPORT_C void CAknAlphaPasswordSettingPage::CAknSettingPage_Reserved_2()
       
   626 	{
       
   627 	}
       
   628 
       
   629 //////////////////////////////////////////////////////////////////////
       
   630 //
       
   631 //  NUMERIC PASSWORD SETTING PAGE
       
   632 //
       
   633 //////////////////////////////////////////////////////////////////////
       
   634 
       
   635 
       
   636 
       
   637 /**
       
   638  *
       
   639  * Constructor from setting page resource id + referenced passwords.
       
   640  *
       
   641  */
       
   642 EXPORT_C CAknNumericPasswordSettingPage::CAknNumericPasswordSettingPage( 
       
   643 	TInt aResourceId, 
       
   644 	TDes& aNewPassword, 
       
   645 	const TDesC& aOldPassword ):
       
   646 	CAknPasswordSettingPage(aResourceId, aNewPassword, aOldPassword)
       
   647 	{
       
   648 	SetMaxPasswordLength( KDefaultNumericPasswordLength );
       
   649 	AKNTASHOOK_ADD( this, "CAknNumericPasswordSettingPage" );
       
   650 	}
       
   651 
       
   652 
       
   653 EXPORT_C CAknNumericPasswordSettingPage::CAknNumericPasswordSettingPage(	
       
   654 								const TDesC* aSettingText, 
       
   655 								TInt aSettingNumber, 
       
   656 								TInt aControlType,
       
   657 								TInt aEditorResourceId, 
       
   658 								TInt aSettingPageResourceId, 
       
   659 								TDes& aNewPassword, 
       
   660 								const TDesC& aOldPassword )
       
   661 								:	CAknPasswordSettingPage( 
       
   662 									aSettingText, 
       
   663 									aSettingNumber, 
       
   664 									aControlType, 
       
   665 									aEditorResourceId, 
       
   666 									aSettingPageResourceId,
       
   667 									aNewPassword, 
       
   668 									aOldPassword )
       
   669 	{
       
   670 	SetMaxPasswordLength( KDefaultNumericPasswordLength );
       
   671 	AKNTASHOOK_ADD( this, "CAknNumericPasswordSettingPage" );
       
   672 	}
       
   673 
       
   674 /**
       
   675  * Destructor
       
   676  *
       
   677  */
       
   678 EXPORT_C CAknNumericPasswordSettingPage::~CAknNumericPasswordSettingPage()
       
   679 	{
       
   680 	AKNTASHOOK_REMOVE();
       
   681 	}
       
   682 
       
   683 
       
   684 /** 
       
   685  *
       
   686  * The 2nd stage construction. Stored internal resource is used to perform the
       
   687  * construction.
       
   688  * Secret editor is reset to zero length.
       
   689  *
       
   690  */
       
   691 EXPORT_C void CAknNumericPasswordSettingPage::ConstructL()
       
   692 	{
       
   693 	BaseConstructL();
       
   694 	NumericPasswordEditor()->SetBorder( TGulBorder::ENone );
       
   695 	NumericPasswordEditor()->Reset();
       
   696 	// Construct an appropriate control context for the contained editor areas.
       
   697 	// Context produced is owned by CAknSettingPage. 
       
   698     SetEditedItemFrameIID( KAknsIIDQsnFrInput, KAknsIIDQsnFrInputCenter );
       
   699 	}
       
   700 
       
   701 /**
       
   702  * Soak up function to do the safe copying of the editor to the referenced value
       
   703  *
       
   704  */
       
   705 EXPORT_C void CAknNumericPasswordSettingPage::UpdateTextL()
       
   706 	{
       
   707 	NumericPasswordEditor()->GetText( NewPassword() );
       
   708 	}
       
   709 /** 
       
   710  *
       
   711  * Type-specific access to the alpha password editor control
       
   712  *
       
   713  */
       
   714 EXPORT_C CAknNumericSecretEditor* CAknNumericPasswordSettingPage::NumericPasswordEditor()
       
   715 	{
       
   716 	return STATIC_CAST( CAknNumericSecretEditor*, EditorControl());
       
   717 	}
       
   718 
       
   719 /**
       
   720  * Writes the internal state of the control and its components to aStream.
       
   721  * Does nothing in release mode.
       
   722  * Designed to be overidden and base called by subclasses.
       
   723  */
       
   724 #ifndef _DEBUG
       
   725 EXPORT_C void CAknNumericPasswordSettingPage::WriteInternalStateL(RWriteStream& /*aWriteStream*/) const
       
   726 	{}
       
   727 #else
       
   728 EXPORT_C void CAknNumericPasswordSettingPage::WriteInternalStateL(RWriteStream& aWriteStream) const
       
   729 	{
       
   730 	CAknPasswordSettingPage::WriteInternalStateL(aWriteStream);
       
   731 	}
       
   732 #endif
       
   733 
       
   734 EXPORT_C void CAknNumericPasswordSettingPage::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
   735     { 
       
   736     CAknPasswordSettingPage::HandlePointerEventL(aPointerEvent); 
       
   737     }
       
   738 
       
   739 EXPORT_C void* CAknNumericPasswordSettingPage::ExtensionInterface( TUid /*aInterface*/ ) 
       
   740     { 
       
   741     return NULL;
       
   742     }
       
   743     
       
   744 /**
       
   745  *	Reserved method derived from CCoeControl
       
   746  */
       
   747 EXPORT_C void CAknNumericPasswordSettingPage::Reserved_2()
       
   748 	{
       
   749 	}
       
   750 
       
   751 /**
       
   752 * Setting Page reserved methods 
       
   753 */ 
       
   754 EXPORT_C void CAknNumericPasswordSettingPage::CAknSettingPage_Reserved_1()
       
   755 	{
       
   756 	}
       
   757 EXPORT_C void CAknNumericPasswordSettingPage::CAknSettingPage_Reserved_2()
       
   758 	{
       
   759 	}
       
   760 
       
   761 // End of File