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

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

?? bluetoothchatappui.cpp

?? 關于symbian s60 2rd如何利用手機藍牙進行通訊
?? CPP
字號:
/**
*
* @brief Definition of CBluetoothChatAppUi
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// Class include
#include "BluetoothChatAppUi.h"

// System includes
#include <AknGlobalNote.h>
#include <AknNoteWrappers.h>
#include <AknQueryDialog.h>
#include <AknWaitDialog.h>
#include <BluetoothChat.rsg>		// R_BLUETOOTHCHAT_DIALOG
#include <eikmenup.h>
#include <stringloader.h>		// StringLoader

// User includes
#include "BluetoothChatDialog.h"	// CBluetoothChatDialog
#include "BluetoothChat.hrh"		// commands
#include "BluetoothDeviceSearcher.h"	// CBluetoothDeviceSearcher
#include "BluetoothServiceSearcher.h"	// CBluetoothServiceSearcher
#include "BluetoothClient.h"		// CBluetoothClient
#include "BluetoothServer.h"		// CBluetoothServer


// Constants
const TInt KFormattedMessagePrefixLength = 10;
_LIT(KFormattedMessagePrefix, "Message:\n");
const TInt KServerCleanupDelayMicroSeconds = 4000000;


// ================= MEMBER FUNCTIONS =======================

/**
* Symbian OS 2nd phase constructor.
* Constructs and executes the application's dialog,
* setting itself as the dialog's MOP parent, and adds it to the control
* stack.
*
* Creates an instance of the Bluetooth Client and Server
*
* @param none
* @return none
*/
void CBluetoothChatAppUi::ConstructL()
	{
	BaseConstructL();
	iAppDialog = new (ELeave) CBluetoothChatDialog;
	iAppDialog->SetMopParent(this);
	iAppDialog->ExecuteLD(R_BLUETOOTHCHAT_DIALOG);
	AddToStackL(iAppDialog);

	iClient = CBluetoothClient::NewL(*this);
	iServer = CBluetoothServer::NewL(*this);
	}

/**
* Destructor.
* Removes the application's dialog from the stack and deletes it.
*
* Deletes the Bluetooth Client and Server, and message buffer
*
*/
CBluetoothChatAppUi::~CBluetoothChatAppUi()
	{
	if (iAppDialog)
		{
		RemoveFromStack(iAppDialog);
		delete iAppDialog;
		}

	delete iWaitDialog;

	delete iClient;
	delete iServer;

	delete iMessage;
	}

/**
* Dynamic Menu Construction
*
* Restricts options available to the User via the Menu
* Performs checks on the state of the Client and Server to see what should be offered
*
* @param aResourceId
* @param @aMenuPane
* @return none
*/
void CBluetoothChatAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
	{
	if (aResourceId == R_BLUETOOTHCHAT_MENU_PANE)
		{
		if (iClient->IsConnected() || iServer->IsConnected())
			{
			aMenuPane->SetItemDimmed(EBluetoothChatConnect, ETrue);
			aMenuPane->SetItemDimmed(EBluetoothChatReceive, ETrue);
			if (iClient->IsConnected())
				{
				aMenuPane->SetItemDimmed(EBluetoothChatStopReceive, ETrue);
				}
			if (!iClient->AvailableToSend() && !iServer->AvailableToSend())
				{
				aMenuPane->SetItemDimmed(EBluetoothChatSend, ETrue);
				}
			}
		else
			{
			aMenuPane->SetItemDimmed(EBluetoothChatStopReceive, ETrue);
			aMenuPane->SetItemDimmed(EBluetoothChatSend, ETrue);
			}
		}
	}

/**
* From CEikAppUi, takes care of command handling.
*
* @param aCommand command to be handled
* @return none
*/
void CBluetoothChatAppUi::HandleCommandL(TInt aCommand)
	{
	switch (aCommand)
		{
		case EBluetoothChatConnect:
			{
			FindRemoteDeviceL();
			break;
			}

		case EBluetoothChatReceive:
			{
			StartReceivingL();
			break;
			}

		case EBluetoothChatStopReceive:
			{
			iServer->StopL();
			break;
			}

		case EBluetoothChatSend:
			{
			if (ComposeMessageL())
				{
				if (iClient->AvailableToSend())
					{
					iClient->Send(*iMessage);
					}
				else if (iServer->AvailableToSend())
					{
					iServer->Send(*iMessage);
					}
				}
			break;
			}

		case EEikCmdExit:
			{
			Exit();
			break;
			}

		default:
			break;
		}
	}

