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 __BTDISCOVERER_H
00026 #define __BTDISCOVERER_H
00027
00028 #include "clientservercommon.h"
00029
00030 class CServerSession;
00031
00032
00033 _LIT(KBTDiscovererPanic, "CBTDiscoverer");
00034
00035 const TInt KErrBtdiscovererBase = -10500;
00036 const TInt KErrBtdiscovererAllocFailed = KErrBtdiscovererBase - 1;
00037
00038
00039 typedef RPointerArray<TNameRecord> RDeviceAddressList;
00040
00047 class CBTDiscoverer : public CActive,
00048 public MSdpAgentNotifier,
00049 public MSdpAttributeValueVisitor
00050 {
00051 public:
00052 static CBTDiscoverer * NewL(RMessage &aMessage, CServerSession &aSession);
00053 ~CBTDiscoverer();
00054
00055 void StartL(RSocketServ &aSocketServ);
00056
00057
00058 void RunL();
00059 TInt RunError(TInt aError);
00060 void DoCancel();
00061
00062
00063 void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError);
00064 void AttributeRequestResult(TSdpServRecordHandle aHandle,
00065 TSdpAttributeID aAttrID,
00066 CSdpAttrValue* aAttrValue);
00067 void NextRecordRequestComplete(TInt aError,
00068 TSdpServRecordHandle aHandle,
00069 TInt aTotalRecordsCount);
00070
00071
00072 void VisitAttributeValueL(CSdpAttrValue &aValue, TSdpElementType aType);
00073 void StartListL(CSdpAttrValueList &aList);
00074 void EndListL();
00075
00076 private:
00077 CBTDiscoverer(RMessage &aMessage, CServerSession &aSession);
00078 void ConstructL();
00079 void DeviceDiscovered();
00080 void DiscoverServices(TNameRecord &aNameRecord);
00081 void FinishDiscovery();
00082 void ParseUuid(TDes &aBuf, const TUUID &aUuid, TUint32 &aUuid32);
00083
00084
00085 RMessage &iMessage;
00086 CServerSession &iSession;
00087
00088
00089 RHostResolver iHr;
00090 TNameEntry iNameEntry;
00091
00092
00093 CSdpSearchPattern *iSdpPattern;
00094 CSdpAgent *iAgent;
00095 CSdpAttrIdMatchList *iAttrMatchList;
00096
00097
00098 TUint32 iLastUuid32;
00099
00100
00101 TInt iRfcommPort;
00102
00103
00104 TInt iL2capPort;
00105
00106
00107 TServiceName iServiceName;
00108
00109
00110 RDeviceAddressList iDeviceAddresses;
00111
00112
00113 TInt iCurrentDeviceIndex;
00114
00115
00116 TInt iNumPeers;
00117
00118
00119 TPeerDataList *iPeerList;
00120 };
00121
00122 #endif