⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bluetoothdevicediscoverer.cpp

📁 roids60 game symbian os application development
💻 CPP
字号:
/*============================================================================ Name			: BlueToothDeviceDiscoverer.cpp Author	  		:  Copyright   	: Description 	: Implementation============================================================================*/// INCLUDE FILES#include <btextnotifiers.h>#include "BluetoothDeviceDiscoverer.h"#include "common.hrh"/*============================================================================CBluetoothDeviceDiscoverer's two stage constructor============================================================================*/CBluetoothDeviceDiscoverer* CBluetoothDeviceDiscoverer::NewL(MBluetoothDeviceDiscovererObserver& aObs)	{    CBluetoothDeviceDiscoverer* self = new (ELeave) CBluetoothDeviceDiscoverer(aObs);    CleanupStack::PushL(self);    self->ConstructL();    CleanupStack::Pop();    return self;	}/*============================================================================CBluetoothDeviceDiscoverer's second phase constructor ============================================================================*/void CBluetoothDeviceDiscoverer::ConstructL()	{	//Create an RNotifier object, and connect it with RNotifier::Connect()	User::LeaveIfError(iBTDevicesNotifier.Connect()); 		}/*============================================================================CBluetoothDeviceDiscoverer's constructor ============================================================================*/CBluetoothDeviceDiscoverer::CBluetoothDeviceDiscoverer(MBluetoothDeviceDiscovererObserver& aObs) :	CActive(CActive::EPriorityStandard), iObserver(aObs)	{	CActiveScheduler::Add(this);	}/*============================================================================CBluetoothDeviceDiscoverer's destructor============================================================================*/CBluetoothDeviceDiscoverer::~CBluetoothDeviceDiscoverer()	{	Cancel();	//After using a RNotifier object we need to close it.		iBTDevicesNotifier.Close();	}	/*============================================================================DoCancel is called as part of the active object's Cancel().Cancel the notifier.============================================================================*/void CBluetoothDeviceDiscoverer::DoCancel()	{	//If the user dismisses the RNotifier's dialog without selecting any devices then we call	//RNotifier::CancelNotifier with the same dialog UID (KDeviceSelectionNotifierUid) we used	//in RNotifier::StartNotifierAndGetResponse.	iBTDevicesNotifier.CancelNotifier(KDeviceSelectionNotifierUid);	}/*============================================================================Displays the BT devices in range for the player to choose from============================================================================*/void CBluetoothDeviceDiscoverer::DiscoverAndSelectDeviceL(const TBTDeviceSelectionParamsPckg& aSelectionFilter)	{	if(IsActive())		{			User::Leave(KErrInUse);		}	else		{				//We ask RNotifier to start the search for other BT devices in range. Seraching for BT devices is done		//asynchronously by calling RNotifier::StartNotifierAndGetResponse. Application can filter the search		//of BT devices by passing a TBTDeviceSelectionParams wrapped in a TBTDeviceSelectionParamsPckg		//pckg buffer. In our example we passed the UID of the authorisation plug-in (KDeviceSelectionNotifierUid)		//that invokes the BT device selection dialog, the device and/or service classes by which to filter		//suitable remote devices (RPS's service class KRPS_BTServiceID), a Bluetooth address object		//that on completion of the dialog will hold information about the device the user selected in		//a packaged TBTDeviceResponseParams.		iBTDevicesNotifier.StartNotifierAndGetResponse(iStatus, KDeviceSelectionNotifierUid, aSelectionFilter, iResponse);		SetActive();		}	}/*============================================================================Handles CBluetoothConnector's completion events============================================================================*/void CBluetoothDeviceDiscoverer::RunL()	{	//We pass on to the engine the BT device address the user selected otherwise we pass on the error	if(iStatus.Int() == KErrNone)		{		iObserver.OnDeviceDiscoveryComplete(iResponse);		}	else		{			iObserver.OnDeviceDiscoveryErr(iStatus.Int());			}	}/*============================================================================Handles a leave occurring in the request completion event handler RunL().Reports the error to the observer============================================================================*/TInt CBluetoothDeviceDiscoverer::RunError(TInt aError)	{	iObserver.OnDeviceDiscoveryErr(aError);	return KErrNone;	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -