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