bluetoothserver.h

来自「《基于symbian手机开发与应用》一书的源代码」· C头文件 代码 · 共 88 行

H
88
字号
#ifndef __BLUETOOTHSERVER_H__
#define __BLUETOOTHSERVER_H__

// System Includes
#include <es_sock.h>
#include <btmanclient.h>

// User defined include files
#include "BluetoothDefinitions.h"
#include "BluetoothObserver.h"

// Forward declaration
class CBluetoothAdvertiser;
class MBluetoothObserver;

// CLASS DECLARATION
/**
*
* @class	CBluetoothServer BluetoothServer.h
* @brief	This is the Bluetooth Server and handles setting up sockets for Bluetooth communications, triggering Security settings,
* and advertising services
*
* It requires an observer to handle UI feedback on certain events
* Copyright (c) EMCC Software Ltd 2003
* @version	1.0
*
*/

class CBluetoothServer : public CActive
	{
	public: // Constructors
		static CBluetoothServer* 	NewL(MBluetoothObserver& aObserver);
		static CBluetoothServer* 	NewLC(MBluetoothObserver& aObserver);
		~CBluetoothServer();

	private: // Consturctors - Symbian 2nd phase
		CBluetoothServer(MBluetoothObserver& aObserver);
		void 				ConstructL();

	public: // Functionality
		void 				StartServerL();
		void				StartAdvertisingL();
		void 				StopL();
		void 				Send(const TDesC& aMessage);
		TBool 				IsConnected();
		TBool 				AvailableToSend();

	public:// from CActive
		void RunL();
		void DoCancel();

	private: // Member functions
		void 				RequestData();
		void 				SetSecurityOnChannelL(TBool aAuthentication, TBool aEncryption, TBool aAuthorisation);
		void				AcceptConnectionsL();
		void 				SendL(const TDesC& aMessage);

	private: // Member data
		CBluetoothAdvertiser*							iAdvertiser;
		RSocketServ										iSocketServer;
		RSocket											iListeningSocket;
		RSocket											iAcceptedSocket;
		TSockXfrLength									iLen;
		TBuf8<KMaxMessageSizeDesc16 + sizeof (TInt)>	iMessage;
		RBTMan											iSecManager;
		MBluetoothObserver&								iObserver;
		RBTSecuritySettings								iSecSettingsSession;
		TInt											iChannel;


	private: // Member data - State machine definition
		enum TState
			{
			EDisconnected,
			ESettingSecurity,
			EConnecting,
			EConnected,
			EWaitingForMessage,
			ESendData
			};

		TState				iState;
	};

#endif // __BLUETOOTHSERVER_H__

// End of file

⌨️ 快捷键说明

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