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 * @return ETrue if Eir data contains name. |
|
115 */ |
|
116 static TBool CheckEirDeviceName( TNameEntry& aEntry, TBTDeviceName& aName ); |
|
117 |
|
118 private: // Functions from base classes |
|
119 |
|
120 /** |
|
121 * From MBTNotifActiveObserver |
|
122 */ |
|
123 void RequestCompletedL( CBTNotifActive* aActive, TInt aId, TInt aStatus ); |
|
124 |
|
125 /** |
|
126 * From MBTNotifActiveObserver |
|
127 */ |
|
128 void HandleError( CBTNotifActive* aActive, TInt aId, TInt aError ); |
|
129 |
|
130 /** |
|
131 * From MBTNotifActiveObserver |
|
132 */ |
|
133 void DoCancelRequest( CBTNotifActive* aActive, TInt aId ); |
|
134 |
|
135 /** |
|
136 * From MBTEngDevManObserver |
|
137 */ |
|
138 void HandleGetDevicesComplete(TInt aErr, CBTDeviceArray* aDeviceArray); |
|
139 |
|
140 /** |
|
141 * From MBTEngDevManObserver |
|
142 */ |
|
143 void HandleDevManComplete(TInt aErr); |
|
144 |
|
145 |
|
146 private: |
|
147 |
|
148 /** |
|
149 * Create the device search active object and prepare for search. |
|
150 */ |
|
151 void CreateScannerL(); |
|
152 |
|
153 /** |
|
154 * Removes the device search active object if it still exists. |
|
155 * @param None. |
|
156 * @return None. |
|
157 */ |
|
158 void RemoveScanner(); |
|
159 |
|
160 /** |
|
161 * Retrieves paired devices from BT Registry |
|
162 * Calls HandleGetDevicesComplete, when done |
|
163 */ |
|
164 void RetrievePairedDevices(); |
|
165 |
|
166 /** |
|
167 * Retrieves used devices from BT Registry |
|
168 * Calls HandleGetDevicesComplete, when done |
|
169 * @return None. |
|
170 */ |
|
171 void RetrieveUsedDevices(); |
|
172 |
|
173 /** |
|
174 * Searches given BT Device from device array. |
|
175 * @param aDeviceArray The device array to search in |
|
176 * @param aDevice The device to be searched. |
|
177 * @return Index of the device if found. |
|
178 */ |
|
179 TInt LookupFromDevicesArray( const CBTDeviceArray* aDeviceArray, const CBTDevice* aDevice ) const; |
|
180 |
|
181 /** |
|
182 * Constructs a device popup list from resources. |
|
183 * @param aSoftkeysResourceId Resource id for softkeys of the list. |
|
184 * @param aTitleResourceId Resource id for the title of the list. |
|
185 * @return None. |
|
186 */ |
|
187 void CreatePopupListL(TInt aSoftkeysResourceId, TInt aTitleResourceId ); |
|
188 |
|
189 /** |
|
190 * Generates a format string and adds it to iDeviceItems array. |
|
191 * Updates friendly name of given device if one is found from registry. |
|
192 * @param aDevice The device to be added to list. |
|
193 * @param aSignalStrength The signal bar for RSSI |
|
194 * @return None. |
|
195 */ |
|
196 void UpdateDeviceListL(CBTDevice* aDevice, const TInt aSignalStrength = 0 ); |
|
197 |
|
198 /** |
|
199 * Creates and adds local bitmap to icon array. |
|
200 * @param aID Item ID of the masked bitmap to be created. |
|
201 * @param aFilename Filename to be used to construct the item. |
|
202 * @param aBitmapId The ID if bitmap |
|
203 * @param aMaskId The ID of bitmap's mask |
|
204 * @param aIconList The icon list for BT devices listbox. |
|
205 */ |
|
206 void CreateAndAppendIconL( const TAknsItemID& aID, |
|
207 const TDesC& aFileName, |
|
208 const TInt aBitmapId, |
|
209 const TInt aMaskId, |
|
210 CAknIconArray* aIconList); |
|
211 |
|
212 /** |
|
213 * Adjust array, leave 5 lastet used devices in the array and remove the rest, |
|
214 * and then insert the paired device array to this array by used time order. |
|
215 * In the adjusted array, the first item will be the most lately used device. |
|
216 * @param aDevArray The bluetooth device arrary to be adjusted. |
|
217 * @return None. |
|
218 */ |
|
219 void AdjustDeviceArrayL( CBTDeviceArray* aDevArray); |
|
220 |
|
221 /** |
|
222 * Filter for searching device |
|
223 * @param The desired device class user selects from the filter |
|
224 * @return User's input select/cancel |
|
225 */ |
|
226 void SelectSearchCategoryL(); |
|
227 |
|
228 /** |
|
229 * Add filtering items to search device filter |
|
230 * @param aResourceId |
|
231 * @return None |
|
232 */ |
|
233 void AddItemToSearchFilterL ( TInt aResourceId ); |
|
234 |
|
235 /** |
|
236 * Show query to ask if unblock device |
|
237 * @param aDevice Selected device |
|
238 * @return Keypress value |
|
239 */ |
|
240 TInt QueryUnblockDeviceL(CBTDevice* aDevice); |
|
241 |
|
242 /** |
|
243 * The callback function for CPeriodic |
|
244 * to reset the inactivity time |
|
245 */ |
|
246 static TInt PeriodicTimerCallBack(TAny* /*aAny*/); |
|
247 |
|
248 void GetColorIconL( TFileName& aFilename, TAknsItemID aItemID, TInt aPic, TInt aPicmask, CAknIconArray* aIconList ); |
|
249 |
|
250 /** |
|
251 * Check if VoIP call is ongoing via WLAN connection. |
|
252 * @return true if it is; false otherwise. |
|
253 */ |
|
254 TBool IsActiveVoIPOverWLAN(); |
|
255 |
|
256 void DoDeviceFrontListSelection(); |
|
257 |
|
258 /** |
|
259 * Displays previous inquiry results. |
|
260 */ |
|
261 void DisplayDevicesFrontListL(); |
|
262 |
|
263 /** |
|
264 * Unblock device after unblock query. |
|
265 * @param aIndex Parameter containing information about selected device. |
|
266 * @return Symbian OS error code. |
|
267 */ |
|
268 TInt UnblockDevice(TInt aIndex); |
|
269 |
|
270 void DeviceSearchUiL(); |
|
271 |
|
272 /** |
|
273 * the initiator of inquiry until the first device found, or no device found, or |
|
274 * other reasons causing inquiry stopped. |
|
275 * @param aReason the reason of the search completion |
|
276 */ |
|
277 TSearchFlowState InitInquiryL(TInt& aReason); |
|
278 |
|
279 void HandleDeviceSelectionL(CBTDevice* aDev); |
|
280 |
|
281 /** |
|
282 * Adds found Bluetooth device into popup list. |
|
283 * @param aInquiryResultRecord TNameEntry and flag, which indicates if Eir device. |
|
284 */ |
|
285 void DeviceAvailableL( const TNameRecord& aNameRecord, const TDesC& aDevName); |
|
286 |
|
287 /** |
|
288 * The inquiry has been completed. |
|
289 * @param aError Status code of the operation. |
|
290 * @return None. |
|
291 */ |
|
292 void InquiryComplete( TInt aError ); |
|
293 |
|
294 /** |
|
295 * Inform the caller of the properties of found BTdevice, |
|
296 * which passes the search filter. Its name will be retrived later |
|
297 */ |
|
298 void HandleInquiryDeviceL(); |
|
299 |
|
300 void HandleFoundNameL(); |
|
301 |
|
302 /** |
|
303 * Allow/Disallow dialer and app key presses. |
|
304 * @param aAllow ETrue to allow key press; EFalse to disallow. |
|
305 */ |
|
306 void AllowDialerAndAppKeyPress( TBool aAllow ); |
|
307 |
|
308 private: // Data |
|
309 CBTNotifUIUtil* iUiUtil; |
|
310 CBTDeviceArray* iLastSeenDevicesArray; // Last seen devices array from BTInqNotifier |
|
311 CBTDeviceArray* iLastUsedDevicesArray; // Used devices from BT registry |
|
312 CBTDeviceArray* iPairedDevicesArray; // Paired devices from Bluetooth registry |
|
313 CBTDeviceArray* iAdjustedUsedDeviceArray; // 5 Lately used devices + All the Paired devices |
|
314 CBTEngDevMan* iDevMan; //Async deviceHandler |
|
315 |
|
316 CDesCArray* iDefaultDeviceNamesArray; // Default device names array |
|
317 CEikonEnv& iEikonEnvRef; // Reference to eikonenv |
|
318 |
|
319 CAknPopupList* iDevicePopupList; // Popup list for devices |
|
320 CDesCArrayFlat* iDeviceListRows; // Array for device list format string rows |
|
321 CAknSingleGraphicPopupMenuStyleListBox* iDeviceListBox; // ListBox for bluetooth devices |
|
322 CAknPopupList* iSearchFilterPopupList; |
|
323 |
|
324 CBTNotifActive* iScanner; |
|
325 |
|
326 TBool iDevicesFound; // Flag if any devices has been found |
|
327 TBool iInquiryComplete; |
|
328 TBool iBroughtForwards; // Flag for BringForwards |
|
329 TInt iInquiryStatus; // Error code from inquiry result |
|
330 |
|
331 TBTRegistryQueryState iBTRegistryQueryState; // which registry query (if any) is in progress. |
|
332 TBTDeviceClass iDesiredDeviceClass; // Device Class user selects from search filter |
|
333 CPeriodic* iPeriodicTimer; // the timer for reseting the user inactivity time |
|
334 TBool iSystemCancel; // Used for a trick to avoid final device list is still on show |
|
335 // while taking out mmc during BT device discovery |
|
336 TBTDeviceResponseParams iDevParams; |
|
337 TInt iHighLightedItemIndex; |
|
338 |
|
339 RSocketServ iSocketServer; // Socket server object |
|
340 RHostResolver iHostResolver; // Host resolver object |
|
341 TInquirySockAddr iInquirySockAddr; // Socket address record |
|
342 TNameEntry iEntry; // Inquiry results record |
|
343 TBool iPageForName; // Flag for inquiry name |
|
344 RArray<TNameRecord> iDevsWithoutName; // Devices without dev name |
|
345 TInt iIndex; // Current btdevice to inquiry its name |
|
346 MBTNDeviceSearchObserver* iDevSearchObserver; |
|
347 |
|
348 TBool iExcludePairedDevices; |
|
349 |
|
350 |
|
351 }; |
|
352 |
|
353 #endif |
|
354 |
|
355 // End of File |
|