libraries/btserial/inc/btincomingserial.h
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // btincomingserial.h
       
     2 // 
       
     3 // Copyright (c) 2008 - 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 // 
       
     9 // Initial Contributors:
       
    10 // Accenture - Initial contribution
       
    11 //
       
    12 
       
    13 #ifndef __BTINCOMING_H__
       
    14 #define __BTINCOMING_H__
       
    15 
       
    16 #include <es_sock.h>
       
    17 #include <bt_sock.h>
       
    18 #include <btsdp.h>
       
    19 
       
    20 
       
    21 enum TBtSerialPanic
       
    22 	{
       
    23 	EBtSerialNotConnected,
       
    24 	EBtSerialWritePending,
       
    25 	EBtSerialReadPending,	
       
    26 	};
       
    27 
       
    28 class CBtService;
       
    29 class CBtRegQuery;
       
    30 
       
    31 class MBtIncomingConnectionObserver
       
    32 	{
       
    33 public:
       
    34 	virtual void BtSerialConnected() = 0;
       
    35 	virtual void BtWriteComplete(TInt aError) = 0;
       
    36 	virtual void BtReadComplete(TInt aError) = 0;
       
    37 	virtual void BtSerialError(TInt aError) = 0;
       
    38 	virtual void BtShutdownComplete(TInt /*aError*/) {};
       
    39 	virtual void BtNameReceived(TInt /*aError*/, const TDesC& /*aName*/) {};
       
    40 	};
       
    41 	
       
    42 class CBluetoothIncomingSerialConnection	: public CBase
       
    43 											, public MBluetoothSocketNotifier
       
    44 	{
       
    45 public:
       
    46 	IMPORT_C static CBluetoothIncomingSerialConnection* NewL(MBtIncomingConnectionObserver& aObserver);
       
    47 	IMPORT_C virtual ~CBluetoothIncomingSerialConnection();
       
    48 	
       
    49 	IMPORT_C void WaitForConnection();
       
    50 	IMPORT_C TBool Connected();
       
    51 	
       
    52 	IMPORT_C TBTDevAddr ConnectedDeviceAddrL();
       
    53 	IMPORT_C void GetConnectedDeviceNameL();
       
    54 	
       
    55 	/**
       
    56 	Write some data. Must already be connected, as signalled via a callback to BtSerialConnected();
       
    57 	
       
    58 	Will callback to BtWriteComplete() when completed, no more write must be sent until this event
       
    59 	occurs.
       
    60 	*/
       
    61 	IMPORT_C void Write(const TDesC8& aData);
       
    62 	IMPORT_C void CancelWrite();
       
    63 	/**
       
    64 	Read some data. Must already be connected, as signalled via a callback to BtSerialConnected();
       
    65 	
       
    66 	Will callback to BtReadComplete() when completed, no more write must be sent until this event
       
    67 	occurs.
       
    68 	*/
       
    69 	IMPORT_C void Read(TDes8& aData);
       
    70 	IMPORT_C void CancelRead();
       
    71 	
       
    72 	IMPORT_C void ShutDown();
       
    73 	
       
    74 private:
       
    75 friend class CBtService;
       
    76 friend class CBtRegQuery;
       
    77 	CBluetoothIncomingSerialConnection(MBtIncomingConnectionObserver& aObserver);
       
    78 	void ConstructL();
       
    79 
       
    80 	virtual void HandleConnectCompleteL(TInt aErr);
       
    81 	virtual void HandleAcceptCompleteL(TInt aErr);
       
    82 	virtual void HandleShutdownCompleteL(TInt aErr);
       
    83 	virtual void HandleSendCompleteL(TInt aErr);
       
    84 	virtual void HandleReceiveCompleteL(TInt aErr);
       
    85 	virtual void HandleIoctlCompleteL(TInt aErr);
       
    86 	virtual void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification& aEventNotification);
       
    87 
       
    88 	void HandleNewConnection(CBluetoothSocket* aConnectedSocket);
       
    89 	void HandleConnectFailed(TInt aError);
       
    90 	
       
    91 	void QueryComplete(TInt aError);
       
    92 private:
       
    93 	MBtIncomingConnectionObserver& iObserver;
       
    94 	RSdp iSdpSession;
       
    95 	RSocketServ iSockServ;
       
    96 	CBtService* iService;
       
    97 
       
    98 	CBluetoothSocket* iSocket;
       
    99 	TBool iSocketReady;
       
   100 	TBool iSending;
       
   101 	TBool iReceiving;
       
   102 	TSockXfrLength iXferLen;
       
   103 	
       
   104 	RBTRegServ iBtRegServ;
       
   105 	RBTRegistry iBtReg;
       
   106 	CBTRegistryResponse* iRegReponse;
       
   107 	CBtRegQuery* iRegQuery;
       
   108 	
       
   109 	CBTDevice* iConnectedDevice;
       
   110 	RBuf iDeviceName;
       
   111 	};
       
   112 
       
   113 #endif //__BTINCOMING_H__