connectionutilities/ConnectionDialogs/cconndlg/src/SelectExplicitDialog.cpp
branchRCL_3
changeset 58 83ca720e2b9a
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
       
     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:  Implementation of class CSelectExplicitDialog.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "SelectExplicitDialog.h"
       
    21 #include "ConnectionInfo.h"
       
    22 #include "ConnectionInfoArray.h"
       
    23 #include "ConnDlgPlugin.h"
       
    24 #include "ConnectionDialogsLogger.h"
       
    25 #include "SelectConnectionDialog.h"
       
    26 #include "ExpiryTimer.h"
       
    27 
       
    28 #include <AknIconArray.h>
       
    29 #include <AknsUtils.h>
       
    30 #include <uikon/eiksrvui.h>
       
    31 
       
    32 #include <data_caging_path_literals.hrh>
       
    33 #include <apsettings.mbg>
       
    34 
       
    35 #include <CConnDlgPlugin.rsg>
       
    36 
       
    37 
       
    38 // ================= MEMBER FUNCTIONS =======================
       
    39 //
       
    40 // ---------------------------------------------------------
       
    41 // CSelectExplicitDialog::CSelectExplicitDialog
       
    42 // ---------------------------------------------------------
       
    43 //
       
    44 CSelectExplicitDialog::CSelectExplicitDialog( 
       
    45                                     CSelectConnectionDialog* aCallerDialog )
       
    46 : CAknListQueryDialog( &iDummy ),
       
    47   iCallerDialog( aCallerDialog ),
       
    48   iFromOkToExit( EFalse )
       
    49     {
       
    50     }
       
    51 
       
    52 
       
    53 // ---------------------------------------------------------
       
    54 // CSelectExplicitDialog::NewL
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 CSelectExplicitDialog* CSelectExplicitDialog::NewL( 
       
    58                                     CSelectConnectionDialog* aCallerDialog )
       
    59     {
       
    60     CSelectExplicitDialog* self = new( ELeave ) 
       
    61                                         CSelectExplicitDialog( aCallerDialog );
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop( self );
       
    65 
       
    66     return self;
       
    67     }
       
    68 
       
    69 
       
    70 // ---------------------------------------------------------
       
    71 // CSelectExplicitDialog::ConstructL()
       
    72 // ---------------------------------------------------------
       
    73 //
       
    74 void CSelectExplicitDialog::ConstructL()
       
    75     {
       
    76     }
       
    77 
       
    78 
       
    79 // ---------------------------------------------------------
       
    80 // CSelectExplicitDialog::~CSelectExplicitDialog()
       
    81 // ---------------------------------------------------------
       
    82 //
       
    83 CSelectExplicitDialog::~CSelectExplicitDialog()
       
    84     {
       
    85     CLOG_ENTERFN( "CSelectExplicitDialog::~CSelectExplicitDialog " );
       
    86     iIAPIds.Close();
       
    87     delete iExpiryTimer;
       
    88     CLOG_LEAVEFN( "CSelectExplicitDialog::~CSelectExplicitDialog " );
       
    89     }
       
    90 
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CSelectExplicitDialog::PreLayoutDynInitL()
       
    94 // ---------------------------------------------------------
       
    95 //
       
    96 void CSelectExplicitDialog::PreLayoutDynInitL()
       
    97     {
       
    98     CLOG_ENTERFN( "CSelectExplicitDialog::PreLayoutDynInitL " );  
       
    99     
       
   100     CAknListQueryDialog::PreLayoutDynInitL();
       
   101 
       
   102     SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   103     SetIconArrayL( iIcons );
       
   104 
       
   105     iExpiryTimer = CExpiryTimer::NewL( *this );
       
   106     iExpiryTimer->Start();
       
   107     
       
   108     CLOG_LEAVEFN( "CSelectExplicitDialog::PreLayoutDynInitL " );      
       
   109     }
       
   110 
       
   111 
       
   112 // ---------------------------------------------------------
       
   113 // CSelectExplicitDialog::OkToExitL
       
   114 // ---------------------------------------------------------
       
   115 //
       
   116 TBool CSelectExplicitDialog::OkToExitL( TInt aButtonId )
       
   117     {
       
   118     CLOG_ENTERFN( "CSelectExplicitDialog::OkToExitL " );      
       
   119     
       
   120     TBool result( EFalse );
       
   121     TInt completeCode( KErrNone );
       
   122     
       
   123     if ( aButtonId == EAknSoftkeySelect || aButtonId == EAknSoftkeyOk ||
       
   124          aButtonId == EAknSoftkeyDone )
       
   125         {
       
   126         iCallerDialog->SetElementIDL( iIAPIds[ListBox()->CurrentItemIndex()] );
       
   127         result = ETrue;
       
   128         }
       
   129     else if ( aButtonId == EAknSoftkeyCancel )
       
   130         {
       
   131         completeCode = KErrCancel;
       
   132         result = ETrue;
       
   133         }
       
   134         
       
   135     if ( result )
       
   136         {
       
   137         iFromOkToExit = ETrue;        
       
   138         
       
   139         iCallerDialog->CompleteL( completeCode );
       
   140         }
       
   141 
       
   142     CLOG_LEAVEFN( "CSelectExplicitDialog::OkToExitL " );      
       
   143 
       
   144     return result;
       
   145     }
       
   146 
       
   147 
       
   148 // ---------------------------------------------------------
       
   149 // CSelectExplicitDialog::PrepareAndRunLD
       
   150 // ---------------------------------------------------------
       
   151 //    
       
   152 void CSelectExplicitDialog::PrepareAndRunLD( CConnectionInfoArray* aIAP,
       
   153                                                CArrayPtr< CGulIcon >* aIcons,
       
   154                                                TBool aIsReallyRefreshing )
       
   155     {
       
   156     PrepareLC( R_LIST_EXPLICIT_QUERY );
       
   157     RefreshDialogL( aIAP, aIcons, aIsReallyRefreshing );
       
   158     RunLD();
       
   159     }
       
   160 
       
   161 
       
   162 // ---------------------------------------------------------
       
   163 // CSelectExplicitDialog::RefreshDialogL
       
   164 // ---------------------------------------------------------
       
   165 //    
       
   166 void CSelectExplicitDialog::RefreshDialogL( CConnectionInfoArray* aIAP, 
       
   167                                               CArrayPtr< CGulIcon >* aIcons,
       
   168                                               TBool aIsReallyRefreshing )
       
   169     {  
       
   170     CLOG_ENTERFN( "CSelectExplicitDialog::RefreshDialogL " );  
       
   171      
       
   172     SetItemTextArray( aIAP );
       
   173     iIcons = aIcons;
       
   174 
       
   175     iIAPIds.Reset();
       
   176 
       
   177     // Determine the preferred IAP
       
   178     TInt numAPs = aIAP->Count();
       
   179     for( TInt ii = 0; ii < numAPs; ii++ )
       
   180         {
       
   181         iIAPIds.AppendL( aIAP->At( ii )->Id() );
       
   182         }
       
   183 
       
   184     if ( numAPs )
       
   185         {
       
   186         ListBox()->SetCurrentItemIndex( 0 );
       
   187         }
       
   188     ListBox()->HandleItemAdditionL();
       
   189 
       
   190     if ( aIsReallyRefreshing )
       
   191         {   // If we are really making a refresh, we need to recalculate the 
       
   192             // layout, because the number of items could be different and the
       
   193             // dialog should be resized accordingly
       
   194         Layout();   
       
   195         SizeChanged();
       
   196         DrawNow();
       
   197         }
       
   198 
       
   199     CLOG_LEAVEFN( "CSelectExplicitDialog::RefreshDialogL " );  
       
   200     }
       
   201     
       
   202 // ---------------------------------------------------------
       
   203 // CSelectExplicitDialog::OfferKeyEventL
       
   204 // ---------------------------------------------------------
       
   205 //
       
   206 TKeyResponse CSelectExplicitDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   207                                                     TEventCode aType)
       
   208     {
       
   209     if( aType == EEventKey && aKeyEvent.iCode == EKeyPhoneSend )
       
   210         {
       
   211         // Let's not obscure the Dialer in the background
       
   212         if ( iExpiryTimer )
       
   213             {
       
   214             iExpiryTimer->Cancel();
       
   215             iExpiryTimer->StartShort();    
       
   216             }
       
   217         }
       
   218         
       
   219     return CAknListQueryDialog::OfferKeyEventL( aKeyEvent,aType ); 
       
   220     }    
       
   221 	
       
   222 void CSelectExplicitDialog::HandleTimedOut()
       
   223     {
       
   224     TRAP_IGNORE( TryExitL(EAknSoftkeyCancel) );
       
   225     }
       
   226 // End of File