phoneapp/phoneuiview/src/cphonedtmfnumberlistquery.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  NumberListQuery for DTMF strings.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include    "cphonedtmfnumberlistquery.h"
       
    21 #include    "mphonequeryobserver.h"
       
    22 #include    "phoneui.hrh"
       
    23 #include    "phonelogger.h"
       
    24 #include    <mphcntmatch.h>
       
    25 #include    <StringLoader.h>
       
    26 #include    <phoneui.rsg>
       
    27 
       
    28 
       
    29 const TInt KPhoneManualDTMFString = R_QTN_ENTER_MANUALLY_QUERY_ITEM;
       
    30 const TInt KPhoneFindDTMFString = R_QTN_FIND_QUERY_ITEM;
       
    31 
       
    32 // ======== MEMBER FUNCTIONS ========
       
    33 
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // Constructor
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CPhoneDtmfNumberListQuery::CPhoneDtmfNumberListQuery(
       
    40     MEikCommandObserver& aCommandObserver,
       
    41     MPhoneQueryObserver& aQueryObserver,
       
    42     HBufC*& aSelectedDtmfNumber ):
       
    43       CAknListQueryDialog( &iIndex ),
       
    44       iCommandObserver( aCommandObserver ),
       
    45       iQueryObserver ( aQueryObserver ),
       
    46       iSelectedDtmfNumber ( aSelectedDtmfNumber ),
       
    47       iArray( 2 )
       
    48     {
       
    49     }
       
    50 // ---------------------------------------------------------------------------
       
    51 // CPhoneDtmfNumberListQuery::NewL
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CPhoneDtmfNumberListQuery* CPhoneDtmfNumberListQuery::NewL( MEikCommandObserver& aCommandObserver,
       
    55                                                            MPhoneQueryObserver& aQueryObserver,
       
    56                                                            HBufC*& aSelectedDtmfNumber  )
       
    57     {
       
    58     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneDtmfNumberListQuery::NewL()");
       
    59     CPhoneDtmfNumberListQuery* self = 
       
    60                 new ( ELeave ) CPhoneDtmfNumberListQuery( aCommandObserver, 
       
    61                                                           aQueryObserver,
       
    62                                                           aSelectedDtmfNumber );
       
    63     CleanupStack::PushL( self );
       
    64     self->ConstructL();
       
    65     CleanupStack::Pop( self );
       
    66     return self;
       
    67     }
       
    68     
       
    69 // ---------------------------------------------------------------------------
       
    70 // ConstructL
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void CPhoneDtmfNumberListQuery::ConstructL()
       
    74     {
       
    75     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneDtmfNumberListQuery::ConstructL()");
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // Destructor
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 CPhoneDtmfNumberListQuery::~CPhoneDtmfNumberListQuery()
       
    83     {
       
    84     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneDtmfNumberListQuery::~CPhoneDtmfNumberListQuery()");
       
    85     iArray.Reset();
       
    86     iQueryObserver.SetQueryDeletedFlag( ETrue );
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // CPhoneDtmfNumberListQuery::PostLayoutDynInitL
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void CPhoneDtmfNumberListQuery::PostLayoutDynInitL()
       
    94     {
       
    95     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneDtmfNumberListQuery::PostLayoutDynInitL()");
       
    96     HBufC* manual = StringLoader::LoadLC( KPhoneManualDTMFString );
       
    97     HBufC* find = StringLoader::LoadLC( KPhoneFindDTMFString );
       
    98     iArray.AppendL( *find );
       
    99     iArray.AppendL( *manual );
       
   100     SetItemTextArray( &iArray );
       
   101     SetOwnershipType( ELbmDoesNotOwnItemArray ); 
       
   102     CleanupStack::PopAndDestroy( 2, manual ); //find, manual  
       
   103     Layout();
       
   104     DrawDeferred(); 
       
   105     }
       
   106     
       
   107 // ---------------------------------------------------------------------------
       
   108 // CPhoneDtmfNumberListQuery::OfferKeyEventL
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 TKeyResponse CPhoneDtmfNumberListQuery::OfferKeyEventL( 
       
   112     const TKeyEvent& aKeyEvent,
       
   113     TEventCode aType )
       
   114     {
       
   115     if ( aType == EEventKey &&
       
   116         ( aKeyEvent.iScanCode == EStdKeyNo || aKeyEvent.iCode == EKeyNo ) )
       
   117         {
       
   118         OkToExitL( EPhoneCmdEnd );
       
   119         }
       
   120     else if ( aKeyEvent.iScanCode == EStdKeyYes )
       
   121         {
       
   122         return EKeyWasConsumed;        
       
   123         }        
       
   124                 
       
   125     return CAknListQueryDialog::OfferKeyEventL( aKeyEvent, aType );     
       
   126     } 
       
   127         
       
   128 // ---------------------------------------------------------------------------
       
   129 // CPhoneDtmfNumberListQuery::AppendStringToArrayL
       
   130 // ---------------------------------------------------------------------------
       
   131 //    
       
   132 void CPhoneDtmfNumberListQuery::AppendStringToArrayL( TDesC& aString )
       
   133     {
       
   134     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneDtmfNumberListQuery::AppendStringToArrayL()");
       
   135     iArray.AppendL( aString );
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // CPhoneDtmfNumberListQuery::OkToExitL
       
   140 //
       
   141 // If softkey is select, result buffer can be filled with DTMF string.
       
   142 // Selection can be 'Find' then single item fetch is started.
       
   143 // 
       
   144 // Otherwise forward to base class. 
       
   145 //
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 
       
   149 TBool CPhoneDtmfNumberListQuery::OkToExitL( 
       
   150         TInt aButtonId )
       
   151     {
       
   152     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneDtmfNumberListQuery::OkToExitL()");
       
   153     TInt index = 0;
       
   154     TInt arraycount = 0;
       
   155     TBool retVal = ETrue;
       
   156     if ( aButtonId == EAknSoftkeySelect || aButtonId == EEikBidOk )
       
   157         {
       
   158         
       
   159         index = ListBox()->CurrentItemIndex();
       
   160         arraycount = ListBox()->Model()->
       
   161                     MatchableTextArray()->MdcaCount();
       
   162         
       
   163         // 'Enter manually' selected.  
       
   164         //  Last in the list.         
       
   165         if ( index == ( arraycount-1 ) )
       
   166             {
       
   167             // Forward pressed CBA to the framework so that we can handle it
       
   168             // in our active state
       
   169             iQueryObserver.ReportQueryCompleteAsync( EPhoneInCallCmdDtmfManualQuery ); 
       
   170             }
       
   171 
       
   172         // Fill result buffer with DTMF string.
       
   173         else if ( index <= ( arraycount-3 ) )     
       
   174             {
       
   175             TPtrC ptr = ListBox()->Model()->
       
   176                     MatchableTextArray()->MdcaPoint( index );
       
   177                     
       
   178             // Caller is responsible to delete object
       
   179             iSelectedDtmfNumber = HBufC::NewL( ptr.Length() );
       
   180             iSelectedDtmfNumber->Des().Append( ptr );           
       
   181             //Let the command observer handle this case.
       
   182             iQueryObserver.ReportQueryCompleteAsync( EPhoneCmdDtmfOk );           
       
   183             }
       
   184            
       
   185         //  Make single item fetch if 'Find' selected.  
       
   186         // 'Find' item is second last.
       
   187         else if ( index == ( arraycount-2 ) )
       
   188             {
       
   189              // Forward pressed CBA to the framework so that we can handle it
       
   190             // in our active state
       
   191             iQueryObserver.ReportQueryCompleteAsync( EPhoneInCallCmdDtmfListViewSearch );
       
   192             }
       
   193         }
       
   194         
       
   195     else if ( aButtonId == EPhoneCmdEnd )  
       
   196         {
       
   197         iQueryObserver.ReportQueryCompleteAsync( EPhoneCmdEnd ); 
       
   198         }        
       
   199     
       
   200     return retVal;
       
   201     }
       
   202     
       
   203 //  End of File