00001
00002
00003
00004
00005 #ifndef SERVICEDISCOVERER_H
00006 #define SERVICEDISCOVERER_H
00007
00008
00009 #include <e32base.h>
00010 #include <aknviewappui.h>
00011
00012 #include <coecntrl.h>
00013 #include <es_sock.h>
00014 #include <btdevice.h>
00015 #include <bt_sock.h>
00016 #include <btsdp.h>
00017
00018 #include "Common.h"
00019
00020 class MServiceDiscoObserver
00021 {
00022
00023 public:
00029 virtual void HandleServiceDiscoveryCompleteL()=0;
00030 virtual void ReportServiceDiscoveryErrorL(TInt aError)=0;
00031 };
00032
00033
00034 class CServiceDiscoverer : public CBase,
00035 public MSdpAgentNotifier,
00036 public MSdpAttributeValueVisitor
00037 {
00038 public:
00039
00046 static CServiceDiscoverer* NewL(MServiceDiscoObserver& aObserver);
00047
00052 static CServiceDiscoverer* NewLC(MServiceDiscoObserver& aObserver);
00053
00059 ~CServiceDiscoverer();
00060
00071 void DiscoverServicesOnDeviceL(TDeviceData* aDevData);
00072
00080 void DiscoverServicesL(TDeviceDataList* aDevDataList);
00081
00089 void FinishDiscovery();
00090
00098 TBool HasServices();
00099
00100
00101 private:
00102
00108 CServiceDiscoverer(MServiceDiscoObserver& aObserver);
00109
00114 void ConstructL();
00115
00122 void HandleServiceDiscoveryCompleteL();
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 void NextRecordRequestComplete(
00134 TInt aError,
00135 TSdpServRecordHandle aHandle,
00136 TInt aTotalRecordsCount);
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 void AttributeRequestResult(
00150 TSdpServRecordHandle aHandle,
00151 TSdpAttributeID aAttrID,
00152 CSdpAttrValue* aAttrValue);
00153
00163 void AttributeRequestComplete(
00164 TSdpServRecordHandle aHandle,
00165 TInt aError);
00166
00175 void VisitAttributeValueL(CSdpAttrValue& aValue, TSdpElementType aType);
00176
00177 void StartListL(CSdpAttrValueList &aList);
00178
00179 void EndListL();
00180
00181 public:
00182
00183 TBool iRunning;
00184
00185 private:
00186
00187
00188 MServiceDiscoObserver& iObserver;
00189
00190 CSdpAgent* iAgent;
00191
00192 CSdpSearchPattern* iSpat;
00193
00194 TUUID iLastUUID;
00195
00196 TUint iPort;
00197
00198 TDeviceData* iDevData;
00199
00200 TDeviceDataList* iDevDataList;
00201
00202
00203
00204 TBool iDevDataChanged;
00205
00206 TInt iDeviceIdx;
00207 };
00208
00209 #endif