locationsystemui/locationsysui/locsuplsettingsui/src/locsuplsessioncontainer.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
     1 /*
       
     2 * Copyright (c) 2008 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:  SUPL session UI View's container
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System Includes
       
    20 #include <eikspane.h> 						// Status pane
       
    21 #include <akntitle.h>   					// CAknTitlePane
       
    22 #include <aknlists.h>
       
    23 #include <StringLoader.h>
       
    24 #include <locsuplsettingsui.rsg>
       
    25 #include <csxhelp/locsupl.hlp.hrh>          // Help File
       
    26 #include <aknview.h>
       
    27 #include <eikmenub.h>
       
    28 #include <gulicon.h>
       
    29 #include <AknIconUtils.h>
       
    30 #include <AknIconArray.h>
       
    31 #include <eikclbd.h>
       
    32 #include <avkon.mbg>						// for select session (mark) icon
       
    33 #include <avkon.rsg>
       
    34 #include <eiklbx.h>
       
    35 #include <ErrorUI.h>
       
    36 #include <AknsUtils.h> 
       
    37 #include <aknapp.h>
       
    38 #include <locsuplsettings.mbg>				// for session NI/TI icon
       
    39 
       
    40 // User Includes
       
    41 #include "locsuplsettings.hrh"
       
    42 #include "locsuplsettingsuid.hrh"
       
    43 #include "locsuplsessioncontainer.h"
       
    44 #include "locsuplsessionview.h"
       
    45 #include "locsuplsessionlbmodel.h"
       
    46 #include "locsuplsettingsuiengine.h"
       
    47 #include "locsuplsettingseventhandler.h"
       
    48 #include "locsupldebug.h"
       
    49 
       
    50 // CONSTANT DEFINITIONS
       
    51 const TInt KIconArrayGranularity = 2; // The number of default icons
       
    52 _LIT( KLocSuplSettingsIconFileName, "locsuplsettings.mif" );
       
    53 
       
    54 
       
    55 // ========================= MEMBER FUNCTIONS ================================
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CLocSUPLSessionContainer::CLocSUPLSessionContainer
       
    59 // Overloaded Constructor
       
    60 //
       
    61 // ---------------------------------------------------------------------------
       
    62 //	
       
    63 CLocSUPLSessionContainer::CLocSUPLSessionContainer( CLocSUPLSessionView* aView )
       
    64     : iView( aView )
       
    65 	{
       
    66 	}
       
    67 	
       
    68 // ---------------------------------------------------------------------------
       
    69 // CLocSUPLSessionContainer::~CLocSUPLSessionContainer
       
    70 // Destructor
       
    71 //
       
    72 // ---------------------------------------------------------------------------	
       
    73 //
       
    74 CLocSUPLSessionContainer::~CLocSUPLSessionContainer()
       
    75 	{
       
    76 	DEBUG( + CLocSUPLSessionContainer::~CLocSUPLSessionContainer );	
       
    77 	// Delete the List box model only after deleting the list box
       
    78 	delete iListBox;
       
    79 	iListBox = NULL;
       
    80 	
       
    81 	delete iListBoxModel;
       
    82 	iListBoxModel = NULL;
       
    83 	DEBUG( - CLocSUPLSessionContainer::~CLocSUPLSessionContainer );	
       
    84 	}
       
    85 	
       
    86 // ---------------------------------------------------------------------------
       
    87 // CLocSUPLSessionContainer* CLocSUPLSessionContainer::NewL
       
    88 // Static Two phase constructor that instantiates the CLocSUPLSessionContainer
       
    89 //
       
    90 // @param aRect							Client rectangle
       
    91 // @param aEngine                       Reference to the SUPL Settings
       
    92 //                                      engine 
       
    93 // @param aEventHandler                 Reference to the parent view
       
    94 // @return CLocSUPLSessionContainer*	Reference to the object created
       
    95 // ---------------------------------------------------------------------------    
       
    96 //
       
    97 CLocSUPLSessionContainer* CLocSUPLSessionContainer::NewL( 
       
    98                     		const TRect&               	aRect,
       
    99                           	CLocSUPLSettingsUiEngine&	aEngine,
       
   100                           	CLocSUPLSessionView* 		aView )
       
   101 	{	
       
   102 	DEBUG( + CLocSUPLSessionContainer::NewL );	
       
   103     CLocSUPLSessionContainer* self = NewLC( aRect, 
       
   104                                            aEngine,
       
   105                                            aView );
       
   106 	CleanupStack::Pop( self );
       
   107 	DEBUG( - CLocSUPLSessionContainer::NewL );	
       
   108 	return self;
       
   109 	}
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // CLocSUPLSessionContainer* CLocSUPLSessionContainer::NewLC
       
   113 // Static Two phase contructor that instantiates the CLocSUPLSessionContainer
       
   114 //
       
   115 // @param aRect							Client rectangle
       
   116 // @param aEngine                       Reference to the SUPL Settings
       
   117 //                                      engine 
       
   118 // @param aEventHandler                 Reference to the parent view
       
   119 // @return CLocSUPLSessionContainer*	Reference to the object created
       
   120 // ---------------------------------------------------------------------------  
       
   121 //  
       
   122 CLocSUPLSessionContainer* CLocSUPLSessionContainer::NewLC( 
       
   123                     		const TRect&               	aRect,
       
   124                           	CLocSUPLSettingsUiEngine&	aEngine,
       
   125                           	CLocSUPLSessionView* 		aView )
       
   126 	{	
       
   127     CLocSUPLSessionContainer* self = new ( ELeave ) CLocSUPLSessionContainer(
       
   128                                                         aView );
       
   129 	CleanupStack::PushL( self );
       
   130 	self->ConstructL( aRect, aEngine );
       
   131 	return self;
       
   132 	}
       
   133 
       
   134 // --------------------------------------------------------------------------- 
       
   135 // void CLocSUPLSessionContainer::ConstructL
       
   136 // Second phase of the two phase Construction process
       
   137 //
       
   138 // @param aRect				 Client rectangle
       
   139 // @param aEngine            Reference to the SUPL Settings engine
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 void CLocSUPLSessionContainer::ConstructL( 
       
   143                                     const TRect& 	aRect ,
       
   144                                     CLocSUPLSettingsUiEngine&     aEngine )
       
   145 	{
       
   146 	DEBUG( + CLocSUPLSessionContainer::ConstructL );	
       
   147 	//Make this control a window-owning control
       
   148 	CreateWindowL(); 
       
   149 	
       
   150 	// Create a New Title for the View
       
   151 	MakeTitleL( R_LOC_SUPL_SERVICES_TITLE );
       
   152 	
       
   153 	CreateListboxL( aEngine );
       
   154 	
       
   155 	// Get the Help context
       
   156 	iContextName = KLOC_HLP_SUPL();
       
   157 	
       
   158     SetRect( aRect );
       
   159     ActivateL();
       
   160 	DEBUG( - CLocSUPLSessionContainer::ConstructL );	
       
   161 	}	
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // void CLocSUPLSessionContainer::UpdateScreenL
       
   165 // Refreshes the screen so that the list box reflects the latest contents
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 void CLocSUPLSessionContainer::UpdateScreenL()
       
   169     {
       
   170 	DEBUG( + CLocSUPLSessionContainer::UpdateScreenL );	
       
   171 	
       
   172 	TInt oldCount 	= SessionIds().Count();	
       
   173 	TInt64 sessionId;
       
   174 	if( iSelectedIndex != KErrNotFound && SessionIds().Count() > iSelectedIndex )
       
   175 		{
       
   176 		sessionId = SessionIds()[ iSelectedIndex ];		
       
   177 		}
       
   178 	
       
   179 	if ( iListBoxModel )
       
   180 		{
       
   181 		iListBoxModel->UpdateSessionIdsL();
       
   182 		}    
       
   183 		
       
   184     TInt newCount 	= SessionIds().Count();
       
   185     
       
   186     if ( iListBox )
       
   187         {
       
   188     	// Update Listbox items
       
   189         if( newCount <= 0 || newCount == oldCount )
       
   190         	{
       
   191          	TRAP_IGNORE( iListBox->HandleItemAdditionL() );
       
   192 	    	TRAP_IGNORE( iListBox->HandleItemRemovalL() );       	
       
   193         	}
       
   194         else if( newCount > oldCount )
       
   195         	{
       
   196         	// notify the listbox for item addition 
       
   197         	TRAP_IGNORE( iListBox->HandleItemAdditionL() );
       
   198 
       
   199         	// set focus to newly added item
       
   200 			TInt index = iListBox->CurrentItemIndex();	
       
   201 			if( index == 0 && newCount == 1 )
       
   202 				{
       
   203 				iListBox->SetCurrentItemIndex( 0 );	
       
   204 				}
       
   205 			else
       
   206 				{
       
   207 				iListBox->SetCurrentItemIndex( newCount - 1 );	
       
   208 				}
       
   209         	}
       
   210         else if( newCount < oldCount )
       
   211         	{
       
   212         	// notify the listbox for item deletion 
       
   213 	    	TRAP_IGNORE( iListBox->HandleItemRemovalL() );
       
   214 			
       
   215         	// set focus at last selected item or index			
       
   216 			if( iSelectedIndex > newCount-1 )
       
   217 				{
       
   218 				iListBox->SetCurrentItemIndex( newCount - 1 );
       
   219 				}
       
   220 			else
       
   221 				{
       
   222 				TInt newIndex = SessionIds().Find( sessionId );
       
   223 				if( newIndex != KErrNotFound )
       
   224 					{
       
   225 					iListBox->SetCurrentItemIndex( newIndex );
       
   226 					}
       
   227 				else
       
   228 					{
       
   229 					iListBox->SetCurrentItemIndex( iSelectedIndex );				
       
   230 					}				
       
   231 				}
       
   232         	}
       
   233         }        
       
   234     DrawDeferred();
       
   235 	DEBUG( - CLocSUPLSessionContainer::UpdateScreenL );	
       
   236     }
       
   237 
       
   238 // ---------------------------------------------------------------------------
       
   239 // void CLocSUPLSessionContainer::HandleResourceChange
       
   240 //
       
   241 // ---------------------------------------------------------------------------	
       
   242 void CLocSUPLSessionContainer::HandleResourceChange(TInt aType)
       
   243 	{
       
   244 	DEBUG( + CLocSUPLSessionContainer::HandleResourceChange );	
       
   245 	// Pass the event to the base class
       
   246 	CCoeControl::HandleResourceChange(aType);
       
   247     switch( aType )
       
   248     	{
       
   249     	// Dynamic Layout switch
       
   250     	case KEikDynamicLayoutVariantSwitch:
       
   251     		{
       
   252     		SetRect( iView->ClientRect() );
       
   253 			break;
       
   254     		}
       
   255     	default:
       
   256     		{
       
   257     		break;
       
   258     		}
       
   259     	}
       
   260 	DEBUG( - CLocSUPLSessionContainer::HandleResourceChange );	
       
   261 	}
       
   262 
       
   263 // -----------------------------------------------------------------------------
       
   264 // CLocSUPLSessionContainer::GetHelpContext
       
   265 //
       
   266 // -----------------------------------------------------------------------------
       
   267 //
       
   268 void CLocSUPLSessionContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   269     {
       
   270 	DEBUG( + CLocSUPLSessionContainer::GetHelpContext );	
       
   271     aContext.iContext = iContextName;
       
   272     aContext.iMajor = TUid::Uid( KLOCSUPLSETTINGSUIUID3 );
       
   273 	DEBUG( - CLocSUPLSessionContainer::GetHelpContext );	
       
   274     }
       
   275     
       
   276 // ---------------------------------------------------------------------------
       
   277 // TInt CLocSUPLSessionContainer::CountComponentControls
       
   278 //
       
   279 // ---------------------------------------------------------------------------
       
   280 TInt CLocSUPLSessionContainer::CountComponentControls() const
       
   281 	{
       
   282 	return 1;
       
   283 	}
       
   284 
       
   285 // ---------------------------------------------------------------------------
       
   286 // CCoeControl* CLocSUPLSessionContainer::ComponentControl
       
   287 //
       
   288 // ---------------------------------------------------------------------------
       
   289 CCoeControl* CLocSUPLSessionContainer::ComponentControl( TInt /*aIndex*/ ) const
       
   290 	{
       
   291 	return iListBox;	
       
   292 	}
       
   293 
       
   294 // ---------------------------------------------------------------------------
       
   295 // void CLocSUPLSessionContainer::OfferKeyEventL
       
   296 //
       
   297 // ---------------------------------------------------------------------------	
       
   298 //
       
   299 TKeyResponse CLocSUPLSessionContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   300 										   					  TEventCode aType )
       
   301 	{
       
   302 	TKeyResponse keyresponse = EKeyWasNotConsumed;
       
   303 	
       
   304     // Now handle the Key Event based on the Key type
       
   305     switch ( aKeyEvent.iScanCode )
       
   306         {            
       
   307         case EStdKeyUpArrow:
       
   308         case EStdKeyDownArrow:
       
   309             {
       
   310             keyresponse = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   311             iView->ChangeMSKL();
       
   312             return keyresponse;         
       
   313             }
       
   314         case EStdKeyBackspace:
       
   315         case EStdKeyDelete:
       
   316             {
       
   317             if(aType == EEventKey )
       
   318                 {
       
   319                 keyresponse = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   320                 iView->HandleCommandL( ELocSuplSessionTerminate ); 
       
   321                 }
       
   322             return keyresponse;               
       
   323             }
       
   324         case EStdKeyHash:
       
   325             {
       
   326             TBool shiftKeyPressed = ( aKeyEvent.iModifiers & EModifierShift );
       
   327             keyresponse = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   328             if( aType == EEventKeyUp && ( EKeyWasConsumed == keyresponse || !shiftKeyPressed ) )
       
   329                 iView->ChangeMSKL();
       
   330             return keyresponse;    
       
   331             }
       
   332         default:
       
   333             {
       
   334             break;  
       
   335             }
       
   336         }
       
   337 
       
   338     // now it's iListBox's job to process the key event
       
   339     return iListBox->OfferKeyEventL( aKeyEvent, aType ); 
       
   340 	}
       
   341 	    
       
   342 // ---------------------------------------------------------------------------
       
   343 // void CLocSUPLSessionContainer::HandleListBoxEventL
       
   344 //
       
   345 // ---------------------------------------------------------------------------
       
   346 //
       
   347 void CLocSUPLSessionContainer::HandleListBoxEventL( CEikListBox*  /* aListBox */, 
       
   348 		 						   					 TListBoxEvent aEventType )
       
   349 	{
       
   350 	DEBUG( + CLocSUPLSessionContainer::HandleListBoxEventL );	
       
   351 	switch ( aEventType )
       
   352         {
       
   353         case EEventItemClicked:
       
   354             {
       
   355             // The item is just selected here. Change the MSK to reflect
       
   356             // the Correct MSK value
       
   357             iView->ChangeMSKL();
       
   358             break;    
       
   359             }
       
   360         // List box Item Selection
       
   361         case EEventEnterKeyPressed:
       
   362         case EEventItemSingleClicked:
       
   363             {
       
   364             if( SelectedCount() )
       
   365                 {
       
   366                 //display menu specific to editor
       
   367                 ShowContextMenuL();
       
   368                 }
       
   369             else
       
   370                 {
       
   371                 iView->HandleCommandL( ELocSuplSessionOpen );   
       
   372                 }
       
   373             break;	
       
   374             }
       
   375         default:
       
   376            break;
       
   377         }
       
   378 	DEBUG( - CLocSUPLSessionContainer::HandleListBoxEventL );	
       
   379 	}
       
   380 	         		 	
       
   381 // ---------------------------------------------------------------------------
       
   382 // void CLocSUPLSessionContainer::FocusChanged
       
   383 //
       
   384 // ---------------------------------------------------------------------------
       
   385 //
       
   386 void CLocSUPLSessionContainer::FocusChanged( TDrawNow aDrawNow )
       
   387 	{
       
   388 	CCoeControl::FocusChanged( aDrawNow );
       
   389 	// The focus event has to be explicitly handed over to all the compound
       
   390 	// controls since CCoeControl does not do that implicitly
       
   391 	if ( iListBox )
       
   392 		{
       
   393 		iListBox->SetFocus( IsFocused(), aDrawNow );				
       
   394 		}
       
   395 	}
       
   396 		
       
   397 // ---------------------------------------------------------------------------
       
   398 // CLocSUPLSessionContainer::SizeChanged
       
   399 // 
       
   400 // ---------------------------------------------------------------------------
       
   401 //
       
   402 void CLocSUPLSessionContainer::SizeChanged()
       
   403 	{
       
   404 	if ( iListBox )
       
   405 		{
       
   406 		iListBox->SetRect( Rect() );
       
   407 		}
       
   408 	}
       
   409 	
       
   410 // ---------------------------------------------------------------------------
       
   411 // void CLocSUPLSessionContainer::MakeTitleL
       
   412 // Sets the Title text
       
   413 //
       
   414 // @param aResourceText Resource to create title
       
   415 // ---------------------------------------------------------------------------
       
   416 //
       
   417 void CLocSUPLSessionContainer::MakeTitleL( TInt aResourceText )
       
   418 	{
       
   419 	DEBUG( + CLocSUPLSessionContainer::MakeTitleL );	
       
   420 	// Obtain the title from the Status Pane
       
   421 	CAknTitlePane* title = static_cast < CAknTitlePane* >( StatusPane()->
       
   422         ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   423        
       
   424     // Set the Title's buffer    
       
   425     HBufC* buf = StringLoader::LoadL( aResourceText );
       
   426     title->SetText( buf ); // Takes ownership of buf
       
   427 	DEBUG( - CLocSUPLSessionContainer::MakeTitleL );	
       
   428 	}
       
   429 
       
   430 // ---------------------------------------------------------------------------
       
   431 // void CLocSUPLSessionContainer::StatusPane
       
   432 // Returns the Appui's status pane
       
   433 //
       
   434 // @return CEikStatusPane* Statuspane pointer
       
   435 // ---------------------------------------------------------------------------
       
   436 //
       
   437 CEikStatusPane* CLocSUPLSessionContainer::StatusPane()
       
   438 	{
       
   439 	return iEikonEnv->AppUiFactory()->StatusPane();	
       
   440 	}
       
   441 
       
   442 // ---------------------------------------------------------------------------
       
   443 // void CLocSUPLSessionContainer::CreateListboxL
       
   444 // Creates the List box and the Listbox model. Associates the list box model 
       
   445 // with the list box
       
   446 //
       
   447 // @param aEngine                       Reference to the SUPL Settings
       
   448 //                                      engine 
       
   449 // ---------------------------------------------------------------------------	
       
   450 //
       
   451 void CLocSUPLSessionContainer::CreateListboxL( 
       
   452                                     CLocSUPLSettingsUiEngine&     aEngine )
       
   453 	{
       
   454 	DEBUG( + CLocSUPLSessionContainer::CreateListboxL );	
       
   455 	// Create the Listbox model
       
   456     iListBoxModel = CLocSUPLSessionLBModel::NewL( aEngine );
       
   457 	
       
   458 	// CAknSingleGraphicStyleListBox	"0\tTextLabel\t1\t2"
       
   459 	
       
   460     iListBox = new ( ELeave ) CAknSingleGraphicStyleListBox;
       
   461 	iListBox->ConstructL( 
       
   462 						this, 
       
   463 						#ifdef RD_SCALABLE_UI_V2
       
   464 						EAknListBoxStylusMarkableList
       
   465 						#else
       
   466 						EAknListBoxMarkableList
       
   467 						#endif //RD_SCALABLE_UI_V2
       
   468 						);
       
   469     // Set the container control.
       
   470 	iListBox->SetContainerWindowL( *this );
       
   471     // Add scrollbars to listbox
       
   472 	iListBox->CreateScrollBarFrameL( ETrue );
       
   473 	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
       
   474 														 CEikScrollBarFrame::EAuto );
       
   475     // Icon array, needed only if listbox style is single number with graphic.
       
   476     CAknIconArray* icons = new( ELeave ) CAknIconArray( KIconArrayGranularity );
       
   477     CleanupStack::PushL( icons );
       
   478 
       
   479     TFileName avkonIconFile = AknIconUtils::AvkonIconFileName();
       
   480 	
       
   481     TRAP_IGNORE( AddIconL(   *icons, 
       
   482                 avkonIconFile,
       
   483                 KAknsIIDQgnIndiMarkedAdd, 
       
   484                 EMbmAvkonQgn_indi_marked_add, 
       
   485                 EMbmAvkonQgn_indi_marked_add_mask ) );
       
   486  	
       
   487 	TFileName *iconFile = IconFileNameLC();
       
   488     
       
   489     TRAP_IGNORE( AddIconL(   *icons, 
       
   490                 *iconFile,
       
   491                 KAknsIIDQgnPropRadiobuttOff, 
       
   492                 EMbmLocsuplsettingsQgn_loc_server_disabled, 
       
   493                 EMbmLocsuplsettingsQgn_loc_server_disabled_mask ) );
       
   494     
       
   495     TRAP_IGNORE( AddIconL(   *icons, 
       
   496                 *iconFile,
       
   497                 KAknsIIDQgnPropRadiobuttOff, 
       
   498                 EMbmLocsuplsettingsQgn_loc_server_disabled, 
       
   499                 EMbmLocsuplsettingsQgn_loc_server_disabled_mask ) );
       
   500  	
       
   501  	CleanupStack::PopAndDestroy( iconFile );
       
   502 	
       
   503     iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
       
   504     CleanupStack::Pop( icons );        
       
   505     
       
   506     // Set the model & observer
       
   507     iListBox->SetListBoxObserver( this  );
       
   508 
       
   509     iListBox->Model()->SetItemTextArray( iListBoxModel );
       
   510     iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );									
       
   511     iListBox->ActivateL();   
       
   512 	DEBUG( - CLocSUPLSessionContainer::CreateListboxL );	
       
   513 	}
       
   514 
       
   515 // -----------------------------------------------------------------------------
       
   516 // CLocSUPLSessionContainer::AddIconL
       
   517 // -----------------------------------------------------------------------------
       
   518 void CLocSUPLSessionContainer::AddIconL( CAknIconArray&  aIcons,
       
   519                                            const TDesC&    aIconFileWithPath,
       
   520                                            TAknsItemID     aSkinID,
       
   521                                            TInt            aIconGraphicsIndex,
       
   522                                            TInt            aIconGraphicsMaskIndex )
       
   523     {
       
   524 	DEBUG( + CLocSUPLSessionContainer::AddIconL );	
       
   525     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   526   
       
   527     CFbsBitmap* bitmap = NULL;
       
   528     CFbsBitmap* bitmapMask = NULL;
       
   529     
       
   530     TRAPD( err, AknsUtils::CreateIconL( skin,
       
   531                             aSkinID,
       
   532                             bitmap,
       
   533                             bitmapMask,
       
   534                             aIconFileWithPath,
       
   535                             aIconGraphicsIndex,
       
   536                             aIconGraphicsMaskIndex ) );
       
   537 
       
   538     if(err != KErrNone)
       
   539         {
       
   540         TRAP( err, AknIconUtils::CreateIconL( bitmap,
       
   541                                 bitmapMask,
       
   542                                 aIconFileWithPath,
       
   543                                 aIconGraphicsIndex,
       
   544                                 aIconGraphicsMaskIndex ) );
       
   545         }
       
   546     User::LeaveIfError( err );
       
   547     
       
   548     CleanupStack::PushL( bitmap );
       
   549     CleanupStack::PushL( bitmapMask );
       
   550     
       
   551     CGulIcon* icon = CGulIcon::NewL( bitmap, bitmapMask );
       
   552     
       
   553     // Remove the Bitmap and the Bitmap Icon from the Clean up stack since 
       
   554     // the ownership is taken over by the icon
       
   555     CleanupStack::Pop( bitmapMask );
       
   556     CleanupStack::Pop( bitmap ); 
       
   557     
       
   558     CleanupStack::PushL( icon );
       
   559     aIcons.AppendL( icon );
       
   560     CleanupStack::Pop( icon ); // icon
       
   561 	DEBUG( - CLocSUPLSessionContainer::AddIconL );	
       
   562     }
       
   563 
       
   564 // -----------------------------------------------------------------------------
       
   565 // CLocSUPLSessionContainer::IconFileNameLC
       
   566 // -----------------------------------------------------------------------------
       
   567 TFileName* CLocSUPLSessionContainer::IconFileNameLC() const
       
   568     {
       
   569     TFileName* fileName = new(ELeave) TFileName;
       
   570     CleanupStack::PushL( fileName );
       
   571     
       
   572 	TFileName* tmpName = new(ELeave) TFileName;
       
   573     CleanupStack::PushL( tmpName );
       
   574 	
       
   575     tmpName->Append( KDC_BITMAP_DIR );
       
   576     tmpName->Append( KLocSuplSettingsIconFileName );
       
   577 
       
   578     CEikAppUi *appUi = ( CEikAppUi *)( CEikonEnv::Static()->AppUi());
       
   579     TFileName appDrive = appUi->Application()->AppFullName();
       
   580     
       
   581     TParse parse;
       
   582     User::LeaveIfError( parse.Set( appDrive, NULL, NULL ) );
       
   583     User::LeaveIfError( parse.Set( parse.Drive(), tmpName, NULL ) );
       
   584     
       
   585 	fileName->Copy(parse.FullName());
       
   586 
       
   587     CleanupStack::PopAndDestroy( tmpName );
       
   588 
       
   589     return fileName;
       
   590     }    
       
   591   
       
   592 // ----------------------------------------------------------------------------
       
   593 // CLocSUPLSessionContainer::ListBoxL()
       
   594 // ----------------------------------------------------------------------------
       
   595 //
       
   596 CEikListBox& CLocSUPLSessionContainer::ListBoxL()
       
   597     {
       
   598     User::LeaveIfNull( iListBox );
       
   599     return *iListBox;
       
   600     }
       
   601 
       
   602 // -----------------------------------------------------------------------------
       
   603 // TInt CLocSUPLSessionContainer::SelectedItemIndex
       
   604 // Returns the Selected element. The list box model defines the enumeration that
       
   605 // would determine the current element that has been selected
       
   606 //
       
   607 // @return TInt Index of the item selected
       
   608 // -----------------------------------------------------------------------------
       
   609 //
       
   610 TInt CLocSUPLSessionContainer::SelectedItemIndex()
       
   611     {
       
   612     return iListBox->CurrentItemIndex();
       
   613     }
       
   614     
       
   615 // ---------------------------------------------------------------------------
       
   616 // void CLocSUPLSessionContainer::FocusToSessionDetailL
       
   617 // Focus move to server detail setting item
       
   618 //
       
   619 // ---------------------------------------------------------------------------
       
   620 //
       
   621 void CLocSUPLSessionContainer::FocusToSessionDetailL( TInt aIndex )
       
   622 	{
       
   623 		iListBox->SetCurrentItemIndex( aIndex );
       
   624 	}
       
   625 				       
       
   626 // ----------------------------------------------------------------------------
       
   627 // CLocSUPLSessionContainer::CurrentSessionId()
       
   628 // ----------------------------------------------------------------------------
       
   629 //
       
   630 TInt64 CLocSUPLSessionContainer::CurrentSessionId()
       
   631 	{
       
   632 	if( SelectedItemIndex() != KErrNotFound && SelectedItemIndex() < SessionCount() )
       
   633 		return iListBoxModel->SessionIds()[ SelectedItemIndex() ];
       
   634 	else
       
   635 		return KErrNotFound;
       
   636 	}
       
   637 
       
   638 // ----------------------------------------------------------------------------
       
   639 // CLocSUPLSessionContainer::SelectedCount()
       
   640 // ----------------------------------------------------------------------------
       
   641 //
       
   642 TInt CLocSUPLSessionContainer::SelectedCount()
       
   643 	{
       
   644 	return iListBox->SelectionIndexes()->Count();
       
   645 	}
       
   646 
       
   647 // ----------------------------------------------------------------------------
       
   648 // CLocSUPLSessionContainer::SessionCount()
       
   649 // ----------------------------------------------------------------------------
       
   650 //
       
   651 TInt CLocSUPLSessionContainer::SessionCount()
       
   652 	{
       
   653 	return iListBox->Model()->NumberOfItems();
       
   654 	}
       
   655 
       
   656 // ---------------------------------------------------------------------------
       
   657 // CLocSUPLSessionContainer::SessionIds()
       
   658 // returns server id array
       
   659 //
       
   660 // ---------------------------------------------------------------------------
       
   661 //  
       
   662 RArray<TInt64>& CLocSUPLSessionContainer::SessionIds()
       
   663 	{
       
   664 	return iListBoxModel->SessionIds();
       
   665 	}
       
   666 
       
   667 // ---------------------------------------------------------------------------
       
   668 // CLocSUPLSessionContainer::SetIndex()
       
   669 // sets the current selected item
       
   670 //
       
   671 // ---------------------------------------------------------------------------
       
   672 //  
       
   673 void CLocSUPLSessionContainer::SetSelectedIndex()
       
   674 	{
       
   675 	iSelectedIndex = SelectedItemIndex();
       
   676 	}
       
   677 
       
   678 // ---------------------------------------------------------------------------
       
   679 // CLocSUPLSessionContainer::CurrentSessionName()
       
   680 // Get the currently focused session name
       
   681 //
       
   682 // ---------------------------------------------------------------------------
       
   683 //  
       
   684 TPtrC CLocSUPLSessionContainer::CurrentSessionName()
       
   685 	{
       
   686 	if( SelectedCount() == 1 )
       
   687 		return iListBoxModel->SessionName( iListBox->SelectionIndexes()->At(0) );
       
   688 	else
       
   689 		return iListBoxModel->SessionName( SelectedItemIndex() );
       
   690 	}
       
   691 
       
   692 // -----------------------------------------------------------------------------
       
   693 // CLocSUPLSessionContainer::ShowContextMenuL
       
   694 // Shows context specific options menu
       
   695 // -----------------------------------------------------------------------------
       
   696 //
       
   697 void CLocSUPLSessionContainer::ShowContextMenuL()
       
   698     {
       
   699 	DEBUG( + CLocSUPLSessionContainer::ShowContextMenuL );	
       
   700 	
       
   701 	// Switch to Context specific options menu,
       
   702 	// Show it and switch back to main options menu.
       
   703 	CEikMenuBar* menuBar = iView->MenuBar();
       
   704 	// TRAP displaying of menu bar.
       
   705 	// If it fails, the correct resource is set back before leave.
       
   706 	TRAPD( err, menuBar->TryDisplayContextMenuBarL() );
       
   707 	User::LeaveIfError( err );
       
   708 	
       
   709 	DEBUG( - CLocSUPLSessionContainer::ShowContextMenuL );	
       
   710     }
       
   711 
       
   712 // End of file