00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __BLUETOOTHCOMMUNICATOR_H
00026 #define __BLUETOOTHCOMMUNICATOR_H
00027
00028 #include <e32base.h>
00029 #include <e32svr.h>
00030 #include <btsdp.h>
00031 #include <es_sock.h>
00032
00033 #include "clientservercommon.h"
00034
00035
00036 _LIT(KBTCommPanic, "CBTCommunicator");
00037
00038 const TInt KErrBTCommAlreadyListening = -9990;
00039 const TInt KerrBTCommFailedToCreateListeningSocket = -9991;
00040
00041
00042 const TInt KListeningQueueSize = 8;
00043
00044 class CServerSession;
00045 class CBTDiscoverer;
00046 class CConcreteConnection;
00047
00054 class CBTCommunicator : public CBase
00055 {
00056 public:
00057 static CBTCommunicator * NewL(CServerSession *aSession);
00058 ~CBTCommunicator();
00059
00066 RSocket* ConnectL(TPeerData *aPeerData);
00067
00076 void DiscoverPeersL(const RMessage &aMessage,
00077 CServerSession &aSession);
00078
00092 CConcreteConnection* StartListeningL(const TInt aServiceClassID,
00093 const TInt aApplicationID,
00094 const TDesC8 &aServiceName,
00095 const TDesC8 &aServiceDesc,
00096 TInt aListeningSocketType);
00100 void StopListeningL();
00101
00110 static TInt ResolveMTU(RSocket& socket);
00111
00112 private:
00113 CBTCommunicator(CServerSession *aSession);
00114 void ConstructL();
00115 void StartAdvertisingL(TInt aPort,
00116 const TInt aServiceClassID,
00117 const TInt aApplicationID,
00118 const TDesC8 &aServiceName,
00119 const TDesC8 &aServiceDesc);
00120 TInt OpenListeningSocketL();
00121 void SetChannelSecurityL(TInt aChannel);
00122 void SetAvailabilityL(TBool aIsAvailable);
00123
00124
00125 CServerSession *iServerSession;
00126
00127
00128 CBTDiscoverer *iDiscoverer;
00129
00130
00131 TBool iIsListening;
00132
00133
00134 TInt iListeningSocketType;
00135
00136
00137 RSocketServ iSocketServ;
00138 RSocket iListeningSocket;
00139 CConcreteConnection *iListeningConnection;
00140
00141
00142 CSdpAgent *iAgent;
00143 RSdp iSdpSession;
00144 RSdpDatabase iSdpDB;
00145
00146
00147 TSdpServRecordHandle iRecord;
00148
00149
00150 TInt iRecordVersion;
00151 };
00152
00153 #endif