phonebookui/Phonebook2/USIMExtension/src/CPsu2NumberQueryDlg.cpp
changeset 0 e686773b3f54
child 21 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002-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:  A dialog for asking fixed dialling phone number.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CPsu2NumberQueryDlg.h"
       
    22 #include <Pbk2USimUIRes.rsg>
       
    23 #include <Pbk2UIControls.rsg>
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CPsu2NumberQueryDlg::CPsu2NumberQueryDlg
       
    29 // C++ default constructor can NOT contain any code, that
       
    30 // might leave.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CPsu2NumberQueryDlg::CPsu2NumberQueryDlg( 
       
    34     TDes& aNumberBuffer )
       
    35     : CAknTextQueryDialog( aNumberBuffer )
       
    36     {
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CPsu2NumberQueryDlg::ConstructL
       
    41 // Symbian 2nd phase constructor can leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CPsu2NumberQueryDlg::ConstructL( const TDesC& aSourceNumber )
       
    45     {
       
    46     TDes& dialogData = Text();
       
    47     dialogData.Copy( aSourceNumber.Left( dialogData.MaxLength() ) );
       
    48     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( 
       
    49         dialogData );
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CPsu2NumberQueryDlg::NewL
       
    54 // Two-phased constructor.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CPsu2NumberQueryDlg* CPsu2NumberQueryDlg::NewL( 
       
    58     const TDesC& aSourceNumber, TDes& aNumberBuffer )
       
    59     {
       
    60     CPsu2NumberQueryDlg* self = 
       
    61         new( ELeave ) CPsu2NumberQueryDlg( aNumberBuffer );
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL( aSourceNumber );
       
    64     CleanupStack::Pop( self );
       
    65     return self;
       
    66     }
       
    67 
       
    68 
       
    69 // Destructor
       
    70 CPsu2NumberQueryDlg::~CPsu2NumberQueryDlg()
       
    71     {
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CPsu2NumberQueryDlg::UpdateLeftSoftKeyL
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void CPsu2NumberQueryDlg::UpdateLeftSoftKeyL()
       
    79     {
       
    80     const TChar questionMark('?');
       
    81 
       
    82     CAknQueryControl* control = QueryControl();
       
    83     if ( control )
       
    84         {
       
    85         TDes& dialogData = Text(); 
       
    86         control->GetText( dialogData );       
       
    87         // Number is ok if it's not empty and it doesn't contain question mark
       
    88         if ( dialogData.Length() > 0 && 
       
    89              dialogData.Locate( questionMark ) == KErrNotFound )
       
    90             {
       
    91             iNumberAccepted = ETrue;
       
    92             MakeLeftSoftkeyVisible( ETrue );
       
    93             MakeMiddleSoftkeyVisibleL( ETrue );
       
    94             }
       
    95         else
       
    96             {
       
    97             iNumberAccepted = EFalse;
       
    98             MakeLeftSoftkeyVisible( EFalse );
       
    99             MakeMiddleSoftkeyVisibleL( EFalse );
       
   100             }
       
   101         }
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CPsu2NumberQueryDlg::OfferKeyEventL
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 TKeyResponse CPsu2NumberQueryDlg::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   109     TEventCode aType )
       
   110     {
       
   111     TKeyResponse ret;
       
   112     if ( aType == EEventKey && aKeyEvent.iCode == EKeyPhoneSend )
       
   113         {
       
   114         if( iNumberAccepted )
       
   115             {
       
   116             TryExitL( EAknSoftkeyOk );
       
   117             }     
       
   118         ret = EKeyWasConsumed;
       
   119         }
       
   120     else
       
   121         {
       
   122         ret = CAknTextQueryDialog::OfferKeyEventL( aKeyEvent, aType );
       
   123         }
       
   124     
       
   125     return ret;
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CPsu2NumberQueryDlg::ExecuteLD
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 TBool CPsu2NumberQueryDlg::ExecuteLD()
       
   133     {
       
   134     TBool result = ETrue;
       
   135     // A stack reference to data must be used because this instance is deleted
       
   136     // after ExecuteLD
       
   137     TDes& dialogData = Text();
       
   138     SetMaxLength( Text().MaxLength() );
       
   139     if ( CAknTextQueryDialog::ExecuteLD( R_PSU2_FDN_NUMBERQUERY_DIALOG ) )
       
   140         {
       
   141         AknTextUtils::ConvertDigitsTo( dialogData, EDigitTypeWestern );
       
   142         }
       
   143     else
       
   144         {
       
   145         result = EFalse;
       
   146         }
       
   147     return result;
       
   148     }
       
   149     
       
   150 // -----------------------------------------------------------------------------
       
   151 // CPsu2NumberQueryDlg::MakeMiddleSoftkeyVisibleL
       
   152 // -----------------------------------------------------------------------------
       
   153 //    
       
   154 void CPsu2NumberQueryDlg::MakeMiddleSoftkeyVisibleL( TBool aVisible )
       
   155 	{
       
   156 	TInt resId( KErrNotFound );
       
   157 	if ( aVisible )
       
   158 		{
       
   159 		resId = R_PBK2_SOFTKEYS_CALL_CANCEL_CALL;
       
   160 		}
       
   161 	else
       
   162 		{
       
   163 		resId = R_PBK2_SOFTKEYS_EMPTY_CANCEL_EMPTY;
       
   164 		}
       
   165 	ButtonGroupContainer().SetCommandSetL( resId );
       
   166 	ButtonGroupContainer().DrawDeferred();
       
   167 	}
       
   168 	
       
   169 //  End of File