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
00041
00042 class CBTDiscoverer : public CActive,
00043 public MSdpAgentNotifier,
00044 public MSdpAttributeValueVisitor
00045 {
00046 public:
00047 static CBTDiscoverer * NewL(RMessage &aMessage, CServerSession &aSession);
00048 ~CBTDiscoverer();
00049
00050 void StartL(RSocketServ &aSocketServ);
00051
00052
00053 void RunL();
00054 TInt RunError(TInt aError);
00055 void DoCancel();
00056
00057
00058 void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError);
00059 void AttributeRequestResult(TSdpServRecordHandle aHandle,
00060 TSdpAttributeID aAttrID,
00061 CSdpAttrValue* aAttrValue);
00062 void NextRecordRequestComplete(TInt aError,
00063 TSdpServRecordHandle aHandle,
00064 TInt aTotalRecordsCount);
00065
00066
00067 void VisitAttributeValueL(CSdpAttrValue &aValue, TSdpElementType aType);
00068 void StartListL(CSdpAttrValueList &aList);
00069 void EndListL();
00070 private:
00071 enum TDiscoveryState {
00072 ENone = 1,
00073 EDiscoveringDevice,
00074 EDiscoveringService
00075 };
00076
00077 CBTDiscoverer(RMessage &aMessage, CServerSession &aSession);
00078 void ConstructL();
00079 void DeviceDiscovered();
00080 void DiscoverServices(TNameRecord &aNameRecord);
00081 void FinishDiscovery();
00082
00083 RMessage &iMessage;
00084 CServerSession &iSession;
00085
00086
00087 RHostResolver iHr;
00088 TNameEntry iNameEntry;
00089
00090
00091 CSdpSearchPattern *iSdpPattern;
00092 CSdpAgent *iAgent;
00093
00094
00095 TInt iAttrNum;
00096 TBool iPeerOk;
00097
00098
00099 RDeviceAddressList iDeviceAddresses;
00100
00101
00102 TInt iCurrentDeviceIndex;
00103
00104
00105 TInt iNumPeers;
00106
00107 TPeerDataList *iPeerList;
00108 };
00109
00110 #endif