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

📄 bluetoothdevicesearcher.cpp

📁 qaSDQDaca<FCSASDAVCASC SDVFDSVDF
💻 CPP
字号:
 /*
============================================================================================
 Name		: BluetoothDeviceSearcher.cpp
 Author	    : BluetoothAPI is a initiative of Embedded LAB - http://www.embedded.ufcg.edu.br/
 			  OpenC/SymbianC++ - http://efforts.embedded.ufcg.edu.br/symbiancpp	
 Version	 :
 Copyright   : This file is part of BluetoothAPI.
               BluetoothAPI is free software: you can redistribute it and/or modify
               it under the terms of the GNU Lesser General Public License as published by
               the Free Software Foundation, either version 3 of the License, or
               (at your option) any later version.

               BluetoothAPI is distributed in the hope that it will be useful,
               but WITHOUT ANY WARRANTY; without even the implied warranty of
               MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
               GNU Lesser General Public License for more details.

               You should have received a copy of the GNU Lesser General Public License
               along with BluetoothAPI. If not, see <http://www.gnu.org/licenses/>.
 
 Description : BluetoothDeviceSearcher.cpp implementation
===========================================================================================
*/


#include "BluetoothDeviceSearcher.h"

CBluetoothDeviceSearcher::CBluetoothDeviceSearcher(MBTDeviceSearcherObserver*	aObserver) : CActive( EPriorityStandard )	// Standard priority
{
	iBTDeviceSearcherObserver = aObserver;
}

CBluetoothDeviceSearcher* CBluetoothDeviceSearcher::NewLC(MBTDeviceSearcherObserver* aObserver)
{
	CBluetoothDeviceSearcher* self = new ( ELeave ) CBluetoothDeviceSearcher(aObserver);
	CleanupStack::PushL( self );
	self->ConstructL();
	return self;
}

CBluetoothDeviceSearcher* CBluetoothDeviceSearcher::NewL(MBTDeviceSearcherObserver* aObserver)
{
	CBluetoothDeviceSearcher* self = CBluetoothDeviceSearcher::NewLC(aObserver);
	CleanupStack::Pop(); // self;
	return self;
}

void CBluetoothDeviceSearcher::ConstructL()
{
	CActiveScheduler::Add( this );				// Add to scheduler
	SearchFlag = EFalse;
}

CBluetoothDeviceSearcher::~CBluetoothDeviceSearcher()
{
	Cancel(); // Cancel any request, if outstanding

	iDeviceDataList.ResetAndDestroy();

	if (iBTDeviceSearcherObserver){
		delete iBTDeviceSearcherObserver;
		iBTDeviceSearcherObserver = NULL;
	}
}

void CBluetoothDeviceSearcher::DoCancel()
{
	Cancel();
	iHostResolver.Close();
}

void CBluetoothDeviceSearcher::StartL()
{
	Cancel();							// Cancel any request, just to be sure
	SetActive();						// Tell scheduler a request is active
}

void CBluetoothDeviceSearcher::RunL()
{
	if (iStatus != KErrNone)
	{
		iHostResolver.Close();
		iBTDeviceSearcherObserver->HandleBTDeviceSearchCompleteL( iDeviceDataList );
		SearchFlag = EFalse;
	}
	else
	{
		TBTDeviceData* deviceData = new (ELeave) TBTDeviceData;
		deviceData->iDeviceAddr = static_cast<TBTSockAddr>(iNameEntry().iAddr).BTAddr();
		deviceData->iDeviceName = iNameEntry().iName;
		iDeviceDataList.Append(deviceData);
		iHostResolver.Next(iNameEntry, iStatus);
		SetActive();			// Tell scheduler a request is active
	}
}

TInt CBluetoothDeviceSearcher::RunError( TInt aError )
{
	return aError;
}

void CBluetoothDeviceSearcher::StartDeviceSearcherL(RSocketServ& aSocketServ)
{
	if (!SearchFlag){
		SearchFlag = ETrue;
		iDeviceDataList.ResetAndDestroy();
		TProtocolDesc protocolDesc;
		User::LeaveIfError(aSocketServ.FindProtocol(_L("BTLinkManager"), protocolDesc));
		User::LeaveIfError(iHostResolver.Open(aSocketServ, protocolDesc.iAddrFamily, protocolDesc.iProtocol));
		iInquirySockAddr.SetIAC(KGIAC);
		iInquirySockAddr.SetAction(KHostResInquiry | KHostResName |	KHostResIgnoreCache);
		iHostResolver.GetByAddress(iInquirySockAddr, iNameEntry, iStatus);
		StartL();
	}
}

⌨️ 快捷键说明

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