亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? btclienttoserver.cpp

?? Symbian OS C++ for Mobile Phones v3 Example Code
?? CPP
字號:
// Copyright (c) 2004 - 2007, Symbian Software Ltd. All rights reserved.

#ifndef __SERIES60_3X__
	#include <qbtselectdlg.hrh>
	#include <qbtselectdlg.h>
#endif

#include "bluetoothtransport.h"


// -------- (de)allocation --------

CBtClientToServer* CBtClientToServer::NewL(MTransportObserver& aObserver)
/**
	Factory function allocates new, connected transport.

	@param	aObserver		Observer to notify about transport events.
							This is managed by the CTransport superclass.
	@return					Connected transport that communicates with
							a remote server over Bluetooth.  This is owned
							by the caller.
 */
	{
	CBtClientToServer* self = new(ELeave) CBtClientToServer(aObserver);
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	return self;
	}

CBtClientToServer::CBtClientToServer(MTransportObserver& aObserver)
/**
	This constructor is defined to initialize the superclass with the
	supplied observer.

	@param	aObserver		Observer to notify about transport events.
							This is managed by the CTransport superclass.
 */
:	CBluetoothTransport(aObserver)
	{
	// empty.
	}

void CBtClientToServer::ConstructL()
/**
	Initialize this device as a client by selecting a device via the UI;
	searching its SDP records for the OandX service; and connecting
	to the host device.
 */
	{
	TRAN_LOG0(">CBtClientToServer::ConstructL");
	
	ConnectToSocketServerL();
	
	TBTDevAddr devAddr;
	AskUserToSelectHostL(devAddr);

	iProtocolChannel = -1;	// indicate no channel found
	FindProtocolDescriptionL(devAddr);
	
	// dialog will be dismissed by user or FinishedSearching
	TInt r = (! iObserver.StartedLookingForServiceL()) ? KErrCancel : iSdpError;
	User::LeaveIfError(r);
	
	// open the socket and connect it to the remote device
	iBtSocket = CBluetoothSocket::NewL(*this, iSocketServ, *iProtocolName);
	
	TBTSockAddr btSockAddr;
	btSockAddr.SetBTAddr(devAddr);
	btSockAddr.SetPort(iProtocolChannel);

	// channel security settings.  No authentication, authorisation, or encryption.
	TBTServiceSecurity oandxSecurity;
	oandxSecurity.SetUid(KUidServiceSDP);
	oandxSecurity.SetAuthentication(EFalse);	// don't require key (PIN) exchange
	oandxSecurity.SetAuthorisation(ETrue);		// require local user to confirm accept
	oandxSecurity.SetEncryption(EFalse);
	oandxSecurity.SetDenied(EFalse);
	btSockAddr.SetSecurity(oandxSecurity);

	r = iBtSocket->Connect(btSockAddr);
	User::LeaveIfError(r);

	// dialog will be dismissed by user or from HandleConnectCompleteL
	r = (! iObserver.StartedConnectingToServiceL()) ? KErrCancel : iConnectError;
	User::LeaveIfError(r);

	CTransport::ConstructL(/*aInitListen*/ ETrue);
	TRAN_LOG0("<CBtClientToServer::ConstructL");
	}

