bluetoothengine/btui/Ecom/src/BTUIDeviceContainer.cpp
changeset 0 f63038272f30
child 10 b6f55cd40afd
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2007 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:  This is the implementation of device list container. It contains 
       
    15 *				 all necessary AVKON components and handles user inputs
       
    16 *				 for paired and blocked devices view.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include <btui.mbg>				// Compiled resource ids
       
    22 #include <BtuiViewResources.rsg> 
       
    23 #include <AknsUtils.h>          // For Extended skinning icons
       
    24 #include <gulicon.h>
       
    25 #include <AknUtils.h>			// For char filter
       
    26 #include <aknlists.h> 
       
    27 #include <avkon.mbg> 			// AVKON icons
       
    28 #include <csxhelp/bt.hlp.hrh>   // Help IDs
       
    29 
       
    30 #include "BTUIDeviceContainer.h"
       
    31 #include "BTUIListedDevicesView.h"
       
    32 #include "debug.h"               
       
    33 #include "btui.h" // Global declarations
       
    34 
       
    35 const TInt KBTNumberOfIcons = 13;    // Number of class of device icons
       
    36 	
       
    37 _LIT( DEV_TYPE_COMPUTER,"0\t");
       
    38 _LIT( DEV_TYPE_PHONE,"1\t");
       
    39 _LIT( DEV_TYPE_AUDIO,"2\t");
       
    40 _LIT( DEV_TYPE_DEFAULT,"3\t");	
       
    41 _LIT( DEV_TYPE_KEYBOARD,"4\t");
       
    42 _LIT( DEV_TYPE_MOUSE,"5\t");
       
    43 _LIT( DEV_TYPE_PRINTER,"6\t");
       
    44 _LIT( DEV_TYPE_CARKIT,"7\t");
       
    45 _LIT( DEV_TYPE_AUDIO_CONNECT,"8\t");
       
    46 _LIT( DEV_TYPE_COMPUTER_CONNECT,"9\t");
       
    47 _LIT( DEV_TYPE_KEYBOARD_CONNECT,"10\t");
       
    48 _LIT( DEV_TYPE_CARKIT_CONNECT,"11\t");
       
    49 _LIT( DEV_TYPE_MOUSE_CONNECT,"12\t");
       
    50 
       
    51 _LIT(DEV_STATUS_NORMAL, "\t" ); 		// blocked in blocked devices view, paired in pairred devices view
       
    52 _LIT(DEV_STATUS_AUTHORIZED, "\t13" ); 	// autorized in paired devices view
       
    53 
       
    54     
       
    55 
       
    56 // ================= MEMBER FUNCTIONS =======================
       
    57   
       
    58 // ---------------------------------------------------------
       
    59 // CBTUiDeviceContainer::ConstructL
       
    60 // ---------------------------------------------------------
       
    61 void CBTUiDeviceContainer::ConstructL(const TRect& aRect, 
       
    62   CBTUIListedDevicesView* aView, TBTDeviceGroup aGroup)
       
    63     {
       
    64 	TRACE_FUNC_ENTRY
       
    65 	
       
    66     CreateWindowL();
       
    67     
       
    68 	iView = aView;
       
    69     iGroup = aGroup;
       
    70     // Create new list for other paired bt-devices
       
    71     //
       
    72     iDeviceList = new (ELeave) CAknSingleGraphicStyleListBox;
       
    73     iDeviceList->SetContainerWindowL(*this);
       
    74     iDeviceList->ConstructL(this, EAknListBoxSelectionList);
       
    75     
       
    76 	iDeviceList->SetListBoxObserver( this );    
       
    77 
       
    78     // Set the empty text at basis of the list
       
    79     HBufC* devEmptyText = NULL ;
       
    80     if(iGroup ==EGroupPaired)
       
    81     	{
       
    82     	devEmptyText=iCoeEnv->AllocReadResourceLC( R_BT_NO_PAIRED_DEVICES);
       
    83     	}    	
       
    84     else
       
    85     	{    
       
    86     	devEmptyText=iCoeEnv->AllocReadResourceLC( R_BT_NO_BLOCKED_DEVICES);
       
    87     	}
       
    88     iDeviceList->View()->SetListEmptyTextL(*devEmptyText );
       
    89     CleanupStack::PopAndDestroy(devEmptyText);
       
    90 
       
    91     // Set up filenames for Btui and Avkon bitmaps
       
    92     TFileName bmpFilename;
       
    93     bmpFilename += KBitmapFileDrive;
       
    94     bmpFilename += KDC_APP_BITMAP_DIR;
       
    95     bmpFilename += KBtuiBmpFileName;
       
    96         
       
    97     // The avkon bitmap we will get from AknIconUtils::AvkonIconFileName()
       
    98     TFileName avkonbmpFilename = AknIconUtils::AvkonIconFileName();
       
    99     
       
   100     // Setup graphic items list for BT devices listbox
       
   101     CAknIconArray* iconList = new(ELeave) CAknIconArray(KBTNumberOfIcons);
       
   102     CleanupStack::PushL( iconList );
       
   103     
       
   104 
       
   105 	CreateAndAppendIconL( KAknsIIDQgnPropBtComputer, 
       
   106 						  avkonbmpFilename, 
       
   107 						  EMbmAvkonQgn_prop_bt_computer,
       
   108 						  EMbmAvkonQgn_prop_bt_computer_mask,
       
   109 						  iconList);
       
   110 
       
   111 	CreateAndAppendIconL( KAknsIIDQgnPropBtPhone,
       
   112 						  avkonbmpFilename, 
       
   113 						  EMbmAvkonQgn_prop_bt_phone,
       
   114 						  EMbmAvkonQgn_prop_bt_phone_mask,
       
   115 						  iconList);
       
   116 
       
   117 	CreateAndAppendIconL( KAknsIIDQgnPropBtAudio,
       
   118 						  avkonbmpFilename, 
       
   119 						  EMbmAvkonQgn_prop_bt_audio,
       
   120 						  EMbmAvkonQgn_prop_bt_audio_mask,
       
   121 						  iconList);
       
   122 
       
   123 	CreateAndAppendIconL( KAknsIIDQgnPropBtMisc,
       
   124 						  avkonbmpFilename, 
       
   125 						  EMbmAvkonQgn_prop_bt_misc,
       
   126 						  EMbmAvkonQgn_prop_bt_misc_mask,
       
   127 						  iconList);
       
   128 						  
       
   129 	CreateAndAppendIconL( KAknsIIDQgnPropBtKeyboard,
       
   130 						  avkonbmpFilename, 
       
   131 						  EMbmAvkonQgn_prop_bt_keyboard,
       
   132 						  EMbmAvkonQgn_prop_bt_keyboard_mask,
       
   133 						  iconList);					  
       
   134 
       
   135 	CreateAndAppendIconL( KAknsIIDQgnPropBtMouse,
       
   136 						  avkonbmpFilename, 
       
   137 						  EMbmAvkonQgn_prop_bt_mouse,
       
   138 						  EMbmAvkonQgn_prop_bt_mouse_mask,
       
   139 						  iconList);
       
   140 						  
       
   141 	CreateAndAppendIconL( KAknsIIDQgnPropBtPrinter,
       
   142 						  avkonbmpFilename, 
       
   143 						  EMbmAvkonQgn_prop_bt_printer,
       
   144 						  EMbmAvkonQgn_prop_bt_printer_mask,
       
   145 						  iconList);					  					  
       
   146 	
       
   147 	CreateAndAppendIconL( KAknsIIDQgnPropBtCarKit,
       
   148 						  avkonbmpFilename, 
       
   149 						  EMbmAvkonQgn_prop_bt_carkit,
       
   150 						  EMbmAvkonQgn_prop_bt_carkit_mask,
       
   151 						  iconList);
       
   152 						  
       
   153 	CreateAndAppendIconL( KAknsIIDQgnPropBtAudioConnect,
       
   154 						  bmpFilename, 
       
   155 						  EMbmBtuiQgn_prop_bt_audio_connect,
       
   156 						  EMbmBtuiQgn_prop_bt_audio_connect_mask,
       
   157 						  iconList);					  
       
   158 						  
       
   159 	CreateAndAppendIconL( KAknsIIDQgnPropBtComputerConnect,
       
   160 						  bmpFilename, 
       
   161 						  EMbmBtuiQgn_prop_bt_computer_connect,
       
   162 						  EMbmBtuiQgn_prop_bt_computer_connect_mask,
       
   163 						  iconList);
       
   164 						  
       
   165     CreateAndAppendIconL( KAknsIIDQgnPropBtKeyboardConnect,
       
   166 						  bmpFilename, 
       
   167 						  EMbmBtuiQgn_prop_bt_keyboard_connect,
       
   168 						  EMbmBtuiQgn_prop_bt_keyboard_connect_mask,
       
   169 						  iconList);						  		
       
   170 						  
       
   171 	CreateAndAppendIconL( KAknsIIDQgnPropBtCarKitConnect,
       
   172 						  bmpFilename, 
       
   173 						  EMbmBtuiQgn_prop_bt_car_kit_connect,
       
   174 						  EMbmBtuiQgn_prop_bt_car_kit_connect_mask,
       
   175 						  iconList);	
       
   176 	
       
   177 	CreateAndAppendIconL( KAknsIIDQgnPropBtMouseConnect,
       
   178                           bmpFilename, 
       
   179                           EMbmBtuiQgn_prop_bt_mouse_connect,
       
   180                           EMbmBtuiQgn_prop_bt_mouse_connect_mask,
       
   181                           iconList);
       
   182 	
       
   183 	CFbsBitmap* bitmap = NULL;
       
   184     CFbsBitmap* mask = NULL;
       
   185     AknsUtils::CreateColorIconLC(AknsUtils::SkinInstance(), 
       
   186                                  KAknsIIDQgnIndiBtTrustedAdd,
       
   187                                  KAknsIIDQsnIconColors,
       
   188                                  EAknsCIQsnIconColorsCG13,
       
   189                                  bitmap, mask,
       
   190                                  avkonbmpFilename,
       
   191                                  EMbmAvkonQgn_indi_bt_trusted_add,
       
   192                                  EMbmAvkonQgn_indi_bt_trusted_add_mask,
       
   193                                  KRgbBlack);
       
   194     CGulIcon* icon = CGulIcon::NewL(bitmap, mask);
       
   195         
       
   196     CleanupStack::Pop(mask);
       
   197     CleanupStack::Pop(bitmap); 
       
   198     
       
   199     CleanupStack::PushL(icon);    
       
   200 	iconList->AppendL( icon );
       
   201     CleanupStack::Pop(icon);
       
   202     
       
   203     	
       
   204     // Transfer iconlist ownership to the listbox
       
   205     iDeviceList->ItemDrawer()->ColumnData()->SetIconArray(iconList);
       
   206     CleanupStack::Pop(iconList);
       
   207 
       
   208     // Create scrollbars
       
   209     iDeviceList->CreateScrollBarFrameL(ETrue);
       
   210     iDeviceList->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   211     	CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);
       
   212 
       
   213     SetRect(aRect);
       
   214     ActivateL();
       
   215 
       
   216     TRACE_FUNC_EXIT
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------
       
   220 // CBTUiDeviceContainer::NewL
       
   221 // ---------------------------------------------------------
       
   222 CBTUiDeviceContainer* CBTUiDeviceContainer::NewL(const TRect& aRect, 
       
   223   CBTUIListedDevicesView* aView, TBTDeviceGroup aGroup, MObjectProvider* aParent)
       
   224     {
       
   225 	 CBTUiDeviceContainer* self = new (ELeave) CBTUiDeviceContainer();
       
   226 	 self->SetMopParent(aParent);
       
   227 	 CleanupStack::PushL(self);
       
   228 	 self->ConstructL(aRect, aView, aGroup);
       
   229 	 CleanupStack::Pop(self);
       
   230 	 return self;
       
   231     }
       
   232 // ---------------------------------------------------------
       
   233 // destructor
       
   234 // ---------------------------------------------------------
       
   235 
       
   236 CBTUiDeviceContainer::~CBTUiDeviceContainer()
       
   237     {
       
   238 	TRACE_FUNC_ENTRY
       
   239     delete iDeviceList;
       
   240 	TRACE_FUNC_EXIT
       
   241     }
       
   242 
       
   243 // ---------------------------------------------------------
       
   244 // CBTUiDeviceContainer::RefreshDeviceListL
       
   245 // This function will refresh only the changed parts of the
       
   246 // screen, if any.
       
   247 // ---------------------------------------------------------   
       
   248 void CBTUiDeviceContainer::RefreshDeviceListL(const RDeviceArray* aDeviceArray,TInt selectedItem)
       
   249     {
       
   250 	TRACE_FUNC_ENTRY
       
   251 	
       
   252     MDesCArray* itemTextArray = iDeviceList->Model()->ItemTextArray();
       
   253     CDesCArray* itemArray = (CDesCArray*) itemTextArray;
       
   254     TBool removal=EFalse;
       
   255     TBool addition=EFalse;
       
   256 	TInt previouslySelected=CurrentItemIndex();
       
   257     TBTDeviceName listItem;
       
   258     TInt deviceCount = aDeviceArray->Count();
       
   259     TInt i = 0;
       
   260     for( ; i < deviceCount; i++)
       
   261         {
       
   262         TBTDevice device = *(*aDeviceArray)[i];
       
   263         CreateListItemL(device, listItem);
       
   264         if(itemArray->Count()<=i)
       
   265         	{
       
   266         	itemArray->AppendL(listItem);
       
   267         	addition=ETrue;
       
   268         	}
       
   269         else
       
   270         	if(listItem != (*itemArray)[i] )
       
   271 				{
       
   272 				itemArray->Delete(i);
       
   273 				itemArray->InsertL(i,listItem);
       
   274 				
       
   275 				removal=ETrue;
       
   276 				addition=ETrue;
       
   277 				}
       
   278         
       
   279         }
       
   280 	if(itemArray->Count()-i>=0)
       
   281 		{
       
   282 		itemArray->Delete(i,itemArray->Count()-i);        
       
   283 		removal=ETrue;
       
   284 		}
       
   285 		
       
   286         
       
   287 	if(removal)        
       
   288 		iDeviceList->HandleItemRemovalL();
       
   289 	if(addition)
       
   290     	iDeviceList->HandleItemAdditionL();
       
   291 
       
   292 	if(deviceCount >0 )
       
   293 		iDeviceList->SetCurrentItemIndex( Max(selectedItem,0 )) ;
       
   294 	
       
   295 	if(addition | removal | previouslySelected!=selectedItem)
       
   296     	iDeviceList->DrawDeferred();
       
   297 	TRACE_FUNC_EXIT
       
   298     } 
       
   299 
       
   300 // ---------------------------------------------------------
       
   301 // CBTUiDeviceContainer::CountItems
       
   302 // ---------------------------------------------------------    
       
   303 TInt CBTUiDeviceContainer::CountItems() 
       
   304 	{   
       
   305 	return iDeviceList->Model()->ItemTextArray()->MdcaCount();    
       
   306 	}
       
   307 
       
   308 // ---------------------------------------------------------
       
   309 // CBTUiDeviceContainer::CreateListItemL
       
   310 // ---------------------------------------------------------
       
   311 void CBTUiDeviceContainer::CreateListItemL(const TBTDevice& aDevice, TBTDeviceName& aListItem)
       
   312     {
       
   313 	TRACE_FUNC_ENTRY
       
   314     aListItem.Zero(); // may not needed
       
   315     
       
   316     TInt iconIndex = (TInt)(aDevice.iType);
       
   317     
       
   318     switch( iconIndex)
       
   319     	{
       
   320     	case EDeviceComputer:
       
   321     		if(( aDevice.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected)
       
   322     			{
       
   323     			aListItem.Append(DEV_TYPE_COMPUTER_CONNECT);   	
       
   324     	    	}
       
   325 			else
       
   326 				{
       
   327 				aListItem.Append(DEV_TYPE_COMPUTER); 
       
   328 				}
       
   329 			break;
       
   330     	
       
   331     	case EDevicePhone:   	
       
   332     		aListItem.Append(DEV_TYPE_PHONE); 
       
   333     		break;
       
   334     		
       
   335     	case EDeviceAudio: 
       
   336     		if(( aDevice.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected)
       
   337     			{
       
   338     			aListItem.Append(DEV_TYPE_AUDIO_CONNECT);   	
       
   339     	    	}
       
   340 			else
       
   341 				{
       
   342     			aListItem.Append(DEV_TYPE_AUDIO);
       
   343 				}
       
   344 			break ;
       
   345     	case EDeviceCarkit: 	  
       
   346     	  	if(( aDevice.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected)
       
   347     			{
       
   348     			aListItem.Append(DEV_TYPE_CARKIT_CONNECT);   	
       
   349     	    	}
       
   350 			else
       
   351 				{
       
   352     			aListItem.Append(DEV_TYPE_CARKIT);
       
   353 				}
       
   354 			break ;
       
   355 				
       
   356 		case EDevicePrinter:
       
   357 			aListItem.Append(DEV_TYPE_PRINTER);
       
   358 			break;
       
   359 			
       
   360 		case EDeviceKeyboard:
       
   361 		
       
   362 			if(( aDevice.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected)
       
   363     			{
       
   364     			aListItem.Append(DEV_TYPE_KEYBOARD_CONNECT);   	
       
   365     	    	}
       
   366 			else
       
   367 				{
       
   368     			aListItem.Append(DEV_TYPE_KEYBOARD);
       
   369 				}
       
   370 			break ;
       
   371 				
       
   372 		case EDeviceMice:
       
   373 		    
       
   374 		    if(( aDevice.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected)
       
   375                 {
       
   376                 aListItem.Append(DEV_TYPE_MOUSE_CONNECT);    
       
   377                 }
       
   378             else
       
   379                 {
       
   380                 aListItem.Append(DEV_TYPE_MOUSE);
       
   381                 }
       
   382 			break;			
       
   383 			
       
   384 		case EDeviceDefault:	
       
   385     		aListItem.Append(DEV_TYPE_DEFAULT); 
       
   386     		break;
       
   387     			
       
   388 		default:
       
   389 			aListItem.Append('\t');
       
   390 			break;
       
   391     	}
       
   392     	    
       
   393     aListItem.Append(aDevice.iName);
       
   394 
       
   395     if((aDevice.iStatus & EStatusTrusted) == EStatusTrusted && iGroup ==EGroupPaired )                            
       
   396         {   	
       
   397     	aListItem.Append(DEV_STATUS_AUTHORIZED);    
       
   398         }    	
       
   399     else 
       
   400     	{	
       
   401   		aListItem.Append( DEV_STATUS_NORMAL );
       
   402     	}
       
   403 	TRACE_FUNC_EXIT    	
       
   404     }
       
   405 
       
   406 
       
   407 // ---------------------------------------------------------
       
   408 // From CCoeControl
       
   409 // CBTUiDeviceContainer::OfferKeyEventL
       
   410 // ---------------------------------------------------------
       
   411 TKeyResponse CBTUiDeviceContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,
       
   412                                                                TEventCode aType)
       
   413     {
       
   414 	TRACE_FUNC_ENTRY    
       
   415     // Inform model where we are now
       
   416     TInt bItemIndex = CurrentItemIndex();
       
   417 
       
   418     // Shortcut for deleting a device
       
   419     if ((aKeyEvent.iCode == EKeyBackspace) && (bItemIndex >= 0))
       
   420         {
       
   421         iView->HandleCommandL( EBTUICmdDelete );
       
   422         return EKeyWasConsumed;
       
   423         }
       
   424 
       
   425     // Show popup commands window if selection or enter key is pressed.
       
   426 	// It should not go to here, unless | EAknEnableMSK is not set
       
   427     if ((aKeyEvent.iCode == EKeyDevice3) || (aKeyEvent.iCode == EKeyEnter))
       
   428         {
       
   429         iView->ProcessCommandL(EAknSoftkeyContextOptions);        
       
   430         return EKeyWasConsumed;
       
   431         }
       
   432 
       
   433     if ((aKeyEvent.iCode != EKeyLeftArrow) && 
       
   434         (aKeyEvent.iCode != EKeyRightArrow))
       
   435         {
       
   436 		TRACE_FUNC_EXIT        
       
   437         return iDeviceList->OfferKeyEventL(aKeyEvent, aType);
       
   438         }
       
   439     else
       
   440         {
       
   441         // BTRegistry operations are not done in atomic way
       
   442         // so we cannot allow them to be interrupted
       
   443         if(iView->DeviceChangeInProgress())
       
   444         	return EKeyWasConsumed;
       
   445         
       
   446 		TRACE_FUNC_EXIT        
       
   447         return EKeyWasNotConsumed;
       
   448         }
       
   449     }
       
   450 
       
   451 // ----------------------------------------------------
       
   452 // CBTUiDeviceContainer::CreateAndAppendIconL
       
   453 // ----------------------------------------------------
       
   454 void CBTUiDeviceContainer::CreateAndAppendIconL( 
       
   455   const TAknsItemID& aID,
       
   456   const TDesC& aFileName,
       
   457   const TInt aBitmapId,
       
   458   const TInt aMaskId,
       
   459   CAknIconArray* aIconList)
       
   460     {    
       
   461 	TRACE_FUNC_ENTRY    
       
   462 	
       
   463     CGulIcon* icon = AknsUtils::CreateGulIconL(AknsUtils::SkinInstance(),
       
   464      aID, aFileName, aBitmapId, aMaskId);
       
   465     
       
   466     CleanupStack::PushL(icon);    
       
   467 	aIconList->AppendL(icon);
       
   468     CleanupStack::Pop(icon);
       
   469 	}
       
   470 
       
   471 // ---------------------------------------------------------
       
   472 // From CCoeControl
       
   473 // CBTUiDeviceContainer::GetHelpContext
       
   474 // ---------------------------------------------------------
       
   475 void CBTUiDeviceContainer::GetHelpContext(TCoeHelpContext& aContext) const
       
   476     {
       
   477 	TRACE_FUNC_ENTRY
       
   478 #ifdef __SERIES60_HELP
       
   479 
       
   480     aContext.iMajor = KBtuiUid3;
       
   481     if( iGroup ==EGroupPaired)
       
   482     	aContext.iContext = KBT_HLP_PAIRED;
       
   483     else
       
   484     	aContext.iContext = KBT_HLP_BLOCKED ;
       
   485 #else    
       
   486 #endif
       
   487     }
       
   488 
       
   489 // ---------------------------------------------------------
       
   490 // From CCoeControl
       
   491 // CBTUiDeviceContainer::SizeChanged
       
   492 // Called by framework when the view size is changed
       
   493 // ---------------------------------------------------------
       
   494 void CBTUiDeviceContainer::SizeChanged()
       
   495     {
       
   496 	TRACE_FUNC_ENTRY    
       
   497     iDeviceList->SetRect(Rect());  // Mandatory, otherwise not drawn
       
   498     }
       
   499 
       
   500 // ---------------------------------------------------------
       
   501 // From CCoeControl
       
   502 // CBTUiDeviceContainer::CountComponentControls
       
   503 // ---------------------------------------------------------
       
   504 TInt CBTUiDeviceContainer::CountComponentControls() const
       
   505     {
       
   506 	TRACE_FUNC_ENTRY    
       
   507     // return number of controls inside this container
       
   508     return 1;
       
   509     }
       
   510 
       
   511 // ---------------------------------------------------------
       
   512 // From CCoeControl
       
   513 // CBTUiDeviceContainer::ComponentControl
       
   514 // ---------------------------------------------------------
       
   515 CCoeControl* CBTUiDeviceContainer::ComponentControl(TInt aIndex) const
       
   516     {
       
   517 	TRACE_FUNC_ENTRY    
       
   518 	if(aIndex == 0)
       
   519 		{
       
   520 		return iDeviceList ;
       
   521 		}    	
       
   522 	else
       
   523 		{
       
   524 		return NULL;	
       
   525 		}		
       
   526     }
       
   527 
       
   528 // ----------------------------------------------------
       
   529 // CBTUiDeviceContainer::CurrentItemIndex
       
   530 // ----------------------------------------------------
       
   531 TInt CBTUiDeviceContainer::CurrentItemIndex()
       
   532     {
       
   533 	TRACE_FUNC_ENTRY    
       
   534 	
       
   535     return iDeviceList->CurrentItemIndex();
       
   536     }
       
   537 
       
   538 // ---------------------------------------------------------
       
   539 // From CCoeControl
       
   540 // CBTUiDeviceContainer::Draw
       
   541 // ---------------------------------------------------------
       
   542 void CBTUiDeviceContainer::Draw( const TRect& /* aRect */ ) const
       
   543     {
       
   544     }
       
   545 
       
   546 // ---------------------------------------------------------
       
   547 // From MCoeControlObserver
       
   548 // CBTUiDeviceContainer::HandleControlEventL
       
   549 // ---------------------------------------------------------
       
   550 void CBTUiDeviceContainer::HandleControlEventL( CCoeControl* /* aControl */, TCoeEvent /* aEventType */ )
       
   551     {
       
   552 	TRACE_FUNC_ENTRY    
       
   553     }
       
   554 
       
   555 // ---------------------------------------------------------
       
   556 // From CCoeControl
       
   557 // CBTUiDeviceContainer::HandleResourceChange
       
   558 // ---------------------------------------------------------
       
   559 void CBTUiDeviceContainer::HandleResourceChange( TInt aType )
       
   560     {
       
   561 	TRACE_FUNC_ENTRY    
       
   562     CCoeControl::HandleResourceChange(aType);
       
   563     TRAP_IGNORE(HandleResourceChangeL(aType));
       
   564     TRACE_FUNC_EXIT
       
   565     }
       
   566 
       
   567 // ---------------------------------------------------------
       
   568 // Internal Leave function
       
   569 // CBTUiDeviceContainer::HandleResourceChangeL
       
   570 // ---------------------------------------------------------
       
   571 void CBTUiDeviceContainer::HandleResourceChangeL( TInt aType )
       
   572     {
       
   573 	TRACE_FUNC_ENTRY    
       
   574 
       
   575     //Handle change in layout orientation
       
   576     if (aType == KEikDynamicLayoutVariantSwitch || aType == KAknsMessageSkinChange )
       
   577         {
       
   578         TRect mainPaneRect;
       
   579         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
       
   580         
       
   581         // Because the trailing icons are not changed properly after theme is changed.
       
   582         // we refresh those icons in the iconlist from iDeviceList manually.
       
   583         
       
   584         // Get iconlist from listbox
       
   585         CAknIconArray* iconList = static_cast<CAknIconArray*>(iDeviceList->ItemDrawer()->ColumnData()->IconArray());
       
   586         
       
   587         CleanupStack::PushL( iconList );
       
   588         // remove the last two icons which will not be updated properly by theme changing.
       
   589 		iconList->Delete(KBTNumberOfIcons-1);
       
   590 	        
       
   591 	    // The avkon bitmap we will get from AknIconUtils::AvkonIconFileName()
       
   592 	    TFileName avkonbmpFilename = AknIconUtils::AvkonIconFileName();
       
   593 	    
       
   594 	  
       
   595 	    
       
   596 		CFbsBitmap* bitmap = NULL;
       
   597 	    CFbsBitmap* mask = NULL;
       
   598 	    AknsUtils::CreateColorIconLC(AknsUtils::SkinInstance(), 
       
   599 	                                 KAknsIIDQgnIndiBtTrustedAdd,
       
   600 	                                 KAknsIIDQsnIconColors,
       
   601 	                                 EAknsCIQsnIconColorsCG13,
       
   602 	                                 bitmap, mask,
       
   603 	                                 avkonbmpFilename,
       
   604 	                                 EMbmAvkonQgn_indi_bt_trusted_add,
       
   605 	                                 EMbmAvkonQgn_indi_bt_trusted_add_mask,
       
   606 	                                 KRgbBlack);
       
   607 	    
       
   608 	    
       
   609 	    CGulIcon* icon = CGulIcon::NewL(bitmap, mask);
       
   610 	     
       
   611 	    CleanupStack::Pop(2); // bitmap, mask;
       
   612 	    
       
   613 	    CleanupStack::PushL(icon);    
       
   614 		
       
   615 		iconList->AppendL( icon );
       
   616 	    CleanupStack::Pop(icon);
       
   617 	    
       
   618 	    	
       
   619 	    // Transfer iconlist ownership back to the listbox
       
   620 	    iDeviceList->ItemDrawer()->ColumnData()->SetIconArray(iconList);
       
   621 	    CleanupStack::Pop(iconList);
       
   622 		
       
   623         SetRect(mainPaneRect);
       
   624 		DrawDeferred();
       
   625 		}
       
   626 	TRACE_FUNC_EXIT
       
   627     }
       
   628 
       
   629 // ---------------------------------------------------------
       
   630 // From CCoeControl
       
   631 // CBTUiDeviceContainer::FocusChanged
       
   632 // ---------------------------------------------------------
       
   633 void CBTUiDeviceContainer::FocusChanged(TDrawNow /*aDrawNow*/)
       
   634     {
       
   635 	TRACE_FUNC_ENTRY    
       
   636 	iDeviceList->SetFocus(IsFocused());
       
   637 	TRACE_FUNC_EXIT        
       
   638     }
       
   639 // ---------------------------------------------------------
       
   640 // From CCoeControl
       
   641 // CBTUiDeviceContainer::HandleListBoxEventL
       
   642 //
       
   643 // Handle touch screen singleclick as MSK devent to paired view or 
       
   644 // as delete key event to blocked devices view.
       
   645 // ---------------------------------------------------------
       
   646 //
       
   647 void CBTUiDeviceContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
       
   648     {
       
   649     TRACE_FUNC_ENTRY
       
   650 	// this is no longer called, unless MSK is disabled.
       
   651 	// if msk is not disabled, then  
       
   652 	// BTMainView::HandleCommand(EBTUICmdMSK) is called instead
       
   653     if( aEventType == EEventEnterKeyPressed 
       
   654     || aEventType == EEventItemSingleClicked) // Selection key pressed, or item clicked
       
   655         {        
       
   656     	// msk open context options in paired devices view.
       
   657     	// it will unblock the selected blocked device in blocked devices view.
       
   658     	if(iGroup==EGroupPaired) 
       
   659     		{
       
   660     		iView->ProcessCommandL( EAknSoftkeyContextOptions);
       
   661     		}				
       
   662 		else
       
   663 			{
       
   664 			iView->ProcessCommandL( EBTUICmdUnblock);				
       
   665 			}
       
   666 			 
       
   667         }
       
   668 	TRACE_FUNC_EXIT
       
   669     }