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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? bluetoothserver.cpp

?? 關(guān)于symbian s60 2rd如何利用手機(jī)藍(lán)牙進(jìn)行通訊
?? CPP
字號(hào):
/**
*
* @brief Definition of CBluetoothServer
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// System include
#include <bt_sock.h>
#include <s32mem.h>

// User include
#include "BluetoothServer.h"
#include "BluetoothAdvertiser.h"
#include "BluetoothChatApplication.h"

/**
* Constructor.
*
* Set observer and flag to indicate not connected
* Add this active object to the scheduler
*
* @param aObserver reference to MBluetoothObserver
**/
CBluetoothServer::CBluetoothServer(MBluetoothObserver& aObserver)
: CActive(CActive::EPriorityStandard),
  iObserver(aObserver),
  iState(EDisconnected)
	{
	CActiveScheduler::Add(this);
	}

/**
* Factory Constructor.
* Only available way to construct class.
* This function can leave L
* @param none
* @return new instance of the CBluetoothServer
*/
CBluetoothServer* CBluetoothServer::NewL(MBluetoothObserver& aObserver)
	{
	CBluetoothServer* self = NewLC(aObserver);
	CleanupStack::Pop(self);
	return self;
	}

/**
* Factory Constructor.
* Only available way to construct class.
* This function can leave L, returning value is on Cleanup Stack C
* @param none
* @return new instance of the CBluetoothServer on Cleanup stack
*/
CBluetoothServer* CBluetoothServer::NewLC(MBluetoothObserver& aObserver)
	{
	CBluetoothServer* self = new (ELeave) CBluetoothServer(aObserver);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

/**
* Destructor.
*
* Cancel this active object, and disconnect the Server
* Delete the advertiser
*
* @param none
* @retval none
**/
CBluetoothServer::~CBluetoothServer()
	{
	TRAPD(err,StopL());
    // Panic in debug if this didn't work
    __ASSERT_DEBUG(err == KErrNone, Panic(EErrorStoppingServer));

	Cancel();

	// Close handles
	if (iSecSettingsSession.SubSessionHandle() != 0)
		{
		iSecSettingsSession.Close();
		}
	if (iSecManager.Handle() != 0)
		{
		iSecManager.Close();
		}
	if (iAcceptedSocket.SubSessionHandle() != 0)
		{
		iAcceptedSocket.Close();
		}
	if (iListeningSocket.SubSessionHandle() != 0)
		{
		iListeningSocket.Close();
		}
	if (iSocketServer.Handle() != 0)
		{
		iSocketServer.Close();
		}

	delete iAdvertiser;
	}

/**
* ConstructL
*
* Create the advertiser
*
* @see NewL
* @see NewLC
* @param none
* @return none
**/
void CBluetoothServer::ConstructL()
	{
	iAdvertiser = CBluetoothAdvertiser::NewL();
	}

void CBluetoothServer::DoCancel()
	{
	switch(iState)
		{
		case EDisconnected :
			{
			break;
			}
		case ESettingSecurity :
			{
			iSecSettingsSession.CancelRequest(iStatus);	// not asynch call
			break;
			}
		case EConnecting :
			{
			iListeningSocket.CancelAccept();
			break;
			}
		case EConnected :
			{
			break;
			}
		case EWaitingForMessage :
			{
			iAcceptedSocket.CancelRecv();
			break;
			}
		case ESendData :
			{
			iAcceptedSocket.CancelSend();
			break;
			}
		default:
			{
			break;
			}
		}
	}

/**
* StartServerL.
*
* Connect to Socket Server
* Open a listening socket on the Server on the RFCOMM protocol (KServerTransportName)
* Get a channel to listen on
* Bind the socket to this port, and listen
* Open another socket on the Server
* Issue an asynchronous Accept on the listening socket, passing through the AcceptedSocket
* When the Accept completes the Accepted Socket may be utilised for communication and the listening socket will continue
* listening for connections.
* Set Security options on the Port/Channel
*
* @param none
* @return none
**/
void CBluetoothServer::StartServerL()
	{
	if (iState != EDisconnected)
		{
		User::Leave(KErrInUse);
		}

	User::LeaveIfError(iSocketServer.Connect());
	User::LeaveIfError(iListeningSocket.Open(iSocketServer, KServerTransportName));

	// Get a channel to listen on - same as the socket's port number
	User::LeaveIfError(iListeningSocket.GetOpt(KRFCOMMGetAvailableServerChannel, KSolBtRFCOMM, iChannel));

	TBTSockAddr listeningAddress;
	listeningAddress.SetPort(iChannel);

	User::LeaveIfError(iListeningSocket.Bind(listeningAddress));
	User::LeaveIfError(iListeningSocket.Listen(KListeningQueSize));

	SetSecurityOnChannelL(EFalse, EFalse, ETrue);
	}

/**
* SetSecurityOnChannelL.
*
* Connect to security manager
* Open a subsession on the security manager used to register settings
* Build the security settings within a TBTServiceSecurity object
* Register these settings
*
* @param aAuthentication true if you wish to enforce authentication
* @param aEncryption true if you wish to enforce encryption on the incomming data
* @param eAuthorisation true if you wish to enforce authorisation.
* @return none
**/
void CBluetoothServer::SetSecurityOnChannelL(TBool aAuthentication, TBool aEncryption, TBool aAuthorisation)
	{
	// connect to the security manager and open a settings session.
	User::LeaveIfError(iSecManager.Connect());
	User::LeaveIfError(iSecSettingsSession.Open(iSecManager));

	// the security settings
	TBTServiceSecurity serviceSecurity(KUidBluetoothChat, KSolBtRFCOMM, 0);

	//Define security requirements
	serviceSecurity.SetAuthentication(aAuthentication);
	serviceSecurity.SetEncryption(aEncryption);
	serviceSecurity.SetAuthorisation(aAuthorisation);

	serviceSecurity.SetChannelID(iChannel);

	// make asynch request
	iSecSettingsSession.RegisterService(serviceSecurity, iStatus);
	iState = ESettingSecurity;
	SetActive();
	}


/**
* AcceptConnectionsL.
*
* Sets the socket which should be used to accept incoming connections at the
* listening socket.
*
* @param none
* @return none
**/
void CBluetoothServer::AcceptConnectionsL()
	{
	iAcceptedSocket.Close();	// close old connection - if any
	User::LeaveIfError(iAcceptedSocket.Open(iSocketServer));	// Open abstract socket

	iState = EConnecting;

	// set the listening socket to accept new connections on
	// the accepted socket.
	iListeningSocket.Accept(iAcceptedSocket, iStatus);

	SetActive();

	// notify the observer that the server has started
	iObserver.ServerStartedL();
	}

/**
* StartAdvertisingL.
*
* Start Advertising
*
* @param none
* @return none
**/
void CBluetoothServer::StartAdvertisingL()
	{
	iAdvertiser->StartAdvertisingL(iChannel);
	iAdvertiser->UpdateAvailabilityL(ETrue);
	}

/**
* StopL.
*
* Stop Advertising
* Close the communication socket
* Close the listening socket
* Close the connection to the socket server
*
* @param none
* @return none
**/
void CBluetoothServer::StopL()
	{
	if (iState != EDisconnected)
		{
		if (iAdvertiser->IsAdvertising())
			{
			iAdvertiser->StopAdvertisingL();
			}

		iAcceptedSocket.Close();
		iListeningSocket.Close();
		iSocketServer.Close();
		}

	iState = EDisconnected;
	}

/**
* SendL.
*
* Issue an asynchronous Write on the socket, passing through the message to send
*
* @param aMessage the message to send the client
* @return none
**/
void CBluetoothServer::Send(const TDesC& aMessage)
	{
	TRAPD(err, SendL(aMessage));
	}

void CBluetoothServer::SendL(const TDesC& aMessage)
	{
	iMessage.Zero();
	TDesBuf buffer;	
	buffer.Set (iMessage);
	
	RWriteStream stream(&buffer);
	CleanupClosePushL(stream);

	stream << aMessage;
	
	CleanupStack::PopAndDestroy();

	iState = ESendData;
	iAcceptedSocket.Write(iMessage, iStatus);
	SetActive();
	}

/**
* RequestData.
*
* Issue an asynchronous receive function on the socket, passing through a buffer to be populated
* @param none
* @return none
**/
void CBluetoothServer::RequestData()
	{
	iMessage.Zero();

	iState = EWaitingForMessage;
	iAcceptedSocket.RecvOneOrMore(iMessage, 0, iStatus, iLen);
	SetActive();
	}

/**
* RunL
*
* Called when an asynchronous request completes.
* iStatus variable indicates error conditions
* iState indicates present state of the Server
*
* @param none
* @return none
**/
void CBluetoothServer::RunL()
	{
	if (iStatus.Int() == KErrNone)
		{
		switch (iState)
			{
			case ESettingSecurity :
				{
				// cleanup after security settings
				iSecSettingsSession.Close();
				iSecManager.Close();

				// accept connections
				AcceptConnectionsL();
				break;
				}
			case EConnecting:
				{
				iObserver.ConnectedL();
				// do not accept any more connections
				iAdvertiser->StopAdvertisingL();
				RequestData();
				break;
				}

			case EWaitingForMessage:
				{
				iState = EConnected;
				TDesBuf buffer;	
				buffer.Set (iMessage);

				RReadStream stream (&buffer);
				CleanupClosePushL(stream);

				TBuf<KMaxMessageLength> rxBuf;

				stream >> rxBuf;

				CleanupStack::PopAndDestroy();

				iObserver.DataReceivedL(rxBuf);
				break;
				}

			case ESendData:
				{
				RequestData();
				break;
				}

			default:
				Panic(EInvalidServerState);
				break;
			}
		}
	else
		{
		StopL();
		iObserver.HandleErrorL(iStatus.Int());
		}
	}

/**
 * Returns information on state of the Bluetooth Server.
 *
 * @param none
 * @returns boolean, true if the server is connected to a client, false otherwise
 */
TBool CBluetoothServer::IsConnected()
	{
	return !(iState == EDisconnected);
	}

/**
 * Returns information on state of the Bluetooth Server.
 *
 * @param none
 * @returns boolean, true if the server is able to send data to the client, false otherwise
 */
TBool CBluetoothServer::AvailableToSend()
	{
	return (iState == EConnected);
	}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产综合久久福利| 国产成人8x视频一区二区| 成人小视频免费在线观看| 欧美三区在线视频| 中文字幕欧美激情| 韩国中文字幕2020精品| 欧美日韩一区小说| 亚洲三级在线免费观看| 国产高清在线精品| 日韩精品一区二区在线观看| 亚洲成人综合在线| 91农村精品一区二区在线| 国产日产亚洲精品系列| 久久国产福利国产秒拍| 欧美肥妇毛茸茸| 亚洲国产精品综合小说图片区| 成人手机电影网| 久久久精品欧美丰满| 麻豆高清免费国产一区| 欧美老女人在线| 亚洲高清免费在线| 色婷婷久久久综合中文字幕| 国产精品私房写真福利视频| 精品一区二区在线视频| 欧美一区二区三区视频在线 | 精品视频全国免费看| 国产精品久久久久久福利一牛影视 | 欧美一区二区免费| 亚洲成a人片在线不卡一二三区| 91香蕉视频黄| 亚洲视频在线一区二区| 99国产欧美久久久精品| 国产精品传媒入口麻豆| fc2成人免费人成在线观看播放| 国产午夜一区二区三区| 国产精品1区2区3区| 久久亚洲精品国产精品紫薇| 国产在线精品一区在线观看麻豆| 欧美电影免费观看高清完整版在线观看 | 欧美精品色一区二区三区| 亚洲一二三四久久| 在线观看亚洲精品视频| 亚洲另类色综合网站| 欧美综合一区二区三区| 亚洲二区在线视频| 欧美精品免费视频| 免费欧美在线视频| 26uuuu精品一区二区| 国产成人免费9x9x人网站视频| 国产精品人妖ts系列视频| 99久久国产综合精品色伊| 亚洲精品免费在线观看| 欧美视频三区在线播放| 五月婷婷激情综合网| 欧美一级精品大片| 国产一区二区三区在线观看免费| 国产欧美日韩视频在线观看| 不卡的av电影在线观看| 一二三区精品视频| 欧美日本一区二区| 国模大尺度一区二区三区| 日本一区二区动态图| 99vv1com这只有精品| 亚洲成人tv网| 26uuu精品一区二区在线观看| 国产99久久久精品| 亚洲欧美日韩国产综合| 欧美伦理影视网| 国产一区二区电影| 亚洲欧美日韩中文播放| 欧美高清hd18日本| 国产美女主播视频一区| 国产精品三级久久久久三级| 一本大道综合伊人精品热热| 日韩高清一区在线| 欧美韩国日本不卡| 欧洲激情一区二区| 久久99久久99小草精品免视看| 国产三区在线成人av| 91免费看视频| 青青草原综合久久大伊人精品优势| 久久精品亚洲一区二区三区浴池| 91香蕉视频污在线| 日本aⅴ亚洲精品中文乱码| 欧美激情一区二区三区蜜桃视频| 在线一区二区三区做爰视频网站| 日本不卡在线视频| 国产精品天天摸av网| 8x8x8国产精品| 成人免费观看av| 日本aⅴ免费视频一区二区三区| 欧美极品另类videosde| 69堂亚洲精品首页| 成人午夜视频在线观看| 爽好多水快深点欧美视频| 国产无人区一区二区三区| 欧美天天综合网| 国产sm精品调教视频网站| 天堂资源在线中文精品| 国产精品国产三级国产aⅴ无密码| 欧美高清性hdvideosex| 99久久精品免费观看| 精品一区二区免费在线观看| 亚洲美腿欧美偷拍| 国产日产欧美一区| 欧美一级黄色片| 欧美影视一区二区三区| 成人晚上爱看视频| 青草国产精品久久久久久| 自拍偷拍亚洲综合| 久久久久久**毛片大全| 91精品国产免费久久综合| 91香蕉视频污| 懂色av一区二区在线播放| 男女男精品视频| 亚洲欧美另类图片小说| 久久久久久免费| 日韩欧美一区二区在线视频| 在线视频欧美精品| 成人sese在线| 国产一区二区三区免费看| 午夜欧美一区二区三区在线播放| 亚洲图片另类小说| 中文字幕高清不卡| 精品99999| 日韩精品综合一本久道在线视频| 欧美色视频在线| 色综合天天狠狠| gogo大胆日本视频一区| 国产成都精品91一区二区三| 九色综合国产一区二区三区| 水蜜桃久久夜色精品一区的特点| 一区二区视频免费在线观看| 国产精品美女久久久久av爽李琼| 欧美成人激情免费网| 91精品黄色片免费大全| 欧美日韩一区三区| 欧美午夜影院一区| 欧美在线播放高清精品| 色综合天天视频在线观看 | 日韩高清不卡一区二区三区| 亚洲国产欧美日韩另类综合 | 亚洲成a天堂v人片| 亚洲成人av福利| 亚洲二区视频在线| 亚洲成人黄色小说| 亚洲不卡在线观看| 天天影视网天天综合色在线播放| 亚洲欧美成人一区二区三区| 亚洲视频一区二区在线观看| 中文字幕字幕中文在线中不卡视频| 国产精品欧美一级免费| 亚洲国产成人私人影院tom| 中文欧美字幕免费| 国产精品久久久久婷婷| 国产精品三级视频| 国产精品高潮呻吟| 亚洲欧洲成人av每日更新| 国产精品高清亚洲| 亚洲乱码国产乱码精品精的特点 | 亚洲蜜臀av乱码久久精品| 亚洲欧美另类久久久精品2019| 一区二区三区中文字幕精品精品 | 26uuuu精品一区二区| 国产亚洲人成网站| 国产精品久久影院| 亚洲欧洲一区二区在线播放| 亚洲黄色小视频| 亚洲韩国精品一区| 秋霞电影网一区二区| 激情综合网最新| 国产成人av电影在线观看| 99在线精品一区二区三区| 在线亚洲一区二区| 欧美电影在线免费观看| 精品国一区二区三区| 国产欧美日韩中文久久| 亚洲视频一二区| 亚洲va天堂va国产va久| 精品一区二区三区在线播放视频| 国产成人午夜精品5599| 91免费视频网| 91精品国产一区二区人妖| 久久免费午夜影院| 亚洲欧美区自拍先锋| 日韩精品电影在线| 国产999精品久久久久久绿帽| 99久久99久久精品免费观看| 欧美色图在线观看| 精品国产乱子伦一区| 国产精品国产三级国产aⅴ入口| 一区二区成人在线视频| 热久久久久久久| 成人午夜av电影| 欧美日韩一区二区在线视频| 精品国产一区二区三区忘忧草| 中文字幕永久在线不卡| 婷婷久久综合九色国产成人| 国产精品一二三四区| 在线免费不卡视频|