void CBtClientToServer::AskUserToSelectHostL(TBTDevAddr& aDevAddr)
/**
	Ask the user to select a Bluetooth device with the platform-specific
	notifier dialog.
	
	@param	aDevAddr		On success this is set to the remote device's address.
 */
	{
	TRAN_LOG0(">CBtClientToServer::AskUserToSelectHostL");
	TInt r;

#ifdef __SERIES60_3X__	
	// ask user to select a device via the extended notifier server
	RNotifier ntf;
	r = ntf.Connect();
	User::LeaveIfError(r);
	
	TRequestStatus rs;
	
	// filter displayed devices by those which support the OandX service.
	// (This may not be supported by the UI.)
	TBTDeviceSelectionParamsPckg devFilter;
	devFilter().SetUUID(iServiceUuid);
	
	TBTDeviceResponseParamsPckg response;
	
	ntf.StartNotifierAndGetResponse(rs, KDeviceSelectionNotifierUid, devFilter, response);
	User::WaitForRequest(rs);
	ntf.Close();

	// ensure a valid device was selected
	r = rs.Int();
	if (r == KErrNone && ! response().IsValidDeviceName())
		r = KErrNotFound;
	User::LeaveIfError(r);
	
	aDevAddr = response().BDAddr();
	
#else

	// select a single device with the UIQ dialog
	CBTDeviceArray* btDevArray = new (ELeave)CBTDeviceArray(1);
	BTDeviceArrayCleanupStack::PushL(btDevArray);
	
	CQBTUISelectDialog* btUiSelDlg = CQBTUISelectDialog::NewL(btDevArray);
	TInt dlgRet = btUiSelDlg->RunDlgLD(KQBTUISelectDlgFlagNone);
	
	TRAN_LOG1("-CBtClientToServer::AskUserToSelectHostL,dlgRet=%d", dlgRet);
	if (dlgRet != EBTDeviceSelected)
		r = KErrNotFound;
	else
		{
		const CBTDevice* dev = (*btDevArray)[0];
		if (! dev->IsValidBDAddr())
			r = KErrNotFound;
		else
			{
			aDevAddr = dev->BDAddr();
			r = KErrNone;
			}
		}
	
	User::LeaveIfError(r);
	CleanupStack::PopAndDestroy(btDevArray);
#endif

	TRAN_LOG0("<CBtClientToServer::AskUserToSelectHostL");
	}

void CBtClientToServer::FindProtocolDescriptionL(const TBTDevAddr& aDevAddr)
/**
	Search the supplied device's SDP database for the OandX SDP record.
	If found, the protocol and its channel are put in iProtocolName and
	iProtocolChannel respectively.
	
	iSdpError is set to KErrNone if the search is successful, or another
	error code otherwise.
	
	@param	aDevAddr		Remote device's address.
 */
	{
	TRAN_LOG0(">CBtClientToServer::FindProtocolDescriptionL");
	
	iSdpAgent = CSdpAgent::NewL(/* MSdpAgentNotifier& */ *this, aDevAddr);

	// only process SDP entries which match the OandX service class
	CSdpSearchPattern* searchPattern = CSdpSearchPattern::NewL();
	CleanupStack::PushL(searchPattern);
	searchPattern->AddL(iServiceUuid);
	iSdpAgent->SetRecordFilterL(*searchPattern);
	CleanupStack::PopAndDestroy(searchPattern);
	
	iSdpAgent->NextRecordRequestL();
	// completes in NextRecordRequestComplete

	TRAN_LOG0("<CBtClientToServer::FindProtocolDescriptionL");
	}

void CBtClientToServer::FinishedSearching(TInt aError)
/**
	This function is called when finished parsing remote SDP records.
	It closes the looking-for-service dialog.

	@param	aError			Symbian OS error code.
 */
	{
	// SDP agent no longer required so clean up
	delete iSdpAgent;
	iSdpAgent = 0;
	
	if (aError != KErrEof)		// KErrEof == parsed all matching records
		iSdpError = aError;
	else
		{
		// did we discover the protocol and channel?
		
		if (iProtocolName != 0 && iProtocolChannel != -1)
			iSdpError = KErrNone;
		else
			iSdpError = KErrNotFound;
		}
	
	iObserver.StoppedLookingForService();
	}

CBtClientToServer::~CBtClientToServer()
/**
	Cancel any outstanding operations and free resources used by this object.
 */
	{
	Cancel();
	delete iSdpAgent;
	FreeDataSocket();
	}


// -------- implement MSdpAgentNotifier --------

void CBtClientToServer::NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount)
/**
	Implement MSdpAgentNotifier by extracting the protocol descriptor list attribute.
	
	@param	aError			Symbian OS error code.  This is KErrEof if there are
							no more SDP records to parse.
	@param	aHandle			Service record which was retrieved from remote device.
	@param	aTotalRecordsCount Total number of matching records.  Not used.
 */
	{
	(void) aTotalRecordsCount;
	TRAN_LOG3(">CBtClientToServer::NextRecordRequestComplete,err=%d,h=0x%x,c=%d", aError, aHandle, aTotalRecordsCount);
	
	if (aError == KErrNone)
		{
		TRAP(aError, iSdpAgent->AttributeRequestL(aHandle, KSdpAttrIdProtocolDescriptorList));
		}

	if (aError != KErrNone)
		FinishedSearching(aError);

	TRAN_LOG0("<CBtClientToServer::NextRecordRequestComplete");
	}

