examples/ForumNokia/BluetoothPMPExample/inc/ServiceDiscoverer.h

00001 /*
00002  * Copyright © 2009 Nokia Corporation.
00003  */
00004 
00005 #ifndef SERVICEDISCOVERER_H
00006 #define SERVICEDISCOVERER_H
00007 
00008 // INCLUDES
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  * NextRecordRequestComplete()
00126  *
00127  * discussion called when an service record
00128  *            (CSdpAgent::NextRecordRequestL()) operation completes.
00129  * param aError KErrNone, or an SDP error
00130  * param aHandle service record for which the query was made
00131  * param aTotalRecordsCount total number of matching records
00132  */
00133     void NextRecordRequestComplete(
00134         TInt aError,
00135         TSdpServRecordHandle aHandle,
00136         TInt aTotalRecordsCount);
00137 
00138 /*
00139  * AttributeRequestResult()
00140  *
00141  * discussion Called by the attribute request
00142  *            (CSdpAgent::AttributeRequestL()) to pass the results of
00143  *            a successful attribute request.
00144  *
00145  * param aHandle service record for which the query was made
00146  * param aAttrID ID of the attribute obtained
00147  * param aAttrValue attribute value obtained
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     // not needed -> not implemented
00177     void StartListL(CSdpAttrValueList &aList);
00178     // not needed -> not implemented
00179     void EndListL();
00180 
00181 public:
00182     // Service Discovery is running
00183     TBool iRunning;
00184 
00185 private:    // data
00186 
00187     // observer reference
00188     MServiceDiscoObserver& iObserver;
00189     // service discovery agent
00190     CSdpAgent* iAgent;
00191     // service discovery search pattern
00192     CSdpSearchPattern* iSpat;
00193     // last discovered uuid in the service attributes
00194     TUUID iLastUUID;
00195     // port (comm channel) found in the service attributes
00196     TUint iPort;
00197     // device data record reference
00198     TDeviceData* iDevData;
00199     // device data list reference
00200     TDeviceDataList* iDevDataList;
00201     // this indicates that a port number was found in the service attributes
00202     // and device data record for this device needs to be updated with the
00203     // port number.
00204     TBool iDevDataChanged;
00205     // index of device in device data list used for service discovery
00206     TInt iDeviceIdx;
00207 };
00208 
00209 #endif

Generated by  doxygen 1.6.2