connectionutilities/ConnectionDialogs/ConnectionUiUtilities/src/ChangeConnectionDlg.cpp
changeset 0 5a93021fdf25
child 3 f7816ffc66ed
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     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 *     Defines dialog CChangeConnectionDlg from Connection Ui Utilities
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include <AknIconArray.h>
       
    23 #include <AknsUtils.h>
       
    24 #include <aknmessagequerycontrol.h>
       
    25 #include <StringLoader.h>
       
    26 #include <featmgr.h>
       
    27 #include <WlanCdbCols.h>
       
    28 
       
    29 #include <data_caging_path_literals.hrh>
       
    30 #include <ConnectionUiUtilities.rsg>
       
    31 #include <apsettings.mbg>
       
    32 
       
    33 #include "ChangeConnectionDlg.h"
       
    34 #include "ActiveCChangeConnectionDlg.h"
       
    35 #include "ConnectionDialogsLogger.h"
       
    36 #include "ExpiryTimer.h"
       
    37 
       
    38 // CONSTANTS
       
    39 
       
    40 // ROM folder
       
    41 _LIT( KDriveZ, "z:" );
       
    42 
       
    43 // Name of the MBM file containing icons
       
    44 _LIT( KFileIcons, "ApSettings.mbm" );
       
    45 
       
    46 #if defined(_DEBUG)
       
    47 _LIT( KErrNullPointer, "NULL pointer" );
       
    48 #endif
       
    49 
       
    50 LOCAL_D const TInt KIconsGranularity = 4;
       
    51 
       
    52 
       
    53 // ================= MEMBER FUNCTIONS =======================
       
    54 
       
    55 // Constructor
       
    56 CChangeConnectionDlg::CChangeConnectionDlg( TInt aIndex,
       
    57                                     TUint32* aIAPId, 
       
    58                                     CActiveCChangeConnectionDlg* aActiveDlg,
       
    59                                     TDes& aConnectionName )
       
    60 : CAknListQueryDialog( &aIndex ),
       
    61   iIAPId( aIAPId ),
       
    62   iConnectionName( aConnectionName ),
       
    63   iIsWLANFeatureSupported( EFalse ),
       
    64   iActiveDlg( aActiveDlg )
       
    65     {
       
    66     }
       
    67 
       
    68 
       
    69 // Destructor
       
    70 CChangeConnectionDlg::~CChangeConnectionDlg()
       
    71     {
       
    72     delete iExpiryTimer;
       
    73     }
       
    74 
       
    75 
       
    76 // ---------------------------------------------------------
       
    77 // CChangeConnectionDlg::NewL
       
    78 // ---------------------------------------------------------
       
    79 //
       
    80 CChangeConnectionDlg* CChangeConnectionDlg::NewL( TUint32* aIAPId, 
       
    81                                       CActiveCChangeConnectionDlg* aActiveDlg,
       
    82                                       TDes& aConnectionName)
       
    83     {
       
    84     CChangeConnectionDlg* temp = new ( ELeave )CChangeConnectionDlg(
       
    85                                     0, aIAPId, aActiveDlg, aConnectionName );
       
    86     CleanupStack::PushL( temp ); 
       
    87     temp->ConstructL();                                    
       
    88     CleanupStack::Pop( temp );
       
    89     return temp;
       
    90     }
       
    91 
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // CChangeConnectionDlg::ConstructAndRunLD
       
    95 // Constructs the dialog and runs it.
       
    96 // ---------------------------------------------------------
       
    97 //
       
    98 void CChangeConnectionDlg::ConstructL()
       
    99     {
       
   100     FeatureManager::InitializeLibL();
       
   101     iIsWLANFeatureSupported = 
       
   102                     FeatureManager::FeatureSupported( KFeatureIdProtocolWlan );
       
   103     FeatureManager::UnInitializeLib();
       
   104     }
       
   105 
       
   106 
       
   107 
       
   108 // ---------------------------------------------------------
       
   109 // CChangeConnectionDlg::OkToExitL( TInt aButtonId)
       
   110 // called by framework when the OK button is pressed
       
   111 // ---------------------------------------------------------
       
   112 //
       
   113 TBool CChangeConnectionDlg::OkToExitL( TInt aButtonId )
       
   114     {
       
   115     CLOG_ENTERFN( "CChangeConnectionDlg::OkToExitL " );  
       
   116     
       
   117     TBool result( EFalse );
       
   118     __ASSERT_DEBUG( iActiveDlg, User::Panic( KErrNullPointer, KErrNone ) );
       
   119     
       
   120     
       
   121     if ( aButtonId == EAknSoftkeySelect || aButtonId == EAknSoftkeyOk )
       
   122         {
       
   123         TInt index = ListBox()->CurrentItemIndex();
       
   124         CConnectionInfo* tempInfo = iActiveDlg->ActIAPs()->At( index );
       
   125         *iIAPId = tempInfo->Id();
       
   126 
       
   127         CLOG_WRITEF( _L( "*iIAPId : %d" ), *iIAPId );
       
   128         
       
   129         iActiveDlg->Cancel();
       
   130         iActiveDlg->SetSelected( ETrue );
       
   131                 
       
   132         result = ETrue;
       
   133         }
       
   134     else if ( aButtonId == EAknSoftkeyCancel )
       
   135         {
       
   136         iActiveDlg->Cancel();  
       
   137                   
       
   138         result = ETrue;
       
   139         }
       
   140     
       
   141     CLOG_LEAVEFN( "CChangeConnectionDlg::OkToExitL " );  
       
   142     
       
   143     return result;
       
   144     }
       
   145 
       
   146 
       
   147 
       
   148 // ---------------------------------------------------------
       
   149 // CChangeConnectionDlg::PreLayoutDynInitL()
       
   150 // called by framework before dialog is shown
       
   151 // ---------------------------------------------------------
       
   152 //
       
   153 void CChangeConnectionDlg::PreLayoutDynInitL()
       
   154     {
       
   155     CLOG_ENTERFN( "CChangeConnectionDlg::PreLayoutDynInitL " );  
       
   156     
       
   157     CAknListQueryDialog::PreLayoutDynInitL();
       
   158 
       
   159     HBufC *desc = StringLoader::LoadL( R_CHANGE_CONNECTION_DESC, 
       
   160                                        iConnectionName );
       
   161     CleanupStack::PushL( desc );
       
   162     MessageBox()->SetMessageTextL( desc );
       
   163     CleanupStack::PopAndDestroy( desc );
       
   164 
       
   165     SetOwnershipType( ELbmOwnsItemArray );
       
   166     SetItemTextArray( iActiveDlg->ActIAPs() );       
       
   167     SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   168 
       
   169     SetIconsL();
       
   170     
       
   171     iExpiryTimer = CExpiryTimer::NewL( *this );
       
   172     iExpiryTimer->Start();
       
   173     CLOG_LEAVEFN( "CChangeConnectionDlg::PreLayoutDynInitL " );  
       
   174     
       
   175     }
       
   176 
       
   177 
       
   178 // ---------------------------------------------------------
       
   179 // CChangeConnectionDlg::RefreshDialogL
       
   180 // ---------------------------------------------------------
       
   181 //    
       
   182 void CChangeConnectionDlg::RefreshDialogL()
       
   183     {  
       
   184     CLOG_ENTERFN( "CChangeConnectionDlg::RefreshDialogL " );  
       
   185      
       
   186     SetItemTextArray( iActiveDlg->ActIAPs() );
       
   187     ListBox()->HandleItemAdditionL();  
       
   188     
       
   189     Layout();   
       
   190     SizeChanged();
       
   191     DrawNow();
       
   192     
       
   193     CLOG_LEAVEFN( "CChangeConnectionDlg::RefreshDialogL " );  
       
   194               
       
   195     }
       
   196 
       
   197 
       
   198 // ---------------------------------------------------------
       
   199 // CChangeConnectionDlg::SetIconsL()
       
   200 // ---------------------------------------------------------
       
   201 //
       
   202 void CChangeConnectionDlg::SetIconsL()
       
   203     {
       
   204     CArrayPtr< CGulIcon >* icons = new( ELeave ) CAknIconArray( 
       
   205                                                         KIconsGranularity );
       
   206     CleanupStack::PushL( icons );
       
   207 
       
   208     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   209 
       
   210     TFileName iconsFileName;
       
   211 
       
   212     iconsFileName.Append( KDriveZ );
       
   213 
       
   214     iconsFileName.Append( KDC_APP_BITMAP_DIR );
       
   215 
       
   216     iconsFileName.Append( KFileIcons );
       
   217 
       
   218     icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   219                             KAknsIIDQgnPropWmlGprs,
       
   220                             iconsFileName, 
       
   221                             EMbmApsettingsQgn_prop_wml_gprs, 
       
   222                             EMbmApsettingsQgn_prop_wml_gprs_mask ) );
       
   223 
       
   224     icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   225                             KAknsIIDQgnPropWmlCsd,
       
   226                             iconsFileName, 
       
   227                             EMbmApsettingsQgn_prop_wml_csd, 
       
   228                             EMbmApsettingsQgn_prop_wml_csd_mask ) );
       
   229 
       
   230     icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   231                             KAknsIIDQgnPropWmlHscsd,
       
   232                             iconsFileName, 
       
   233                             EMbmApsettingsQgn_prop_wml_hscsd, 
       
   234                             EMbmApsettingsQgn_prop_wml_hscsd_mask ) );
       
   235 
       
   236     if ( iIsWLANFeatureSupported )
       
   237         {
       
   238         icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   239                             KAknsIIDQgnPropWlanEasy,
       
   240                             iconsFileName, 
       
   241                             EMbmApsettingsQgn_prop_wlan_easy, 
       
   242                             EMbmApsettingsQgn_prop_wlan_easy_mask ) );
       
   243     
       
   244         icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   245                             KAknsIIDQgnPropWlanBearer,
       
   246                             iconsFileName, 
       
   247                             EMbmApsettingsQgn_prop_wlan_bearer, 
       
   248                             EMbmApsettingsQgn_prop_wlan_bearer_mask ) );
       
   249         }
       
   250     
       
   251     SetIconArrayL( icons );
       
   252 
       
   253     CleanupStack::Pop( icons );
       
   254     }
       
   255 
       
   256 
       
   257 
       
   258 
       
   259 // ----------------------------------------------------------------------------
       
   260 // void CChangeConnectionDlg::HandleResourceChange( TInt aType )
       
   261 // Handle resource change events. 
       
   262 // ----------------------------------------------------------------------------
       
   263 //
       
   264 void CChangeConnectionDlg::HandleResourceChange( TInt aType )
       
   265     {
       
   266     if ( aType == KAknsMessageSkinChange )
       
   267         {
       
   268         CAknListQueryDialog::HandleResourceChange( aType );
       
   269 
       
   270         TRAP_IGNORE( SetIconsL() );
       
   271         SizeChanged();
       
   272         }
       
   273     else
       
   274         {
       
   275         if ( aType == KEikDynamicLayoutVariantSwitch )
       
   276             {
       
   277             TRect mainPaneRect;
       
   278             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   279                                                mainPaneRect );
       
   280 
       
   281             TAknLayoutRect layoutRect;
       
   282             layoutRect.LayoutRect( TRect( TPoint( 0, 0 ), 
       
   283                                    mainPaneRect.Size() ),
       
   284                                    AKN_LAYOUT_WINDOW_list_gen_pane( 0 ) );
       
   285 
       
   286             ListBox()->SetRect( layoutRect.Rect() );
       
   287             }
       
   288 
       
   289         // Base call
       
   290         CAknListQueryDialog::HandleResourceChange( aType );
       
   291         }
       
   292     }
       
   293 
       
   294 void CChangeConnectionDlg::HandleTimedOut()
       
   295     {
       
   296     TRAP_IGNORE( TryExitL(EAknSoftkeyCancel) );
       
   297     }
       
   298 
       
   299 
       
   300 // End of File