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

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

?? bluetoothserver.cpp

?? 一些symbian開發的小例子
?? CPP
字號:
/**
*
* @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);
	}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆精品国产91久久久久| 成人免费看黄yyy456| 欧美视频在线一区二区三区 | 国产日韩一级二级三级| 蜜臀av一区二区三区| 欧美成人高清电影在线| 国产一区 二区| 国产精品美女久久久久久久久久久| 成人avav影音| 五月天欧美精品| 精品国产区一区| 成人不卡免费av| 亚洲国产精品久久艾草纯爱| 欧美一二三区在线| 国产xxx精品视频大全| 亚洲丝袜制服诱惑| 欧美日韩不卡在线| 国产精品伊人色| 怡红院av一区二区三区| 欧美精品v国产精品v日韩精品 | 国产欧美精品一区二区色综合| 97精品视频在线观看自产线路二| 亚洲国产三级在线| 亚洲视频每日更新| 91麻豆精品国产91久久久| 国产成人在线色| 亚洲综合清纯丝袜自拍| 337p粉嫩大胆噜噜噜噜噜91av| 99视频精品免费视频| 日本va欧美va欧美va精品| 中文在线资源观看网站视频免费不卡 | 免费在线看一区| 亚洲国产精品av| 91精品国产色综合久久ai换脸| 成人精品在线视频观看| 日欧美一区二区| 中文字幕一区二区三区在线观看| 欧美高清视频在线高清观看mv色露露十八 | 亚洲国产岛国毛片在线| 欧美日韩精品欧美日韩精品| 国产成人免费网站| 青青青伊人色综合久久| 一卡二卡三卡日韩欧美| 中文欧美字幕免费| 日韩女优制服丝袜电影| 欧美午夜寂寞影院| 91丨九色丨尤物| 国产suv精品一区二区三区| 热久久一区二区| 亚洲成人av福利| 国产精品成人在线观看| 国产日韩精品一区二区三区| 日韩欧美激情四射| 欧美日韩1234| 91看片淫黄大片一级在线观看| 国产福利精品导航| 九九热在线视频观看这里只有精品| 亚洲午夜一区二区| 亚洲国产精品激情在线观看| 久久精品欧美日韩精品 | 欧美日韩视频一区二区| 91麻豆精品在线观看| 丁香婷婷综合激情五月色| 久久激情综合网| 日韩福利视频导航| 日本中文字幕一区二区有限公司| 一区二区视频在线看| 亚洲免费在线看| 亚洲乱码国产乱码精品精小说| 国产精品国产三级国产专播品爱网| 久久精品一区蜜桃臀影院| 精品国产乱码久久久久久夜甘婷婷 | 久久99热狠狠色一区二区| 午夜不卡在线视频| 偷拍亚洲欧洲综合| 亚洲在线一区二区三区| 亚洲一区二区av电影| 亚洲成人精品在线观看| 图片区小说区区亚洲影院| 偷拍一区二区三区| 久久国产精品99精品国产| 久久99精品久久只有精品| 精品一区二区在线观看| 国产乱码字幕精品高清av| 国产成人一级电影| 成人一区二区在线观看| 91免费看视频| 欧美日韩国产一级片| 欧美一区二区三区在线视频| 日韩精品资源二区在线| 国产亚洲欧美色| 中文字幕一区二区三区蜜月 | 国产精品嫩草影院av蜜臀| 国产精品久久久久久亚洲毛片| 亚洲另类春色国产| 日韩国产欧美在线视频| 国内外成人在线| 成人av网站在线观看| 欧美色涩在线第一页| 91精品国产综合久久久久久久久久| 欧美电影免费观看完整版| 国产精品天干天干在观线| 亚洲免费观看高清| 免费久久99精品国产| 成人午夜视频在线| 欧美手机在线视频| 欧美精品一区二区久久久| 日韩毛片在线免费观看| 蜜桃免费网站一区二区三区| 成人99免费视频| 8x8x8国产精品| 国产日韩成人精品| 亚洲午夜免费电影| 国产在线不卡一区| 在线观看欧美精品| 久久久亚洲精品一区二区三区| 亚洲欧洲av另类| 麻豆91精品视频| 在线视频一区二区三| 精品国产免费人成在线观看| 亚洲欧美日韩人成在线播放| 精品一区二区三区在线观看| 在线看日本不卡| 国产午夜亚洲精品午夜鲁丝片 | 亚洲精品在线一区二区| 亚洲免费视频中文字幕| 国产一二精品视频| 欧美群妇大交群的观看方式| 国产精品激情偷乱一区二区∴| 奇米精品一区二区三区四区| 91在线云播放| 久久综合国产精品| 亚洲电影欧美电影有声小说| 成人丝袜18视频在线观看| 欧美一区二视频| 亚洲一区二区三区免费视频| 不卡一区二区三区四区| 欧美草草影院在线视频| 亚洲综合一二区| 高清beeg欧美| 2023国产精品自拍| 青青草视频一区| 精品视频一区三区九区| 国产精品福利一区| 成人一区二区三区中文字幕| 26uuu国产一区二区三区| 婷婷中文字幕综合| 欧美日韩久久久久久| 一区二区三区欧美日| 99国产精品99久久久久久| 欧美激情一区三区| 国产成人啪免费观看软件| 亚洲精品一区二区三区精华液| 舔着乳尖日韩一区| 欧美日韩高清一区二区不卡 | 日韩欧美国产电影| 日韩在线播放一区二区| 欧美无乱码久久久免费午夜一区 | 久久精品一区二区三区不卡牛牛| 日韩国产欧美一区二区三区| 91精品国产综合久久蜜臀| 日本怡春院一区二区| 欧美精品日韩综合在线| 天堂av在线一区| 91精品免费观看| 免费成人av在线| 日韩欧美在线观看一区二区三区| 亚洲第一二三四区| 欧美一区二区三区色| 久久精品国产精品亚洲综合| 日韩精品专区在线影院观看| 韩国成人在线视频| 日本一区二区三区国色天香| 国产91精品免费| 亚洲人成网站影音先锋播放| 91福利国产成人精品照片| 亚洲一区二区三区小说| 8x8x8国产精品| 国模少妇一区二区三区| 国产亚洲欧洲一区高清在线观看| 成人免费看黄yyy456| 亚洲精品午夜久久久| 在线不卡一区二区| 老色鬼精品视频在线观看播放| 精品处破学生在线二十三| 成人午夜私人影院| 亚洲主播在线播放| 日韩女优av电影在线观看| 风间由美一区二区三区在线观看| 亚洲欧美一区二区三区国产精品| 欧美日韩一二三区| 毛片不卡一区二区| 国产精品电影一区二区三区| 欧美视频在线一区| 国产美女精品人人做人人爽| 亚洲欧美中日韩| 日韩欧美久久久| 99久久精品国产观看| 日韩精品久久久久久| 国产精品美女视频|