/**
* Begin Client side communication.
*
* Find a Device
* Find Service on device and obtain Port information
* Pass to the Client to form a connection
* @param none
* @return none
*/
void CBluetoothChatAppUi::FindRemoteDeviceL()
	{
	iDeviceSearcher = CBluetoothDeviceSearcher::NewL(*this);
	iDeviceSelectionResponse = new (ELeave) TBTDeviceResponseParamsPckg();
	iDeviceSearcher->SelectDeviceL(*iDeviceSelectionResponse);
	}

void CBluetoothChatAppUi::DeviceFoundL(TInt result)
	{
	delete iDeviceSearcher;	// delete and cleanup
	iDeviceSearcher = 0;

	if (result == KErrNone)
		{
		TInt port = 0;
		CBluetoothServiceSearcher* serviceSearcher = CBluetoothServiceSearcher::NewLC(port);
		TInt serviceFound = serviceSearcher->FindServiceL((*iDeviceSelectionResponse)().BDAddr());
		CleanupStack::PopAndDestroy( serviceSearcher );

		if (serviceFound == KErrNone)
			{
			iClient->ConnectToServerL((*iDeviceSelectionResponse)().BDAddr(), port);
			}
		else
			{
			CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
			HBufC* warning = StringLoader::LoadLC(R_SERVICE_NOT_FOUND);
			globalNote->ShowNoteL(EAknGlobalWarningNote, *warning);
			CleanupStack::PopAndDestroy(globalNote);
			CleanupStack::PopAndDestroy(warning);

			// Permit clean up of Bluetooth server connection
			User::After(TTimeIntervalMicroSeconds32(KServerCleanupDelayMicroSeconds));
			}
		}

	delete iDeviceSelectionResponse;
	iDeviceSelectionResponse = 0;
	}

/**
* Begin Server side communication.
*
* Starts Server - this will start the server and configure the security settings
*
* @param none
* @return none
*/
void CBluetoothChatAppUi::StartReceivingL()
	{
	iServer->StartServerL();
	}


/**
* React to completion of server startup.
*
* Starts advertising on server
* Display a dialog box with the option to cancel this listening process
*
* @param none
* @return none
*/
void CBluetoothChatAppUi::ServerStartedL()
	{

	// start the server's advertiser.
	iServer->StartAdvertisingL();

	// display a dialog to allow a user to cancel listening if required.
	delete iWaitDialog;
	iWaitDialog = NULL;
	iWaitDialog = new (ELeave) CAknWaitDialog(NULL, ETrue);
	HBufC* waitingMessage = StringLoader::LoadLC(R_WAITING_MESSAGE);
	iWaitDialog->SetTextL(*waitingMessage);
	CleanupStack::PopAndDestroy(waitingMessage);
	TInt retVal = iWaitDialog->ExecuteLD(R_BLUETOOTH_CONNECTION_WAIT_DIALOG);
	iWaitDialog = NULL;

	if (retVal != EAknSoftkeyDone)
		{
		// User has cancelled this connection process
		iServer->StopL();
		}

	}


/**
* Connection Made.
*
* Server - Remove the Cancel dialog
* Client - Provide feedback that a connection has been made
* @param none
* @return none
*/
void CBluetoothChatAppUi::ConnectedL()
	{
	if (iWaitDialog)
		{
		iWaitDialog->ProcessFinishedL();
		iWaitDialog = NULL;
		}

	if (iClient->IsConnected())
		{
		CAknInformationNote* infoDialog = new (ELeave) CAknInformationNote();
		HBufC* message = StringLoader::LoadLC(R_CONNECTED);
		infoDialog->ExecuteLD(*message);
		CleanupStack::PopAndDestroy(message);
		}
	}

/**
* Provides a UI Text Query Dialog requesting message to be sent.
*
* @param none
* @return true if message was composed by user
*/
TBool CBluetoothChatAppUi::ComposeMessageL()
	{
	TBool retVal = EFalse;

	delete iMessage;
	iMessage = NULL;
	iMessage = HBufC::NewL(KMaxMessageLength);
	TPtr message = iMessage->Des();

	HBufC* titleBuf = StringLoader::LoadLC(R_CHAT_TITLE);
	CAknTextQueryDialog* messageDialog = new (ELeave) CAknTextQueryDialog(message, *titleBuf, CAknTextQueryDialog::ENoTone);
	CleanupStack::PopAndDestroy(titleBuf);
	messageDialog->SetMaxLength(KMaxMessageLength);

	if (messageDialog->ExecuteLD(R_BLUETOOTH_CHAT_MESSAGE_DIALOG))
		{
		retVal = ETrue;
		}

	return retVal;
	}