void CBtClientToServer::AttributeRequestResult(TSdpServRecordHandle aHandle, TSdpAttributeID aAttrID, CSdpAttrValue* aAttrValue)
/**
	Implement MSdpAgentNotifier by processing the supplied attribute.
	The supplied attribute must describe the protocol descriptor list because
	of the attribute selection in NextRecordRequestComplete.
	
	@param	aHandle			The service's record handle, as set by the remote device.  Not used.
	@param	aAttrID			The attribute ID.  See BLUETOOTH SPECIFICATION Version 2.0 + EDR [vol 4]
							Section 5 for a list of attribute IDs.  Not used.
	@param	aAttrValue		The attribute's value.  This function supplies itself as an
							MSdpAttributeValueVisitor to read the protocol descriptor list.
							This function takes ownership of the value object and must delete it.
 */
	{
	(void) aHandle;
	(void) aAttrID;
	TRAN_LOG3(">CBtClientToServer::AttributeRequestResult,h=0x%x,id=0x%x,type=%d", aHandle, aAttrID, aAttrValue->Type());
	
	TRAPD(r, aAttrValue->AcceptVisitorL(/* MSdpAttributeValueVisitor */ *this));
	if (r != KErrNone)
		FinishedSearching(r);

	delete aAttrValue;

	TRAN_LOG0("<CBtClientToServer::NextRecordRequestComplete");
	}

void CBtClientToServer::AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError)
/**
	Implement MSdpAgentNotifier by searching the next record for its protocol descriptor list.
	
	@param	aHandle			The service's record handle, as set by the remote device.  Not used.
	@param	aError			Symbian OS error code.
 */
	{
	(void) aHandle;
	TRAN_LOG2(">CBtClientToServer::AttributeRequestComplete,h=0x%x,err=%d", aHandle, aError);
	
	if (aError == KErrNone)
		{
		TRAP(aError, iSdpAgent->NextRecordRequestL());
		}
	
	if (aError != KErrNone)
		FinishedSearching(aError);
	
	TRAN_LOG0("<CBtClientToServer::AttributeRequestComplete");
	}


// -------- implement MSdpAttributeValueVisitor --------

void CBtClientToServer::VisitAttributeValueL(CSdpAttrValue& aValue, TSdpElementType aType)
/**
	Implement MSdpAttributeValueVisitor by extracting protocol type and channel number.
	
	The protocol descriptor list contains ((L2CAP, PSM)) if using an L2CAP channel, and
	((L2CAP, RFCOMM-PSM) (RFCOMM, rfcomm-channel)) if using an RFCOMM channel.
	The attributes in a DES are passed to this function in the order in which they occur
	in the list, so the RFCOMM protocol and value will overwrite the L2CAP protocol and
	channel if it appears.

	(This won't catch the malformed case (L2CAP, RFCOMM-PSM) (RFCOMM) but the subsequent
	connection will fail if RFCOMM-PSM isn't a valid RFCOMM channel.)
	
	@param	aValue			The attribute's value.  This function extracts the value as
							an UUID to identify the protocol, or as an integer to identify
							the channel.
	@param	aType			The value's type.
 */
	{
	TRAN_LOG1(">CBtClientToServer::VisitAttributeValueL,type=%d", aType);
	
	switch (aType)
		{
	case ETypeUUID:
		{
		const TUUID protocolUuid = aValue.UUID();
		if (protocolUuid == TUUID(KL2CAP))
			iProtocolName = &KL2CAPDesC;
		else if (protocolUuid == TUUID(KRFCOMM))
			iProtocolName = &KRFCOMMDesC;
		else
			User::Leave(KErrNotSupported);
		TRAN_LOG1("-CBtClientToServer::VisitAttributeValueL,iProtocolName=%S", iProtocolName);
		}
		break;
	
	case ETypeUint:
		iProtocolChannel = aValue.Uint();
		TRAN_LOG1("-CBtClientToServer::VisitAttributeValueL,iProtocolChannel=%d", iProtocolChannel);
		break;
	
	default:
		// ignore other attribute types.
		break;
		}
	
	TRAN_LOG0("<CBtClientToServer::VisitAttributeValueL");
	}

