nettools/conntest/src/CustomPrefsItemList.cpp
changeset 0 857a3e953887
equal deleted inserted replaced
-1:000000000000 0:857a3e953887
       
     1 /*
       
     2  * Copyright (c) 2006-2009 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: CCustomPrefsItemList implemets the Extended Connection Preferences setting
       
    15  * list for Conntest.
       
    16  *
       
    17  */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <cmapplicationsettingsui.h>
       
    21 #include <extendedconnpref.h>
       
    22 
       
    23 #include "CustomPrefsItemList.h"
       
    24 #include "CustomPrefsData.h"
       
    25 #include "conntest.hrh"
       
    26 #include "Utils.h"
       
    27 #include "cmapplicationsettingsui.h"
       
    28 
       
    29 // ================= MEMBER FUNCTIONS =========================================
       
    30 
       
    31 // ----------------------------------------------------------------------------
       
    32 // CCustomPrefsItemList::CreateSettingItemL
       
    33 // Inherited from CAknSettingItem. Updates descriptor array for list box.
       
    34 // ----------------------------------------------------------------------------
       
    35 //
       
    36 CAknSettingItem* CCustomPrefsItemList::CreateSettingItemL( TInt aIdentifier )
       
    37     {
       
    38     CAknSettingItem* customPrefsItem = NULL;
       
    39     
       
    40     switch (aIdentifier)
       
    41         {
       
    42         case EConnTestExtConnPrefsItemSnapPurpose:
       
    43             customPrefsItem = new (ELeave) CAknEnumeratedTextPopupSettingItem(
       
    44                     aIdentifier, iData->iSnapPurpose );
       
    45             break;
       
    46         case EConnTestExtConnPrefsItemSnapId:
       
    47             customPrefsItem = new (ELeave) CAknIntegerEdwinSettingItem(
       
    48                     aIdentifier, iData->iSnapId );
       
    49             break;
       
    50         case EConnTestExtConnPrefsItemIapId:
       
    51             customPrefsItem = new (ELeave) CAknIntegerEdwinSettingItem(
       
    52                     aIdentifier, iData->iIapId );
       
    53             break;
       
    54         case EConnTestExtConnPrefsItemBearerSet:
       
    55             customPrefsItem = new (ELeave) CAknEnumeratedTextPopupSettingItem(
       
    56                     aIdentifier, iData->iBearerSet );
       
    57             break;
       
    58         case EConnTestExtConnPrefsItemNoteBehaviour:
       
    59             customPrefsItem = new (ELeave) CAknEnumeratedTextPopupSettingItem(
       
    60                     aIdentifier, iData->iNoteBehaviour );
       
    61             break;
       
    62         case EConnTestExtConnPrefsItemDisconnectDialog:
       
    63             customPrefsItem = new (ELeave) CAknBinaryPopupSettingItem(
       
    64                     aIdentifier, iData->iDisconnectDialog );
       
    65             break;
       
    66         case EConnTestExtConnPrefsItemConnSelectionDialog:
       
    67             customPrefsItem = new (ELeave) CAknBinaryPopupSettingItem(
       
    68                     aIdentifier, iData->iConnSelectionDialog );
       
    69             break;
       
    70         case EConnTestExtConnPrefsItemForcedRoaming:
       
    71             customPrefsItem = new (ELeave) CAknBinaryPopupSettingItem(
       
    72                     aIdentifier, iData->iForcedRoaming );
       
    73             break;
       
    74         default:
       
    75             break;
       
    76         }
       
    77     return customPrefsItem;
       
    78     }
       
    79 
       
    80 // ----------------------------------------------------------------------------
       
    81 // CCustomPrefsItemList::SetData
       
    82 // 
       
    83 // ----------------------------------------------------------------------------
       
    84 //
       
    85 void CCustomPrefsItemList::SetData( CCustomPrefsData* aData )
       
    86     {
       
    87     iData = aData;
       
    88     }
       
    89 
       
    90 // ----------------------------------------------------------------------------
       
    91 // CCustomPrefsItemList::SizeChanged
       
    92 // Size changed handler
       
    93 // ----------------------------------------------------------------------------
       
    94 //
       
    95 void CCustomPrefsItemList::SizeChanged()
       
    96     {
       
    97     if (ListBox())
       
    98         {
       
    99         ListBox()->SetRect( Rect() );
       
   100         }
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------
       
   104 // CCustomPrefsItemList::SelectSnapL()
       
   105 // Selects a SNAP
       
   106 // ---------------------------------------------------------
       
   107 //
       
   108 void CCustomPrefsItemList::SelectSnapL()
       
   109     {
       
   110     // Start the SNAP selection dialog
       
   111     CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL();
       
   112     CleanupStack::PushL( settings );
       
   113     TCmSettingSelection selection;
       
   114     TUint listItems = CMManager::EShowDestinations;
       
   115     TBearerFilterArray filterArray;
       
   116     
       
   117     settings->RunApplicationSettingsL( selection, listItems, filterArray );
       
   118 
       
   119     CleanupStack::PopAndDestroy( settings );
       
   120     
       
   121     switch (selection.iResult)
       
   122         {
       
   123         case CMManager::EDestination:
       
   124             {
       
   125             iData->iSnapId = selection.iId;
       
   126             break;
       
   127             }
       
   128         default:
       
   129             {
       
   130             iData->iSnapId = 0;
       
   131             RDebug::Print( _L("ConnTest: Invalid selection") );
       
   132             break;
       
   133             }
       
   134         }
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------
       
   138 // CCustomPrefsItemList::SelectIapL()
       
   139 // Selects an IAP
       
   140 // ---------------------------------------------------------
       
   141 //
       
   142 void CCustomPrefsItemList::SelectIapL()
       
   143     {
       
   144     // IAP selection menu
       
   145     TUint32 iapId;
       
   146     TInt popupOk = Utils::AskIapIdL( iapId );
       
   147     
       
   148     if (popupOk)
       
   149         {
       
   150         RDebug::Print( _L("ConnTest: Selected IAP id=%d"), iapId );
       
   151         iData->iIapId = iapId;
       
   152         }
       
   153     else
       
   154         {
       
   155         RDebug::Print( _L("ConnTest: Invalid selection") );
       
   156         iData->iIapId = 0;
       
   157         }
       
   158     }
       
   159 
       
   160 // ---------------------------------------------------------
       
   161 // CCustomPrefsItemList::EditItemL()
       
   162 // Edits a menu item
       
   163 // ---------------------------------------------------------
       
   164 //
       
   165 void CCustomPrefsItemList::EditItemL( TInt aIndex, TBool aCalledFromMenu )
       
   166     {
       
   167     if (aIndex == EConnTestExtConnPrefsItemSnapId)
       
   168         {
       
   169         // SNAP selection menu
       
   170         SelectSnapL();
       
   171         // Update the selected value into the CustomPrefsItemList
       
   172         CCustomPrefsSelectedIntegerItem* snapItem =
       
   173                 (CCustomPrefsSelectedIntegerItem*)(*SettingItemArray())[aIndex];
       
   174         snapItem->EditSelectedIntegerItemL( iData->iSnapId );
       
   175         }
       
   176     else if (aIndex == EConnTestExtConnPrefsItemIapId)
       
   177         {
       
   178         // IAP selection menu
       
   179         SelectIapL();
       
   180         // Update the selected value into the CustomPrefsItemList
       
   181         CCustomPrefsSelectedIntegerItem* iapItem =
       
   182                 (CCustomPrefsSelectedIntegerItem*)(*SettingItemArray())[aIndex];
       
   183         iapItem->EditSelectedIntegerItemL( iData->iIapId );
       
   184         }
       
   185     else
       
   186         {
       
   187         // The rest are handled "traditionally", via the base class
       
   188         CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
       
   189         }
       
   190     }
       
   191 
       
   192 // ---------------------------------------------------------
       
   193 // CCustomPrefsSelectedIntegerItem::EditSelectedIntegerItemL()
       
   194 // Edits a SNAP or IAP item
       
   195 // ---------------------------------------------------------
       
   196 //
       
   197 void CCustomPrefsItemList::CCustomPrefsSelectedIntegerItem::EditSelectedIntegerItemL( TInt aId )
       
   198     {
       
   199     this->SetExternalValue( aId );
       
   200     this->LoadL();
       
   201     this->UpdateListBoxTextL();
       
   202     }
       
   203 
       
   204 // End of File