/**
* Display the message received from remote device.
* @param aMessage the message received
* @return none
*/
void CBluetoothChatAppUi::DataReceivedL(const TDesC& aMessage)
	{
	TBuf<KMaxMessageLength + KFormattedMessagePrefixLength> formattedMessage;
	formattedMessage.Append(KFormattedMessagePrefix);
	formattedMessage.Append(aMessage);
	CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog(formattedMessage, CAknQueryDialog::ENoTone);

	if (queryDialog->ExecuteLD(R_BLUETOOTH_CHAT_REPLY_DIALOG) == EBluetoothReply)
		{
		HandleCommandL(EBluetoothChatSend);
		}
	}

/**
* Provide UI feedback of errors occured during communication
* @param aErrorCode code repesenting the error that occured
*/
void CBluetoothChatAppUi::HandleErrorL(TInt aErrorCode)
	{
	HBufC* message;

	switch (aErrorCode)
		{
		case (KErrDisconnected):
		case (KErrAbort):
			{
			message = StringLoader::LoadLC(R_DISCONNECTED);
			break;
			}

		case (KErrNotReady):
			{
			message = StringLoader::LoadLC(R_CONNECTION_LOST);
			break;
			}

		case (KErrCouldNotConnect):
			{
			message = StringLoader::LoadLC(R_COULD_NOT_CONNECT);
			break;
			}

		default:
			{
			message = StringLoader::LoadLC(R_UNKNOWN_ERROR);
			break;
			}
		}

	CAknWarningNote* errorDialog = new (ELeave) CAknWarningNote();
	errorDialog->ExecuteLD(*message);
	CleanupStack::PopAndDestroy(message);
	}

