www.pudn.com > ExampleBluetoothChat.rar > BluetoothServer.h


#ifndef __BLUETOOTHSERVER_H__ 
#define __BLUETOOTHSERVER_H__ 
 
// System Includes 
#include  
#include  
 
// 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	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