void CBtClientToServer::StartListL(CSdpAttrValueList& aList)
/**
	Implement MSdpAttributeValueVisitor by doing nothing.
	When this function returns, VisitAttributeValueL will be called
	for every value in the list.
	
	@param	aList			The list which is being visited.
	@see VisitAttributeValueL
	@see EndListL
 */
	{
	(void) aList;
	// empty.
	}

void CBtClientToServer::EndListL()
/**
	Implement MSdpAttributeValueVisitor by doing nothing.

	@see VisitAttributeValueL
	@see StartListL
 */
	{
	// empty.
	}


// -------- partially implement MBluetoothSocketNotifier, override CBluetoothTransport --------

void CBtClientToServer::HandleConnectCompleteL(TInt aErr)
/**
	Implement MBluetoothSocketNotifier by dismissing the
	connecting dialog.  Flow control returns to ConstructL.

	@param	aErr			Symbian OS error code.  This is stored in iConnectError.
 */
	{
	iConnectError = aErr;
	iObserver.StoppedConnectingToService();
	}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美亚洲一区二区在线| 91精品国产综合久久婷婷香蕉 | 欧美精品粉嫩高潮一区二区| 亚洲免费观看高清完整版在线观看熊| 国产精品资源站在线| 国产日韩欧美麻豆| 99国产精品久久| 亚洲品质自拍视频网站| 一本一道综合狠狠老| 一级中文字幕一区二区| 欧美午夜一区二区| 日韩av高清在线观看| 亚洲精品在线三区| 风间由美一区二区av101| 国产精品福利一区二区| 欧美日韩一级视频| 久久电影网电视剧免费观看| 精品国产1区二区| 成人午夜电影网站| 亚洲综合激情小说| 日韩免费高清av| 9久草视频在线视频精品| 亚洲精品高清在线观看| 日韩一区二区三区免费观看| 国产99精品视频| 亚洲一区二区三区四区五区中文| 欧美色精品天天在线观看视频| 日韩和的一区二区| 国产欧美一区二区三区在线老狼| 色视频成人在线观看免| 久久精品国产精品青草| 日韩理论片一区二区| 3d成人动漫网站| 成人免费黄色大片| 免费观看一级欧美片| 中文字幕在线观看一区二区| 欧美亚洲尤物久久| 国产aⅴ综合色| 日韩**一区毛片| 亚洲欧洲制服丝袜| 中文字幕五月欧美| 7777精品伊人久久久大香线蕉经典版下载| 91色porny在线视频| 久久久久久久综合日本| 日韩专区一卡二卡| 欧美亚日韩国产aⅴ精品中极品| 国产清纯白嫩初高生在线观看91 | 亚洲精品视频免费观看| 欧美日韩激情一区二区| 亚洲一区二区三区视频在线播放| 国产精选一区二区三区| 91玉足脚交白嫩脚丫在线播放| 3d动漫精品啪啪| 亚洲精品国产a久久久久久| 国产九九视频一区二区三区| 久久精品视频网| 亚洲超碰精品一区二区| 欧美mv和日韩mv的网站| 成人h精品动漫一区二区三区| 中文字幕一区二区三区四区| 一本到不卡精品视频在线观看| 一区二区三区在线播| 91麻豆精品91久久久久同性| 国产福利视频一区二区三区| 亚洲老司机在线| 久久精品视频一区二区三区| 欧美日韩亚洲综合一区| 不卡在线视频中文字幕| 国产日产欧美一区二区三区| www.欧美日韩国产在线| 亚洲成人午夜影院| 久久综合久久综合亚洲| 亚洲成av人**亚洲成av**| 亚洲三级电影网站| 国产精品蜜臀av| 欧美韩日一区二区三区四区| 久久久午夜精品理论片中文字幕| 67194成人在线观看| 欧美日韩视频在线观看一区二区三区 | 久久精品国产精品亚洲综合| 亚洲不卡一区二区三区| 亚洲国产色一区| 亚洲永久精品国产| 亚洲香肠在线观看| 亚洲第一激情av| 亚洲18色成人| 日韩福利电影在线观看| 日韩1区2区3区| 久久er99精品| 国产二区国产一区在线观看| 国内成+人亚洲+欧美+综合在线| 精品一区二区三区免费| 蜜臀久久99精品久久久久久9| 丝袜美腿高跟呻吟高潮一区| 日韩1区2区3区| 国产一区二区视频在线| 处破女av一区二区| 色综合久久久久综合99| 欧美午夜免费电影| 欧美另类高清zo欧美| 久久99精品国产| 亚洲国产精品一区二区www| 亚洲欧美一区二区三区久本道91| 日韩欧美一区中文| 日韩精品在线一区二区| 国产精品免费丝袜| 一区二区三区蜜桃网| 午夜精品福利一区二区三区av | 日韩一区在线看| 亚洲乱码国产乱码精品精的特点| 亚洲成人免费视频| 狠狠色综合日日| 99久久精品国产毛片| 欧美精品乱码久久久久久| 精品国产三级a在线观看| 国产精品色一区二区三区| 一区二区三区高清在线| 国内偷窥港台综合视频在线播放| 成人精品在线视频观看| 欧美日韩国产免费| 国产欧美视频在线观看| 亚洲高清免费一级二级三级| 国产美女精品在线| 欧美性色黄大片手机版| 久久久久久久久99精品| 亚洲mv大片欧洲mv大片精品| 国产剧情一区二区| 欧美日韩精品二区第二页| 久久亚洲综合av| 亚洲一区二区精品久久av| 韩国一区二区三区| av网站免费线看精品| 精品久久人人做人人爰| 夜夜操天天操亚洲| 国产白丝精品91爽爽久久| 欧美日韩精品专区| 亚洲欧美怡红院| 久久精品国产99久久6| 一本色道久久综合狠狠躁的推荐 | 色狠狠一区二区三区香蕉| 久久综合色8888| 日韩av一级片| 欧美日韩精品一区视频| 成人欧美一区二区三区视频网页 | 亚洲va在线va天堂| av中文字幕在线不卡| 精品国产伦一区二区三区观看方式| 亚洲精品少妇30p| 成人少妇影院yyyy| 91黄色免费观看| 亚洲精品国产成人久久av盗摄| 国产成人aaa| 亚洲欧洲精品一区二区精品久久久| 亚洲国产aⅴ天堂久久| 91在线观看下载| 亚洲欧美一区二区久久| 欧美日韩一区二区三区在线| 一区二区三区四区蜜桃| 国产aⅴ精品一区二区三区色成熟| 日韩一区二区三| 亚洲国产cao| 亚洲五码中文字幕| 北岛玲一区二区三区四区| 久久综合九色综合久久久精品综合 | 高清成人在线观看| 日韩久久精品一区| 秋霞午夜鲁丝一区二区老狼| 欧美三级三级三级| 亚洲精品国产一区二区精华液| 国产精品一区三区| 国产亚洲精品超碰| 国产美女一区二区| 国产亚洲欧洲一区高清在线观看| 毛片av一区二区| 日韩视频免费观看高清完整版| 日韩专区一卡二卡| 91精品国产福利| 久久精品噜噜噜成人88aⅴ| 欧美一区二区在线免费播放| 五月天欧美精品| 欧美一级欧美三级在线观看| 蜜桃视频在线一区| 久久香蕉国产线看观看99| 夫妻av一区二区| 亚洲色图另类专区| 欧美日韩精品一区二区天天拍小说| 亚洲成a天堂v人片| 国产亚洲综合av| 成人免费毛片app| 亚洲欧美视频一区| 欧美日韩精品专区| 国产一区三区三区| 中文字幕一区不卡| 欧美剧在线免费观看网站| 蜜桃精品视频在线| 国产亚洲精品中文字幕| 日本高清免费不卡视频| 日韩国产精品91| 国产香蕉久久精品综合网| 97精品国产露脸对白|