|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
#include <ChatBtServiceSearcher.h>
Inheritance diagram for CChatBtServiceSearcher:

Public Member Functions | |
| virtual | ~CChatBtServiceSearcher () |
| void | SelectDeviceByDiscoveryL (TRequestStatus &aObserverRequestStatus) |
| void | FindServiceL (TRequestStatus &aObserverRequestStatus) |
| const TBTDevAddr & | BTDevAddr () |
| const TBTDeviceResponseParams & | ResponseParams () |
| void | NextRecordRequestComplete (TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount) |
| void | AttributeRequestResult (TSdpServRecordHandle aHandle, TSdpAttributeID aAttrID, CSdpAttrValue *aAttrValue) |
| void | AttributeRequestComplete (TSdpServRecordHandle aHandle, TInt aError) |
Protected Member Functions | |
| CChatBtServiceSearcher (MLog &aLog) | |
| virtual void | Finished (TInt aError=KErrNone) |
| virtual TBool | HasFinishedSearching () const |
| TBool | HasFoundService () const |
| virtual RArray< TChatSdpAttributeParser::TChatSdpAttributeNode > & | ProtocolList ()=0 |
| virtual const TUUID & | ServiceClass () const =0 |
| virtual void | FoundElementL (TInt aKey, CSdpAttrValue &aValue)=0 |
Private Member Functions | |
| void | NextRecordRequestCompleteL (TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount) |
| void | AttributeRequestResultL (TSdpServRecordHandle aHandle, TSdpAttributeID aAttrID, CSdpAttrValue *aAttrValue) |
| void | AttributeRequestCompleteL (TSdpServRecordHandle, TInt aError) |
Private Attributes | |
| TRequestStatus * | iStatusObserver |
| TBool | iIsDeviceSelectorConnected |
| RNotifier | iDeviceSelector |
| TBTDeviceResponseParamsPckg | iResponse |
| TBTDeviceSelectionParamsPckg | iSelectionFilter |
| CSdpAgent * | iAgent |
| CSdpSearchPattern * | iSdpSearchPattern |
| TBool | iHasFoundService |
| MLog & | iLog |
Definition at line 39 of file ChatBtServiceSearcher.h.
|
|
~CChatBtServiceSearcher() Destroy the object and release all memory objects Definition at line 40 of file ChatBtServiceSearcher.cpp. References iAgent, iDeviceSelector, iIsDeviceSelectorConnected, and iSdpSearchPattern. 00041 { 00042 if ( iIsDeviceSelectorConnected ) 00043 { 00044 iDeviceSelector.CancelNotifier( KDeviceSelectionNotifierUid ); 00045 iDeviceSelector.Close(); 00046 } 00047 delete iSdpSearchPattern; 00048 iSdpSearchPattern = NULL; 00049 00050 delete iAgent; 00051 iAgent = NULL; 00052 }
|
|
|
CChatBtServiceSearcher() Constructs this object
Definition at line 29 of file ChatBtServiceSearcher.cpp. 00030 : iIsDeviceSelectorConnected( EFalse ), 00031 iLog( aLog ) 00032 { 00033 }
|
|
|
SelectDeviceByDiscoveryL() Select a device
Definition at line 59 of file ChatBtServiceSearcher.cpp. References iDeviceSelector, iIsDeviceSelectorConnected, iResponse, iSelectionFilter, and ServiceClass(). 00061 { 00062 if ( ! iIsDeviceSelectorConnected ) 00063 { 00064 User::LeaveIfError( iDeviceSelector.Connect() ); 00065 iIsDeviceSelectorConnected = ETrue; 00066 } 00067 00068 00069 iSelectionFilter().SetUUID( ServiceClass() ); 00070 00071 iDeviceSelector.StartNotifierAndGetResponse( 00072 aObserverRequestStatus, 00073 KDeviceSelectionNotifierUid, 00074 iSelectionFilter, 00075 iResponse ); 00076 }
|
|
|
FindServiceL() Find a service on the specified device
Definition at line 83 of file ChatBtServiceSearcher.cpp. References BTDevAddr(), iAgent, iHasFoundService, iResponse, iSdpSearchPattern, iStatusObserver, and ServiceClass(). 00084 { 00085 if ( !iResponse().IsValidBDAddr() ) 00086 { 00087 User::Leave( KErrNotFound ); 00088 } 00089 iHasFoundService = EFalse; 00090 00091 // delete any existing agent and search pattern 00092 delete iSdpSearchPattern; 00093 iSdpSearchPattern = NULL; 00094 00095 delete iAgent; 00096 iAgent = NULL; 00097 00098 iAgent = CSdpAgent::NewL( *this, BTDevAddr() ); 00099 00100 iSdpSearchPattern = CSdpSearchPattern::NewL(); 00101 00102 iSdpSearchPattern->AddL( ServiceClass() ); 00103 // return code is the position in the list that the UUID is inserted at 00104 // and is intentionally ignored 00105 00106 iAgent->SetRecordFilterL( *iSdpSearchPattern ); 00107 00108 iStatusObserver = &aObserverRequestStatus; 00109 00110 iAgent->NextRecordRequestL(); 00111 }
|
|
Definition at line 289 of file ChatBtServiceSearcher.cpp. References iResponse. 00290 { 00291 return iResponse().BDAddr(); 00292 }
|
|
Definition at line 299 of file ChatBtServiceSearcher.cpp. References iResponse. 00300 { 00301 return iResponse(); 00302 }
|
|
|
Finished() The search has finished. Notify the observer that the process is complete. Definition at line 265 of file ChatBtServiceSearcher.cpp. References HasFoundService(), and iStatusObserver. 00266 { 00267 if ( aError == KErrNone && !HasFoundService() ) 00268 { 00269 aError = KErrNotFound; 00270 } 00271 User::RequestComplete( iStatusObserver, aError ); 00272 }
|
|
|
HasFinishedSearching() Is the instance still wanting to search.
Definition at line 279 of file ChatBtServiceSearcher.cpp.
|
|
Definition at line 309 of file ChatBtServiceSearcher.cpp. References iHasFoundService. 00310 { 00311 return iHasFoundService; 00312 }
|
|
|
ProtocolList() The list of Protocols required by the service. Implemented in CChatServiceSearcher. |
|
|
ServiceClass() The service class to search for
Implemented in CChatServiceSearcher. |
|
||||||||||||
|
FoundElementL() Read the data element
Implements MChatSdpAttributeNotifier. Implemented in CChatServiceSearcher. |
|
||||||||||||||||
|
NextRecordRequestComplete() Process the result of the next record request
Definition at line 118 of file ChatBtServiceSearcher.cpp. References NextRecordRequestCompleteL(). 00122 { 00123 TRAPD( error, 00124 NextRecordRequestCompleteL( aError, aHandle, aTotalRecordsCount ) ); 00125 00126 if ( error != KErrNone ) 00127 { 00128 Panic( EChatBtServiceSearcherNextRecordRequestComplete ); 00129 } 00130 }
|
|
||||||||||||||||
|
AttributeRequestResult() Process the next attribute requested
Definition at line 174 of file ChatBtServiceSearcher.cpp. References AttributeRequestResultL(). 00178 { 00179 TRAPD( error, AttributeRequestResultL( aHandle, aAttrID, aAttrValue ) ); 00180 if ( error != KErrNone ) 00181 { 00182 Panic( EChatBtServiceSearcherAttributeRequestResult ); 00183 } 00184 // Delete obsolete local atribute pointer. 00185 delete aAttrValue; 00186 aAttrValue = NULL; 00187 }
|
|
||||||||||||
|
AttributeRequestComplete() Process the arrtibute request completion
Definition at line 218 of file ChatBtServiceSearcher.cpp. References AttributeRequestCompleteL(). 00220 { 00221 TRAPD( error, AttributeRequestCompleteL( aHandle, aError ) ); 00222 if ( error != KErrNone ) 00223 { 00224 Panic( EChatBtServiceSearcherAttributeRequestComplete ); 00225 } 00226 }
|
|
||||||||||||||||
|
NextRecordRequestCompleteL() Process the result of the next record request
Definition at line 137 of file ChatBtServiceSearcher.cpp. References Finished(), iAgent, iLog, and MLog::LogL(). 00141 { 00142 if ( aError == KErrEof ) 00143 { 00144 Finished(); 00145 return; 00146 } 00147 00148 if ( aError != KErrNone ) 00149 { 00150 iLog.LogL( KErrNRRCErr, aError ); 00151 Finished( aError ); 00152 return; 00153 } 00154 00155 if ( aTotalRecordsCount == 0 ) 00156 { 00157 HBufC* errNRRCNoRecords = StringLoader 00158 ::LoadLC ( R_CHAT_ERR_NRRC_NO_RECORDS ); 00159 iLog.LogL( *errNRRCNoRecords ); 00160 CleanupStack::PopAndDestroy ( errNRRCNoRecords ); 00161 Finished( KErrNotFound ); 00162 return; 00163 } 00164 00165 // Request its attributes 00166 iAgent->AttributeRequestL( aHandle, KSdpAttrIdProtocolDescriptorList ); 00167 }
|
|
||||||||||||||||
|
AttributeRequestResultL() Process the next attribute requested
Definition at line 194 of file ChatBtServiceSearcher.cpp. References TChatSdpAttributeParser::HasFinished(), iHasFoundService, and ProtocolList(). 00198 { 00199 __ASSERT_ALWAYS( aAttrID == KSdpAttrIdProtocolDescriptorList, 00200 User::Leave( KErrNotFound ) ); 00201 TChatSdpAttributeParser parser( ProtocolList(), *this ); 00202 00203 // Validate the attribute value, and extract the RFCOMM channel 00204 aAttrValue->AcceptVisitorL( parser ); 00205 00206 if ( parser.HasFinished() ) 00207 { 00208 // Found a suitable record so change state 00209 iHasFoundService = ETrue; 00210 } 00211 }
|
|
||||||||||||
|
AttributeRequestCompleteL() Process the arrtibute request completion
Definition at line 233 of file ChatBtServiceSearcher.cpp. References Finished(), HasFinishedSearching(), iAgent, iLog, and MLog::LogL(). 00236 { 00237 if ( aError != KErrNone ) 00238 { 00239 HBufC* errCantGetAttribute = StringLoader 00240 ::LoadLC ( R_CHAT_ERR_CANT_GET_ATTRIBUTE ); 00241 iLog.LogL( *errCantGetAttribute, aError ); 00242 CleanupStack::PopAndDestroy ( errCantGetAttribute ); 00243 } 00244 else if ( !HasFinishedSearching() ) 00245 { 00246 // have not found a suitable record so request another 00247 iAgent->NextRecordRequestL(); 00248 } 00249 else 00250 { 00251 HBufC* errAttrReqCom = StringLoader 00252 ::LoadLC ( R_CHAT_ERR_ATTR_REQ_COM ); 00253 iLog.LogL( *errAttrReqCom ); 00254 CleanupStack::PopAndDestroy ( errAttrReqCom ); 00255 Finished(); 00256 } 00257 }
|
|
|
iStatusObserver pointer to the request status observer Not owned by CChatBtServiceSearcher Definition at line 209 of file ChatBtServiceSearcher.h. |
|
|
iIsDeviceSelectorConnected is the device selector connected? Definition at line 215 of file ChatBtServiceSearcher.h. |
|
|
iDeviceSelector a handle to the bluetooth device selector notifier Definition at line 221 of file ChatBtServiceSearcher.h. |
|
|
iResponse the response of the device selection. Definition at line 227 of file ChatBtServiceSearcher.h. |
|
|
iSelectionFilter Request a device selection Definition at line 233 of file ChatBtServiceSearcher.h. |
|
|
iAgent a connetction to the SDP client Owned by CChatBtServiceSearcher Definition at line 238 of file ChatBtServiceSearcher.h. |
|
|
iSdpSearchPattern a search pattern Owned by CChatBtServiceSearcher Definition at line 244 of file ChatBtServiceSearcher.h. |
|
|
iHasFoundService has the service been found ? Definition at line 249 of file ChatBtServiceSearcher.h. |
|
|
iLog the log to send output to Definition at line 254 of file ChatBtServiceSearcher.h. |
|
© Nokia 2006 |