connectionutilities/ConnectionDialogs/cconndlg/src/IAPDialog.cpp
branchRCL_3
changeset 57 05bc53fe583b
parent 55 fc7b30ed2058
child 58 83ca720e2b9a
equal deleted inserted replaced
55:fc7b30ed2058 57:05bc53fe583b
     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 CIapDialog.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "IAPDialog.h"
       
    21 #include "ConnectionInfo.h"
       
    22 #include "ConnectionInfoArray.h"
       
    23 #include "ConnDlgPlugin.h"
       
    24 #include "ConnectionDialogsLogger.h"
       
    25 #include "ExpiryTimer.h"
       
    26 
       
    27 #include <AknIconArray.h>
       
    28 #include <AknsUtils.h>
       
    29 #include <uikon/eiksrvui.h>
       
    30 
       
    31 #include <data_caging_path_literals.hrh>
       
    32 #include <apsettings.mbg>
       
    33 
       
    34 
       
    35 // CONST DECLARATIONS
       
    36 
       
    37 // ROM folder
       
    38 _LIT( KDriveZ, "z:" );
       
    39 
       
    40 
       
    41 // Name of the MBM file containing icons
       
    42 _LIT( KApsettingsMBMFile, "ApSettings.mbm" );
       
    43 
       
    44 #if defined(_DEBUG)
       
    45 _LIT( KErrNullPointer, "NULL pointer" );
       
    46 #endif
       
    47 
       
    48 // CONSTANTS
       
    49 
       
    50 LOCAL_D const TInt KIconsGranularity = 4;
       
    51 
       
    52 
       
    53 // ================= MEMBER FUNCTIONS =======================
       
    54 //
       
    55 // ---------------------------------------------------------
       
    56 // CIapDialog::CIapDialog
       
    57 // ---------------------------------------------------------
       
    58 //
       
    59 CIapDialog::CIapDialog( CConnDlgIapPlugin* aPlugin )
       
    60 : CAknListQueryDialog( &iDummy ),
       
    61   iPlugin( aPlugin ),
       
    62   iFromOkToExit( EFalse )
       
    63     {
       
    64     }
       
    65 
       
    66 
       
    67 // ---------------------------------------------------------
       
    68 // CIapDialog::NewL
       
    69 // ---------------------------------------------------------
       
    70 //
       
    71 CIapDialog* CIapDialog::NewL( CConnDlgIapPlugin* aPlugin )
       
    72     {
       
    73     CIapDialog* self = new( ELeave ) CIapDialog( aPlugin );
       
    74     CleanupStack::PushL( self );
       
    75     self->ConstructL();
       
    76     CleanupStack::Pop( self );
       
    77 
       
    78     return self;
       
    79     }
       
    80 
       
    81 
       
    82 // ---------------------------------------------------------
       
    83 // CIapDialog::ConstructL()
       
    84 // ---------------------------------------------------------
       
    85 //
       
    86 void CIapDialog::ConstructL()
       
    87     {
       
    88     }
       
    89 
       
    90 
       
    91 // ---------------------------------------------------------
       
    92 // CIapDialog::~CIapDialog()
       
    93 // ---------------------------------------------------------
       
    94 //
       
    95 CIapDialog::~CIapDialog()
       
    96     {
       
    97     CLOG_ENTERFN( "CIapDialog::~CIapDialog " );
       
    98     iIAPIds.Close();
       
    99     delete iExpiryTimer;
       
   100     STATIC_CAST( CEikServAppUi*, 
       
   101                 CCoeEnv::Static()->AppUi() )->SuppressAppSwitching( EFalse );
       
   102     CLOG_LEAVEFN( "CIapDialog::~CIapDialog " );
       
   103     }
       
   104 
       
   105 
       
   106 // ---------------------------------------------------------
       
   107 // CIapDialog::PreLayoutDynInitL()
       
   108 // ---------------------------------------------------------
       
   109 //
       
   110 void CIapDialog::PreLayoutDynInitL()
       
   111     {
       
   112     CLOG_ENTERFN( "CIapDialog::PreLayoutDynInitL " );  
       
   113     
       
   114     CAknListQueryDialog::PreLayoutDynInitL();
       
   115 
       
   116     SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   117     SetIconsL();
       
   118 
       
   119     STATIC_CAST( CEikServAppUi*, 
       
   120                 CCoeEnv::Static()->AppUi() )->SuppressAppSwitching( ETrue );
       
   121 
       
   122     iExpiryTimer = CExpiryTimer::NewL( *this );
       
   123     iExpiryTimer->Start();
       
   124     
       
   125     CLOG_LEAVEFN( "CIapDialog::PreLayoutDynInitL " );      
       
   126     }
       
   127 
       
   128 
       
   129 // ---------------------------------------------------------
       
   130 // CIapDialog::SetIconsL()
       
   131 // ---------------------------------------------------------
       
   132 //
       
   133 void CIapDialog::SetIconsL()
       
   134     {
       
   135     CLOG_ENTERFN( "CIapDialog::SetIconsL " );  
       
   136     
       
   137     CArrayPtr< CGulIcon >* icons = new( ELeave ) CAknIconArray( 
       
   138                                                         KIconsGranularity );
       
   139     CleanupStack::PushL( icons );
       
   140 
       
   141     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   142 
       
   143     TFileName iconsFileName;
       
   144 
       
   145     iconsFileName.Append( KDriveZ );
       
   146     iconsFileName.Append( KDC_APP_BITMAP_DIR );
       
   147     iconsFileName.Append( KApsettingsMBMFile );
       
   148 
       
   149     icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   150                             KAknsIIDQgnPropWmlGprs,
       
   151                             iconsFileName, 
       
   152                             EMbmApsettingsQgn_prop_wml_gprs, 
       
   153                             EMbmApsettingsQgn_prop_wml_gprs_mask ) );
       
   154 
       
   155     icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   156                             KAknsIIDQgnPropWmlCsd,
       
   157                             iconsFileName, 
       
   158                             EMbmApsettingsQgn_prop_wml_csd, 
       
   159                             EMbmApsettingsQgn_prop_wml_csd_mask ) );
       
   160 
       
   161     icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   162                             KAknsIIDQgnPropWmlHscsd,
       
   163                             iconsFileName, 
       
   164                             EMbmApsettingsQgn_prop_wml_hscsd, 
       
   165                             EMbmApsettingsQgn_prop_wml_hscsd_mask ) );
       
   166 
       
   167     icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   168                         KAknsIIDQgnPropWlanEasy,
       
   169                         iconsFileName, 
       
   170                         EMbmApsettingsQgn_prop_wlan_easy, 
       
   171                         EMbmApsettingsQgn_prop_wlan_easy_mask ) );
       
   172 
       
   173     icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   174                         KAknsIIDQgnPropWlanBearer,
       
   175                         iconsFileName, 
       
   176                         EMbmApsettingsQgn_prop_wlan_bearer, 
       
   177                         EMbmApsettingsQgn_prop_wlan_bearer_mask ) );
       
   178     
       
   179     SetIconArrayL( icons );
       
   180 
       
   181     CleanupStack::Pop( icons );
       
   182     CLOG_LEAVEFN( "CIapDialog::SetIconsL " );      
       
   183     }
       
   184 
       
   185 
       
   186 // ---------------------------------------------------------
       
   187 // CIapDialog::OkToExitL
       
   188 // ---------------------------------------------------------
       
   189 //
       
   190 TBool CIapDialog::OkToExitL( TInt aButtonId )
       
   191     {
       
   192     CLOG_ENTERFN( "CIapDialog::OkToExitL " );      
       
   193     
       
   194     TBool result( EFalse );
       
   195     TInt completeCode( KErrNone );
       
   196     
       
   197     if ( aButtonId == EAknSoftkeySelect || aButtonId == EAknSoftkeyOk ||
       
   198          aButtonId == EAknSoftkeyDone )
       
   199         {
       
   200         iPlugin->SetPreferredIapIdL( iIAPIds[ListBox()->CurrentItemIndex()] );
       
   201         result = ETrue;
       
   202         }
       
   203     else if ( aButtonId == EAknSoftkeyCancel )
       
   204         {
       
   205         completeCode = KErrCancel;
       
   206         result = ETrue;
       
   207         }
       
   208         
       
   209     if ( result )
       
   210         {
       
   211         iFromOkToExit = ETrue;        
       
   212         
       
   213         __ASSERT_DEBUG( iPlugin, User::Panic( KErrNullPointer, KErrNone ) );
       
   214         iPlugin->CompleteL( completeCode );
       
   215         }
       
   216 
       
   217     CLOG_LEAVEFN( "CIapDialog::OkToExitL " );      
       
   218 
       
   219     return result;
       
   220     }
       
   221 
       
   222 
       
   223 // ---------------------------------------------------------
       
   224 // CIapDialog::RefreshDialogL
       
   225 // ---------------------------------------------------------
       
   226 //    
       
   227 void CIapDialog::RefreshDialogL( CConnectionInfoArray* aIAP, 
       
   228                                  TBool aIsReallyRefreshing )
       
   229     {  
       
   230     CLOG_ENTERFN( "CIapDialog::RefreshDialogL " );  
       
   231      
       
   232     SetItemTextArray( aIAP );
       
   233 
       
   234     iIAPIds.Reset();
       
   235     
       
   236     TInt numAPs = aIAP->Count();
       
   237     for( TInt ii = 0; ii < numAPs; ii++ )
       
   238         {
       
   239         TUint32 id = aIAP->At( ii )->Id();
       
   240         iIAPIds.AppendL( id );        
       
   241         }
       
   242     
       
   243     ListBox()->SetCurrentItemIndex( 0 );
       
   244 
       
   245     ListBox()->HandleItemAdditionL();
       
   246 
       
   247     if ( aIsReallyRefreshing )
       
   248         {   // If we are really making a refresh, we need to recalculate the 
       
   249             // layout, because the number of items could be different and the
       
   250             // dialog should be resized accordingly
       
   251         Layout();   
       
   252         SizeChanged();
       
   253         DrawNow();
       
   254         }
       
   255 
       
   256     CLOG_LEAVEFN( "CIapDialog::RefreshDialogL " );  
       
   257     }
       
   258 
       
   259 // ---------------------------------------------------------
       
   260 // CIapDialog::OfferKeyEventL
       
   261 // ---------------------------------------------------------
       
   262 //
       
   263 TKeyResponse CIapDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   264                                          TEventCode aType)
       
   265     {
       
   266     if( aType == EEventKey && aKeyEvent.iCode == EKeyPhoneSend )
       
   267         {
       
   268         // Let's not obscure the Dialer in the background
       
   269         if ( iExpiryTimer )
       
   270             {
       
   271             iExpiryTimer->Cancel();
       
   272             iExpiryTimer->StartShort();    
       
   273             }
       
   274         }
       
   275         
       
   276     return CAknListQueryDialog::OfferKeyEventL( aKeyEvent,aType ); 
       
   277     }
       
   278 
       
   279 void CIapDialog::HandleTimedOut()
       
   280     {
       
   281     TRAP_IGNORE( TryExitL(EAknSoftkeyCancel) );
       
   282     }
       
   283 
       
   284 
       
   285 
       
   286 // End of File