apengine/apsettingshandlerui/src/ApNetSelPopupList.cpp
changeset 0 5a93021fdf25
child 8 2e6c4614c58e
child 27 489cf6208544
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 CApNetSelPopupList for access point selection.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include <ApNetworkItem.h>
       
    23 #include <csxhelp/cp.hlp.hrh>
       
    24 #include <featmgr.h>
       
    25 
       
    26 #include "ApSettingsHandlerUI.hrh"
       
    27  
       
    28 
       
    29 #include "ApNetSelPopupList.h"
       
    30 #include "ApNetSelectorListBoxModel.h"
       
    31 #include "ApSettingsModel.h"
       
    32 #include <ApSetUI.rsg>
       
    33 #include "ApsettingshandleruiImpl.h"
       
    34 
       
    35 
       
    36 #include "ApSettingsHandlerLogger.h"
       
    37 
       
    38 #include "AccessPointTextSettingPage.h"
       
    39 
       
    40 
       
    41 
       
    42 #include <ApProtHandler.h>  // for protection of settings
       
    43 
       
    44 
       
    45 // ================= MEMBER FUNCTIONS =======================
       
    46 
       
    47 // ---------------------------------------------------------
       
    48 // CApNetSelPopupList::NewL
       
    49 // ---------------------------------------------------------
       
    50 //
       
    51 CApNetSelPopupList* CApNetSelPopupList::NewL( CApSettingsModel& aModel,
       
    52                                        CApSettingsHandlerImpl& aHandler,
       
    53                                        TInt& aCurrentSelectionIndex,
       
    54                                        TInt& aPreferredUid,
       
    55                                        TUint32& aEventStore,
       
    56                                        CDesCArrayFlat* aItemArray,
       
    57                                        TBool aNeedsNone )
       
    58     {
       
    59     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::NewL")
       
    60     
       
    61     CApNetSelPopupList* self = 
       
    62         new ( ELeave ) CApNetSelPopupList(
       
    63                                          aModel, aHandler,
       
    64                                          aCurrentSelectionIndex,
       
    65                                          aPreferredUid, aItemArray,
       
    66                                          aEventStore, aNeedsNone
       
    67                                          );
       
    68 //  till that point, object is only partially constructed!
       
    69     
       
    70     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::NewL")
       
    71     return self;
       
    72     }
       
    73 
       
    74 
       
    75 // ---------------------------------------------------------
       
    76 // CApNetSelPopupList::ConstructL
       
    77 // ---------------------------------------------------------
       
    78 //
       
    79 void CApNetSelPopupList::ConstructL()
       
    80     {
       
    81     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::ConstructL")
       
    82 
       
    83     FeatureManager::InitializeLibL();
       
    84     iHelpSupported = FeatureManager::FeatureSupported( KFeatureIdHelp );
       
    85     iProtectionSupported = FeatureManager::FeatureSupported( 
       
    86                                            KFeatureIdSettingsProtection );
       
    87     FeatureManager::UnInitializeLib();
       
    88     
       
    89     CAknRadioButtonSettingPage::ConstructL();
       
    90     iList = ListBoxControl();
       
    91     iModel = new( ELeave )CApNetSelectorListboxModel();
       
    92     iList->Model()->SetItemTextArray( iModel );
       
    93     FillListBoxWithDataL();
       
    94     iDataModel->Database()->AddObserverL( this );
       
    95     
       
    96     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::ConstructL")
       
    97     }
       
    98 
       
    99 
       
   100 // Destructor
       
   101 CApNetSelPopupList::~CApNetSelPopupList()
       
   102     {
       
   103     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::~CApNetSelPopupList")
       
   104     
       
   105     if ( iDataModel )
       
   106         {
       
   107         if ( iDataModel->Database() )
       
   108             {
       
   109             // must remove observer here as there is a chance that we do not exit
       
   110             // through the standard way but through Leave(KErrLeaveWithoutAlert)...
       
   111             iDataModel->Database()->RemoveObserver( this );            
       
   112             }
       
   113         }
       
   114     if ( iModel )
       
   115         {
       
   116         iModel->ResetAndDestroy();
       
   117         delete iModel;
       
   118         }
       
   119     
       
   120     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::~CApNetSelPopupList")
       
   121     }
       
   122 
       
   123 
       
   124 
       
   125 // Constructor
       
   126 CApNetSelPopupList::CApNetSelPopupList(
       
   127                                  CApSettingsModel& aModel,
       
   128                                  CApSettingsHandlerImpl& aHandler,
       
   129                                  TInt& aIndex, TInt& aPreferredUid,
       
   130                                  CDesCArrayFlat* aItemArray,
       
   131                                  TUint32& aEventStore, TBool aNeedsNone
       
   132                                  )
       
   133 :CAknRadioButtonSettingPage( R_POPUP_LIST_NETWORK_SETTING_PAGE, 
       
   134                              aIndex, aItemArray ),
       
   135 iDataModel( &aModel ),
       
   136 iSelected( &aPreferredUid ),
       
   137 iHandler( &aHandler ),
       
   138 iEventStore( &aEventStore ),
       
   139 iNeedsNone( aNeedsNone ),
       
   140 iNeedUnlock( EFalse )
       
   141     {
       
   142     }
       
   143 
       
   144 
       
   145 
       
   146 
       
   147 
       
   148 // ---------------------------------------------------------
       
   149 // CApNetSelPopupList::SetHighlighted()
       
   150 // called when needs to change the highlighting
       
   151 // ---------------------------------------------------------
       
   152 //
       
   153 void CApNetSelPopupList::SetHighlighted()
       
   154     {
       
   155     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::SetHighlighted")
       
   156     
       
   157     if ( iPreferredUid )
       
   158         {
       
   159         TInt err( KErrNone );
       
   160         TInt idx = iModel->Item4Uid( iPreferredUid, err );
       
   161         // if UID exists, set as current, else set 0 as current.
       
   162         if ( err == KErrNone )
       
   163             {
       
   164             iList->SetCurrentItemIndexAndDraw( idx );
       
   165             iPreferredUid = 0;
       
   166             }
       
   167         else
       
   168             {
       
   169             iList->SetCurrentItemIndexAndDraw( 0 );
       
   170             }
       
   171         }
       
   172     
       
   173     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::SetHighlighted")
       
   174     }
       
   175 
       
   176 
       
   177 // ---------------------------------------------------------
       
   178 // CApNetSelPopupList::GetHelpContext()
       
   179 // ---------------------------------------------------------
       
   180 //
       
   181 void CApNetSelPopupList::GetHelpContext(TCoeHelpContext& aContext) const
       
   182     {
       
   183     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::GetHelpContext")
       
   184     
       
   185     aContext.iMajor = iHandler->iHelpMajor;
       
   186     // help no longer available for user, use dummy ID
       
   187     aContext.iContext = KSET_HLP_AP_SETTING_GPRS;
       
   188     
       
   189     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::GetHelpContext")
       
   190     }
       
   191 
       
   192 
       
   193 // ---------------------------------------------------------
       
   194 // CApNetSelPopupList::HandleApDbEventL
       
   195 // called by the active access point framework
       
   196 // ---------------------------------------------------------
       
   197 //
       
   198 void CApNetSelPopupList::HandleApDbEventL( TEvent anEvent )
       
   199     {
       
   200     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::HandleApDbEventL")
       
   201     
       
   202     switch ( anEvent )
       
   203         {
       
   204         case EDbChanged:
       
   205             {
       
   206             FillListBoxWithDataL();
       
   207             break;
       
   208             }
       
   209         case EDbClosing:
       
   210             {
       
   211             break;
       
   212             }
       
   213         case EDbAvailable:
       
   214             {
       
   215             if ( iNeedUnlock )
       
   216                 {
       
   217                 FillListBoxWithDataL();
       
   218                 }
       
   219             break;
       
   220             }
       
   221         default:
       
   222             {
       
   223             __ASSERT_DEBUG( EFalse, Panic( EUnknownCase ) );
       
   224             break;
       
   225             }
       
   226         }
       
   227     
       
   228     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::HandleApDbEventL")
       
   229     }
       
   230 
       
   231 
       
   232 // ---------------------------------------------------------
       
   233 // CApNetSelPopupList::ActivateL()
       
   234 // called after the dialog is shown
       
   235 // used to handle empty list - query
       
   236 // ---------------------------------------------------------
       
   237 //
       
   238 void CApNetSelPopupList::ActivateL()
       
   239     {
       
   240     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::ActivateL")
       
   241     
       
   242     CAknRadioButtonSettingPage::ActivateL();
       
   243     
       
   244     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::ActivateL")
       
   245     }
       
   246 
       
   247 
       
   248 
       
   249 // ---------------------------------------------------------
       
   250 // CApNetSelPopupList::SelectCurrentItemL()
       
   251 // called after the setting had been changed
       
   252 // ---------------------------------------------------------
       
   253 //
       
   254 void CApNetSelPopupList::SelectCurrentItemL()
       
   255     {
       
   256     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::SelectCurrentItemL")
       
   257     
       
   258     CAknRadioButtonSettingPage::SelectCurrentItemL();
       
   259     TInt idx = iList->CurrentItemIndex();
       
   260     if ( idx >= 0 )
       
   261         {
       
   262         *iSelected = iModel->At( idx )->Uid();
       
   263         }
       
   264     
       
   265     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::SelectCurrentItemL")
       
   266     }
       
   267 
       
   268 
       
   269 
       
   270 // ---------------------------------------------------------
       
   271 // CApNetSelPopupList::OkToExitL( TInt aButtonId )
       
   272 // called by framework when the OK button is pressed
       
   273 // ---------------------------------------------------------
       
   274 //
       
   275 TBool CApNetSelPopupList::OkToExitL( TInt aButtonId )
       
   276     {
       
   277     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::OkToExitL")
       
   278     
       
   279     // Translate the button presses into commands for the appui & current
       
   280     // view to handle.
       
   281     // This is a very good thing, that aButtonId is a TInt,
       
   282     // but the caller ( CAknSettingPage ) simply uses a TBool.
       
   283     // The value of ETrue means the button usually for Yes, Ok, Options, etc
       
   284     // and EFalse means Back, Cancel, etc.
       
   285     // so we must act according to a boolean value and not
       
   286     // according to the real button id...
       
   287     TBool IsAccepted = aButtonId;
       
   288 
       
   289     if ( IsAccepted )
       
   290         {
       
   291         TInt idx = iList->CurrentItemIndex();
       
   292         if ( idx >= 0 )
       
   293             {
       
   294             *iSelected = iModel->At( idx )->Uid();
       
   295             }
       
   296         }
       
   297     
       
   298     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::OkToExitL")
       
   299     return ETrue;
       
   300     }
       
   301 
       
   302 
       
   303 
       
   304 // ---------------------------------------------------------
       
   305 // CApNetSelPopupList::FillListBoxWithDataL()
       
   306 // called when listbox needs to be filled with data
       
   307 // ---------------------------------------------------------
       
   308 //
       
   309 void CApNetSelPopupList::FillListBoxWithDataL()
       
   310     {
       
   311     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::FillListBoxWithDataL")
       
   312     
       
   313     iPreferredLine = iList->CurrentItemIndex();
       
   314     if ( iPreferredLine < 0 )
       
   315         {
       
   316         iPreferredLine = 0;
       
   317         }
       
   318 
       
   319     if ( !iPreferredUid )
       
   320         { // if not specified explicitly, get current and use as 'preferred'
       
   321         if ( iPreferredLine >= 0 )
       
   322             {
       
   323             if ( iModel->Count() )
       
   324                 {
       
   325                 iPreferredUid = iModel->At( iPreferredLine )->Uid();
       
   326                 }
       
   327             }
       
   328         }
       
   329 
       
   330     TBool isLocked(EFalse);
       
   331     iNeedUnlock = EFalse;
       
   332 
       
   333     iDataModel->NetWorkListDataL( isLocked, *iModel );
       
   334 
       
   335     if ( isLocked )
       
   336         {
       
   337         iNeedUnlock = ETrue;
       
   338         }
       
   339 
       
   340     iList->View()->SetDisableRedraw( ETrue );
       
   341 
       
   342     if ( iNeedsNone )
       
   343         {
       
   344         HBufC* buf = iEikonEnv->AllocReadResourceLC( R_APUI_VIEW_AP_NONE );
       
   345         CApNetworkItem* NoneItem = CApNetworkItem::NewLC();
       
   346         NoneItem->SetUid( KApNoneUID );
       
   347         NoneItem->SetNameL( *buf );
       
   348         iModel->InsertL( 0, NoneItem );
       
   349         // as InsertL passes ownership of item to array,
       
   350         // remove from cleanupstack
       
   351         CleanupStack::Pop(); // NoneItem, as ownership is passed to array
       
   352         CleanupStack::PopAndDestroy(); // buf, as item has copied it...
       
   353         }
       
   354 
       
   355     iList->HandleItemAdditionL();
       
   356 
       
   357     SetSelectedL();
       
   358 
       
   359     SetHighlighted();
       
   360 
       
   361     iList->View()->SetDisableRedraw( EFalse );
       
   362     iList->HandleItemAdditionL();
       
   363 
       
   364     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::FillListBoxWithDataL")
       
   365     }
       
   366 
       
   367 
       
   368 // ---------------------------------------------------------
       
   369 // CApNetSelPopupList::SetSelectedL()
       
   370 // ---------------------------------------------------------
       
   371 //
       
   372 void CApNetSelPopupList::SetSelectedL()
       
   373     {
       
   374     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::SetSelectedL")
       
   375     
       
   376     TInt i( 0 );
       
   377     for( i=0; i<iModel->Count(); i++ )
       
   378         {
       
   379         if ( iModel->At( i )->Uid() == TUint32( *iSelected ) )
       
   380             {
       
   381             iList->SetCurrentItemIndexAndDraw( i );
       
   382             HandleListBoxEventL(iList,
       
   383                                 MEikListBoxObserver::EEventItemSingleClicked);
       
   384           /*  HandleListBoxEventL(iList,
       
   385                                             MEikListBoxObserver::EEventItemDoubleClicked);*/
       
   386             return; //exit here
       
   387             }
       
   388         }
       
   389     iList->SetCurrentItemIndexAndDraw( 0 );//set something that does no harm...
       
   390     HandleListBoxEventL(iList,
       
   391         MEikListBoxObserver::EEventItemSingleClicked ); // simulate selection...
       
   392     /*HandleListBoxEventL(iList,
       
   393         MEikListBoxObserver::EEventItemDoubleClicked);*/
       
   394     
       
   395     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::SetSelectedL")
       
   396     }
       
   397 
       
   398 
       
   399 
       
   400 
       
   401 // ---------------------------------------------------------
       
   402 // CApNetSelPopupList::DynInitMenuPaneL
       
   403 // ---------------------------------------------------------
       
   404 //
       
   405 void CApNetSelPopupList::DynInitMenuPaneL( TInt aResourceId,
       
   406                                         CEikMenuPane* aMenuPane )
       
   407     {
       
   408     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::DynInitMenuPaneL")
       
   409     
       
   410     CAknSettingPage::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   411     if ( aResourceId == R_APSETTINGSUI_MENU_NETWORK )
       
   412         {
       
   413         if ( Need2DeleteSelect( aResourceId ) )
       
   414             {
       
   415             aMenuPane->DeleteMenuItem( EApSelCmdSelect );
       
   416             }
       
   417         if ( Need2DeleteOpenDelete( aResourceId ) )
       
   418             {
       
   419             aMenuPane->DeleteMenuItem( EApSelCmdDelete );
       
   420             }
       
   421         if ( iProtectionSupported )
       
   422             {
       
   423             if ( CApProtHandler::IsTableProtectedL( 
       
   424                   iDataModel->Database()->Database() ) )
       
   425                 {            
       
   426                 aMenuPane->DeleteMenuItem( EApSelCmdNew );                
       
   427                 }
       
   428             }
       
   429 		if ( !iHelpSupported )
       
   430 			{
       
   431 			aMenuPane->DeleteMenuItem( EAknCmdHelp );
       
   432 			}        
       
   433         }
       
   434 
       
   435     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::DynInitMenuPaneL")
       
   436     }
       
   437 
       
   438 
       
   439 // From MEikCommandObserver
       
   440 // ---------------------------------------------------------
       
   441 // CApNetSelPopupList::ProcessCommandL
       
   442 // ---------------------------------------------------------
       
   443 //
       
   444 void CApNetSelPopupList::ProcessCommandL( TInt aCommandId )
       
   445     {
       
   446     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::ProcessCommandL")
       
   447     
       
   448     if ( MenuShowing() )
       
   449         {
       
   450         HideMenu();
       
   451         }
       
   452 
       
   453     switch ( aCommandId )
       
   454         {
       
   455         case EAknSoftkeyOptions:
       
   456             {
       
   457             DisplayMenuL();
       
   458             break;
       
   459             }
       
   460         case EAknSoftkeyBack:
       
   461             {
       
   462             AttemptExitL( EFalse );
       
   463             break;
       
   464             }
       
   465         case EAknSoftkeyCancel:
       
   466             {
       
   467             *iEventStore |= KApUiEventShutDownRequested;
       
   468             AttemptExitL( EFalse );
       
   469             break;
       
   470             }
       
   471         case EApSelCmdSelect:
       
   472             {
       
   473             *iEventStore |= KApUiEventSelected;
       
   474             AttemptExitL( ETrue );
       
   475             break;
       
   476             }
       
   477         case EApSelCmdNew:
       
   478             {
       
   479             // create a new network group here
       
   480             if ( HandleCreateNewNetworkGroupL() )
       
   481                 {
       
   482                 SetHighlighted();
       
   483                 }
       
   484             break; 
       
   485             }
       
   486         case EApSelCmdDelete:
       
   487             {
       
   488             // As it might have been started by the Clear key,
       
   489             // we must check if there is any...
       
   490             TInt cnt = iModel->Count();
       
   491             if ( ( iNeedsNone & ( cnt > 1 ) ) || ( !iNeedsNone && cnt ) )
       
   492                 {
       
   493                 // as we must be standing on an item, it must exists...
       
   494                 // So no problem on iModel->At( ...)
       
   495                 if ( iList->CurrentItemIndex() < ( iModel->Count()-1 ) )
       
   496                     {// move to next one if possible
       
   497                     iPreferredUid = iModel->At(
       
   498                             iList->CurrentItemIndex()+1 )->Uid();
       
   499                     }
       
   500                 else
       
   501                     { // if it is the last, move to previous if possible.
       
   502                     // if not, set to 0
       
   503                     if ( iModel->Count()> 1 )
       
   504                         {// move to prev. one if possible
       
   505                         iPreferredUid = iModel->At(
       
   506                             iList->CurrentItemIndex()-1 )->Uid();
       
   507                         }
       
   508                     else
       
   509                         {
       
   510                         iPreferredUid = 0;
       
   511                         }
       
   512                     }
       
   513                 iHandler->HandleNetworkDeleteCmdL(
       
   514                             iModel->At( iList->CurrentItemIndex() )->Uid() );
       
   515                 }
       
   516             break;
       
   517             }
       
   518         case EAknCmdHelp:
       
   519             {
       
   520 			if ( iHelpSupported )
       
   521 				{
       
   522 				iDataModel->LaunchHelpL();	
       
   523 				}
       
   524             break;
       
   525             }
       
   526         default:
       
   527             {
       
   528             // silently ignore it
       
   529             break;
       
   530             }
       
   531         }
       
   532     // check if user wants to Exit....
       
   533     if ( *iEventStore & KApUiEventExitRequested )
       
   534         {
       
   535         AttemptExitL( EFalse );
       
   536         }
       
   537     else
       
   538         {
       
   539         switch ( aCommandId )
       
   540             {
       
   541             case EApSelCmdExit:
       
   542                 {
       
   543                 *iEventStore |= KApUiEventExitRequested;
       
   544                 AttemptExitL( EFalse );
       
   545                 break;
       
   546                 }
       
   547             case EEikCmdExit:
       
   548                 {
       
   549                 *iEventStore |= KApUiEventShutDownRequested;
       
   550                 AttemptExitL( EFalse );
       
   551                 break;
       
   552                 }
       
   553             default:
       
   554                 {
       
   555                 break;
       
   556                 }
       
   557             }
       
   558         }
       
   559     
       
   560     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::ProcessCommandL")
       
   561     }
       
   562 
       
   563 
       
   564 
       
   565 // From CCoeControl
       
   566 // ---------------------------------------------------------
       
   567 // CApNetSelPopupList::OfferKeyEventL
       
   568 // ---------------------------------------------------------
       
   569 //
       
   570 TKeyResponse CApNetSelPopupList::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   571                                               TEventCode aType)
       
   572     {
       
   573     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::OfferKeyEventL")
       
   574     TKeyResponse retval;
       
   575     if ( aType == EEventKey )
       
   576         {
       
   577         if ( ( aKeyEvent.iCode == EKeyDelete ) ||
       
   578             ( aKeyEvent.iCode == EKeyBackspace ) )
       
   579             {
       
   580             ProcessCommandL( EApSelCmdDelete );
       
   581             retval = EKeyWasConsumed;
       
   582             }
       
   583         else
       
   584             {
       
   585             if ( aKeyEvent.iCode == EKeyOK )
       
   586                 { // process only if command is available...
       
   587                 ProcessCommandL( EApSelCmdSelect );
       
   588                 retval = EKeyWasConsumed;
       
   589                 }
       
   590             else
       
   591                 {
       
   592                 retval = CAknRadioButtonSettingPage::OfferKeyEventL(
       
   593                                         aKeyEvent, aType );
       
   594                 }
       
   595             }
       
   596         }
       
   597     else
       
   598         {
       
   599         retval = CAknRadioButtonSettingPage::OfferKeyEventL( aKeyEvent, aType );
       
   600         }
       
   601     
       
   602     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::OfferKeyEventL")
       
   603     return retval;
       
   604     }
       
   605 
       
   606 
       
   607 
       
   608 // ---------------------------------------------------------
       
   609 // CApNetSelPopupList::Need2DeleteSelect
       
   610 // ---------------------------------------------------------
       
   611 //
       
   612 TBool CApNetSelPopupList::Need2DeleteSelect( TInt aResourceId )
       
   613     {
       
   614     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::Need2DeleteSelect<->")
       
   615     return ( ( aResourceId == R_APSETTINGSUI_MENU_SELECT_NORMAL ) &&
       
   616              ( iList->Model()->NumberOfItems() == 0 ) );
       
   617     }
       
   618 
       
   619 
       
   620 
       
   621 // ---------------------------------------------------------
       
   622 // CApNetSelPopupList::Need2DeleteOpenDelete
       
   623 // ---------------------------------------------------------
       
   624 //
       
   625 TBool CApNetSelPopupList::Need2DeleteOpenDelete( TInt aResourceId )
       
   626     {
       
   627     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::Need2DeleteOpenDelete<->")
       
   628     
       
   629     return ( ( aResourceId == R_APSETTINGSUI_MENU_NETWORK ) &&
       
   630              (
       
   631                (
       
   632                  ( iList->Model()->NumberOfItems() == 0) && 
       
   633                  ( iNeedsNone == EFalse )
       
   634                )
       
   635                ||
       
   636                ( ( iNeedsNone ) &&
       
   637                  ( iModel->At( iList->CurrentItemIndex() )->Uid() 
       
   638                                   == KApNoneUID )
       
   639              ) ) );
       
   640     }
       
   641 
       
   642 
       
   643 
       
   644 // ---------------------------------------------------------
       
   645 // CApNetSelPopupList::HandleCreateNewNetworkGroupL
       
   646 // ---------------------------------------------------------
       
   647 //
       
   648 TBool CApNetSelPopupList::HandleCreateNewNetworkGroupL()
       
   649     {
       
   650     APSETUILOGGER_ENTERFN( EListbox,"NetSelPopup::HandleCreateNewNetworkGroupL")
       
   651     
       
   652     TBool retval( EFalse );
       
   653 
       
   654     // must be prepared for the worst case...
       
   655     TBuf<KModifiableLongTextLength> textToChange;    
       
   656 
       
   657     TInt TextSettingPageFlags( EAknSettingPageNoOrdinalDisplayed );
       
   658 
       
   659     CAccessPointTextSettingPage* dlg =
       
   660         new( ELeave )CAccessPointTextSettingPage( 
       
   661                         R_TEXT_SETTING_PAGE_NETW_NAME, 
       
   662                         textToChange,
       
   663                         TextSettingPageFlags,
       
   664                         EFalse );
       
   665 
       
   666     if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) )
       
   667         {
       
   668         CApNetworkItem* network = CApNetworkItem::NewLC();
       
   669         network->SetUid( 0 ); // will be assigned when written toi disk
       
   670         network->SetNameL( textToChange );
       
   671         iDataModel->DataHandler()->CreateNetworkL( *network );
       
   672         iPreferredUid = network->Uid();
       
   673         CleanupStack::PopAndDestroy( network );
       
   674         retval = ETrue;
       
   675         }
       
   676     *iEventStore |= KApUiEventEdited;
       
   677     
       
   678     APSETUILOGGER_LEAVEFN( EListbox,"NetSelPopup::HandleCreateNewNetworkGroupL")
       
   679     return retval;
       
   680     }
       
   681 
       
   682 // End of File