// End of File

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品久久五月天| 亚洲欧美一区二区久久 | 欧美色精品天天在线观看视频| 在线不卡免费av| 国产精品色一区二区三区| 亚洲成av人在线观看| 成人精品视频一区二区三区尤物| 欧美一区二区三区在线观看| 亚洲伦在线观看| 国产一区二区0| 91精品免费在线| 亚洲一区二区三区四区在线免费观看| 国产精品一级黄| 日韩欧美中文字幕制服| 亚洲午夜成aⅴ人片| 国产精品久久影院| 日韩你懂的电影在线观看| 亚洲男人的天堂在线观看| 国产精品456| 精品国产乱码91久久久久久网站| 亚洲免费观看高清完整版在线观看熊 | 亚洲综合一区二区三区| 懂色中文一区二区在线播放| 欧美xxxx在线观看| 美女精品自拍一二三四| 欧美精品三级日韩久久| 洋洋成人永久网站入口| 日本韩国视频一区二区| 18涩涩午夜精品.www| 成人av综合在线| 国产精品每日更新| 成人永久aaa| 7777精品伊人久久久大香线蕉最新版 | 国产经典欧美精品| 久久久久久久电影| 国产在线不卡视频| 国产偷国产偷精品高清尤物| 国产一区二区三区不卡在线观看 | 亚洲日本韩国一区| 99久久伊人网影院| 亚洲女同一区二区| 在线免费观看日本一区| 亚洲第一av色| 日韩欧美中文字幕精品| 久久丁香综合五月国产三级网站 | 欧美日韩精品一区二区三区四区 | 国产精品久久福利| 一本色道**综合亚洲精品蜜桃冫| 一级做a爱片久久| 欧美日韩一区视频| 精品中文字幕一区二区小辣椒| 精品国产免费久久 | 91精品国产综合久久精品| 欧美专区日韩专区| 亚洲成人中文在线| 日韩欧美成人激情| 国产露脸91国语对白| 亚洲欧洲精品一区二区精品久久久| 色婷婷久久一区二区三区麻豆| 亚洲成在人线在线播放| 日韩欧美在线网站| 成人av在线资源| 亚洲 欧美综合在线网络| 欧美精品一区男女天堂| 99re成人在线| 麻豆91在线播放| 亚洲日穴在线视频| 日韩午夜av电影| 成人18视频日本| 日本不卡视频在线| 国产精品国产三级国产aⅴ入口| 欧美日本国产视频| 国产 日韩 欧美大片| 亚洲福利一区二区三区| 久久久综合九色合综国产精品| av激情成人网| 久久er99热精品一区二区| 日韩毛片一二三区| 精品国产乱码久久久久久夜甘婷婷| 成人免费高清在线观看| 日本免费新一区视频| 日本一区二区三区四区| 在线综合视频播放| 日本精品一区二区三区高清| 另类小说图片综合网| 亚洲激情自拍偷拍| 国产午夜精品久久久久久久 | 成人精品高清在线| 免费高清视频精品| 亚洲午夜成aⅴ人片| 国产精品美女视频| 久久品道一品道久久精品| 欧美高清精品3d| 日本精品一级二级| 波多野结衣视频一区| 国产电影一区在线| 国产一区二区三区不卡在线观看| 一区二区三区日韩欧美| 精品国产乱码久久| 欧美三级韩国三级日本一级| 成人禁用看黄a在线| 国产一区91精品张津瑜| 秋霞国产午夜精品免费视频| 亚洲综合成人网| 亚洲欧美日韩在线不卡| 中文字幕一区二区三区在线播放| 久久奇米777| 国产亚洲欧美激情| 久久综合久色欧美综合狠狠| 精品少妇一区二区三区在线视频| 欧美夫妻性生活| 制服丝袜中文字幕亚洲| 欧美日韩中文字幕精品| 欧美在线你懂得| 欧美性生活大片视频| 91福利视频网站| 欧美日韩中字一区| 欧美日韩精品一区二区天天拍小说| 91啪亚洲精品| 欧美视频在线播放| 欧美日韩国产区一| 日韩片之四级片| 26uuuu精品一区二区| 久久丝袜美腿综合| 国产精品久久毛片a| 亚洲丝袜另类动漫二区| 亚洲精品乱码久久久久久| 亚洲人成小说网站色在线| 亚洲另类春色校园小说| 午夜精品久久久久久| 蜜臀久久99精品久久久久宅男| 久久国产尿小便嘘嘘| 丰满少妇久久久久久久| 99精品国产热久久91蜜凸| 欧美三级电影网| 日韩欧美www| 欧美激情中文字幕| 一区二区三区成人在线视频| 午夜精品视频一区| 国内精品不卡在线| 99久久综合色| 在线成人小视频| 国产农村妇女毛片精品久久麻豆| 亚洲男同性恋视频| 日韩二区在线观看| 国产91高潮流白浆在线麻豆| 99久久精品免费看国产| 日本高清成人免费播放| 日韩一区二区免费在线电影| 国产婷婷色一区二区三区 | 欧美mv日韩mv国产| 18欧美亚洲精品| 美女久久久精品| 94-欧美-setu| 亚洲精品一线二线三线| 亚洲色图视频免费播放| 久久99精品国产.久久久久久 | 国产成人免费高清| 欧美少妇bbb| 国产精品美女一区二区| 美女一区二区三区| 日本道色综合久久| 久久久久久久综合狠狠综合| 天天影视涩香欲综合网| 成a人片国产精品| 日韩精品专区在线影院观看 | 捆绑变态av一区二区三区| av在线一区二区三区| 日韩欧美国产综合在线一区二区三区| 国产精品热久久久久夜色精品三区 | 91精品国产麻豆国产自产在线| 亚洲国产精品精华液ab| 久久不见久久见免费视频7| 欧美性视频一区二区三区| 日本一二三四高清不卡| 经典三级在线一区| 欧美久久久久久久久久| 亚洲精品视频观看| 国产成人高清在线| 欧美zozo另类异族| 五月天丁香久久| 欧美日韩精品一区二区三区四区 | 日韩激情av在线| 色久综合一二码| 中文字幕亚洲一区二区va在线| 精品一区二区三区蜜桃| 日韩天堂在线观看| 免费观看成人鲁鲁鲁鲁鲁视频| 欧美性xxxxxxxx| 亚洲一区成人在线| 91丝袜美腿高跟国产极品老师| 国产日韩欧美综合一区| 国产高清在线观看免费不卡| 精品免费99久久| 国精产品一区一区三区mba视频 | 亚洲国产乱码最新视频| 色哟哟亚洲精品| 亚洲免费在线观看视频| 成人黄色一级视频| 国产精品久久久久久久久免费丝袜 |