|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : ChatBtServiceSearcher.h 00004 * Part of : Chat 00005 * Interface : 00006 * Description : 00007 * Version : 00008 * 00009 * Copyright (c) 2005-2006 Nokia Corporation. 00010 * This material, including documentation and any related 00011 * computer programs, is protected by copyright controlled by 00012 * Nokia Corporation. 00013 * ============================================================================== 00014 */ 00015 00016 #ifndef CHATBTSERVICESEARCHER_H 00017 #define CHATBTSERVICESEARCHER_H 00018 00019 // INCLUDES 00020 #include <e32base.h> 00021 #include <bttypes.h> 00022 #include <btextnotifiers.h> 00023 00024 #include "ChatSdpAttributeParser.h" 00025 #include "ChatSdpAttributeNotifier.h" 00026 #include "Log.h" 00027 #include "ChatProtocolConstants.h" 00028 00029 // CONSTANTS 00030 _LIT( KErrNRRCErr, "NRRC ERR" ); 00031 00032 // CLASS DECLARATIONS 00033 00034 /** 00035 * CChatBtServiceSearcher 00036 * Searches for a service on a remote machine 00037 */ 00038 00039 class CChatBtServiceSearcher : public CBase, 00040 public MSdpAgentNotifier, 00041 public MChatSdpAttributeNotifier 00042 { 00043 public: // Destructor 00044 00045 /** 00046 * ~CChatBtServiceSearcher() 00047 * Destroy the object and release all memory objects 00048 */ 00049 virtual ~CChatBtServiceSearcher(); 00050 00051 public: // New functions 00052 00053 /** 00054 * SelectDeviceByDiscoveryL() 00055 * Select a device 00056 * @param aObserverRequestStatus the observer that is to 00057 * be notified when the device selection is complete. 00058 */ 00059 void SelectDeviceByDiscoveryL( 00060 TRequestStatus& aObserverRequestStatus ); 00061 00062 /** 00063 * FindServiceL() 00064 * Find a service on the specified device 00065 * @param aObserverRequestStatus the observer that is to be notified 00066 * when the service search is complete 00067 */ 00068 void FindServiceL( TRequestStatus& aObserverRequestStatus ); 00069 00070 /** 00071 * BTDevAddr() 00072 * @return the bluetooth device address 00073 */ 00074 const TBTDevAddr& BTDevAddr(); 00075 00076 /** 00077 * ResponseParams() 00078 * @return Information about the device selected by the user 00079 */ 00080 const TBTDeviceResponseParams& ResponseParams(); 00081 00082 protected: // New functions 00083 00084 /** 00085 * CChatBtServiceSearcher() 00086 * Constructs this object 00087 * @param aLog the log to send output to 00088 */ 00089 CChatBtServiceSearcher( MLog& aLog ); 00090 00091 /** 00092 * Finished() 00093 * The search has finished. Notify the observer 00094 * that the process is complete. 00095 */ 00096 virtual void Finished( TInt aError = KErrNone ); 00097 00098 /** 00099 * HasFinishedSearching() 00100 * Is the instance still wanting to search. 00101 * @return EFalse if the instance wants searching to continue. 00102 */ 00103 virtual TBool HasFinishedSearching() const; 00104 00105 /** 00106 * HasFoundService() 00107 * @return ETrue if a service has been found 00108 */ 00109 TBool HasFoundService() const; 00110 00111 protected: // abstract methods 00112 00113 /** 00114 * ProtocolList() 00115 * The list of Protocols required by the service. 00116 */ 00117 virtual RArray <TChatSdpAttributeParser::TChatSdpAttributeNode>& 00118 ProtocolList() = 0; 00119 00120 /** 00121 * ServiceClass() 00122 * The service class to search for 00123 * @return the service class UUID 00124 */ 00125 virtual const TUUID& ServiceClass() const = 0; 00126 00127 /** 00128 * FoundElementL() 00129 * Read the data element 00130 * @param aKey a key that identifies the element 00131 * @param aValue the data element 00132 */ 00133 virtual void FoundElementL( TInt aKey, CSdpAttrValue& aValue ) = 0; 00134 00135 public: // from MSdpAgentNotifier 00136 00137 /** 00138 * NextRecordRequestComplete() 00139 * Process the result of the next record request 00140 * @param aError the error code 00141 * @param aHandle the handle of the service record 00142 * @param aTotalRecordsCount the total number of matching 00143 * service records 00144 */ 00145 void NextRecordRequestComplete( TInt aError, 00146 TSdpServRecordHandle aHandle, 00147 TInt aTotalRecordsCount ); 00148 00149 /** 00150 * AttributeRequestResult() 00151 * Process the next attribute requested 00152 * @param aHandle the handle of the service record 00153 * @param aAttrID the id of the attribute 00154 * @param aAttrValue the value of the attribute 00155 */ 00156 void AttributeRequestResult( TSdpServRecordHandle aHandle, 00157 TSdpAttributeID aAttrID, 00158 CSdpAttrValue* aAttrValue ); 00159 00160 /** 00161 * AttributeRequestComplete() 00162 * Process the arrtibute request completion 00163 * @param aHandle the handle of the service record 00164 * @param aError the error code 00165 */ 00166 void AttributeRequestComplete( TSdpServRecordHandle aHandle, 00167 TInt aError ); 00168 00169 private: // Functions from base classes 00170 00171 /** 00172 * NextRecordRequestCompleteL() 00173 * Process the result of the next record request 00174 * @param aError the error code 00175 * @param aHandle the handle of the service record 00176 * @param aTotalRecordsCount the total number of 00177 * matching service records 00178 */ 00179 void NextRecordRequestCompleteL( TInt aError, 00180 TSdpServRecordHandle aHandle, 00181 TInt aTotalRecordsCount ); 00182 00183 /** 00184 * AttributeRequestResultL() 00185 * Process the next attribute requested 00186 * @param aHandle the handle of the service record 00187 * @param aAttrID the id of the attribute 00188 * @param aAttrValue the value of the attribute 00189 */ 00190 void AttributeRequestResultL( TSdpServRecordHandle aHandle, 00191 TSdpAttributeID aAttrID, 00192 CSdpAttrValue* aAttrValue ); 00193 00194 /** 00195 * AttributeRequestCompleteL() 00196 * Process the arrtibute request completion 00197 * @param aHandle the handle of the service record 00198 * @param aError the error code 00199 */ 00200 void AttributeRequestCompleteL( TSdpServRecordHandle, 00201 TInt aError ); 00202 00203 private: // data 00204 00205 /** 00206 * iStatusObserver pointer to the request status observer 00207 * Not owned by CChatBtServiceSearcher 00208 */ 00209 TRequestStatus* iStatusObserver; 00210 00211 /** 00212 * iIsDeviceSelectorConnected is the device 00213 * selector connected? 00214 */ 00215 TBool iIsDeviceSelectorConnected; 00216 00217 /** 00218 * iDeviceSelector 00219 * a handle to the bluetooth device selector notifier 00220 */ 00221 RNotifier iDeviceSelector; 00222 00223 /** 00224 * iResponse 00225 * the response of the device selection. 00226 */ 00227 TBTDeviceResponseParamsPckg iResponse; 00228 00229 /** 00230 * iSelectionFilter 00231 * Request a device selection 00232 */ 00233 TBTDeviceSelectionParamsPckg iSelectionFilter; 00234 /** 00235 * iAgent a connetction to the SDP client 00236 * Owned by CChatBtServiceSearcher 00237 */ 00238 CSdpAgent* iAgent; 00239 00240 /** 00241 * iSdpSearchPattern a search pattern 00242 * Owned by CChatBtServiceSearcher 00243 */ 00244 CSdpSearchPattern* iSdpSearchPattern; 00245 00246 /** 00247 * iHasFoundService has the service been found ? 00248 */ 00249 TBool iHasFoundService; 00250 00251 /** 00252 * iLog the log to send output to 00253 */ 00254 MLog& iLog; 00255 }; 00256 00257 #endif // CHATBTSERVICESEARCHER_H 00258 00259 // End of File
|
© Nokia 2006 |