bluetoothengine/btnotif/src/BTNInqUI.cpp
branchRCL_3
changeset 56 9386f31cc85b
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
       
     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:  Declares Bluetooth device inquiry user interface class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <avkon.hrh>            // AVKON components
       
    21 #include <AknIconArray.h>
       
    22 #include <aknlists.h>
       
    23 #include <aknPopup.h>
       
    24 #include <avkon.mbg>
       
    25 #include <wlaninternalpskeys.h> // For WLAN state checking
       
    26 #include <ctsydomainpskeys.h>
       
    27 #include <AknNotiferAppServerApplication.h> 
       
    28 #include <barsread.h>           // Resource reader
       
    29 #include <BTNotif.rsg>          // Own resources
       
    30 #include <bt_subscribe.h>
       
    31 #include <btnotif.mbg>
       
    32 #include <wlanplugin.mbg>       // Borrow WLan signal strenth bar to show RSSI  
       
    33 #include <devui_const.h>
       
    34 #include <btengutil.h>
       
    35 #include <bluetoothuiutil.h>
       
    36 #include "btninqui.h"           // Own class definition
       
    37 #include "btNotifDebug.h"       // Debugging macros
       
    38 #include "btnotifnameutils.h"
       
    39 
       
    40 
       
    41 const TInt KBTAllPurposeBufferLength = 266;
       
    42 const TInt KBTNotifNonPairedUsedDevicesMaxNumber= 5;
       
    43 // RSSI value range: -127dB ~ +20dB
       
    44 const TInt KRssiRangeOffset = 127 + 1;  // Offset for getting a non-zero positive value
       
    45 const TInt KMinimumStrength = 1;
       
    46 const TInt KMediumStrength = 53;
       
    47 const TInt KHighStrength = 82;
       
    48 const TUint32 ExcludePairedDeviceMask = 0x800000;
       
    49 const TUint32 ResetExcludePairedDeviceMask = 0xFF7FFFFF;
       
    50 _LIT(KBtnotifBmpFileName,"btnotif.mbm");
       
    51 _LIT(KWLanBmpFileName,"wlanplugin.mif");
       
    52 
       
    53 // ================= MEMBER FUNCTIONS =======================
       
    54 
       
    55 // ----------------------------------------------------------
       
    56 // CBTInqUI::CBTInqUI
       
    57 // C++ default constructor can NOT contain any code, that
       
    58 // might leave.
       
    59 // ----------------------------------------------------------
       
    60 //
       
    61 CBTInqUI::CBTInqUI( MBTNDeviceSearchObserver* aObserver, 
       
    62         CBTNotifUIUtil* aUtil, 
       
    63         const TBTDeviceClass& aDesiredDevClass): 
       
    64         iUiUtil (aUtil),
       
    65         iEikonEnvRef( iUiUtil->LocalEikonEnv() ),
       
    66         iDevicesFound (EFalse),
       
    67         iBroughtForwards (EFalse),
       
    68         iDesiredDeviceClass (aDesiredDevClass),
       
    69         iSystemCancel (EFalse), 
       
    70         iPageForName ( EFalse ),
       
    71         iCurrentlyResolvingUnnamedDeviceIndex (0),
       
    72         iDevSearchObserver (aObserver)
       
    73     {
       
    74 	iBTRegistryQueryState=ENoQuery;
       
    75 	}
       
    76 
       
    77 // ----------------------------------------------------------
       
    78 // CBTInqUI::ConstructL
       
    79 // Symbian 2nd phase constructor can leave.
       
    80 // Creates first device list (not shown yet) and initializes 
       
    81 // couple of member variables with default values.
       
    82 // ----------------------------------------------------------
       
    83 //
       
    84 void CBTInqUI::ConstructL()
       
    85     {
       
    86     FLOG(_L("[BTNOTIF]\t CBTInqUI::ConstructL()"));
       
    87     
       
    88     // Read default device names to an array
       
    89     iDefaultDeviceNamesArray = iEikonEnvRef.ReadDesCArrayResourceL( R_BT_DEFAULT_DEVICE_NAMES );
       
    90 
       
    91     // create the timer
       
    92     iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityIdle);
       
    93     
       
    94     // Create device array
       
    95     //
       
    96     iDeviceListRows = new(ELeave) CDesCArrayFlat(1);
       
    97     
       
    98     iPairedDevicesArray = new (ELeave) CBTDeviceArray(1);
       
    99     iLastUsedDevicesArray = new(ELeave) CBTDeviceArray(1);
       
   100     iLastSeenDevicesArray = new(ELeave) CBTDeviceArray(1);
       
   101 	iAdjustedUsedDeviceArray = new(ELeave) CBTDeviceArray(1);	
       
   102 	
       
   103 	iDevMan=CBTEngDevMan::NewL(this);
       
   104 	
       
   105 	iExcludePairedDevices = iDesiredDeviceClass.DeviceClass() & ExcludePairedDeviceMask ? 
       
   106                             ETrue : EFalse;	
       
   107     if ( iExcludePairedDevices )
       
   108         {         
       
   109         FLOG (_L("[BTNOTIF]\t CBTInqUI::ConstrucL Excluding paired devices"));
       
   110         iDesiredDeviceClass = iDesiredDeviceClass.DeviceClass() & ResetExcludePairedDeviceMask;
       
   111         }
       
   112     // Retrieve paired devices to a local array
       
   113     RetrievePairedDevices();
       
   114 
       
   115     FLOG(_L("[BTNOTIF]\t CBTInqUI::ConstructL() completed"));
       
   116     }
       
   117 
       
   118 // ----------------------------------------------------------
       
   119 // CBTInqUI::RetrieveUsedDevices- Substitute
       
   120 // ----------------------------------------------------------
       
   121 //
       
   122 void CBTInqUI::RetrieveUsedDevices()
       
   123 	{
       
   124 	FLOG(_L("[BTNOTIF]\t CBTInqUI::RetrieveUsedDevicesL()"));	
       
   125 
       
   126 	TBTRegistrySearch searchPattern;
       
   127 	searchPattern.FindAll();
       
   128 	
       
   129     //Ignore this error. Continue device search.
       
   130 	TInt err=iDevMan->GetDevices( searchPattern, iLastUsedDevicesArray );	
       
   131 	if(err)
       
   132 	    {
       
   133 	    TRAP_IGNORE(AdjustDeviceArrayL(iAdjustedUsedDeviceArray));
       
   134 	    DoDeviceFrontListSelection();
       
   135 	    FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI: get useddevice err %d"), err));  
       
   136 	    }
       
   137 	else
       
   138 	    {
       
   139 	    iBTRegistryQueryState=EQueryUsed;
       
   140 	    }
       
   141 	FLOG(_L("[BTNOTIF]\t CBTInqUI::RetrieveUsedDevicesL() returned"));
       
   142 	}
       
   143 	
       
   144 //---------------------------------------------------------------
       
   145 // CBTInqUI::RetrievePairedDevices
       
   146 //---------------------------------------------------------------
       
   147 void CBTInqUI::RetrievePairedDevices()
       
   148     {
       
   149 	FLOG(_L("[BTNOTIF]\t CBTInqUI::RetrievePairedDevicesL()"));
       
   150 
       
   151 	TBTRegistrySearch searchPattern;
       
   152     searchPattern.FindBonded();
       
   153 
       
   154 	TInt err= iDevMan->GetDevices( searchPattern, iPairedDevicesArray );	
       
   155 	FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI: get paireddevice err %d"), err));  
       
   156 	if(err)
       
   157 	    {
       
   158         //Next: try to get used devices
       
   159 	    RetrieveUsedDevices();
       
   160 	    }
       
   161 	else
       
   162 	    {
       
   163 	    iBTRegistryQueryState=EQueryPaired;	
       
   164 	    }
       
   165 	FLOG(_L("[BTNOTIF]\t CBTInqUI::RetrievePairedDevicesL() returned"));
       
   166     }
       
   167     
       
   168 // ----------------------------------------------------------
       
   169 // CBTInqUI::HandleGetDevicesComplete
       
   170 // ----------------------------------------------------------
       
   171 //
       
   172 void CBTInqUI::HandleGetDevicesComplete(TInt aErr, CBTDeviceArray* /*aDeviceArray*/)
       
   173 	{
       
   174 	FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleGetDevicesComplete() err: %d"), aErr));	
       
   175 	(void) aErr;
       
   176 	switch(iBTRegistryQueryState)
       
   177 		{
       
   178 		case EQueryPaired:
       
   179 		    // If a device is paired in Just Works model but without user awareness,
       
   180 		    // This device won't be shown in UI paired view, so we have to 
       
   181 		    // remove it from this array so that it will be shown to user
       
   182 		    // in the last used device list.
       
   183 		    for (int i = iPairedDevicesArray->Count() - 1; i >= 0; --i )
       
   184 		        {
       
   185 		        if ( !IsUserAwarePaired( iPairedDevicesArray->At( i )->AsNamelessDevice() ) )
       
   186 		            {
       
   187 		            delete iPairedDevicesArray->At( i );
       
   188 		            iPairedDevicesArray->Delete( i );
       
   189 		            }
       
   190 		        }
       
   191 			RetrieveUsedDevices();
       
   192 			break;
       
   193 		case EQueryUsed:
       
   194 			// fill in the list of last seen devices, so it can be shown
       
   195 			TRAP_IGNORE(AdjustDeviceArrayL(iAdjustedUsedDeviceArray));
       
   196 			DoDeviceFrontListSelection();
       
   197 			break;
       
   198 		default:
       
   199 			break;
       
   200 		}
       
   201 	
       
   202 	FLOG(_L("[BTNOTIF]\t CBTInqUI::HandleGetDevicesComplete() Complete"));		
       
   203 	}
       
   204 
       
   205 // ----------------------------------------------------------
       
   206 // Destructor
       
   207 // ----------------------------------------------------------
       
   208 //
       
   209 CBTInqUI::~CBTInqUI()
       
   210     {
       
   211     FLOG(_L("[BTNOTIF]\t CBTInqUI::~CBTInqUI()"));
       
   212 
       
   213     if( iBroughtForwards )
       
   214         {
       
   215         iEikonEnvRef.BringForwards(EFalse);
       
   216         iBroughtForwards = EFalse;
       
   217         }
       
   218 
       
   219     if( iPairedDevicesArray ) 
       
   220         {
       
   221         iPairedDevicesArray->ResetAndDestroy();	            
       
   222         delete iPairedDevicesArray; 
       
   223         }
       
   224     if( iLastUsedDevicesArray ) 
       
   225         {  
       
   226         iLastUsedDevicesArray->ResetAndDestroy();	    
       
   227         delete iLastUsedDevicesArray; 
       
   228         }       
       
   229     if( iLastSeenDevicesArray ) 
       
   230         {  
       
   231         iLastSeenDevicesArray->ResetAndDestroy();
       
   232         delete iLastSeenDevicesArray; 
       
   233         }
       
   234 
       
   235     iLastSeenDevicesNameComplete.Close();
       
   236 
       
   237     if( iAdjustedUsedDeviceArray )
       
   238         {
       
   239         iAdjustedUsedDeviceArray->ResetAndDestroy();
       
   240         delete iAdjustedUsedDeviceArray; 
       
   241         }
       
   242     if( iDefaultDeviceNamesArray )
       
   243         {
       
   244         iDefaultDeviceNamesArray->Reset();
       
   245         delete iDefaultDeviceNamesArray;
       
   246         }
       
   247     
       
   248 	delete iDevMan;    
       
   249     delete iDeviceListBox;
       
   250     delete iDeviceListRows;
       
   251 	delete iPeriodicTimer;	
       
   252 	    
       
   253     FLOG(_L("[BTNOTIF]\t CBTInqUI::~CBTInqUI() completed"));
       
   254     }
       
   255 
       
   256 // ----------------------------------------------------------
       
   257 // CBTInqUI::Cancel
       
   258 // ----------------------------------------------------------
       
   259 //
       
   260 void CBTInqUI::Cancel()
       
   261     {
       
   262     FLOG(_L("[BTNOTIF]\t CBTInqUI::Cancel()"));  
       
   263     
       
   264     iSystemCancel = ETrue;
       
   265     if(iDevMan)
       
   266  	   {
       
   267  	   iDevMan->Cancel();  	
       
   268   	   }
       
   269 
       
   270     if( iSearchFilterPopupList )
       
   271         {
       
   272         iSearchFilterPopupList->CancelPopup();
       
   273         }
       
   274 
       
   275     if(iPeriodicTimer)
       
   276         {
       
   277         iPeriodicTimer->Cancel();
       
   278         }
       
   279     
       
   280     RemoveScanner();
       
   281     InquiryComplete(KErrCancel);
       
   282 
       
   283     FLOG(_L("[BTNOTIF]\t CBTInqUI::Cancel() completed"));
       
   284     }
       
   285 
       
   286 // ----------------------------------------------------------
       
   287 // CBTInqUI::DisplayDevicesFrontListL
       
   288 // Display last seen devices popuplist
       
   289 // ----------------------------------------------------------
       
   290 //
       
   291 void CBTInqUI::DisplayDevicesFrontListL()
       
   292     {
       
   293     FLOG(_L("[BTNOTIF]\t CBTInqUI::DisplayDevicesFrontListL()"));
       
   294 
       
   295     
       
   296     if ( iAdjustedUsedDeviceArray->Count() <= 0 )
       
   297         {
       
   298         SelectSearchCategoryL();
       
   299         return;
       
   300         }
       
   301     
       
   302     if( !iBroughtForwards )
       
   303         {
       
   304         iEikonEnvRef.BringForwards(ETrue); // Destructor will release this later on
       
   305         iBroughtForwards = ETrue;
       
   306         }
       
   307 
       
   308     // Create the devices popuplist
       
   309     CreatePopupListL( R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT , R_BT_LAST_USED_DEVS_POPUP_TITLE );
       
   310 
       
   311     // Add devices into device list.
       
   312     for( TInt index = 0; index < iAdjustedUsedDeviceArray->Count(); index++ )
       
   313     	{        
       
   314    	    AddToDeviceListBoxL ( iAdjustedUsedDeviceArray->At(index) );  
       
   315         }  
       
   316 
       
   317     // Add "more devices" command as first item of list
       
   318     HBufC* formatString = HBufC::NewLC( KBTAllPurposeBufferLength );
       
   319     formatString->Des().Copy( TPtrC(KDeviceIconFormatTable[EDeviceIconBlank].iFormat ) );
       
   320     HBufC* moreDevicesString = iEikonEnvRef.AllocReadResourceLC( R_BT_MORE_DEVICES_ITEM );
       
   321     formatString->Des().Append( *moreDevicesString );
       
   322     CleanupStack::PopAndDestroy(); // moreDevicesString
       
   323     iDeviceListRows->InsertL( 0, *formatString );
       
   324     CleanupStack::Pop(); // formatString
       
   325 
       
   326     // Launch popup list and wait for user input 
       
   327     AllowDialerAndAppKeyPress( EFalse );
       
   328     TInt popupRetVal = iDevicePopupList->ExecuteLD();    
       
   329     iDevicePopupList = NULL;   
       
   330     AllowDialerAndAppKeyPress( ETrue );
       
   331     
       
   332     if( !popupRetVal )
       
   333         { 
       
   334         // query cancelled by user or system, complete device search:
       
   335         iDevSearchObserver->NotifyDeviceSearchCompleted(KErrCancel);
       
   336         return;
       
   337         }
       
   338     TInt currentDeviceIndex = iDeviceListBox->CurrentItemIndex();
       
   339     
       
   340     // Delete device list box and reset device items array
       
   341     delete iDeviceListBox;
       
   342     iDeviceListBox = NULL;
       
   343     iDeviceListRows->Reset();
       
   344 
       
   345     if( currentDeviceIndex > 0 ) // User selected "a used device"
       
   346         {
       
   347         HandleDeviceSelectionL( iAdjustedUsedDeviceArray->At( currentDeviceIndex - 1 ) );   
       
   348         return;
       
   349         }
       
   350     
       
   351     // user selected more devices.
       
   352     SelectSearchCategoryL();
       
   353     FLOG(_L("[BTNOTIF]\t CBTInqUI::DisplayDevicesFrontListL() completed"));
       
   354     }
       
   355 
       
   356 // ----------------------------------------------------------
       
   357 // CBTInqUI::DeviceSearchUiL
       
   358 // Execute bluetooth device search/inquiry.
       
   359 // Parameters:
       
   360 //  OUT: aDevice     - selected device after inquiry
       
   361 //  IN:  aObexOnly   - flag if OBEX capable devices is requested
       
   362 // ----------------------------------------------------------
       
   363 //
       
   364 void CBTInqUI::DeviceSearchUiL()
       
   365     {
       
   366     FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceSearchUiL()"));
       
   367     
       
   368     TSearchFlowState searchFlow;
       
   369     TInt err;
       
   370     AllowDialerAndAppKeyPress( EFalse );
       
   371     do
       
   372         {
       
   373         searchFlow = InitInquiryL(err);
       
   374         } while (searchFlow == ESearchAgain);
       
   375     
       
   376     if (searchFlow == ESearchCompleted)
       
   377         {
       
   378         // search completed caused by either user cancel or failure
       
   379         iDevSearchObserver->NotifyDeviceSearchCompleted(err);
       
   380         AllowDialerAndAppKeyPress( ETrue );
       
   381         return;
       
   382         }
       
   383  
       
   384     FLOG(_L("[BTNOTIF]\t CBTInqUI, Displaying devices already found"));
       
   385 
       
   386     TInt keypress(0);
       
   387     // Show devices popup list for received devices while
       
   388     // inquiry is still active and list may be updated.
       
   389     if( !iInquiryComplete )
       
   390         {
       
   391         CreatePopupListL( R_BT_SOFTKEYS_SELECT_STOP, R_BT_SEARCH_DEVS_POPUP_TITLE );
       
   392 
       
   393         // Set animation
       
   394         iDevicePopupList->Heading()->SetHeaderAnimationL( R_BT_ANIMATION_FOR_POPUPLIST );
       
   395 
       
   396         // Launch popup list and wait for user input
       
   397         keypress = iDevicePopupList->ExecuteLD();    
       
   398         iDevicePopupList = NULL;
       
   399         }
       
   400 
       
   401     // If Cancel() is called while DoInquery() is still running,
       
   402     // such as taking out MMC while bt devices discovery or user pressed redkey.                 
       
   403     // In such cases, We need to dismiss anything and function returns immediately.
       
   404     //
       
   405     if (iSystemCancel )
       
   406         {
       
   407         FLOG(_L("[BTNOTIF]\t inquiry was canncelled by the system!"));
       
   408         iSystemCancel = EFalse;
       
   409         AllowDialerAndAppKeyPress( ETrue );
       
   410         iDevSearchObserver->NotifyDeviceSearchCompleted(KErrCancel);
       
   411         return;
       
   412         }
       
   413 
       
   414     // Cancel inquiry
       
   415     RemoveScanner();
       
   416     
       
   417     // Store the highlighted device index and destroy list box
       
   418     iHighLightedItemIndex = 0;
       
   419     if( iDeviceListBox )
       
   420         {
       
   421         iHighLightedItemIndex = iDeviceListBox->CurrentItemIndex();
       
   422         delete iDeviceListBox;
       
   423         iDeviceListBox = NULL;
       
   424         }
       
   425     
       
   426     // user selected a device during active inquiry
       
   427     if (keypress)
       
   428         {
       
   429         AllowDialerAndAppKeyPress( ETrue );
       
   430         HandleDeviceSelectionL( iLastSeenDevicesArray->At( iHighLightedItemIndex ) );
       
   431         return;
       
   432         }
       
   433 
       
   434     // Error encountered in inquiry
       
   435     if (iInquiryStatus)
       
   436         {
       
   437         AllowDialerAndAppKeyPress( ETrue );
       
   438         iDevSearchObserver->NotifyDeviceSearchCompleted(iInquiryStatus);
       
   439         return;
       
   440         }
       
   441     
       
   442     // Inquiry completed, show final device list 
       
   443     FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceSearchUiL Displaying final devicelist"));          
       
   444     CreatePopupListL( R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, R_BT_FOUND_DEVS_POPUP_TITLE );
       
   445 
       
   446     //cancel iPeriodicTimer after the final list is shown
       
   447     iPeriodicTimer->Cancel();
       
   448     User::ResetInactivityTime();
       
   449     // Set highlight on top of same device as it was in previous popuplist
       
   450     if( iHighLightedItemIndex >= 0 )
       
   451         {
       
   452         iDeviceListBox->HandleItemAdditionL();
       
   453         iDeviceListBox->SetCurrentItemIndex(iHighLightedItemIndex);
       
   454         }
       
   455 
       
   456     // Launch popup list and wait for user input
       
   457     keypress = iDevicePopupList->ExecuteLD();
       
   458     iDevicePopupList = NULL;
       
   459     AllowDialerAndAppKeyPress( ETrue );
       
   460     // If dialog is cancelled by system:
       
   461     if( !keypress)
       
   462         {
       
   463         iDevSearchObserver->NotifyDeviceSearchCompleted(KErrCancel);
       
   464         return;
       
   465         }
       
   466 
       
   467     // Get user selection
       
   468     TInt index = iDeviceListBox->CurrentItemIndex();
       
   469     delete iDeviceListBox;
       
   470     iDeviceListBox = NULL;
       
   471 
       
   472     HandleDeviceSelectionL( iLastSeenDevicesArray->At( index ) );
       
   473 
       
   474     FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceSearchUiL() complete"));    
       
   475     }
       
   476 
       
   477 TSearchFlowState CBTInqUI::InitInquiryL(TInt& aReason)
       
   478     {
       
   479     FLOG(_L("[BTNOTIF]\t CBTInqUI::InitInquiryL"));
       
   480     if (IsActiveVoIPOverWLAN())
       
   481         {
       
   482         iUiUtil->ShowInfoNoteL( R_BT_NO_DEVICE_DISCOVERY_VOIP, ECmdBTnotifUnavailable );
       
   483         aReason = KErrInUse;
       
   484         return ESearchCompleted;
       
   485         }
       
   486 
       
   487     // starting  the timer
       
   488     iPeriodicTimer->Cancel();
       
   489     iPeriodicTimer->Start(KPeriodicTimerInterval4Sec, KPeriodicTimerInterval4Sec, 
       
   490                         TCallBack(PeriodicTimerCallBack, this));
       
   491     
       
   492     // Prepare for using hostresolver to search devices 
       
   493     CreateScannerL();
       
   494     
       
   495     iInquiryStatus = KErrCancel; // Give a initial value (for end key handling)
       
   496     iDevicesFound = EFalse;
       
   497     iInquiryComplete = EFalse;
       
   498     iSystemCancel = EFalse;   
       
   499     
       
   500     // Show wait note until dialog is dismissed by inquirey result callbacks or user cancel
       
   501     TInt ret = iUiUtil->ShowWaitDlgL( R_BT_SEARCHING_DEVICES_NOTE );
       
   502     
       
   503     // If user cancels searching, ret will be KerrNone.  
       
   504     // According to Description of Eikdialog, ShowWaitDlgL() returns zero 
       
   505     // if it was the cancel button (@c EEikBidCancel). 
       
   506     if( ret == KErrNone || iSystemCancel )
       
   507         {
       
   508         FLOG(_L("[BTNOTIF]\t CBTInqUI, User cancelled waiting note"));
       
   509         RemoveScanner();
       
   510         aReason = KErrCancel;
       
   511         return ESearchCompleted;
       
   512         }
       
   513 
       
   514      if( !iDevicesFound ) // No devices found at all
       
   515          {
       
   516          FLOG(_L("[BTNOTIF]\t CBTInqUI no devices found at all"));
       
   517          RemoveScanner(); // Cancel inquiry
       
   518 
       
   519          if( iInquiryStatus != KErrNone )
       
   520              {
       
   521              aReason = iInquiryStatus;
       
   522              return ESearchCompleted;
       
   523              }
       
   524          
       
   525          // Show try again query
       
   526          TBool keypress(0);
       
   527          keypress = iUiUtil->ShowQueryL( KErrNone, R_BT_TRY_AGAIN_QUERY, ECmdBTnotifUnavailable );
       
   528          if( !keypress ) // User has not requested new inquiry
       
   529              {
       
   530              aReason = KErrCancel;
       
   531              return ESearchCompleted;
       
   532              }
       
   533          else
       
   534              {
       
   535              FLOG(_L("[BTNOTIF]\t CBTInqUI user wanted to try again"));
       
   536              return ESearchAgain;
       
   537              }
       
   538          }
       
   539      return ESearchFirstDeviceFound;
       
   540     }
       
   541 
       
   542 // ----------------------------------------------------------
       
   543 // CBTInqUI::DeviceAvailableL
       
   544 // Bluetooth device has been received.
       
   545 // ----------------------------------------------------------
       
   546 //
       
   547 void CBTInqUI::DeviceAvailableL( const TNameRecord& aNameRecord, const TDesC& aDevName, TBool aIsNameComplete )
       
   548     {
       
   549     FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceAvailableL()"));
       
   550 
       
   551     if( !iDevicesFound )
       
   552         {
       
   553         FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceAvailableL() first found, clear last seen devices array"));
       
   554         iLastSeenDevicesArray->ResetAndDestroy(); // Remove previous inquiry results
       
   555         iDevicesFound = ETrue; 
       
   556         iInquiryStatus = KErrNone;
       
   557         }
       
   558     
       
   559     iUiUtil->CompleteWaitDlgL();
       
   560 
       
   561     TInquirySockAddr& sa = TInquirySockAddr::Cast( aNameRecord.iAddr );
       
   562     
       
   563     // Create device object with received CoD information
       
   564     CBTDevice* newDevice = CBTDevice::NewLC( sa.BTAddr() );      
       
   565     TBTDeviceClass cod( sa.MajorServiceClass(), sa.MajorClassOfDevice(), sa.MinorClassOfDevice() );
       
   566     newDevice->SetDeviceClass( cod );
       
   567     FTRACE(FPrint(_L("[BTNOTIF]\t CoD %b"), cod.DeviceClass() ));
       
   568     TInt rssi = 0;
       
   569     if( sa.ResultFlags() & TInquirySockAddr::ERssiValid )
       
   570         {
       
   571         rssi = sa.Rssi() + KRssiRangeOffset;
       
   572         }
       
   573 
       
   574     TBTDeviceName name(aDevName);
       
   575     if (!aIsNameComplete)
       
   576         {
       
   577         // Append a little "..." to partial names.
       
   578         _LIT(KToBeContd, "...");
       
   579         if (name.MaxLength() - name.Length() >= KToBeContd().Length())
       
   580             {
       
   581             name.Append(KToBeContd);
       
   582             }
       
   583         }
       
   584     BtNotifNameUtils::SetDeviceNameL(name, *newDevice);
       
   585 
       
   586     // Append newDevice in the bottom of the "last seen" device array.
       
   587     iLastSeenDevicesArray->AppendL(newDevice);
       
   588     iLastSeenDevicesNameComplete.AppendL(aIsNameComplete);
       
   589     CleanupStack::Pop(); // new device is under iLastSeenDevicesArray control now
       
   590 
       
   591     __ASSERT_DEBUG(iLastSeenDevicesArray->Count() == iLastSeenDevicesNameComplete.Count(),
       
   592                    User::Panic(_L("BTNotifInqUI - device array and name resolution status array out of sync"), KErrCorrupt));
       
   593 
       
   594     // Update device popup list with newDevice
       
   595     AddToDeviceListBoxL( newDevice, rssi );
       
   596 
       
   597     __ASSERT_DEBUG(iLastSeenDevicesArray->Count() == iDeviceListRows->Count(),
       
   598                    User::Panic(_L("BTNotifInqUI - device array and UI list out of sync"), KErrCorrupt));
       
   599 
       
   600     FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceAvailableL() completed"));
       
   601     }
       
   602 
       
   603 void CBTInqUI::DeviceNameUpdatedL(const TNameRecord& aNameRecord, TInt aLastSeenIndex)
       
   604     {
       
   605     FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::DeviceUpdatedL() Name found: %S"), &(aNameRecord.iName) ));
       
   606 
       
   607     TInquirySockAddr& sa = TInquirySockAddr::Cast( iEntry().iAddr );
       
   608 
       
   609     TInt rssi = 0;
       
   610     if( sa.ResultFlags() & TInquirySockAddr::ERssiValid )
       
   611         {
       
   612         rssi = sa.Rssi() + KRssiRangeOffset;
       
   613         }
       
   614 
       
   615     BtNotifNameUtils::SetDeviceNameL(aNameRecord.iName, *iLastSeenDevicesArray->At(aLastSeenIndex));
       
   616     DeviceUpdatedL(rssi, aLastSeenIndex);
       
   617 
       
   618     FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceUpdatedL() completed"));
       
   619     }
       
   620 
       
   621 void CBTInqUI::PageTimeoutOnDeviceWithPartialNameL(TInt aLastSeenIndex)
       
   622     {
       
   623     FLOG(_L("[BTNOTIF]\t CBTInqUI::PageTimeoutOnDeviceWithPartialNameL()"));
       
   624     DeviceUpdatedL(KMinimumStrength, aLastSeenIndex);
       
   625     FLOG(_L("[BTNOTIF]\t CBTInqUI::PageTimeoutOnDeviceWithPartialNameL() completed"));
       
   626     }
       
   627 
       
   628 
       
   629 void CBTInqUI::DeviceUpdatedL(TInt aSignalStrength, TInt aLastSeenIndex)
       
   630     {
       
   631     FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceUpdatedL()"));
       
   632 
       
   633     HBufC* formatString = HBufC::NewLC( KBTAllPurposeBufferLength );
       
   634     FormatListBoxEntryL(*iLastSeenDevicesArray->At(aLastSeenIndex), aSignalStrength, formatString->Des());
       
   635 
       
   636     // The assumption here is that iLastSeenDevicesArray is always accurately reflected
       
   637     // in iDeviceListRows so device indexes match.
       
   638     __ASSERT_DEBUG(iLastSeenDevicesArray->Count() == iDeviceListRows->Count(),
       
   639                    User::Panic(_L("BTNotifInqUI - device array and UI dev list out of sync not created"), KErrCorrupt));
       
   640 
       
   641     iDeviceListRows->Delete(aLastSeenIndex);
       
   642     iDeviceListRows->InsertL(aLastSeenIndex, *formatString);
       
   643     CleanupStack::PopAndDestroy();  // formatString
       
   644 
       
   645     __ASSERT_DEBUG(iDeviceListBox,
       
   646                    User::Panic(_L("BTNotifInqUI - UI list non-existant on name update"), KErrCorrupt));
       
   647     iDeviceListBox->HandleItemAdditionL();
       
   648 
       
   649     FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceUpdatedL()"));
       
   650     }
       
   651 
       
   652 void CBTInqUI::FormatListBoxEntryL(CBTDevice& aDevice, const TInt aSignalStrength, TPtr aFormatString)
       
   653     {
       
   654     FLOG(_L("[BTNOTIF]\t CBTInqUI::FormatListBoxEntryL()"));
       
   655 
       
   656     TInt iconIndex (EDeviceIconDefault);
       
   657     TInt defNameIndex (EBTDeviceNameIndexDefault);
       
   658 
       
   659     // Check whether the device is already in registry.
       
   660     TInt index = LookupFromDevicesArray(iPairedDevicesArray, &aDevice );
       
   661     if( index >= 0 )
       
   662         {
       
   663         // Update device's link key and friendly name 
       
   664         // with those found from registry.
       
   665         aDevice.UpdateL( *( iPairedDevicesArray->At( index ) ) );
       
   666         }
       
   667 
       
   668     for (TInt i = 0; i < KDeviceRowLayoutTableSize; i++)
       
   669         {
       
   670         if ( ( aDevice.DeviceClass().MajorDeviceClass() == KDeviceRowLayoutTable[i].iMajorDevClass ) &&
       
   671             ( (aDevice.DeviceClass().MinorDeviceClass() == KDeviceRowLayoutTable[i].iMinorDevClass ) ||
       
   672                     KDeviceRowLayoutTable[i].iMinorDevClass == 0 ) )
       
   673             {
       
   674             iconIndex = KDeviceRowLayoutTable[i].iIconIndex;
       
   675             defNameIndex = KDeviceRowLayoutTable[i].iDefaultNameIndex;
       
   676             break;
       
   677             }
       
   678         }
       
   679     
       
   680     if ( !aDevice.IsValidFriendlyName() && !aDevice.IsValidDeviceName() )
       
   681         {
       
   682         BtNotifNameUtils::SetDeviceNameL(iDefaultDeviceNamesArray->MdcaPoint(defNameIndex), aDevice);
       
   683         }
       
   684 
       
   685     //Convert device name to Unocode for display
       
   686     if ( aDevice.IsValidFriendlyName() )
       
   687         {
       
   688         aFormatString.Copy( aDevice.FriendlyName() );
       
   689         }
       
   690     else 
       
   691         {
       
   692         aFormatString.Copy( BTDeviceNameConverter::ToUnicodeL(aDevice.DeviceName()));
       
   693         }
       
   694 
       
   695     TPtrC iconFormat (KDeviceIconFormatTable[iconIndex].iFormat);
       
   696     
       
   697     aFormatString.Insert( 0, iconFormat );
       
   698 
       
   699     if( aSignalStrength > 0)
       
   700         {
       
   701         if( aSignalStrength <= KMediumStrength )
       
   702             {
       
   703             aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiLow].iFormat ) );
       
   704             }
       
   705         else if( aSignalStrength <= KHighStrength )
       
   706             {
       
   707             aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiMed].iFormat ) );
       
   708             }
       
   709         else
       
   710             {
       
   711             aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiGood].iFormat ) );
       
   712             }
       
   713         }
       
   714     
       
   715     // If the device is paired, add paired icon to format list
       
   716     // Paired device using JustWork file transfering mode is not shown as paired here. 
       
   717     if( index >= 0 && IsUserAwarePaired ( aDevice.AsNamelessDevice() ) )
       
   718         {
       
   719         aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconPaired].iFormat ) );
       
   720         }
       
   721     else
       
   722         {
       
   723         // if device is blocked, add blocked icon to format list
       
   724         
       
   725         TInt indexB = LookupFromDevicesArray(iLastUsedDevicesArray, &aDevice );
       
   726         
       
   727         if ( indexB>=0 && iLastUsedDevicesArray->At( indexB )->GlobalSecurity().Banned())
       
   728             {
       
   729             aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconBlocked].iFormat ) );
       
   730             }
       
   731         }
       
   732     FLOG(_L("[BTNOTIF]\t CBTInqUI::FormatListBoxEntryL() completed"));
       
   733     }
       
   734 
       
   735 
       
   736 // ----------------------------------------------------------
       
   737 // CBTInqUI::InquiryComplete
       
   738 // Inquiry has been completed.
       
   739 // ----------------------------------------------------------
       
   740 //
       
   741 void CBTInqUI::InquiryComplete( TInt aError )
       
   742     {
       
   743     FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::InquiryComplete() status = %d: %d devices found"), aError, iLastSeenDevicesArray->Count() ));
       
   744     iInquiryComplete = ETrue;
       
   745     // Remove popup list if any devices exists
       
   746     if( iDevicePopupList )
       
   747         {
       
   748         iDevicePopupList->CancelPopup();
       
   749         iDevicePopupList = NULL;
       
   750         }
       
   751     
       
   752     TRAP_IGNORE( iUiUtil->CompleteWaitDlgL() );
       
   753     
       
   754     if ( aError == KErrNone || aError == KErrCancel || aError == KErrEof )
       
   755         {
       
   756         iInquiryStatus = (aError == KErrEof ) ? KErrNone : aError;
       
   757         }
       
   758     else
       
   759         {
       
   760         iLastSeenDevicesArray->ResetAndDestroy(); // Remove previous inquiry results
       
   761         }
       
   762 
       
   763     FLOG(_L("[BTNOTIF]\t CBTInqUI::InquiryComplete() completed"));
       
   764     }
       
   765 
       
   766 // ----------------------------------------------------------
       
   767 // CBTInqUI::PeriodicTimerCallBack(TAny* aAny)
       
   768 // The call back function
       
   769 // ----------------------------------------------------------
       
   770 //
       
   771 TInt CBTInqUI::PeriodicTimerCallBack(TAny* /*aAny*/)
       
   772     {
       
   773     User::ResetInactivityTime();
       
   774     return KErrNone; // Return value ignored by CPeriodic
       
   775     }
       
   776 
       
   777 // ----------------------------------------------------------
       
   778 // CBTInqUI::RemoveScanner
       
   779 // Remove scanner active object if still exists.
       
   780 // ----------------------------------------------------------
       
   781 //
       
   782 void CBTInqUI::RemoveScanner()
       
   783     {
       
   784     FLOG(_L("[BTNOTIF]\t CBTInqUI::RemoveScanner()"));
       
   785     if( iScanner )
       
   786         {
       
   787         iScanner->CancelRequest();
       
   788         iHostResolver.Close();
       
   789         iSocketServer.Close(); 
       
   790         delete iScanner; 
       
   791         iScanner = NULL;
       
   792         }
       
   793     iDevsWithoutName.Close();
       
   794     FLOG(_L("[BTNOTIF]\t CBTInqUI::RemoveScanner() completed"));
       
   795     }
       
   796 
       
   797 // ----------------------------------------------------------
       
   798 // CBTInqUI::CreatePopupListL
       
   799 // ----------------------------------------------------------
       
   800 //
       
   801 void CBTInqUI::CreatePopupListL(TInt aSoftkeysResourceId, TInt aTitleResourceId )
       
   802     {
       
   803     FLOG(_L("[BTNOTIF]\t CBTInqUI::CreatePopupListL()"));
       
   804 
       
   805     __ASSERT_DEBUG( !iDeviceListBox,   User::Panic(_L("BTNotifInqUI - iDeviceListBox not released!"  ), KErrAlreadyExists));
       
   806     __ASSERT_DEBUG( !iDevicePopupList, User::Panic(_L("BTNotifInqUI - iDevicePopupList not released!"),KErrAlreadyExists));
       
   807 
       
   808     // Create listbox for devices
       
   809     iDeviceListBox = new(ELeave) CAknSingleGraphicPopupMenuStyleListBox;
       
   810 
       
   811     // Create popup list
       
   812     iDevicePopupList = CAknPopupList::NewL( iDeviceListBox, aSoftkeysResourceId, AknPopupLayouts::EDynMenuWindow );
       
   813 
       
   814     iDeviceListBox->ConstructL(iDevicePopupList, EAknListBoxMenuList );
       
   815     iDeviceListBox->CreateScrollBarFrameL(ETrue);
       
   816     iDeviceListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
   817 
       
   818     // Read title from resources
       
   819     HBufC* popupListTitle = iEikonEnvRef.AllocReadResourceLC( aTitleResourceId );
       
   820     iDevicePopupList->SetTitleL(*popupListTitle);
       
   821     CleanupStack::PopAndDestroy(); // popupListTitle
       
   822 
       
   823     // Create list box model for devices
       
   824     CTextListBoxModel* model = iDeviceListBox->Model();
       
   825     model->SetItemTextArray(iDeviceListRows);
       
   826     model->SetOwnershipType(ELbmDoesNotOwnItemArray);  // Do not destroy items
       
   827 
       
   828     // Set up filename for Avkon bitmap
       
   829     TFileName avkonbmpFilename = AknIconUtils::AvkonIconFileName();
       
   830 
       
   831     // Setup graphic items list for BT devices listbox
       
   832     CAknIconArray* iconList = new(ELeave) CAknIconArray(KDeviceIconCount);
       
   833     CleanupStack::PushL( iconList );
       
   834 	
       
   835 	CreateAndAppendIconL( KAknsIIDQgnPropBtComputer, avkonbmpFilename, 
       
   836 						  EMbmAvkonQgn_prop_bt_computer,
       
   837 						  EMbmAvkonQgn_prop_bt_computer_mask, iconList);
       
   838 
       
   839 	CreateAndAppendIconL( KAknsIIDQgnPropBtPhone, avkonbmpFilename, 
       
   840 						  EMbmAvkonQgn_prop_bt_phone,
       
   841 						  EMbmAvkonQgn_prop_bt_phone_mask, iconList);
       
   842 
       
   843 	CreateAndAppendIconL( KAknsIIDQgnPropBtAudio, avkonbmpFilename, 
       
   844 						  EMbmAvkonQgn_prop_bt_audio,
       
   845 						  EMbmAvkonQgn_prop_bt_audio_mask, iconList);
       
   846 
       
   847 	CreateAndAppendIconL( KAknsIIDQgnPropBtMisc, avkonbmpFilename, 
       
   848 						  EMbmAvkonQgn_prop_bt_misc,
       
   849 						  EMbmAvkonQgn_prop_bt_misc_mask, iconList);
       
   850 
       
   851 	CreateAndAppendIconL( KAknsIIDQgnStatBtBlank, avkonbmpFilename, 
       
   852 						  EMbmAvkonQgn_stat_bt_blank,
       
   853 						  EMbmAvkonQgn_stat_bt_blank, iconList);
       
   854 	
       
   855 	CreateAndAppendIconL( KAknsIIDQgnPropBtKeyboard, avkonbmpFilename, 
       
   856 						  EMbmAvkonQgn_prop_bt_keyboard,
       
   857 						  EMbmAvkonQgn_prop_bt_keyboard_mask, iconList);					  
       
   858 
       
   859 	CreateAndAppendIconL( KAknsIIDQgnPropBtMouse, avkonbmpFilename, 
       
   860 						  EMbmAvkonQgn_prop_bt_mouse,
       
   861 						  EMbmAvkonQgn_prop_bt_mouse_mask, iconList);
       
   862 						  
       
   863 	CreateAndAppendIconL( KAknsIIDQgnPropBtPrinter, avkonbmpFilename, 
       
   864 						  EMbmAvkonQgn_prop_bt_printer,
       
   865 						  EMbmAvkonQgn_prop_bt_printer_mask, iconList);					  					  
       
   866 	
       
   867 	CreateAndAppendIconL( KAknsIIDQgnPropBtCarKit, avkonbmpFilename, 
       
   868 						  EMbmAvkonQgn_prop_bt_carkit,
       
   869 						  EMbmAvkonQgn_prop_bt_carkit_mask, iconList);
       
   870 	
       
   871 	GetColorIconL( avkonbmpFilename, KAknsIIDQgnIndiBtPairedAdd, 
       
   872 	                EMbmAvkonQgn_indi_bt_paired_add, 
       
   873 	                EMbmAvkonQgn_indi_bt_paired_add_mask, iconList );
       
   874 	
       
   875     
       
   876     TFileName bmpFilename;
       
   877     bmpFilename += KFileDrive;
       
   878     bmpFilename += KDC_BITMAP_DIR;
       
   879     bmpFilename += KBtnotifBmpFileName;	
       
   880 	
       
   881 	GetColorIconL( bmpFilename, KAknsIIDQgnIndiBtBlocked, 
       
   882 	                EMbmBtnotifQgn_indi_bt_blocked, 
       
   883 	                EMbmBtnotifQgn_indi_bt_blocked_mask, iconList );
       
   884 	
       
   885 	bmpFilename.Zero();
       
   886 	bmpFilename.Append( KFileDrive );
       
   887 	bmpFilename.Append( KDC_APP_BITMAP_DIR );
       
   888 	bmpFilename.Append( KWLanBmpFileName );
       
   889 	
       
   890     GetColorIconL( bmpFilename, KAknsIIDQgnIndiWlanSignalLowAdd, 
       
   891 	                EMbmWlanpluginQgn_indi_wlan_signal_low_add, 
       
   892 	                EMbmWlanpluginQgn_indi_wlan_signal_low_add_mask, iconList);
       
   893 	
       
   894     GetColorIconL( bmpFilename, KAknsIIDQgnIndiWlanSignalMedAdd, 
       
   895                     EMbmWlanpluginQgn_indi_wlan_signal_med_add, 
       
   896                     EMbmWlanpluginQgn_indi_wlan_signal_med_add_mask, iconList );
       
   897 
       
   898     GetColorIconL( bmpFilename, KAknsIIDQgnIndiWlanSignalGoodAdd, 
       
   899                     EMbmWlanpluginQgn_indi_wlan_signal_good_add, 
       
   900                     EMbmWlanpluginQgn_indi_wlan_signal_good_add_mask, iconList );
       
   901 	
       
   902 	// Transfer iconlist ownership to the listbox
       
   903 	//
       
   904 	iDeviceListBox->ItemDrawer()->ColumnData()->SetIconArray(iconList);
       
   905 	CleanupStack::Pop(); // iconList
       
   906 	
       
   907     FLOG(_L("[BTNOTIF]\t CBTInqUI::CreatePopupListL() completed"));
       
   908     }
       
   909 
       
   910 // ----------------------------------------------------------
       
   911 // CBTInqUI::UpdateDeviceListL
       
   912 // ----------------------------------------------------------
       
   913 //
       
   914 void CBTInqUI::AddToDeviceListBoxL( CBTDevice* aDevice, const TInt aSignalStrength )
       
   915     {
       
   916     FLOG(_L("[BTNOTIF]\t CBTInqUI::AddToDeviceListBoxL()")); 
       
   917     
       
   918     HBufC* formatString = HBufC::NewLC( KBTAllPurposeBufferLength );
       
   919     FormatListBoxEntryL(*aDevice, aSignalStrength, formatString->Des());
       
   920 
       
   921     // Add device format string into device items
       
   922     //
       
   923     TInt deviceCount = iDeviceListRows->Count();
       
   924 	iDeviceListRows->InsertL( deviceCount, *formatString );      
       
   925     CleanupStack::PopAndDestroy();  // formatString
       
   926 
       
   927     TInt currentItemIndex = 0;
       
   928 	if(deviceCount != 0 && iDeviceListBox)
       
   929 		{
       
   930 	 	// Store temporarily the highlighted device and destroy list box
       
   931 	    //
       
   932 	    currentItemIndex = iDeviceListBox->CurrentItemIndex();		
       
   933 		}
       
   934 
       
   935     if( iDeviceListBox )
       
   936         {
       
   937         iDeviceListBox->HandleItemAdditionL();
       
   938         
       
   939 		if(deviceCount != 0 )	
       
   940 			{
       
   941 			//set highligh back to user selected one.       
       
   942 			iDeviceListBox->SetCurrentItemIndex(currentItemIndex); 
       
   943 			}
       
   944 
       
   945 		// Adjust top item index in order to "scroll up" the list. 
       
   946 		// If current highlight device is not the top one and the listbox's visible slots are full(at least 5 devices are listed), 
       
   947 		// to make the newly discovered device visible, the list needs to be scrolled up. 
       
   948 		//
       
   949 		TInt topIndex = iDeviceListBox->TopItemIndex();
       
   950 		deviceCount = iDeviceListRows->Count();
       
   951 		
       
   952 		if( (currentItemIndex != topIndex  && deviceCount > 5 ) && (currentItemIndex+1 < deviceCount ) )
       
   953 			{
       
   954 			iDeviceListBox->SetTopItemIndex( topIndex+1 ); //scroll up
       
   955 			}
       
   956         }
       
   957 
       
   958     FLOG(_L("[BTNOTIF]\t CBTInqUI::AddToDeviceListBoxL() completed"));
       
   959     }
       
   960 
       
   961 // ----------------------------------------------------------
       
   962 // CBTInqUI::LookupFromDevicesArrayL
       
   963 // Check if the BT device is paired devices array
       
   964 // ----------------------------------------------------------
       
   965 //
       
   966 TInt CBTInqUI::LookupFromDevicesArray(const CBTDeviceArray* aDeviceArray, const CBTDevice* aDevice ) const
       
   967     {
       
   968     FLOG(_L("[BTNOTIF]\t CBTInqUI::LookupFromDevicesArray()"));
       
   969 
       
   970     __ASSERT_DEBUG( aDeviceArray, User::Panic(_L("BTNotifInqUI - aDeviceArray not created"), KErrNotFound ));
       
   971 
       
   972     for( TInt index = 0; index < aDeviceArray->Count(); index++ )
       
   973         {
       
   974         // Try to find device by its address.
       
   975         if ( aDeviceArray->At( index )->BDAddr() == aDevice->BDAddr() )
       
   976             {
       
   977             FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::LookupFromDevicesArrayL()idx %d"), index));
       
   978             return index; // Return index to the device at array
       
   979             }
       
   980         }
       
   981     return KErrNotFound;
       
   982     }
       
   983     
       
   984 // ----------------------------------------------------
       
   985 // CBTInqUI::CreateAndAppendIconL
       
   986 // ----------------------------------------------------
       
   987 void CBTInqUI::CreateAndAppendIconL( const TAknsItemID& aID,
       
   988 									 const TDesC& aFileName,
       
   989 									 const TInt aBitmapId,
       
   990 									 const TInt aMaskId,
       
   991 									 CAknIconArray* aIconList)
       
   992     {
       
   993 	CGulIcon* icon = AknsUtils::CreateGulIconL(AknsUtils::SkinInstance(), aID, aFileName, aBitmapId, aMaskId);
       
   994     
       
   995     CleanupStack::PushL(icon);    
       
   996 	aIconList->AppendL( icon );
       
   997     CleanupStack::Pop(); // icon
       
   998 	}
       
   999 
       
  1000 // ---------------------------------------------------------
       
  1001 // CBTInqUI::AdjustDeviceArrayL
       
  1002 // Applend max 5 lately used non-paird devices plus all the 
       
  1003 // paired devices to the input parameter by the order of 
       
  1004 // the last used time stamp.
       
  1005 // ---------------------------------------------------------
       
  1006 //
       
  1007 void CBTInqUI::AdjustDeviceArrayL(CBTDeviceArray* aDeviceArray)
       
  1008     {
       
  1009     FLOG(_L("[BTNOTIF]\t CBTInqUI::AdjustDeviceArrayL()"));
       
  1010 
       
  1011     TInt lSize = iLastUsedDevicesArray->Count(); 
       
  1012     
       
  1013     if (lSize <= 0)
       
  1014         {
       
  1015         return;
       
  1016         }
       
  1017     
       
  1018     TInt pSize = iPairedDevicesArray->Count();   
       
  1019 	TInt nonPairedUsedDevicesNumber = lSize - pSize;	
       
  1020     	
       
  1021     // Pickup 5 latest used devices (paired devices are excluded)
       
  1022     //   		    
       
  1023     TInt count(0);
       
  1024  
       
  1025     if (nonPairedUsedDevicesNumber <= KBTNotifNonPairedUsedDevicesMaxNumber)
       
  1026     	count = nonPairedUsedDevicesNumber;
       
  1027     else 
       
  1028     	count = KBTNotifNonPairedUsedDevicesMaxNumber;
       
  1029     
       
  1030 	for(TInt i=0; i < count; i++ )
       
  1031 		{
       
  1032 	    TInt targetDeviceIndex = 0;
       
  1033 	    	   	    
       
  1034 	    //go through iLastUsedDevicesArray, compare each device's time stamp and, find the latest used one.
       
  1035 	    for(TInt k=0; k < lSize; k++)
       
  1036 	    	{
       
  1037 		    if(iLastUsedDevicesArray->At(targetDeviceIndex)->Used() < iLastUsedDevicesArray->At(k)->Used())
       
  1038 		    	{
       
  1039 		    	targetDeviceIndex = k;
       
  1040 		    	}
       
  1041 	    	}
       
  1042 	    	
       
  1043 		//if result is not a paired device, add it to the adjuested device array.	    	
       
  1044 	   	if( LookupFromDevicesArray(iPairedDevicesArray, iLastUsedDevicesArray->At(targetDeviceIndex)) == KErrNotFound )
       
  1045 	   		{
       
  1046 		    aDeviceArray->AppendL(iLastUsedDevicesArray->At(targetDeviceIndex)->CopyL()); 	  	   			   		
       
  1047 	   		}
       
  1048 	    //if result is a paired device, ignore this search round and step-back counter i to make sure this 
       
  1049 	    //search round won't be count.
       
  1050 		else
       
  1051 	   		{
       
  1052 	   		i--; 
       
  1053 	   		}
       
  1054    		    
       
  1055 	    //set the time stamp to -1, in order to ignore this device during next search round.
       
  1056 	    iLastUsedDevicesArray->At(targetDeviceIndex)->SetUsed(-1);	    
       
  1057 		}
       
  1058 
       
  1059 	// Add paired devices to the adjusted list(if paired device exist),
       
  1060 	// by the order of last used time.
       
  1061 	//
       
  1062     if(pSize > 0)
       
  1063     	{
       
  1064 	    for( TInt i = 0; i < pSize; i++ )
       
  1065 	        {
       
  1066 	    	//count size in the beginning of each loop, since the size could grow,
       
  1067 	    	//if new item has been appended in last loop round. 
       
  1068 			TInt sSize = aDeviceArray->Count();
       
  1069 	        
       
  1070 	        TInt j = 0;
       
  1071 	        for (; j < sSize ; j++)
       
  1072 	            {
       
  1073 	            //check if this paired device alreay on the list jump out this loop
       
  1074 	            if (iPairedDevicesArray->At(i)->BDAddr() == aDeviceArray->At(j)->BDAddr())
       
  1075 	            	{
       
  1076 	                break;
       
  1077 	                }
       
  1078 	            
       
  1079 	            // We do not add device still valid paired into list if iExcludePairedDevices is set.  
       
  1080 	            if ( IsUserAwarePaired( iPairedDevicesArray->At(i)->AsNamelessDevice() ) &&
       
  1081 	                    iExcludePairedDevices )
       
  1082 	                {
       
  1083 	                break;
       
  1084 	                }
       
  1085 	                
       
  1086 	            //if this device is not on the list and it is used later then current comparing
       
  1087 	            //device, insert the paired device to aDeviceArray at suitable position.
       
  1088 				TTime pTime = iPairedDevicesArray->At(i)->Used();
       
  1089 				TTime sTime = aDeviceArray->At(j)->Used();
       
  1090 				
       
  1091 	            if ( pTime > sTime)
       
  1092 	            	{
       
  1093 	                aDeviceArray->InsertL(j, iPairedDevicesArray->At(i)->CopyL());
       
  1094 	                break;
       
  1095 	                }
       
  1096 	            }	            
       
  1097 	            
       
  1098 			//if this paired device is not on the sorted list(it is older then all the devices on the list),
       
  1099 			//append it to the end of the list.
       
  1100 	        if (j == sSize) 
       
  1101 	            {
       
  1102 				if ( iExcludePairedDevices )
       
  1103 				    {                
       
  1104                     // Add device to list if device is not paired and iExcludePairedDevices is not set. 
       
  1105                     if ( !IsUserAwarePaired( iPairedDevicesArray->At(i)->AsNamelessDevice() ) )
       
  1106                         {                                      
       
  1107                         aDeviceArray->AppendL(iPairedDevicesArray->At(i)->CopyL());
       
  1108                         }			           
       
  1109 	               }
       
  1110 	            else
       
  1111 	            	{
       
  1112 	            	aDeviceArray->AppendL(iPairedDevicesArray->At(i)->CopyL());
       
  1113 	            	}
       
  1114 	            }	            
       
  1115 	        }    	
       
  1116     	}
       
  1117  
       
  1118     FLOG(_L("[BTNOTIF]\t CBTInqUI::AdjustDeviceArrayL()  Complete."));
       
  1119     }
       
  1120 
       
  1121 //----------------------------------------------------------
       
  1122 // CBTInqUI::QueryUnblockDeviceL
       
  1123 //----------------------------------------------------------
       
  1124 TInt CBTInqUI::QueryUnblockDeviceL(CBTDevice* aDevice)
       
  1125 	{
       
  1126 	FLOG(_L("[BTNOTIF]\t CBTInqUI::QueryUnblockDeviceL()"));
       
  1127 	RBuf stringholder;
       
  1128 	stringholder.CleanupClosePushL();
       
  1129     TBTDeviceName name;
       
  1130     BtNotifNameUtils::GetDeviceDisplayName( name, aDevice );
       
  1131     BluetoothUiUtil::LoadResourceAndSubstringL( 
       
  1132             stringholder, R_BT_UNBLOCK_DEVICE, name, 0 );
       
  1133     TInt keypress(0);
       
  1134     keypress = iUiUtil->ShowQueryL( stringholder, R_BT_UNBLOCK_QUERY, 
       
  1135             ECmdBTnotifUnavailable, name, CAknQueryDialog::EConfirmationTone );
       
  1136     CleanupStack::PopAndDestroy();  // stringholder
       
  1137     FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::QueryUnblockDeviceL()  keypress= %d"),keypress));    
       
  1138 
       
  1139 	return keypress;
       
  1140 	}
       
  1141 
       
  1142 // ----------------------------------------------------------
       
  1143 // CBTInqUI::UnblockDevice
       
  1144 // Unblock device by modifying registry
       
  1145 //-----------------------------------------------------------
       
  1146 //
       
  1147 TInt CBTInqUI::UnblockDevice(TInt aIndex)
       
  1148     {
       
  1149     TInt returnValue = KErrNone;
       
  1150     TBTDeviceSecurity deviceSecuritySettings = iLastUsedDevicesArray->At(aIndex)->GlobalSecurity();
       
  1151     deviceSecuritySettings.SetBanned(EFalse);
       
  1152     iLastUsedDevicesArray->At(aIndex)->DeleteLinkKey();
       
  1153     //DeleteLinkKey() invalidates the LinkKey and IsPaired entries in Lisbon, so...       
       
  1154     iLastUsedDevicesArray->At(aIndex)->SetGlobalSecurity(deviceSecuritySettings);
       
  1155     returnValue = iDevMan->ModifyDevice(*iLastUsedDevicesArray->At(aIndex));
       
  1156     if (!returnValue)
       
  1157         {
       
  1158         iBTRegistryQueryState = ESetDeviceUnblocked;
       
  1159         }
       
  1160     return returnValue;
       
  1161     }
       
  1162 
       
  1163 // ---------------------------------------------------------
       
  1164 // CBTInqUI::HandleDevManComplete
       
  1165 // CBTEngDevMan callback
       
  1166 // ---------------------------------------------------------
       
  1167 //
       
  1168 void CBTInqUI::HandleDevManComplete(TInt aErr)
       
  1169 	{
       
  1170 	FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleDevManComplete()  aErr= %d"),aErr));
       
  1171 	
       
  1172 	switch(iBTRegistryQueryState)
       
  1173 		{	
       
  1174 		case ESetDeviceUnblocked:
       
  1175 		    FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleDevManComplete() EModifyDevice")));  
       
  1176 		    iDevSearchObserver->NotifyDeviceSearchCompleted(aErr, iDevParams);
       
  1177 		    break;
       
  1178 		}
       
  1179 
       
  1180 	FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleDevManComplete()  complete")));
       
  1181 	}
       
  1182 		
       
  1183 //----------------------------------------------------------------
       
  1184 // CBTInqUI: DeviceSearchFilter
       
  1185 //----------------------------------------------------------------
       
  1186 void CBTInqUI::SelectSearchCategoryL()
       
  1187 	{
       
  1188 	FLOG(_L("[BTNOTIF]\t CBTInqUI::SelectSearchCategoryL()"));
       
  1189 	
       
  1190 	if( !(iDesiredDeviceClass == TBTDeviceClass(0)) )
       
  1191 	    {
       
  1192 	    // Notifier caller passed specified COD to search device, not need to show filter query.
       
  1193         DeviceSearchUiL();
       
  1194         FLOG(_L("[BTNOTIF]\t CBTInqUI::SelectSearchCategoryL() complete: not show filter query"));
       
  1195         return;
       
  1196 	    }
       
  1197 	// Create listbox for devices
       
  1198     //
       
  1199     CEikTextListBox* searchFilterListBox = new(ELeave) CAknSinglePopupMenuStyleListBox;
       
  1200 	CleanupStack::PushL(searchFilterListBox);
       
  1201 
       
  1202     // Create popup list    
       
  1203     //
       
  1204 	iSearchFilterPopupList = CAknPopupList::NewL(
       
  1205         searchFilterListBox,
       
  1206         R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT,
       
  1207         AknPopupLayouts::EDynMenuWindow );
       
  1208 
       
  1209     searchFilterListBox->ConstructL(iSearchFilterPopupList, EAknListBoxMenuList );
       
  1210     searchFilterListBox->CreateScrollBarFrameL(ETrue);
       
  1211     searchFilterListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
  1212         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
  1213 
       
  1214     // Read title from resources
       
  1215     //
       
  1216     HBufC* popupListTitle = iEikonEnvRef.AllocReadResourceLC( R_BT_SEARCH_FILTER_POPUP_TITLE );
       
  1217     iSearchFilterPopupList->SetTitleL(*popupListTitle);
       
  1218     CleanupStack::PopAndDestroy(); // popupListTitle
       
  1219 
       
  1220 	// reuse iDeviceListRows for serch filter items
       
  1221 	iDeviceListRows->Reset();
       
  1222 
       
  1223     // Create list box model for devices
       
  1224     //
       
  1225     
       
  1226     CTextListBoxModel* model = searchFilterListBox->Model();
       
  1227     model->SetItemTextArray(iDeviceListRows);
       
  1228     model->SetOwnershipType(ELbmDoesNotOwnItemArray);  // Do not destroy items
       
  1229     
       
  1230     
       
  1231 	// Add itms of filter to popuplist
       
  1232     // Order must be same as in enum EBTSerchFilterItem
       
  1233     //
       
  1234     
       
  1235     AddItemToSearchFilterL(R_BT_SEARCH_FOR_ALL); 
       
  1236     AddItemToSearchFilterL(R_BT_SEARCH_FOR_AUDIO);
       
  1237     AddItemToSearchFilterL(R_BT_SEARCH_FOR_PHONE);
       
  1238     AddItemToSearchFilterL(R_BT_SEARCH_FOR_COMPUTER);
       
  1239     AddItemToSearchFilterL(R_BT_SEARCH_FOR_INPUT);
       
  1240 
       
  1241     // Launch popup list and wait for user input, disable other Ui key presses first:
       
  1242     AllowDialerAndAppKeyPress( EFalse );
       
  1243     // After input, destroy popup list
       
  1244     //
       
  1245     TInt popupRetVal = iSearchFilterPopupList->ExecuteLD(); 
       
  1246     iSearchFilterPopupList = NULL;
       
  1247     AllowDialerAndAppKeyPress( ETrue );
       
  1248 
       
  1249     if( popupRetVal )
       
  1250         {
       
  1251         TInt currentDeviceIndex = searchFilterListBox->CurrentItemIndex();
       
  1252 		switch(currentDeviceIndex)
       
  1253 			{
       
  1254 			case EBTSearchForAll:				
       
  1255 				iDesiredDeviceClass = TBTDeviceClass(0,0,0);  				
       
  1256 				break;
       
  1257 			case EBTSearchForAudio:
       
  1258 				iDesiredDeviceClass = TBTDeviceClass(0,EMajorDeviceAV,0);					
       
  1259 				break;
       
  1260 				 
       
  1261 			case EBTSearchForPhone:	
       
  1262 				iDesiredDeviceClass = TBTDeviceClass(0,EMajorDevicePhone,0);					
       
  1263 				break;	 
       
  1264 				
       
  1265 			case EBTSearchForComputer:					
       
  1266 				iDesiredDeviceClass = TBTDeviceClass(0,EMajorDeviceComputer,0);
       
  1267 				break;
       
  1268 				 	 
       
  1269 			case EBTSearchForInput:
       
  1270 				iDesiredDeviceClass = TBTDeviceClass(0,EMajorDevicePeripheral,0);
       
  1271 				break;	 
       
  1272 				 			
       
  1273 			default:                    
       
  1274 				break;
       
  1275 			}
       
  1276         } 
       
  1277 
       
  1278 	CleanupStack::PopAndDestroy(); //searchFilterListBox 
       
  1279 	iDeviceListRows->Reset();
       
  1280 
       
  1281     if( !popupRetVal )
       
  1282         {
       
  1283         iDevSearchObserver->NotifyDeviceSearchCompleted(KErrCancel);
       
  1284         }
       
  1285     else
       
  1286         {
       
  1287         DeviceSearchUiL();
       
  1288         }
       
  1289     
       
  1290 	FLOG(_L("[BTNOTIF]\t CBTInqUI::SelectSearchCategoryL() complete"));
       
  1291 	}
       
  1292    
       
  1293 //------------------------------------------------------------------------------
       
  1294 // CBTInqUI: AddItemToSearchFilterL
       
  1295 //------------------------------------------------------------------------------
       
  1296 void CBTInqUI::AddItemToSearchFilterL ( TInt aResourceId )
       
  1297 	{
       
  1298 	HBufC* formatString = HBufC::NewLC( KBTAllPurposeBufferLength );
       
  1299     HBufC* string = iEikonEnvRef.AllocReadResourceLC( aResourceId );
       
  1300     formatString->Des().Append( *string );
       
  1301     CleanupStack::PopAndDestroy(); // string
       
  1302     iDeviceListRows->AppendL( *formatString );
       
  1303     CleanupStack::Pop(); // formatString
       
  1304 	}
       
  1305 
       
  1306 void CBTInqUI::GetColorIconL( TFileName& aFilename, TAknsItemID aItemID, 
       
  1307                         TInt aPic, TInt aPicmask, CAknIconArray* aIconList )
       
  1308     {
       
  1309     CFbsBitmap* bitmap = NULL;
       
  1310     CFbsBitmap* mask = NULL;
       
  1311     
       
  1312     AknsUtils::CreateColorIconLC(AknsUtils::SkinInstance(), aItemID,
       
  1313                                 KAknsIIDQsnIconColors,
       
  1314                                 EAknsCIQsnIconColorsCG13,
       
  1315                                 bitmap, mask, aFilename, aPic, aPicmask, KRgbBlack);
       
  1316     
       
  1317     CGulIcon* icon = CGulIcon::NewL(bitmap, mask);
       
  1318     CleanupStack::Pop(2); // bitmap, mask;
       
  1319     CleanupStack::PushL(icon);    
       
  1320     aIconList->AppendL( icon );
       
  1321     CleanupStack::Pop(); // icon
       
  1322     }
       
  1323 
       
  1324 TBool CBTInqUI::IsActiveVoIPOverWLAN()
       
  1325     {
       
  1326     TInt error = KErrNone;
       
  1327     
       
  1328     // check VoIP over WLAN is on going or not:
       
  1329     //
       
  1330     TInt wlanStatus = 0;
       
  1331     error = RProperty::Get(KPSUidWlan, KPSWlanIndicator, wlanStatus);                       
       
  1332     FTRACE( FPrint( _L( "CBTInqNotifier::CheckActivationOfVoIPOverWLAN() WLAN state: %d (error %d)" ), wlanStatus, error ) );
       
  1333     if (error)
       
  1334         {
       
  1335         return EFalse;
       
  1336         }
       
  1337 
       
  1338     TInt callState = 0;
       
  1339     error = RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallType, callState ); 
       
  1340     FTRACE( FPrint( _L( "CBTInqNotifier::CheckActivationOfVoIPOverWLAN() call state: %d (error %d)" ), callState, error ) );
       
  1341     if( error == KErrNone &&
       
  1342       (wlanStatus == EPSWlanIndicatorActive || wlanStatus == EPSWlanIndicatorActiveSecure)&&
       
  1343       callState == EPSCTsyCallTypeVoIP )
       
  1344         {
       
  1345         FTRACE( FPrint( _L( " VoIP call ongoing, do not allow inquiry!" ) ) );
       
  1346         return ETrue;
       
  1347         }
       
  1348     return EFalse;
       
  1349     }
       
  1350 
       
  1351 void CBTInqUI::DoDeviceFrontListSelection()
       
  1352     {
       
  1353     TRAPD(err, DisplayDevicesFrontListL());
       
  1354     if (err)
       
  1355         {
       
  1356         iDevSearchObserver->NotifyDeviceSearchCompleted(err);
       
  1357         }
       
  1358     }
       
  1359 
       
  1360 void CBTInqUI::HandleDeviceSelectionL(CBTDevice* aDev)
       
  1361     {
       
  1362     iDevParams = TBTDeviceResponseParams();
       
  1363     iDevParams.SetDeviceAddress( aDev->BDAddr());
       
  1364     iDevParams.SetDeviceClass( aDev->DeviceClass());
       
  1365     if( aDev->IsValidFriendlyName())
       
  1366         {
       
  1367         iDevParams.SetDeviceName( aDev->FriendlyName());
       
  1368         }
       
  1369     else if( aDev->IsValidDeviceName())
       
  1370         {
       
  1371         iDevParams.SetDeviceName( BTDeviceNameConverter::ToUnicodeL( aDev->DeviceName() ) );
       
  1372         }
       
  1373     //check if this device is blocked
       
  1374     TInt index = LookupFromDevicesArray(iLastUsedDevicesArray, aDev);
       
  1375     TBool blocked = ( index >= 0 && iLastUsedDevicesArray->At( index )->GlobalSecurity().Banned() );
       
  1376     if (!blocked)
       
  1377         {
       
  1378         iDevSearchObserver->NotifyDeviceSearchCompleted(KErrNone, iDevParams);
       
  1379         return;
       
  1380         }
       
  1381 
       
  1382     TInt toUnblk = QueryUnblockDeviceL(aDev);
       
  1383     if (!toUnblk)
       
  1384         {
       
  1385         iDevSearchObserver->NotifyDeviceSearchCompleted(KErrCancel);
       
  1386         return;
       
  1387         }
       
  1388     TInt err = UnblockDevice( index );
       
  1389     if (err)
       
  1390         {
       
  1391         iDevSearchObserver->NotifyDeviceSearchCompleted(err);
       
  1392         }  
       
  1393     // otherwise NotifyDeviceSearchCompleted will be called after unblock is really done.
       
  1394     }
       
  1395 
       
  1396 void CBTInqUI::AllowDialerAndAppKeyPress( TBool aAllow )
       
  1397     {
       
  1398     CEikAppUi* const eikAppUi = CEikonEnv::Static()->EikAppUi();
       
  1399     if ( aAllow)
       
  1400         {
       
  1401         // Enable dialer
       
  1402         static_cast<CAknAppUi*>( eikAppUi )->SetKeyEventFlags( 0x00 );     
       
  1403         // Activate apps key.
       
  1404         // Ignore the return error code as we can do nothing if this operation fails
       
  1405         (void) static_cast<CAknNotifierAppServerAppUi*>(eikAppUi)->SuppressAppSwitching(EFalse);         
       
  1406         }
       
  1407     else
       
  1408         {
       
  1409         // Disable dialer
       
  1410         static_cast<CAknAppUi*>( eikAppUi )->SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort | 
       
  1411                 CAknAppUiBase::EDisableSendKeyLong);
       
  1412         // Deactivate apps key
       
  1413         (void) static_cast<CAknNotifierAppServerAppUi*>(eikAppUi)->SuppressAppSwitching(ETrue); 
       
  1414         }
       
  1415     FTRACE( FPrint( _L( "CBTInqUI::AllowDialerAndAppKeyPress : %d" ), aAllow ) );
       
  1416     }
       
  1417 
       
  1418 TBool CBTInqUI::HaveDevsWithPartialName(TInt& aFirstFoundIndex )
       
  1419     {
       
  1420     FLOG(_L("[BTNOTIF]\t CBTInqUI::HaveDevsWithPartialName()."));
       
  1421     for (TInt i = 0; i < iLastSeenDevicesNameComplete.Count(); i++)
       
  1422         {
       
  1423         if (!iLastSeenDevicesNameComplete[i])
       
  1424             {
       
  1425             FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HaveDevsWithPartialName() index %d is partial."), i));
       
  1426 
       
  1427             aFirstFoundIndex = i;
       
  1428             return ETrue;
       
  1429             }
       
  1430         }
       
  1431     return EFalse;
       
  1432     }
       
  1433 
       
  1434 // End of File