ImagePrint/ImagePrintEngine/DeviceProtocols/btprotocol/src/crsbtdiscoverengine.cpp
branchRCL_3
changeset 20 159fc2f68139
parent 17 26673e532f65
child 21 d59c248c9d36
equal deleted inserted replaced
17:26673e532f65 20:159fc2f68139
     1 /*
       
     2 * Copyright (c) 2004-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:  Contains the CRsBtDiscoverEngine class definition and its observer
       
    15 * 	 		     definition (MBtDiscoveryObserver).
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "crsbtdiscoverengine.h"
       
    21 #include "cbtdiscover.h"
       
    22 #include "crsbtdevice.h"
       
    23 #include "rsutils.h"
       
    24 #include "cbtdevicecontainer.h"
       
    25 #include "btprotocolconsts.h"
       
    26 #include "clog.h"
       
    27 
       
    28 //////////////////////////////////////////////////////////////////////
       
    29 // Construction/Destruction
       
    30 //////////////////////////////////////////////////////////////////////
       
    31 CRsBtDiscoverEngine* CRsBtDiscoverEngine::NewL(MBtDiscoveryObserver& aObs)
       
    32 {
       
    33 	CRsBtDiscoverEngine* self = new (ELeave) CRsBtDiscoverEngine(aObs);
       
    34 	CleanupStack::PushL(self);
       
    35 	self->ConstructL();
       
    36 	CleanupStack::Pop(self);
       
    37 	return self;
       
    38 }
       
    39 
       
    40 
       
    41 CRsBtDiscoverEngine::CRsBtDiscoverEngine(MBtDiscoveryObserver& aObs)
       
    42 	: CActive(CActive::EPriorityStandard),
       
    43 	iState(EFindingDevices),
       
    44 	iObserver(aObs),
       
    45 	iDevice(NULL),
       
    46 	iRequestedProtocols(0)
       
    47 {
       
    48 		CActiveScheduler::Add(this);
       
    49 }
       
    50 
       
    51 /**
       
    52  * @brief Second phase constructor.
       
    53  *
       
    54  * @param aFolderToUser Folder where the device cache will be read/stored.
       
    55  */
       
    56 void CRsBtDiscoverEngine::ConstructL()
       
    57 	{
       
    58 	iDiscover = CBtDiscover::NewL();
       
    59 	iDelayFindDevices.CreateLocal();
       
    60 	iTimeout = CBtTimer::NewL( *this );
       
    61 	}
       
    62 
       
    63 /**
       
    64  * @brief Destructor.
       
    65  */
       
    66 CRsBtDiscoverEngine::~CRsBtDiscoverEngine()
       
    67 	{
       
    68 	LOG("CRsBtDiscoverEngine::~CRsBtDiscoverEngine begin");
       
    69 	Cancel();
       
    70 	delete iDiscover;
       
    71 	ResetDevice();
       
    72 	iFoundBeforeArray.Close();
       
    73 	iDelayFindDevices.Close();
       
    74 	delete iTimeout;
       
    75 	LOG("CRsBtDiscoverEngine::~CRsBtDiscoverEngine end");
       
    76 	}
       
    77 
       
    78 /**
       
    79  * @brief Cancels asynchronous tasks of this active object. Terminates the Device and Service Discovery.
       
    80  */
       
    81 void CRsBtDiscoverEngine::DoCancel()
       
    82 	{
       
    83 	LOG("CRsBtDiscoverEngine::DoCancel begin");
       
    84 	ResetDevice();
       
    85 	iTimeout->Cancel();
       
    86 	iDiscover->Stop();
       
    87 	iDiscover->StopSDP();
       
    88 	iDelayFindDevices.Cancel();
       
    89 	iFoundBeforeArray.Reset();
       
    90 	LOG("CRsBtDiscoverEngine::DoCancel end");
       
    91 	}
       
    92 
       
    93 /**
       
    94  * @brief Called by the Active Scheduler when an asynchronous call finish.
       
    95  */
       
    96 void CRsBtDiscoverEngine::RunL()
       
    97 	{
       
    98 	LOG1("CRsBtDiscoverEngine::RunL iStatus.Int(): %d", iStatus.Int());
       
    99 	LOG1("CRsBtDiscoverEngine::RunL iState: %d", iState);
       
   100 
       
   101 	iTimeout->Cancel();
       
   102 
       
   103 	if( iStatus != KErrNone )
       
   104 		{
       
   105 		switch( iState )
       
   106 			{
       
   107 			case EDelayFindDevices:
       
   108 				LOG1("[CRsBtDiscoverEngine::RunL]\t Try to find again... (error %d)", iStatus.Int());
       
   109 				break;
       
   110 			case EFindingDevices:
       
   111 				if( iStatus == (KHCIErrorBase - ECommandDisallowed) )
       
   112 					{
       
   113 					LOG("[CRsBtDiscoverEngine::RunL]\t Retry discovery");
       
   114 					iState = EDelayFindDevices;
       
   115 					iDelayFindDevices.Cancel();
       
   116 					iDelayFindDevices.After(iStatus,500000);
       
   117 					SetActive();
       
   118 					break;
       
   119 					}
       
   120 				else if (iStatus == KErrHostResNoMoreResults)
       
   121 					{
       
   122 					LOG("[CRsBtDiscoverEngine::RunL]\t No more devices, all found.");
       
   123 					ResetDevice();
       
   124 					//Make call to callback function informing that all is done
       
   125 					iObserver.HandleDiscoveryEvent(MBtDiscoveryObserver::EDoneFindingPrinters, KErrNone);
       
   126 					break;
       
   127 					}
       
   128 			default:
       
   129 				LOG1("[CRsBtDiscoverEngine::RunL]\t Leave error %d", iStatus.Int());
       
   130 				User::Leave(iStatus.Int());
       
   131 				break;
       
   132 			}
       
   133 		}
       
   134 	else
       
   135 		{
       
   136 			switch( iState )
       
   137 				{
       
   138 				case EFindingDevices:
       
   139 					if( CheckBtDevice() )
       
   140 						{
       
   141 						TNameRecord name = iDiscover->GetNameRecord();
       
   142 						TBTDevAddr addr = ((TBTSockAddr)name.iAddr).BTAddr();
       
   143 						TInt nPos = iFoundBeforeArray.Find( addr );
       
   144 
       
   145 						if( nPos == KErrNotFound )
       
   146 							{
       
   147 							// found new printer, add to list and check service capabilities
       
   148 							User::LeaveIfError( iFoundBeforeArray.Append( addr ) );
       
   149 							ServiceDiscoveryL();
       
   150 							break;
       
   151 							}
       
   152 						}
       
   153 						ContinueDiscovery();
       
   154 					break;
       
   155 				case EGettingServices:
       
   156 					if( ComposeDeviceL() )
       
   157 						{
       
   158 						LOG1("CRsBtDiscoverEngine::RunL wanted device: %S", &(iDiscover->GetDeviceName()));
       
   159 						//Make call to callback function informing that new device has been found.
       
   160 						iObserver.HandleDiscoveryEvent(MBtDiscoveryObserver::EFoundBtPrinter, iStatus.Int());
       
   161 						}
       
   162 					//And search for more devices
       
   163 					ContinueDiscovery();
       
   164 					break;
       
   165 
       
   166 				case EDelayFindDevices:
       
   167 					StartDiscovery();
       
   168 					break;
       
   169 				default:
       
   170 					break;
       
   171 			}
       
   172 		}
       
   173 
       
   174 	LOG("CRsBtDiscoverEngine::RunL end");
       
   175 	}
       
   176 
       
   177 TInt CRsBtDiscoverEngine::RunError(TInt aError)
       
   178 	{
       
   179 	LOG1("CRsBtDiscoverEngine::RunError aError: %d", aError);
       
   180 	Stop();
       
   181 	
       
   182 	//Make call to callback function informing that there was an error.
       
   183 	iObserver.HandleDiscoveryEvent(MBtDiscoveryObserver::EErrorDuringDiscover,iStatus.Int());
       
   184 	LOG("CRsBtDiscoverEngine::RunError end");
       
   185 	return KErrNone;
       
   186 	}
       
   187 
       
   188 /**
       
   189  * @brief Starts the asynchronous discovery of devices.
       
   190  *
       
   191  * Starts the asynchronous discovery of devices, it will first report
       
   192  * the devices that are stored on the cache from a previous run.
       
   193  * If no devices were returned from the cache, it will start the
       
   194  * Bluetooth discovery process inmediatly.
       
   195  *
       
   196  * @param aRequestedProtocols The requested protocols.
       
   197  */
       
   198 void CRsBtDiscoverEngine::Start(TUint aRequestedProtocols)
       
   199 	{
       
   200 	LOG1("[CRsBtDiscoverEngine::StartL]\t aRequestedProtocols: %d", aRequestedProtocols);
       
   201 	iRequestedProtocols = aRequestedProtocols;
       
   202 	iFoundBeforeArray.Reset();
       
   203 
       
   204 	if(!iDiscover->IsFindingDevices() && !iDiscover->IsDoingSDP())
       
   205 		{
       
   206 		LOG("[CRsBtDiscoverEngine::StartL]\t inside IF clause");
       
   207 		Cancel();
       
   208 		ResetDevice();
       
   209 
       
   210 		StartDiscovery();
       
   211 		}
       
   212 
       
   213 	LOG("[CRsBtDiscoverEngine::StartL]\t exit");
       
   214 	}
       
   215 
       
   216 /**
       
   217  * @brief Stops the asynchronous discovery of devices.
       
   218  *
       
   219  * Starts the asynchronous discovery of devices, it will first report
       
   220  * the devices that are stored on the cache from a previous run.
       
   221  * If no devices were returned from the cache, it will start the
       
   222  * Bluetooth discovery process inmediatly.
       
   223  *
       
   224  * @param aRequestedProtocols The requested protocols.
       
   225  */
       
   226 void CRsBtDiscoverEngine::Stop()
       
   227 	{
       
   228 	LOG("[CRsBtDiscoverEngine::Stop]\t");
       
   229 	
       
   230 	if(IsActive())
       
   231 		Cancel();
       
   232 	else
       
   233 		DoCancel();
       
   234 	
       
   235 	LOG("[CRsBtDiscoverEngine::Stop]\t exit");
       
   236 	}
       
   237 
       
   238 /**
       
   239  * @brief Start the asynchronous Bluetooth discovery process.
       
   240  *
       
   241  * This function calls the method CBtDiscover::FindDevicesL() which
       
   242  * will cause RunL() with status EFindingDevices to be called when a
       
   243  * device is discovered. All bluetooth devices will be find, and RunL()
       
   244  * will determine if it might be a device that we can use.
       
   245  *
       
   246  * @sa FindMoreDevices()
       
   247  */
       
   248 void CRsBtDiscoverEngine::StartDiscovery()
       
   249 	{
       
   250 	LOG("[CRsBtDiscoverEngine::StartDiscovery]\t begin");
       
   251 	iState = EFindingDevices;
       
   252 	iDiscover->Start( iStatus );
       
   253 
       
   254 	LOG1( "[CRsBtDiscoverEngine::StartDiscovery]\t iStatus.Int(): 0x%X", iStatus.Int() );
       
   255 	if( iStatus == KErrNotSupported )
       
   256 	{
       
   257 		// cleanup if error
       
   258 		iDiscover->Stop();
       
   259 		TRequestStatus *tmpStat = &iStatus;
       
   260 		User::RequestComplete(tmpStat, KErrHostResNoMoreResults);
       
   261 	}
       
   262 	else
       
   263 	{
       
   264 		iTimeout->Cancel();
       
   265 		iTimeout->Start(KDiscoveryDelay);
       
   266 	}
       
   267 	SetActive();
       
   268 	LOG("[CRsBtDiscoverEngine::StartDiscovery]\t end");
       
   269 	}
       
   270 
       
   271 /**
       
   272  * @brief Find the next device.
       
   273  *
       
   274  * It the current state is ESendingCached this will call
       
   275  * ReportCachedDeviceL() again to fetch the next cached device.
       
   276  *
       
   277  * If the state is ERemovingStale it will call
       
   278  * RemoveStalePrintersL() again to remove the next stale device.
       
   279  *
       
   280  * Otherwise, it will call CBtDiscover::FindMoreDevices() to
       
   281  * discover another device.
       
   282  */
       
   283 void CRsBtDiscoverEngine::ContinueDiscovery()
       
   284 	{
       
   285 	LOG1("[CRsBtDiscoverEngine::ContinueDiscoveryL]\t begin iState: %d", iState);
       
   286 
       
   287 	Cancel();
       
   288 
       
   289 	iState = EFindingDevices;
       
   290 	iDiscover->GetNextDevice(iStatus);
       
   291 	iTimeout->Cancel();
       
   292 	iTimeout->Start(KDiscoveryDelay);
       
   293 	SetActive();
       
   294 
       
   295 	}
       
   296 
       
   297 void CRsBtDiscoverEngine::HandleTimeoutL()
       
   298 	{
       
   299 	LOG("[CRsBtDiscoverEngine::HandleTimeoutL]\t begin");
       
   300 
       
   301 	Stop();
       
   302 	if (iState == EGettingServices && IsActive())
       
   303 	{
       
   304 		LOG("[CRsBtDiscoverEngine::StopServiceDiscovery]\t complete iStatus IS IT OK???");
       
   305 		TRequestStatus *tmpStat = &iStatus;
       
   306 		User::RequestComplete(tmpStat, KErrNone);
       
   307 	}
       
   308 	iObserver.HandleDiscoveryEvent(MBtDiscoveryObserver::EDoneFindingPrinters, KErrNone);
       
   309 
       
   310 	LOG("[CRsBtDiscoverEngine::HandleTimeoutL]\t end");
       
   311 	}
       
   312 
       
   313 /**
       
   314  * @brief Determine if the BT Device could be a device we need.
       
   315  *
       
   316  * When any BT Device is discovered RunL() will be called, and it
       
   317  * will use this function to do a first check on the device to see
       
   318  * if it is a device that we could use, or if it is a device that
       
   319  * is totally unrelated to printing and we can ignore rigth away.
       
   320  *
       
   321  * Currently we are checking if the device is either a Rendering
       
   322  * device or a Computer device. If it is a computer it should support
       
   323  * Object Transfers to be useful.
       
   324  *
       
   325  * With this first check we can't be 100% sure if this is a device
       
   326  * that we can use. If it is a potentially useful device we will need
       
   327  * to do a Service Discovery (SDP) check later.
       
   328  *
       
   329  * @return ETrue if this is an appropiate BT Device, EFalse if this device must be ignored.
       
   330  *
       
   331  * @sa ServiceDiscoveryL()
       
   332  */
       
   333 TBool CRsBtDiscoverEngine::CheckBtDevice()
       
   334 	{
       
   335 	// Algorithm to understand Device / Service Class bits
       
   336 
       
   337 	//1. Are "Rendering"0x40000 and "Object Transfer"0x100000 bits set in the Major Service
       
   338 	//   Class field? If not, check if it is a Computer and Supports Object Transfer.
       
   339 	//2. If it is a Rendering device and the Major Device Class is "Imaging"0x600, is the "Printer"0x80 bit set in
       
   340 	//   the Minor Device Class field? If not, ignore this Bluetooth device.
       
   341 	//3. If the device was a Computer and it supports Object Transfer, check that
       
   342 	//   the MinorDeviceClass Field is any of  Desktop | Laptop | Server.
       
   343 
       
   344 	// http://www.bluetooth.org/assigned-numbers/baseband.htm
       
   345 	// http://www.bluetooth.org/assigned-numbers/sdp.htm
       
   346 
       
   347 	TUint32 devClass = iDiscover->GetDeviceClass().DeviceClass();
       
   348 	LOG1("[CRsBtDiscoverEngine::CheckBtDevice]\t devClass: %d", devClass);
       
   349 
       
   350 	TBool potentialDevice = EFalse;
       
   351 	
       
   352 	if( !(devClass & KBTMjrSvcClassObjectTransfer_V2) )
       
   353 	{
       
   354 		LOG("[CRsBtDiscoverEngine::CheckBtDevice]\t !KBTMjrSvcClassObjectTransfer_V2 -> return");
       
   355 		return potentialDevice;
       
   356 	}
       
   357 	
       
   358 	if (devClass & KBTMjrSvcClassRendering_V2)
       
   359 	{
       
   360 		if( (devClass & KBTMjrDevClassImaging_V2) && !(devClass & KBTMinDevClassPrinter_V2) )
       
   361 		{
       
   362 			// Other imaging device
       
   363 			LOG("[CRsBtDiscoverEngine::CheckBtDevice]\t other imaging device");
       
   364 			potentialDevice = EFalse;
       
   365 		}
       
   366 		else
       
   367 		{
       
   368 			// Possibly a BPP printer,
       
   369 			LOG("[CRsBtDiscoverEngine::CheckBtDevice]\t KBTMjrSvcClassRendering_V2 and KBTMjrSvcClassObjectTransfer_V2");
       
   370 			potentialDevice = ETrue;
       
   371 		}
       
   372 	}
       
   373 	else if(devClass & KBTMjrDevClassComputer)
       
   374 	{
       
   375 		// Note: If it is a Rendering Device, it could support BPP or OPP or both. So we will need to do a SDP to know.
       
   376 		// On the other hand, if the Device is of Class Computer, we can check here if we want the device or not
       
   377 		// by checking if iRequestedProtocols contains KImagePrint_PrinterProtocol_OPP_PC. If not, then we don't want
       
   378 		// any Computer Devices.
       
   379 
       
   380 		
       
   381 		if ( (iRequestedProtocols & KImagePrint_PrinterProtocol_OPP_PC) &&
       
   382 		     ( (devClass & KBTMinDevClassDesktop) || 
       
   383 		       (devClass & KBTMinDevClassServer) || 
       
   384 		       (devClass & KBTMinDevClassLaptop) ) )
       
   385 		{
       
   386 			LOG("[CRsBtDiscoverEngine::CheckBtDevice] OPP Computers were requested and this is a computer");
       
   387 			potentialDevice = ETrue;
       
   388 		}
       
   389 	}
       
   390 	
       
   391 	LOG1("[CRsBtDiscoverEngine::CheckBtDevice]\t potentialDevice: %d", potentialDevice);
       
   392 	return potentialDevice;
       
   393 	}
       
   394 
       
   395 /**
       
   396  * @brief Start SDP (Service Discovery Protocol) on a device.
       
   397  *
       
   398  * Start SDP (Service Discovery Protocol) on a device to make sure that
       
   399  * it supports the services needed by this system. The Services that
       
   400  * we are looking for are DirectPrinting (BPP) and OBEX Object Push (OPP).
       
   401  *
       
   402  * This method will only call CBtDiscover::VerifyServiceSupportL() which
       
   403  * is an asynchronous call. RunL() will be called back when the results are
       
   404  * ready.
       
   405  */
       
   406 void CRsBtDiscoverEngine::ServiceDiscoveryL()
       
   407 	{
       
   408 		iDiscover->GetSupportedServicesL(iStatus, KBtMaskObexLevel);
       
   409 		iState = EGettingServices;
       
   410 		SetActive();
       
   411 	}
       
   412 
       
   413 void CRsBtDiscoverEngine::StopServiceDiscovery()
       
   414 {
       
   415 	LOG1("[CRsBtDiscoverEngine::StopServiceDiscovery]\t iState %d",iState);
       
   416 	if (iState == EGettingServices && IsActive())
       
   417 	{
       
   418 		LOG("[CRsBtDiscoverEngine::StopServiceDiscovery]\t complete iStatus IS IT OK???");
       
   419 		TRequestStatus *tmpStat = &iStatus;
       
   420 		User::RequestComplete(tmpStat, KErrNone);
       
   421 	}
       
   422 	iDiscover->StopSDP();
       
   423 }
       
   424 
       
   425 /**
       
   426  * @brief Compose the device.
       
   427  *
       
   428  * When a Service Discovery has finished, we need to see
       
   429  * if the services that we want were found on the device.
       
   430  * This function will also tell if this device supports a
       
   431  * protocol that was requested.
       
   432  *
       
   433  * If a device was determined to support BPP and/or OPP it 
       
   434  * supports a protocol this library can manage.
       
   435  *
       
   436  * For example:
       
   437  * If the libray is requesting devices that support
       
   438  * the protocol KImagePrint_PrinterProtocol_OPP_Printer and the
       
   439  * current device supports only KImagePrint_PrinterProtocol_BPP
       
   440  * then this device will be handled because this library
       
   441  * can manage BPP Printers. But this device will not be used because
       
   442  * the library is currently requesting only the OPP_Printer protocol.
       
   443  * In this case ComposeDeviceL() will return EFalse, indicating that
       
   444  * we won't use this device.
       
   445  *
       
   446  * @return ETrue if this is a device that we can use, EFalse if this device cannot be used.
       
   447  */
       
   448 TBool CRsBtDiscoverEngine::ComposeDeviceL()
       
   449 	{
       
   450 	LOG("[CRsBtDiscoverEngine::ComposeDeviceL]\t begin");
       
   451 
       
   452 	TBool wantedDevice( EFalse );
       
   453 	TNameRecord name = iDiscover->GetNameRecord();
       
   454 	ResetDevice();
       
   455 	CRsBtDevice *device = CRsBtDevice::NewLC( name );
       
   456 
       
   457 	TUint supportedProtocols( 0 );
       
   458 	if( iDiscover->IsBPPSupported() )
       
   459 		{
       
   460 		LOG("[CRsBtDiscoverEngine::ComposeDeviceL]\t BPP supported");
       
   461 		// We indicate that this device does support this protocol
       
   462 		supportedProtocols = KImagePrint_PrinterProtocol_BPP;
       
   463 		// But we still need to see if that protocol was requested.
       
   464 		if( iRequestedProtocols & KImagePrint_PrinterProtocol_BPP )
       
   465 			{
       
   466 			device->SetBPPPort( iDiscover->GetBPPPort() );
       
   467 			device->SetSTSPort( iDiscover->GetSTSPort() );
       
   468 			wantedDevice = ETrue;
       
   469 			}
       
   470 		}
       
   471 
       
   472 	if( iDiscover->IsOPPSupported() )
       
   473 		{
       
   474 		// It must be either a Computer or a Printer, but NOT both!
       
   475 		TBTDeviceClass deviceClass = device->DeviceClass();
       
   476 
       
   477 		if( deviceClass.DeviceClass() & KBTMjrDevClassComputer )
       
   478 			{
       
   479 			LOG("[CRsBtDiscoverEngine::ComposeDeviceL]\t OPP computer");
       
   480 			supportedProtocols |= KImagePrint_PrinterProtocol_OPP_PC;
       
   481 			if( iRequestedProtocols & KImagePrint_PrinterProtocol_OPP_PC )
       
   482 				{
       
   483 				device->SetOPPPort(iDiscover->GetOPPPort());
       
   484 				wantedDevice = ETrue;
       
   485 				}
       
   486 			}
       
   487 		else
       
   488 			{
       
   489 			LOG("[CRsBtDiscoverEngine::ComposeDeviceL]\t OPP printer(?)");
       
   490 			supportedProtocols |= KImagePrint_PrinterProtocol_OPP_Printer;
       
   491 			if( iRequestedProtocols & KImagePrint_PrinterProtocol_OPP_Printer )
       
   492 				{
       
   493 				device->SetOPPPort(iDiscover->GetOPPPort());
       
   494 				wantedDevice = ETrue;
       
   495 				}
       
   496 			}
       
   497 		}
       
   498 
       
   499 	// Store if wanted device
       
   500 	if( wantedDevice )
       
   501 		{
       
   502 		LOG1("[CRsBtDiscoverEngine::ComposeDeviceL]\t iRequestedProtocols: %d", iRequestedProtocols);
       
   503 		LOG1("[CRsBtDiscoverEngine::ComposeDeviceL]\t supportedProtocols: %d", supportedProtocols);
       
   504 		device->SetSupportedProtocols(supportedProtocols);
       
   505 		device->SetPrinterModelL(iDiscover->GetPrinterModel());
       
   506 		device->SetVendor(iDiscover->GetVendor());
       
   507 		device->SetJustFound(ETrue);
       
   508 
       
   509 		iDevice = device;
       
   510 		CleanupStack::Pop(device);
       
   511 		device = NULL;
       
   512 		LOG1("[CRsBtDiscoverEngine::ComposeDeviceL]\t iDevice: %d", iDevice);
       
   513 		}
       
   514 	else
       
   515 		{
       
   516 		LOG("[CRsBtDiscoverEngine::ComposeDeviceL]\t NOT wanted device, don't store");
       
   517 		CleanupStack::PopAndDestroy(device);
       
   518 		}
       
   519 
       
   520 	// We have now added this device to the cache, along with the protocols
       
   521 	// that it supports. However we wont report it if it does not support
       
   522 	// the specific protocol that was requested.
       
   523 
       
   524 	LOG1("[CRsBtDiscoverEngine::ComposeDeviceL]\t end with: %d", wantedDevice);
       
   525 	return wantedDevice;
       
   526 	}
       
   527 
       
   528 /**
       
   529  * @brief Obtain the current device.
       
   530  *
       
   531  * @param[out] aSequence Will obtain the position the current device.
       
   532  *
       
   533  * @return A reference to the current CRsBtDevice.
       
   534  */
       
   535 CRsBtDevice& CRsBtDiscoverEngine::GetDevice()
       
   536 	{
       
   537 	return *iDevice;
       
   538 	}
       
   539 
       
   540 void CRsBtDiscoverEngine::ResetDevice()
       
   541 {
       
   542 	if(iDevice)
       
   543 		{
       
   544 		delete iDevice;
       
   545 		iDevice = NULL;
       
   546 		}
       
   547 }
       
   548 
       
   549 //  End of File
       
   550