1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Service starter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef BT_SERVICE_STARTER_H |
|
21 #define BT_SERVICE_STARTER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "BTServiceAPI.h" |
|
25 #include "BTServiceUtils.h" |
|
26 #include "BTServiceParameterList.h" |
|
27 #include "BTServiceDelayedDestroyer.h" |
|
28 |
|
29 #include <btengdiscovery.h> |
|
30 #include <btengsettings.h> |
|
31 #include <obexutilsdialog.h> |
|
32 #include <msvapi.h> |
|
33 |
|
34 // DATA TYPES |
|
35 |
|
36 enum TBTServiceProfile |
|
37 { |
|
38 EBTSNone, |
|
39 EBTSBPP, |
|
40 EBTSOPP, |
|
41 EBTSBIP |
|
42 }; |
|
43 |
|
44 enum TBTActiveNotifier |
|
45 { |
|
46 ENoneQuery = 0, |
|
47 EOfflineQuery, |
|
48 ENameQuery |
|
49 }; |
|
50 |
|
51 // FORWARD DECLARATIONS |
|
52 class CObexUtilsUiLayer; |
|
53 class MBTServiceProgressGetter; |
|
54 class CBTSController; |
|
55 |
|
56 |
|
57 const TUint KBTSdpObjectPush = 0x1105; |
|
58 const TUint KBTSdpBasicImaging = 0x111b; |
|
59 const TUint KBTSdpBasicPrinting = 0x1120; |
|
60 |
|
61 |
|
62 // CLASS DECLARATION |
|
63 |
|
64 /** |
|
65 * An observer interface for service controllers. |
|
66 */ |
|
67 class MBTServiceObserver |
|
68 { |
|
69 public: // New functions |
|
70 |
|
71 /** |
|
72 * Informs the observer that the handler has completed its tasks. |
|
73 * @param aStatus The the completion status of the handler. |
|
74 * @return None. |
|
75 */ |
|
76 virtual void ControllerComplete( TInt aStatus ) = 0; |
|
77 |
|
78 /** |
|
79 * Informs the observer that a progress note should be shown. |
|
80 * @param aGetter A pointer to a progess status getter object. |
|
81 * @return None. |
|
82 */ |
|
83 virtual void LaunchProgressNoteL( MBTServiceProgressGetter* aGetter, TInt aTotalSize ) = 0; |
|
84 |
|
85 /** |
|
86 * Informs the observer that a confirmation query for sending |
|
87 * should be shouwn for BIP sendign |
|
88 * @return |
|
89 */ |
|
90 virtual TInt LaunchConfirmationQuery(TInt aResouceId)=0; |
|
91 |
|
92 /** |
|
93 * Informs the observer that a connect is timedout |
|
94 * @return |
|
95 */ |
|
96 virtual void ConnectTimedOut()=0; |
|
97 |
|
98 }; |
|
99 |
|
100 |
|
101 /** |
|
102 * A starter class for Bluetooth services. |
|
103 */ |
|
104 NONSHARABLE_CLASS (CBTServiceStarter) : public CActive, |
|
105 public MBTServiceObserver, |
|
106 public MObexUtilsDialogObserver, |
|
107 public MObexUtilsProgressObserver, |
|
108 public MBTEngSdpResultReceiver, |
|
109 public MBTEngSettingsObserver |
|
110 { |
|
111 public: // Constructors and destructor |
|
112 |
|
113 /** |
|
114 * Two-phased constructor. |
|
115 */ |
|
116 static CBTServiceStarter* NewL(); |
|
117 |
|
118 /** |
|
119 * Destructor. |
|
120 */ |
|
121 virtual ~CBTServiceStarter(); |
|
122 |
|
123 public: // New functions |
|
124 |
|
125 /** |
|
126 * Starts the given service. |
|
127 * @param aService The service to be started. |
|
128 * @param aList Parameters for the service. |
|
129 * @param aWaiter A pointer to a waiter object. |
|
130 * @return None. |
|
131 */ |
|
132 void StartServiceL( TBTServiceType aService, |
|
133 CBTServiceParameterList* aList, |
|
134 CActiveSchedulerWait* aWaiter = NULL ); |
|
135 |
|
136 private: // Functions from base classes |
|
137 |
|
138 |
|
139 |
|
140 /** |
|
141 * From MBTServiceObserver A controller has completed. |
|
142 * @param aStatus The completion status of the controller. |
|
143 * @return None. |
|
144 */ |
|
145 void ControllerComplete( TInt aStatus ); |
|
146 |
|
147 /** |
|
148 * From MBTServiceObserver A progress note should be shown. |
|
149 * @param aGetter A pointer to a progess status getter object. |
|
150 * @param aTotalSize Max size of the progress bar. |
|
151 * @return None. |
|
152 */ |
|
153 void LaunchProgressNoteL( MBTServiceProgressGetter* aGetter, TInt aTotalSize ); |
|
154 |
|
155 /** |
|
156 * From MObexUtilsWaitDialogObserver The wait note has been dismissed. |
|
157 * @param aButtonId The button id that was used to dismiss the dialog. |
|
158 * @return None. |
|
159 */ |
|
160 void DialogDismissed( TInt aButtonId ); |
|
161 |
|
162 /** |
|
163 * From MObexUtilsProgressObserver request for number of bytes sent |
|
164 * @Param None. |
|
165 * @return Number of bytes sent. |
|
166 */ |
|
167 TInt GetProgressStatus(); |
|
168 |
|
169 /** |
|
170 * From MBTServiceObserver A confirmation query for BIP |
|
171 * profile should be shown. |
|
172 * @return key |
|
173 */ |
|
174 TInt LaunchConfirmationQuery(TInt aResourceId); |
|
175 |
|
176 /** |
|
177 * From MBTServiceObserver a connect request is timedout |
|
178 * @return |
|
179 */ |
|
180 void ConnectTimedOut(); |
|
181 |
|
182 |
|
183 /** |
|
184 * Provides notification of the result of a service search that matches |
|
185 * the requested UUID (through CBTEngDiscovery::RemoteSdpQuery). |
|
186 * This method indicates that the search has completed, and returns |
|
187 * all the results to the caller at once. |
|
188 * |
|
189 * @since S60 v3.2 |
|
190 * @param aResult Array of record handles that match the requested UUID. |
|
191 * Note: the array will not be available anymore after |
|
192 * this method returns. |
|
193 * @param aTotalRecordsCount The total number of records returned. |
|
194 * @param aErr Error code of the service search operation; KErrNone if |
|
195 * sucessful, KErrEof if no record matched the requested UUID, |
|
196 * KErrCouldNotConnect and KErrCouldDisconnected in case of |
|
197 * Bluetooth connection errors; otherwise one of the |
|
198 * system-wide error codes. |
|
199 */ |
|
200 void ServiceSearchComplete( const RSdpRecHandleArray& aResult, |
|
201 TUint aTotalRecordsCount, TInt aErr ); |
|
202 |
|
203 /** |
|
204 * Provides notification of the result of an attribute search that matches |
|
205 * the requested attribute (through CBTEngDiscovery::RemoteSdpQuery). |
|
206 * This method indicates that the search has completed, and returns |
|
207 * all the results to the caller at once. |
|
208 * |
|
209 * @since S60 v3.2 |
|
210 * @param aHandle Record handle of the service record containing the result. |
|
211 * @param aAttr Array containing the attribute that matches the |
|
212 * requested attribute. |
|
213 * Note: the array will not be available anymore after |
|
214 * this method returns. |
|
215 * @param aErr Error code of the service search operation; KErrNone if |
|
216 * sucessful, KErrEof if the requested attribute was not |
|
217 * contained in the specified service record, |
|
218 * KErrCouldNotConnect and KErrCouldDisconnected in case of |
|
219 * Bluetooth connection errors; otherwise one of the |
|
220 * system-wide error codes. |
|
221 */ |
|
222 void AttributeSearchComplete( TSdpServRecordHandle aHandle, |
|
223 const RSdpResultArray& aAttr, |
|
224 TInt aErr ); |
|
225 |
|
226 /** |
|
227 * Provides notification of the result of an combination of a service |
|
228 * and attribute search (through CBTEngDiscovery::RemoteSdpQuery). |
|
229 * This method is called for each service and attribute combination for |
|
230 * which a match was found. The last result (which could be empty if no |
|
231 * match was found) contain error code KErrEof to indicate that the |
|
232 * search has completed. |
|
233 * |
|
234 * @since S60 v3.2 |
|
235 * @param aHandle Record handle of the service record containing the result. |
|
236 * @param aAttr Array containing the attribute that matches the |
|
237 * requested attribute. |
|
238 * Note: the array will not be available anymore after |
|
239 * this method returns. |
|
240 * @param aErr Error code of the service search operation; KErrNone if |
|
241 * sucessful and more results follow, KErrEof indicates that |
|
242 * this is the last result (which could be empty if no match |
|
243 * was found), KErrCouldNotConnect and KErrCouldDisconnected |
|
244 * in case of Bluetooth connection errors; otherwise one of |
|
245 * the system-wide error codes. |
|
246 */ |
|
247 void ServiceAttributeSearchComplete( TSdpServRecordHandle aHandle, |
|
248 const RSdpResultArray& aAttr, |
|
249 TInt aErr ); |
|
250 |
|
251 /** |
|
252 * Provides notification of the result of the discovery of nearby |
|
253 * Bluetooth devices. |
|
254 * |
|
255 * @since S60 v3.2 |
|
256 * @param aDevice The data structure encapsulates all information |
|
257 * about the selected device. Ownership of the data |
|
258 * structure has not been transfered and is still with |
|
259 * the API client. |
|
260 * @param aErr Error code of the device search operation; KErrNone if |
|
261 * sucessful, KErrCancel if the user cancelled the |
|
262 * dialog, KErrCancel if CBTEngDiscovery::CancelSearchRemoteDevice |
|
263 * was called; otherwise one of the system-wide error codes. |
|
264 */ |
|
265 void DeviceSearchComplete( CBTDevice* aDevice, TInt aErr ); |
|
266 |
|
267 /** |
|
268 * From MBTEngSettingsObserver. |
|
269 * Provides notification of changes in the power state |
|
270 * of the Bluetooth hardware. |
|
271 * |
|
272 * @since S60 v3.2 |
|
273 * @param aState EBTPowerOff if the BT hardware has been turned off, |
|
274 * EBTPowerOn if it has been turned off. |
|
275 */ |
|
276 void PowerStateChanged( TBTPowerStateValue aState ); |
|
277 |
|
278 /** |
|
279 * From MBTEngSettingsObserver. |
|
280 * Provides notification of changes in the discoverability |
|
281 * mode of the Bluetooth hardware. |
|
282 * |
|
283 * @since S60 v3.2 |
|
284 * @param aState EBTDiscModeHidden if the BT hardware is in hidden mode, |
|
285 * EBTDiscModeGeneral if it is in visible mode. |
|
286 */ |
|
287 void VisibilityModeChanged( TBTVisibilityMode aState ); |
|
288 |
|
289 /** |
|
290 * From CActive. |
|
291 * Called by the active scheduler when the request has been cancelled. |
|
292 * |
|
293 * @since S60 v3.2 |
|
294 */ |
|
295 void DoCancel(); |
|
296 |
|
297 /** |
|
298 * From CActive. |
|
299 * Called by the active scheduler when the request has been completed. |
|
300 * |
|
301 * @since S60 v3.2 |
|
302 */ |
|
303 void RunL(); |
|
304 |
|
305 /** |
|
306 * From CActive. |
|
307 * Called by the active scheduler when an error in RunL has occurred. |
|
308 * |
|
309 * @since S60 v3.2 |
|
310 */ |
|
311 TInt RunError( TInt aError ); |
|
312 |
|
313 private: |
|
314 |
|
315 /** |
|
316 * C++ default constructor. |
|
317 */ |
|
318 CBTServiceStarter(); |
|
319 |
|
320 /** |
|
321 * By default Symbian 2nd phase constructor is private. |
|
322 */ |
|
323 void ConstructL(); |
|
324 |
|
325 /** |
|
326 * Check that the parameters are valid for a given service. |
|
327 * @param aService The requested service. |
|
328 * @param aList Parameters for the service. |
|
329 * @return None. |
|
330 */ |
|
331 TBool ValidParameters( TBTServiceType aService, |
|
332 const CBTServiceParameterList* aList) const; |
|
333 |
|
334 /** |
|
335 * Starts finding a Bluetooth profile suitable for requested service. |
|
336 * @param aService The requested service. |
|
337 * @return None. |
|
338 */ |
|
339 void StartProfileSelectL( TBTServiceType aService ); |
|
340 |
|
341 /** |
|
342 * Start a controller for the given Bluetooth profile. |
|
343 * @param aProfile The profile to be started. |
|
344 * @return None. |
|
345 */ |
|
346 void StartProfileL( TBTServiceProfile aProfile ); |
|
347 |
|
348 /** |
|
349 * Launches a connecting wait note |
|
350 * @param None. |
|
351 * @return None. |
|
352 */ |
|
353 void LaunchWaitNoteL(); |
|
354 |
|
355 /** |
|
356 * Cancel connecting wait note |
|
357 * @param None. |
|
358 * @return None. |
|
359 */ |
|
360 void CancelWaitNote(); |
|
361 |
|
362 /** |
|
363 * Show a note with given error value |
|
364 * @param aReason Error value |
|
365 * @return None. |
|
366 */ |
|
367 void ShowNote( TInt aReason ) const; |
|
368 |
|
369 /** |
|
370 * Cancel progress note |
|
371 * @param None. |
|
372 * @return None. |
|
373 */ |
|
374 void CancelProgressNote(); |
|
375 |
|
376 /** |
|
377 * StopTransfer and show information note |
|
378 * @param aError Error code if error exist. |
|
379 * @return None. |
|
380 */ |
|
381 void StopTransfer( TInt aError ); |
|
382 |
|
383 /** |
|
384 * Check if phone is in offline mode, and ask the user if it is.. |
|
385 * @return ETrue if the phone is in offline mode, otherwise EFalse. |
|
386 */ |
|
387 TBool CheckOfflineModeL(); |
|
388 |
|
389 /** |
|
390 * Start BT device discovery. |
|
391 * @return None. |
|
392 */ |
|
393 void StartDiscoveryL(); |
|
394 |
|
395 /** |
|
396 * Turn BT power on. |
|
397 * @param aState The current BT power state. |
|
398 * @return None. |
|
399 */ |
|
400 void TurnBTPowerOnL( const TBTPowerStateValue aState ); |
|
401 private: // Data definitions |
|
402 |
|
403 enum TBTServiceStarterState |
|
404 { |
|
405 EBTSStarterIdle, |
|
406 EBTSStarterFindingBPP, |
|
407 EBTSStarterFindingOPP, |
|
408 EBTSStarterFindingBIP, |
|
409 EBTSStarterStoppingService |
|
410 }; |
|
411 |
|
412 private: // Data |
|
413 |
|
414 CBTDevice* iDevice; |
|
415 CBTEngDiscovery* iBTEngDiscovery; |
|
416 CBTServiceParameterList* iList; |
|
417 CObexUtilsDialog* iDialog; |
|
418 CBTSController* iController; |
|
419 |
|
420 TBTServiceType iService; |
|
421 TInt iClientChannel; |
|
422 TBTServiceStarterState iState; |
|
423 TBool iServiceStarted; |
|
424 TMsvId iMessageServerIndex; |
|
425 |
|
426 MBTServiceProgressGetter* iProgressGetter; |
|
427 CActiveSchedulerWait* iWaiter; |
|
428 TBool iAllSend; |
|
429 TInt iBytesSendWithBIP; |
|
430 TBool iProgressDialogActive; |
|
431 TBool iUserCancel; |
|
432 CBTEngSettings* iBTEngSettings; |
|
433 TBool iWaitingForBTPower; |
|
434 RNotifier iNotifier; // Handle to the generic notifier. |
|
435 TPckgBuf<TBool> iOffline; |
|
436 TPckgBuf<TBool> iName; |
|
437 TBool iSendToBIPOnlyDevice; |
|
438 TBTActiveNotifier iActiveNotifier; |
|
439 TBool iFeatureManagerInitialized; |
|
440 TBool iTriedBIP; |
|
441 TBool iTriedOPP; |
|
442 CBTServiceDelayedDestroyer* iDelayedDestroyer; |
|
443 }; |
|
444 |
|
445 #endif // BT_SERVICE_CONTROLLER_H |
|
446 |
|
447 // End of File |
|
448 |
|