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: Declares Bluetooth device inquiry user interface class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef BTNINQUI_H |
|
20 #define BTNINQUI_H |
|
21 |
|
22 // INCLUDES |
|
23 |
|
24 #include <btextnotifiers.h> // Bluetooth notifiers API |
|
25 #include <badesca.h> // For array handling |
|
26 #include <AknIconArray.h> |
|
27 #include "btnotifactive.h" // Active Object Helper class for inquiry |
|
28 #include <bt_sock.h> |
|
29 #include <btengdevman.h> |
|
30 #include "btnotifier.h" |
|
31 |
|
32 const TInt KPeriodicTimerInterval4Sec(4000000); |
|
33 |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 |
|
37 class CAknStaticNoteDialog; |
|
38 class CAknSingleGraphicPopupMenuStyleListBox; |
|
39 class CAknPopupList; |
|
40 class CAknQueryDialog; |
|
41 class CBTInqNotifier; |
|
42 |
|
43 // CONSTANTS |
|
44 enum TSearchFlowState |
|
45 { |
|
46 ESearchCompleted, // search completed for any reason, end of UI flow. |
|
47 ESearchAgain, // no device found, user wants to search again. |
|
48 ESearchFirstDeviceFound, // the first device is found, show found device list. |
|
49 }; |
|
50 |
|
51 // CLASS DECLARATION |
|
52 /** |
|
53 * Class MBTNDeviceSearchObserver |
|
54 * |
|
55 * Callback class to notify device searching completed. |
|
56 */ |
|
57 class MBTNDeviceSearchObserver |
|
58 { |
|
59 public: |
|
60 |
|
61 /** |
|
62 * Callback to notify that the device search request has completed. |
|
63 * |
|
64 * @since S60 5.1 |
|
65 * @param aErr Error code |
|
66 * @param aDevice Pckgbuf to retrieve the response from the device selection. |
|
67 */ |
|
68 virtual void NotifyDeviceSearchCompleted(TInt aErr, |
|
69 const TBTDeviceResponseParams& aDevice = TBTDeviceResponseParams()) = 0; |
|
70 }; |
|
71 |
|
72 /** |
|
73 * A helper class used in Bluetooth device search. |
|
74 * This class is responsible of the UI activity. |
|
75 */ |
|
76 NONSHARABLE_CLASS(CBTInqUI) : public CBase, public MBTEngDevManObserver, public MBTNotifActiveObserver |
|
77 { |
|
78 public: // Constructor and destructor |
|
79 /** |
|
80 * C++ default constructor. |
|
81 */ |
|
82 CBTInqUI( MBTNDeviceSearchObserver* aObserver, |
|
83 CBTNotifUIUtil* aUtil, const TBTDeviceClass& aDesiredDevClass); |
|
84 |
|
85 /** |
|
86 * The 2nd phase constructor is required to do Asyncronous operations, |
|
87 * So the readiness of the CBTInqUI is notified Asynchronously to the caller |
|
88 */ |
|
89 void ConstructL(); |
|
90 |
|
91 /** |
|
92 * Destructor. |
|
93 */ |
|
94 virtual ~CBTInqUI(); |
|
95 |
|
96 public: // New functions |
|
97 |
|
98 /** |
|
99 * Cancels all inquiry activity. |
|
100 */ |
|
101 void Cancel(); |
|
102 |
|
103 /** |
|
104 * Issues a device inquiry request. |
|
105 * @param None. |
|
106 * @return None. |
|
107 */ |
|
108 void IssueRequestL(); |
|
109 |
|
110 /** |
|
111 * Check if Eir device name available. |
|
112 * @param TNameEntry Decode it to get device name |
|
113 * @param TBTDeviceName Device name returned |
|
114 * @param TBool Is the name returned complete |
|
115 * @return ETrue if Eir data contains name. |
|
116 */ |
|
117 static TBool CheckEirDeviceName( TNameEntry& aEntry, TBTDeviceName& aName, TBool& aIsComplete ); |
|
118 |
|
119 private: // Functions from base classes |
|
120 |
|
121 /** |
|
122 * From MBTNotifActiveObserver |
|
123 */ |
|
124 void RequestCompletedL( CBTNotifActive* aActive, TInt aId, TInt aStatus ); |
|
125 |
|
126 /** |
|
127 * From MBTNotifActiveObserver |
|
128 */ |
|
129 void HandleError( CBTNotifActive* aActive, TInt aId, TInt aError ); |
|
130 |
|
131 /** |
|
132 * From MBTNotifActiveObserver |
|
133 */ |
|
134 void DoCancelRequest( CBTNotifActive* aActive, TInt aId ); |
|
135 |
|
136 /** |
|
137 * From MBTEngDevManObserver |
|
138 */ |
|
139 void HandleGetDevicesComplete(TInt aErr, CBTDeviceArray* aDeviceArray); |
|
140 |
|
141 /** |
|
142 * From MBTEngDevManObserver |
|
143 */ |
|
144 void HandleDevManComplete(TInt aErr); |
|
145 |
|
146 |
|
147 private: |
|
148 |
|
149 /** |
|
150 * Create the device search active object and prepare for search. |
|
151 */ |
|
152 void CreateScannerL(); |
|
153 |
|
154 /** |
|
155 * Removes the device search active object if it still exists. |
|
156 * @param None. |
|
157 * @return None. |
|
158 */ |
|
159 void RemoveScanner(); |
|
160 |
|
161 /** |
|
162 * Retrieves paired devices from BT Registry |
|
163 * Calls HandleGetDevicesComplete, when done |
|
164 */ |
|
165 void RetrievePairedDevices(); |
|
166 |
|
167 /** |
|
168 * Retrieves used devices from BT Registry |
|
169 * Calls HandleGetDevicesComplete, when done |
|
170 * @return None. |
|
171 */ |
|
172 void RetrieveUsedDevices(); |
|
173 |
|
174 /** |
|
175 * Searches given BT Device from device array. |
|
176 * @param aDeviceArray The device array to search in |
|
177 * @param aDevice The device to be searched. |
|
178 * @return Index of the device if found. |
|
179 */ |
|
180 TInt LookupFromDevicesArray( const CBTDeviceArray* aDeviceArray, const CBTDevice* aDevice ) const; |
|
181 |
|
182 /** |
|
183 * Constructs a device popup list from resources. |
|
184 * @param aSoftkeysResourceId Resource id for softkeys of the list. |
|
185 * @param aTitleResourceId Resource id for the title of the list. |
|
186 * @return None. |
|
187 */ |
|
188 void CreatePopupListL(TInt aSoftkeysResourceId, TInt aTitleResourceId ); |
|
189 |
|
190 /** |
|
191 * Generates a format string and adds it to iDeviceItems array. |
|
192 * Updates friendly name of given device if one is found from registry. |
|
193 * @param aDevice The device to be added to list. |
|
194 * @param aSignalStrength The signal bar for RSSI |
|
195 * @return None. |
|
196 */ |
|
197 void AddToDeviceListBoxL(CBTDevice* aDevice, const TInt aSignalStrength = 0 ); |
|
198 |
|
199 /** |
|
200 * Creates and adds local bitmap to icon array. |
|
201 * @param aID Item ID of the masked bitmap to be created. |
|
202 * @param aFilename Filename to be used to construct the item. |
|
203 * @param aBitmapId The ID if bitmap |
|
204 * @param aMaskId The ID of bitmap's mask |
|
205 * @param aIconList The icon list for BT devices listbox. |
|
206 */ |
|
207 void CreateAndAppendIconL( const TAknsItemID& aID, |
|
208 const TDesC& aFileName, |
|
209 const TInt aBitmapId, |
|
210 const TInt aMaskId, |
|
211 CAknIconArray* aIconList); |
|
212 |
|
213 /** |
|
214 * Adjust array, leave 5 lastet used devices in the array and remove the rest, |
|
215 * and then insert the paired device array to this array by used time order. |
|
216 * In the adjusted array, the first item will be the most lately used device. |
|
217 * @param aDevArray The bluetooth device arrary to be adjusted. |
|
218 * @return None. |
|
219 */ |
|
220 void AdjustDeviceArrayL( CBTDeviceArray* aDevArray); |
|
221 |
|
222 /** |
|
223 * Filter for searching device |
|
224 * @param The desired device class user selects from the filter |
|
225 * @return User's input select/cancel |
|
226 */ |
|
227 void SelectSearchCategoryL(); |
|
228 |
|
229 /** |
|
230 * Add filtering items to search device filter |
|
231 * @param aResourceId |
|
232 * @return None |
|
233 */ |
|
234 void AddItemToSearchFilterL ( TInt aResourceId ); |
|
235 |
|
236 /** |
|
237 * Show query to ask if unblock device |
|
238 * @param aDevice Selected device |
|
239 * @return Keypress value |
|
240 */ |
|
241 TInt QueryUnblockDeviceL(CBTDevice* aDevice); |
|
242 |
|
243 /** |
|
244 * The callback function for CPeriodic |
|
245 * to reset the inactivity time |
|
246 */ |
|
247 static TInt PeriodicTimerCallBack(TAny* /*aAny*/); |
|
248 |
|
249 void GetColorIconL( TFileName& aFilename, TAknsItemID aItemID, TInt aPic, TInt aPicmask, CAknIconArray* aIconList ); |
|
250 |
|
251 /** |
|
252 * Check if VoIP call is ongoing via WLAN connection. |
|
253 * @return true if it is; false otherwise. |
|
254 */ |
|
255 TBool IsActiveVoIPOverWLAN(); |
|
256 |
|
257 void DoDeviceFrontListSelection(); |
|
258 |
|
259 /** |
|
260 * Displays previous inquiry results. |
|
261 */ |
|
262 void DisplayDevicesFrontListL(); |
|
263 |
|
264 /** |
|
265 * Unblock device after unblock query. |
|
266 * @param aIndex Parameter containing information about selected device. |
|
267 * @return Symbian OS error code. |
|
268 */ |
|
269 TInt UnblockDevice(TInt aIndex); |
|
270 |
|
271 void DeviceSearchUiL(); |
|
272 |
|
273 /** |
|
274 * the initiator of inquiry until the first device found, or no device found, or |
|
275 * other reasons causing inquiry stopped. |
|
276 * @param aReason the reason of the search completion |
|
277 */ |
|
278 TSearchFlowState InitInquiryL(TInt& aReason); |
|
279 |
|
280 void HandleDeviceSelectionL(CBTDevice* aDev); |
|
281 |
|
282 /** |
|
283 * Adds found Bluetooth device into popup list. |
|
284 * @param aInquiryResultRecord TNameEntry and flag, which indicates if Eir device. |
|
285 */ |
|
286 void DeviceAvailableL( const TNameRecord& aNameRecord, const TDesC& aDevName, TBool aIsNameComplete ); |
|
287 |
|
288 /** |
|
289 * The inquiry has been completed. |
|
290 * @param aError Status code of the operation. |
|
291 * @return None. |
|
292 */ |
|
293 void InquiryComplete( TInt aError ); |
|
294 |
|
295 /** |
|
296 * Inform the caller of the properties of found BTdevice, |
|
297 * which passes the search filter. Its name will be retrived later |
|
298 */ |
|
299 void HandleInquiryDeviceL(); |
|
300 |
|
301 /** |
|
302 * Name lookup complete for the current device in the unnamed devices queue. |
|
303 */ |
|
304 void HandleFoundNameL(); |
|
305 |
|
306 /** |
|
307 * Name lookup complete for device aLastSeenIndex in the last seen array |
|
308 * (this is done for devices with partial names returned by EIR). |
|
309 */ |
|
310 void HandleUpdatedNameL(TInt aLastSeenIndex); |
|
311 |
|
312 /** |
|
313 * Allow/Disallow dialer and app key presses. |
|
314 * @param aAllow ETrue to allow key press; EFalse to disallow. |
|
315 */ |
|
316 void AllowDialerAndAppKeyPress( TBool aAllow ); |
|
317 |
|
318 /** |
|
319 * Update the inquiry list box with a new (complete) device name |
|
320 * (this is done for devices with partial names returned by EIR). |
|
321 */ |
|
322 void DeviceNameUpdatedL(const TNameRecord& aNameRecord, TInt aLastSeenIndex); |
|
323 void DeviceUpdatedL(TInt aSignalStrength, TInt aLastSeenIndex); |
|
324 |
|
325 /** |
|
326 * React to page timeout on a device that's already in the inquiry list box |
|
327 * (which can happen for devices with partial names returned by EIR). |
|
328 */ |
|
329 void PageTimeoutOnDeviceWithPartialNameL(TInt aLastSeenIndex); |
|
330 |
|
331 void FormatListBoxEntryL(CBTDevice& aDevice, const TInt aSignalStrength, TPtr aFormatString); |
|
332 |
|
333 TBool HaveDevsWithPartialName(TInt& aFirstFoundIndex); |
|
334 |
|
335 private: // Data |
|
336 CBTNotifUIUtil* iUiUtil; |
|
337 CBTDeviceArray* iLastSeenDevicesArray; // Last seen devices array from BTInqNotifier |
|
338 RArray<TBool> iLastSeenDevicesNameComplete; // Is the name in corresponding cell of iLastSeenDevicesArray complete ? |
|
339 CBTDeviceArray* iLastUsedDevicesArray; // Used devices from BT registry |
|
340 CBTDeviceArray* iPairedDevicesArray; // Paired devices from Bluetooth registry |
|
341 CBTDeviceArray* iAdjustedUsedDeviceArray; // 5 Lately used devices + All the Paired devices |
|
342 CBTEngDevMan* iDevMan; //Async deviceHandler |
|
343 |
|
344 CDesCArray* iDefaultDeviceNamesArray; // Default device names array |
|
345 CEikonEnv& iEikonEnvRef; // Reference to eikonenv |
|
346 |
|
347 CAknPopupList* iDevicePopupList; // Popup list for devices |
|
348 CDesCArrayFlat* iDeviceListRows; // Array for device list format string rows |
|
349 CAknSingleGraphicPopupMenuStyleListBox* iDeviceListBox; // ListBox for bluetooth devices |
|
350 CAknPopupList* iSearchFilterPopupList; |
|
351 |
|
352 CBTNotifActive* iScanner; |
|
353 |
|
354 TBool iDevicesFound; // Flag if any devices has been found |
|
355 TBool iInquiryComplete; |
|
356 TBool iBroughtForwards; // Flag for BringForwards |
|
357 TInt iInquiryStatus; // Error code from inquiry result |
|
358 |
|
359 TBTRegistryQueryState iBTRegistryQueryState; // which registry query (if any) is in progress. |
|
360 TBTDeviceClass iDesiredDeviceClass; // Device Class user selects from search filter |
|
361 CPeriodic* iPeriodicTimer; // the timer for reseting the user inactivity time |
|
362 TBool iSystemCancel; // Used for a trick to avoid final device list is still on show |
|
363 // while taking out mmc during BT device discovery |
|
364 TBTDeviceResponseParams iDevParams; |
|
365 TInt iHighLightedItemIndex; |
|
366 |
|
367 RSocketServ iSocketServer; // Socket server object |
|
368 RHostResolver iHostResolver; // Host resolver object |
|
369 TInquirySockAddr iInquirySockAddr; // Socket address record |
|
370 TNameEntry iEntry; // Inquiry results record |
|
371 TBool iPageForName; // Flag for inquiry name |
|
372 RArray<TNameRecord> iDevsWithoutName; // Devices without dev name |
|
373 TInt iCurrentlyResolvingUnnamedDeviceIndex; // Current btdevice to inquiry its name |
|
374 MBTNDeviceSearchObserver* iDevSearchObserver; |
|
375 |
|
376 TBool iExcludePairedDevices; |
|
377 |
|
378 |
|
379 }; |
|
380 |
|
381 #endif |
|
382 |
|
383 // End of File |
|