|
1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #ifndef BTTEXTNOTIFIERS_H |
|
22 #define BTTEXTNOTIFIERS_H |
|
23 |
|
24 #include <e32std.h> |
|
25 #include <e32base.h> |
|
26 #include <bt_sock.h> |
|
27 #include <btextnotifiers.h> // contains definitions of standard Bluetooth notifiers |
|
28 #include <btextnotifierspartner.h> |
|
29 #include <twintnotifier.h> |
|
30 #include <btdevice.h> |
|
31 #include <btmanclient.h> // contains definitions of standard Bluetooth secuirty notfiers (pre-SSP) |
|
32 #include <networking/panuiinterfaces.h> // for KBTPanDeviceSelectionNotifierUid |
|
33 |
|
34 const TUid KScreenOutputChannel ={0x00000666}; |
|
35 |
|
36 /** |
|
37 The maximum number of devices to show on screen at once |
|
38 @internalComponent |
|
39 */ |
|
40 const TInt KMaxDeviceRows=12; |
|
41 |
|
42 typedef RPointerArray<CBTDevice> RBTDevices; |
|
43 |
|
44 enum TRegistryState |
|
45 /** |
|
46 The state of the registry lookup to get info about a device |
|
47 @internalComponent |
|
48 */ |
|
49 { |
|
50 EFinding, //< finding device details in registry |
|
51 EGetting, //< getting PIN from console |
|
52 }; |
|
53 |
|
54 /** |
|
55 Class for containing console utility methods used by BTTextNotifiers. |
|
56 */ |
|
57 class BTTextNotifiersConsole |
|
58 { |
|
59 public: |
|
60 static CConsoleBase* AutoSizeNewL(const TDesC& aTitle, TSize aSize); |
|
61 }; |
|
62 |
|
63 |
|
64 |
|
65 // ----------------- |
|
66 // PIN Code Entry UI |
|
67 // ----------------- |
|
68 |
|
69 /** |
|
70 Mixing for receiving notifications about PIN code entry from the UI. |
|
71 */ |
|
72 class MBTPinCodeEntryObserver |
|
73 { |
|
74 public: |
|
75 virtual void MbpceoPinInputComplete(const TBTPinCode& aPin, TInt aReason) = 0; |
|
76 }; |
|
77 |
|
78 |
|
79 class CBTManPinNotifierEngine; |
|
80 |
|
81 /** |
|
82 Notifier to get a PIN for pairing - This is the legacy version (i.e. not SSP aware). |
|
83 @internalTechnology |
|
84 */ |
|
85 NONSHARABLE_CLASS(CBTManPinNotifier) |
|
86 : public CBase |
|
87 , public MNotifierBase2 |
|
88 , public MBTPinCodeEntryObserver |
|
89 { |
|
90 public: |
|
91 static CBTManPinNotifier* NewLC(); |
|
92 |
|
93 private: // from MNotifierBase2 |
|
94 void Release(); |
|
95 TNotifierInfo RegisterL(); |
|
96 TNotifierInfo Info() const; |
|
97 TPtrC8 StartL(const TDesC8& aBuffer); |
|
98 void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); |
|
99 void Cancel(); |
|
100 TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
101 |
|
102 private: // from MBTPinCodeEntryObserver |
|
103 void MbpceoPinInputComplete(const TBTPinCode& aPin, TInt aReason); |
|
104 |
|
105 private: |
|
106 CBTManPinNotifier(); |
|
107 void ConstructL(); |
|
108 ~CBTManPinNotifier(); |
|
109 |
|
110 private: |
|
111 TNotifierInfo iInfo; |
|
112 RMessage2 iMessage; |
|
113 TInt iReplySlot; |
|
114 TBool iNeedToCompleteMessage; |
|
115 CBTManPinNotifierEngine* iEngine; |
|
116 }; |
|
117 |
|
118 |
|
119 #ifndef __BT_TEXT_NOTIFIERS_NO_SSP__ |
|
120 /** |
|
121 Notifier to get a PIN for pairing - This is the SSP aware version. |
|
122 @internalTechnology |
|
123 */ |
|
124 NONSHARABLE_CLASS(CBTUIPinCodeEntry) |
|
125 : public CBase |
|
126 , public MNotifierBase2 |
|
127 , public MBTPinCodeEntryObserver |
|
128 { |
|
129 public: |
|
130 static CBTUIPinCodeEntry* NewLC(); |
|
131 |
|
132 private: // from MNotifierBase2 |
|
133 void Release(); |
|
134 TNotifierInfo RegisterL(); |
|
135 TNotifierInfo Info() const; |
|
136 TPtrC8 StartL(const TDesC8& aBuffer); |
|
137 void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); |
|
138 void Cancel(); |
|
139 TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
140 |
|
141 private: // from MBTPinCodeEntryObserver |
|
142 void MbpceoPinInputComplete(const TBTPinCode& aPin, TInt aReason); |
|
143 |
|
144 private: |
|
145 CBTUIPinCodeEntry(); |
|
146 void ConstructL(); |
|
147 ~CBTUIPinCodeEntry(); |
|
148 |
|
149 private: |
|
150 TNotifierInfo iInfo; |
|
151 RMessage2 iMessage; |
|
152 TInt iReplySlot; |
|
153 TBool iNeedToCompleteMessage; |
|
154 CBTManPinNotifierEngine* iEngine; |
|
155 }; |
|
156 |
|
157 #endif // __BT_TEXT_NOTIFIERS_NO_SSP__ |
|
158 |
|
159 |
|
160 class CHostResolverCacheProdder; |
|
161 class CBTGetPinFromConsole; |
|
162 |
|
163 NONSHARABLE_CLASS(CBTManPinNotifierEngine) : public CActive |
|
164 { |
|
165 public: |
|
166 static CBTManPinNotifierEngine* NewL(MBTPinCodeEntryObserver& aObserver); |
|
167 ~CBTManPinNotifierEngine(); |
|
168 |
|
169 void StartLegacyPinEntryL(const TDesC8& aBuffer); |
|
170 void StartPinEntryL(const TDesC8& aBuffer); |
|
171 void Stop(); |
|
172 |
|
173 TPtrC8 LegacyUpdateL(const TDesC8& aBuffer); |
|
174 TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
175 |
|
176 void HostResolverCacheInfoReceived(const TNameEntry& aResult); |
|
177 void PinInputComplete(const TBTPinCode& aPin, TInt aReason); |
|
178 |
|
179 private: |
|
180 CBTManPinNotifierEngine(MBTPinCodeEntryObserver& aObserver); |
|
181 void DoStartPinEntryL(); |
|
182 void StoreNameUpdateL(const TDesC8& aBuffer); |
|
183 void PerformNameUpdateL(TInt aResult); |
|
184 |
|
185 private: // from CActive |
|
186 void RunL(); |
|
187 void DoCancel(); |
|
188 void ConstructL(); |
|
189 |
|
190 private: |
|
191 MBTPinCodeEntryObserver& iObserver; // the notifier to signal when we have a PIN |
|
192 |
|
193 CHostResolverCacheProdder* iHostResolverCacheProdder; |
|
194 CBTDevice* iDevice; // the device for which we're prompting for a PIN |
|
195 CBTGetPinFromConsole* iGetPinFromConsole; // responsible for getting the PIN from the user |
|
196 RBTRegServ iRegistry; |
|
197 RBTRegistry iRegistryView; |
|
198 TBTRegistrySearch iRegistrySearch; |
|
199 TRegistryState iRegistryState; |
|
200 CBTRegistryResponse* iResponse; |
|
201 |
|
202 TBTDevAddr iDeviceAddress; |
|
203 TBTDeviceName iDeviceName; |
|
204 TUint iPasskeyMinLength; |
|
205 TBool iLocallyInitiated; |
|
206 TBool iStrongKeyRequired; |
|
207 TUint iRecommendedPasskeyMinLength; |
|
208 }; |
|
209 |
|
210 NONSHARABLE_CLASS(CHostResolverCacheProdder): public CActive |
|
211 /** |
|
212 Get CoD from HostResolver class |
|
213 @internalComponent |
|
214 */ |
|
215 { |
|
216 public: |
|
217 static CHostResolverCacheProdder* NewL(CBTManPinNotifierEngine* aParent); |
|
218 static CHostResolverCacheProdder* NewLC(CBTManPinNotifierEngine* aParent); |
|
219 ~CHostResolverCacheProdder(); |
|
220 TInt Start(const TBTDevAddr& aBDAddr); |
|
221 |
|
222 private: |
|
223 CHostResolverCacheProdder(CBTManPinNotifierEngine* aParent); |
|
224 void DoCancel(){iHostResolver.Cancel();}; |
|
225 void RunL(); |
|
226 |
|
227 private: |
|
228 CBTManPinNotifierEngine* iParent; |
|
229 RHostResolver iHostResolver; |
|
230 TNameEntry iResult; |
|
231 TInquirySockAddr iAddr; |
|
232 }; |
|
233 |
|
234 /** |
|
235 Display a console and get a PIN response |
|
236 @internalComponent |
|
237 */ |
|
238 NONSHARABLE_CLASS(CBTGetPinFromConsole) |
|
239 : public CActive |
|
240 { |
|
241 public: |
|
242 static CBTGetPinFromConsole* NewL(CBTManPinNotifierEngine* aParent, const CBTDevice& aDevice, |
|
243 TUint aPasskeyMinLength, TBool aInternallyInitiated, TBool aStringKeyRequired, |
|
244 TUint aRecommendedPasskeyMinLength); |
|
245 ~CBTGetPinFromConsole(); |
|
246 |
|
247 void GetPinL(); |
|
248 void DeviceNameRetrieved(const TPtrC aName, TInt aResult); |
|
249 void CoDRetrieved(TBTDeviceClass& aCoD); |
|
250 |
|
251 private: // from CActive |
|
252 void RunL(); |
|
253 void DoCancel(); |
|
254 |
|
255 #ifdef __BT_TEXT_NOTIFIERS_AUTO__ |
|
256 static TInt AutoNotifierCallBack(TAny *aConsolePin); |
|
257 #endif |
|
258 |
|
259 protected: |
|
260 CBTGetPinFromConsole(CBTManPinNotifierEngine* aPtr, TUint aPasskeyMinLength, TBool aInternallyInitiated, TBool aStrongKeyRequired, TUint aRecommendedPasskeyMinLength); |
|
261 |
|
262 private: |
|
263 void ConstructL(const CBTDevice& aDevice); |
|
264 void IssueRequestL(); |
|
265 |
|
266 private: |
|
267 const CBTDevice* iDevice; |
|
268 CBTManPinNotifierEngine* iParent; // the class to notify when we have a PIN code |
|
269 CConsoleBase* iConsole; // console for interaction with the user |
|
270 TBTPinCode iPin; |
|
271 TInt iInsert; |
|
272 TUint iPasskeyMinLength; |
|
273 TBool iInternallyInitiated; |
|
274 TBool iStrongKeyRequired; |
|
275 TUint iRecommendedPasskeyMinLength; |
|
276 |
|
277 #ifdef __BT_TEXT_NOTIFIERS_AUTO__ |
|
278 CAsyncCallBack* iAutoNotifierCallback; |
|
279 #endif |
|
280 }; |
|
281 |
|
282 class CBTManAuthNotifierEngine; |
|
283 NONSHARABLE_CLASS(CBTManAuthNotifier): public CBase, public MNotifierBase2 |
|
284 { |
|
285 public: |
|
286 static CBTManAuthNotifier* NewLC(); |
|
287 ~CBTManAuthNotifier(); |
|
288 void Release(); |
|
289 TNotifierInfo RegisterL(); |
|
290 TNotifierInfo Info() const; |
|
291 TPtrC8 StartL(const TDesC8& aBuffer); |
|
292 void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); |
|
293 void Cancel(); |
|
294 TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
295 void AuthorisationComplete(TBool aDecision, TInt aReason); |
|
296 |
|
297 private: |
|
298 void ConstructL(); |
|
299 |
|
300 private: |
|
301 TNotifierInfo iInfo; |
|
302 CBTManAuthNotifierEngine* iEngine; |
|
303 RMessage2 iMessage; |
|
304 TInt iReplySlot; |
|
305 TBool iNeedToCompleteMessage; |
|
306 }; |
|
307 |
|
308 class CBTGetAuthFromConsole; |
|
309 NONSHARABLE_CLASS(CBTManAuthNotifierEngine) : public CActive |
|
310 /** |
|
311 The implementation of authorisation notifier plugin. |
|
312 @note Separate class to avoid CActive and MNotifyBase Cancel name clash. |
|
313 */ |
|
314 { |
|
315 public: |
|
316 static CBTManAuthNotifierEngine* NewL(CBTManAuthNotifier& aParent); |
|
317 void StartAuthorisationL(const TDesC8& aBuffer); |
|
318 void AuthorisationComplete(TBool aDecision, TInt aReason); |
|
319 TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
320 ~CBTManAuthNotifierEngine(); |
|
321 void Stop(); |
|
322 |
|
323 private: |
|
324 CBTManAuthNotifierEngine(CBTManAuthNotifier& aParent); |
|
325 void RunL(); |
|
326 void DoCancel(); |
|
327 |
|
328 private: |
|
329 CBTGetAuthFromConsole* iGetAuthFromConsole; |
|
330 RBTRegServ iRegistry; |
|
331 RBTRegistry iRegistryView; |
|
332 TBTRegistrySearch iRegistrySearch; |
|
333 TRegistryState iRegistryState; |
|
334 CBTRegistryResponse* iResponse; |
|
335 CBTDevice* iDevice; |
|
336 TBTAuthorisationParamsPckg iAuthPckg; |
|
337 CBTManAuthNotifier& iParent; |
|
338 }; |
|
339 |
|
340 NONSHARABLE_CLASS(CBTGetAuthFromConsole) : public CActive |
|
341 /** |
|
342 Display a console and get a Y/N response |
|
343 @internalComponent |
|
344 */ |
|
345 { |
|
346 public: |
|
347 static CBTGetAuthFromConsole* NewL(CBTManAuthNotifierEngine* aParent, const CBTDevice& aDevice, TUid aUid); |
|
348 static CBTGetAuthFromConsole* NewLC(CBTManAuthNotifierEngine* aParent, const CBTDevice& aDevice, TUid aUid); |
|
349 ~CBTGetAuthFromConsole(); |
|
350 void AuthoriseL(); |
|
351 void RunL(); |
|
352 void DoCancel(); |
|
353 void DeviceNameRetrieved(const TDesC& aName, TInt aResult); |
|
354 |
|
355 #ifdef __BT_TEXT_NOTIFIERS_AUTO__ |
|
356 static TInt AutoNotifierCallBack(TAny *aConsoleAuth); |
|
357 #endif |
|
358 |
|
359 protected: |
|
360 CBTGetAuthFromConsole(CBTManAuthNotifierEngine* aParent); |
|
361 |
|
362 private: |
|
363 TInt GetDeviceName(const TBTDevAddr& aBDAddr, TDes& aName); |
|
364 void ConstructL(const CBTDevice& aDevice, TUid aUid); |
|
365 void IssueRequest(); |
|
366 |
|
367 private: |
|
368 TUid iServiceUid; |
|
369 const CBTDevice* iDevice; |
|
370 CBTManAuthNotifierEngine* iParent; |
|
371 CConsoleBase* iConsole; |
|
372 |
|
373 #ifdef __BT_TEXT_NOTIFIERS_AUTO__ |
|
374 CAsyncCallBack* iAutoNotifierCallback; |
|
375 #endif |
|
376 }; |
|
377 |
|
378 NONSHARABLE_CLASS(CBTManDeviceSelectionNotifier) |
|
379 : public CBase |
|
380 , public MNotifierBase2 |
|
381 { |
|
382 public: |
|
383 enum TUserResult |
|
384 { |
|
385 EScanStateSelected, |
|
386 EScanStateContinue, |
|
387 EScanStateCancelled |
|
388 }; |
|
389 public: |
|
390 static CBTManDeviceSelectionNotifier* NewLC(); |
|
391 ~CBTManDeviceSelectionNotifier(); |
|
392 TKeyCode GetResponseL(TRefByValue<const TDesC> aPrompt, TInt aWidth, TInt aHeight); |
|
393 void GetAddressL(TBTDevAddr& aBDAddr); |
|
394 void GetNameL(TBTDeviceName& aName); |
|
395 //void GetClassL(TBTDeviceClass& aClass); |
|
396 void DisplayErrorMessageL(); |
|
397 |
|
398 private: // from MNotifierBase2 |
|
399 void Release(); |
|
400 TNotifierInfo RegisterL(); |
|
401 TNotifierInfo Info() const; |
|
402 TPtrC8 StartL(const TDesC8& aBuffer); |
|
403 void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); |
|
404 void Cancel(); |
|
405 TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
406 |
|
407 private: |
|
408 CBTManDeviceSelectionNotifier(); |
|
409 void ConstructL(); |
|
410 TNotifierInfo iInfo; |
|
411 TBTDevAddr iBDAddr; |
|
412 TBTDeviceName iName; |
|
413 TBTDeviceClass iClass; |
|
414 }; |
|
415 |
|
416 NONSHARABLE_CLASS(CBTManDeviceScanner): public CBase |
|
417 { |
|
418 public: |
|
419 enum TScanState |
|
420 { |
|
421 EScanStateUnfinished, |
|
422 EScanStateCancelled, |
|
423 EScanStateSelected |
|
424 }; |
|
425 public: |
|
426 static CBTManDeviceScanner* NewL(); |
|
427 ~CBTManDeviceScanner(); |
|
428 TBool GetByScanL(TBTDevAddr& aBDAddr, TBTDeviceName& aName, TBTDeviceClass& aClass); |
|
429 private: |
|
430 CBTManDeviceScanner(); |
|
431 void ConstructL(); |
|
432 |
|
433 void NotifyErrorL(TRefByValue<const TDesC> aErrorNotification); |
|
434 void ResetDeviceLists(); |
|
435 void EnsureConsoleExistsL(); |
|
436 void StartWaitMessageL(); |
|
437 void StopWaitMessage(); |
|
438 void AddDiscoveredDeviceL(RBTDevices& aDeviceArray, const TNameEntry& aNameEntry); |
|
439 // void AddDiscoveredDeviceL(CBTDevInfoArray& aDevInfoArray, TNameEntry aNameEntry); |
|
440 void SetupDeviceParams(RHostResolver aHr, TBTNamelessDevice& aDevInfo); |
|
441 void SetupDeviceParams(const THostName& aName, TBTNamelessDevice& aDevInfo); |
|
442 void PrintDiscoveredDevice(TUint aCount, CBTDevice& aDevice); |
|
443 void RubOutWaitMessage(); |
|
444 void PrintDiscoveredDevice(); |
|
445 TBool DeviceNumberFromUserL(TBool allowMore); |
|
446 void DisplayNoDeviceMessageL(TBool isMore); |
|
447 void CheckUnfinishedL(); |
|
448 |
|
449 private: |
|
450 CConsoleBase* iConsole; |
|
451 CConsoleBase* iWaitConsole; |
|
452 TPtrC iWaitMessage; |
|
453 RBTDevices iDevices; |
|
454 RPointerArray<TNameEntry> iNoNameDevices; |
|
455 // CBTDevInfoArray* iDevsWithName; |
|
456 |
|
457 TUint iPrintedCounter; |
|
458 TUint iChosenDeviceIndex; |
|
459 TUint iResultCountWithName; |
|
460 TUint iResultCountNoName; |
|
461 TBTDeviceResponseParams iDevPms; |
|
462 |
|
463 TScanState iScanState; |
|
464 }; |
|
465 |
|
466 // |
|
467 // BT PAN profile device discovery notifier classes |
|
468 // |
|
469 |
|
470 class MBTPanDeviceSelectionNotify |
|
471 /** |
|
472 Notification interface from PAN device selection engine to the notifier |
|
473 @internalComponent |
|
474 */ |
|
475 { |
|
476 public: |
|
477 /** |
|
478 Remote device(s) have been selected |
|
479 */ |
|
480 virtual void DeviceSelectionComplete(TBTDeviceList& aDevices) = 0; |
|
481 virtual void DeviceSelectionError(TInt aError) = 0; |
|
482 |
|
483 protected: |
|
484 ~MBTPanDeviceSelectionNotify() {}; |
|
485 }; |
|
486 |
|
487 class CBTPanDeviceSelectionNotifierEngine; |
|
488 class CBTPanDeviceSelectionNotifier |
|
489 : public CBase |
|
490 , public MNotifierBase2 |
|
491 , private MBTPanDeviceSelectionNotify |
|
492 /** |
|
493 An example notifier for Bluetooth PAN profile device selection. This allows the selection of |
|
494 multiple devices. |
|
495 @internalTechnology |
|
496 */ |
|
497 { |
|
498 public: |
|
499 static CBTPanDeviceSelectionNotifier* NewLC(); |
|
500 ~CBTPanDeviceSelectionNotifier(); |
|
501 |
|
502 // MNotifierBase2 methods |
|
503 virtual void Release(); |
|
504 virtual TNotifierInfo RegisterL(); |
|
505 virtual TNotifierInfo Info() const; |
|
506 virtual TPtrC8 StartL(const TDesC8& aBuffer); |
|
507 virtual void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); |
|
508 virtual void Cancel(); |
|
509 virtual TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
510 |
|
511 // MBTPanDeviceSelectionNotify methods |
|
512 virtual void DeviceSelectionComplete(TBTDeviceList& aDevices); |
|
513 virtual void DeviceSelectionError(TInt aError); |
|
514 |
|
515 private: |
|
516 CBTPanDeviceSelectionNotifier(); |
|
517 void ConstructL(); |
|
518 |
|
519 public: |
|
520 |
|
521 private: |
|
522 TNotifierInfo iInfo; //< Info about this notifier |
|
523 RMessage2 iMessage; //< Client message to signal when device selection is complete |
|
524 TBool iMessageOutstanding; //< Have we got a message outstanding that needs to be completed? |
|
525 TInt iReplySlot; //< The slot in the message that contains the reply buffer |
|
526 |
|
527 CBTPanDeviceSelectionNotifierEngine* iEngine; //< Engine to do the actual device scanning and selection |
|
528 }; |
|
529 |
|
530 class MBTPanDeviceDiscoveryNotify |
|
531 /** |
|
532 Notification interface for when new devices are discovered |
|
533 @internalComponent |
|
534 */ |
|
535 { |
|
536 public: |
|
537 /** |
|
538 A new device has been found |
|
539 @param aNewDevice Information about the new device |
|
540 @note aNewDevice must be copied if you want to use it after this method completes |
|
541 */ |
|
542 virtual void NewDeviceFoundL(TNameRecord& aNewDevice) = 0; |
|
543 |
|
544 /** |
|
545 The search for devices has completed |
|
546 */ |
|
547 virtual void DeviceSearchComplete(TInt aError) = 0; |
|
548 |
|
549 protected: |
|
550 ~MBTPanDeviceDiscoveryNotify() {}; |
|
551 }; |
|
552 |
|
553 class CBTPanDeviceSelectionNotifierDeviceDiscoverer; |
|
554 class CBTPanDeviceSelectionNotifierEngine : public CActive, private MBTPanDeviceDiscoveryNotify |
|
555 /** |
|
556 Engine to display discovered devices to the user and get them to select some |
|
557 @internalComponent |
|
558 */ |
|
559 { |
|
560 public: |
|
561 static CBTPanDeviceSelectionNotifierEngine* NewL(MBTPanDeviceSelectionNotify& aNotify); |
|
562 ~CBTPanDeviceSelectionNotifierEngine(); |
|
563 |
|
564 void PromptForDevicesL(const TDesC8& aBuffer); |
|
565 void Stop(); |
|
566 |
|
567 // CActive methods |
|
568 virtual void RunL(); |
|
569 virtual void DoCancel(); |
|
570 |
|
571 // MBTPanDeviceDiscoveryNotify methods |
|
572 virtual void NewDeviceFoundL(TNameRecord& aNewDevice); |
|
573 virtual void DeviceSearchComplete(TInt aError); |
|
574 |
|
575 private: |
|
576 CBTPanDeviceSelectionNotifierEngine(MBTPanDeviceSelectionNotify& aNotify); |
|
577 void ConstructL(); |
|
578 |
|
579 void DisplayInstructions(TPtr& aDisplayBuf); |
|
580 TInt DisplayDevice(TUint aDeviceNumber, TPtr& aDisplayBuf); |
|
581 void Redraw(); |
|
582 void PackageSelectedDevicesAndCompleteNotifier(); |
|
583 void CompleteNotifierWithError(TInt aError); |
|
584 void AbortEverything(); |
|
585 |
|
586 TInt NumberOfDevicesSelected(); |
|
587 |
|
588 public: |
|
589 |
|
590 private: |
|
591 class TBTDeviceSelectionInfo |
|
592 { |
|
593 public: |
|
594 TBool iSelected; |
|
595 TNameRecord iNameRecord; |
|
596 }; |
|
597 |
|
598 RPointerArray<TBTDeviceSelectionInfo> iDevices; |
|
599 |
|
600 CConsoleBase* iConsole; |
|
601 HBufC* iDisplayBuf; //< Buffer into which to put text for display |
|
602 TPtr iDisplayPtr; |
|
603 TUint iCurrentlySelectedDevice; //< The index of the device to which the cursor is currently pointing |
|
604 TUint iPositionOfTopDeviceInList; //< The index of the device which is at the top of the list currently being displayed to the user |
|
605 TBool iDeviceSearchComplete; //< Has the device search completed? |
|
606 |
|
607 TBool iAborting; //< Flag to stop us going round in circles as AOs complete with KErrCancel and signal us |
|
608 |
|
609 CBTPanDeviceSelectionNotifierDeviceDiscoverer* iDeviceDiscoverer; |
|
610 MBTPanDeviceSelectionNotify& iNotify; //< the class to be notified when the devices have been selected |
|
611 }; |
|
612 |
|
613 class CBTPanDeviceSelectionNotifierDeviceDiscoverer : public CActive |
|
614 /** |
|
615 Discovers remote devices and notifies the engine about them |
|
616 @internalComponent |
|
617 */ |
|
618 { |
|
619 public: |
|
620 static CBTPanDeviceSelectionNotifierDeviceDiscoverer* NewL(MBTPanDeviceDiscoveryNotify& iNotify); |
|
621 ~CBTPanDeviceSelectionNotifierDeviceDiscoverer(); |
|
622 |
|
623 void StartDeviceDiscovery(); |
|
624 |
|
625 // CActive methods |
|
626 virtual void RunL(); |
|
627 virtual void DoCancel(); |
|
628 |
|
629 private: |
|
630 CBTPanDeviceSelectionNotifierDeviceDiscoverer(MBTPanDeviceDiscoveryNotify& iNotify); |
|
631 void ConstructL(); |
|
632 |
|
633 public: |
|
634 |
|
635 private: |
|
636 RSocketServ iSockServ; //< Socket server session |
|
637 RHostResolver iHostResolver; //< Host resolver to discover devices |
|
638 TNameEntry iNameEntry; //< Name entry into which to return results |
|
639 TInquirySockAddr iInquiryAddr; //< The inquiry address to use to discover devices |
|
640 |
|
641 MBTPanDeviceDiscoveryNotify& iNotify; //< The class to notify when a new device is found |
|
642 }; |
|
643 |
|
644 // forward declarations |
|
645 class CPbapAuthNotifierConsole; |
|
646 class CPbapAuthNotifierEngine; |
|
647 |
|
648 /** |
|
649 Console utility class |
|
650 @internalTechnology |
|
651 */ |
|
652 class PbapTextNotifiersConsole |
|
653 { |
|
654 public: |
|
655 static CConsoleBase* AutoSizeNewL(const TDesC& aTitle, TSize aSize); |
|
656 }; |
|
657 |
|
658 /** |
|
659 PBAP OBEX authentication notifier. |
|
660 Handles notification of a PBAP client challenge when attempting to connect to the server. |
|
661 @internalTechnology |
|
662 */ |
|
663 NONSHARABLE_CLASS(CPbapAuthNotifier): public CBase, public MNotifierBase2 |
|
664 { |
|
665 public: |
|
666 static CPbapAuthNotifier* NewLC(); |
|
667 ~CPbapAuthNotifier(); |
|
668 |
|
669 void PasswordInputComplete(const TDesC& aPassword, TInt aReason); |
|
670 |
|
671 public: |
|
672 // from MNotifierBase2 |
|
673 void Release(); |
|
674 TNotifierInfo RegisterL(); |
|
675 TNotifierInfo Info() const; |
|
676 TPtrC8 StartL(const TDesC8& aBuffer); |
|
677 void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); |
|
678 void Cancel(); |
|
679 TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
680 |
|
681 private: |
|
682 CPbapAuthNotifier(); |
|
683 void ConstructL(); |
|
684 |
|
685 private: |
|
686 TNotifierInfo iInfo; |
|
687 RMessage2 iMessage; |
|
688 TInt iReplySlot; |
|
689 TBool iNeedToCompleteMessage; |
|
690 CPbapAuthNotifierEngine* iEngine; |
|
691 }; |
|
692 |
|
693 NONSHARABLE_CLASS(CPbapAuthNotifierEngine) : public CActive |
|
694 { |
|
695 public: |
|
696 static CPbapAuthNotifierEngine* NewL(CPbapAuthNotifier& aParent); |
|
697 ~CPbapAuthNotifierEngine(); |
|
698 |
|
699 void StartPasswordEntryL(const TDesC8& aBuffer); |
|
700 void Stop(); |
|
701 void PasswordInputComplete(const TDesC& aPassword, TInt aReason); |
|
702 |
|
703 private: |
|
704 CPbapAuthNotifierEngine(CPbapAuthNotifier& aParent); |
|
705 void ConstructL(); |
|
706 |
|
707 // from CActive |
|
708 void RunL(); |
|
709 void DoCancel(); |
|
710 |
|
711 private: |
|
712 enum TRegistryState |
|
713 { |
|
714 EFinding, |
|
715 EGetting |
|
716 }; |
|
717 private: |
|
718 CPbapAuthNotifier& iParent; |
|
719 CBTDevice* iDevice; |
|
720 CPbapAuthNotifierConsole* iAuthConsole; |
|
721 RBTRegServ iRegistry; |
|
722 RBTRegistry iRegistryView; |
|
723 TBTRegistrySearch iRegistrySearch; |
|
724 TRegistryState iRegistryState; |
|
725 CBTRegistryResponse* iResponse; |
|
726 TPbapAuthNotifierParamsPckg iParamsPckg; |
|
727 }; |
|
728 |
|
729 /** |
|
730 Display a console and get a password response |
|
731 @internalComponent |
|
732 */ |
|
733 NONSHARABLE_CLASS(CPbapAuthNotifierConsole) : public CActive |
|
734 { |
|
735 public: |
|
736 static CPbapAuthNotifierConsole* NewL(CPbapAuthNotifierEngine* aParent, const CBTDevice& aDevice, const TDesC& aRealm, TBool aRealmTruncated); |
|
737 ~CPbapAuthNotifierConsole(); |
|
738 |
|
739 void GetPasswordL(); |
|
740 |
|
741 #ifdef __PBAP_TEXT_NOTIFIERS_AUTO__ |
|
742 static TInt AutoNotifierCallBack(TAny *aConsolePin); |
|
743 #endif |
|
744 |
|
745 protected: |
|
746 CPbapAuthNotifierConsole(CPbapAuthNotifierEngine* aParent, const TDesC& aRealm, TBool aRealmTruncated); |
|
747 |
|
748 private: |
|
749 void ConstructL(const CBTDevice& aDevice); |
|
750 void IssueRequestL(); |
|
751 |
|
752 // from CActive |
|
753 void RunL(); |
|
754 void DoCancel(); |
|
755 |
|
756 private: |
|
757 CPbapAuthNotifierEngine* iParent; |
|
758 const CBTDevice* iDevice; |
|
759 TBufC<KPbapAuthRealmLength> iRealm; |
|
760 TBool iRealmTruncated; |
|
761 CConsoleBase* iConsole; |
|
762 TBuf<KPbapAuthPasswordLength> iPassword; |
|
763 |
|
764 #ifdef __PBAP_TEXT_NOTIFIERS_AUTO__ |
|
765 CAsyncCallBack* iAutoNotifierCallback; |
|
766 #endif |
|
767 }; |
|
768 |
|
769 |
|
770 #ifndef __BT_TEXT_NOTIFIERS_NO_SSP__ |
|
771 |
|
772 class MBTGetNCResultFromConsoleObserver |
|
773 { |
|
774 public: |
|
775 virtual void NumericComparisonComplete(TBool aDecision, TInt aReason)=0; |
|
776 }; |
|
777 |
|
778 class CBTUINumericComparisonEngine; |
|
779 NONSHARABLE_CLASS(CBTUINumericComparison): public CBase, |
|
780 public MNotifierBase2, |
|
781 public MBTGetNCResultFromConsoleObserver |
|
782 { |
|
783 public: |
|
784 static CBTUINumericComparison* NewLC(); |
|
785 ~CBTUINumericComparison(); |
|
786 void Release(); |
|
787 TNotifierInfo RegisterL(); |
|
788 TNotifierInfo Info() const; |
|
789 TPtrC8 StartL(const TDesC8& aBuffer); |
|
790 void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); |
|
791 void Cancel(); |
|
792 TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
793 |
|
794 // MBTGetNCResultFromConsoleObserver |
|
795 void NumericComparisonComplete(TBool aDecision, TInt aReason); |
|
796 |
|
797 private: |
|
798 void ConstructL(); |
|
799 |
|
800 private: |
|
801 TNotifierInfo iInfo; |
|
802 CBTUINumericComparisonEngine* iEngine; |
|
803 RMessage2 iMessage; |
|
804 TInt iReplySlot; |
|
805 TBTNumericComparisonParamsPckg iNumericComparisonParamsPckg; |
|
806 TBool iNeedToCompleteMessage; |
|
807 }; |
|
808 |
|
809 NONSHARABLE_CLASS(CBTUINumericComparisonEngine) : public CActive |
|
810 { |
|
811 public: |
|
812 static CBTUINumericComparisonEngine* NewL(MBTGetNCResultFromConsoleObserver& aObserver); |
|
813 static CBTUINumericComparisonEngine* NewLC(MBTGetNCResultFromConsoleObserver& aObserver); |
|
814 ~CBTUINumericComparisonEngine(); |
|
815 |
|
816 void DoComparisonL(TBTNumericComparisonParams& aNumericComparisonParams); |
|
817 TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
818 void Stop(); |
|
819 void RunL(); |
|
820 void DoCancel(); |
|
821 |
|
822 protected: |
|
823 CBTUINumericComparisonEngine(MBTGetNCResultFromConsoleObserver& aObserver); |
|
824 |
|
825 private: |
|
826 void ConstructL(); |
|
827 void IssueRequest(); |
|
828 |
|
829 private: |
|
830 MBTGetNCResultFromConsoleObserver& iObserver; |
|
831 CConsoleBase* iConsole; |
|
832 }; |
|
833 |
|
834 |
|
835 // ---------------------- |
|
836 // Passkey Entry UI (SSP) |
|
837 // ---------------------- |
|
838 |
|
839 class MBTGetPasskeyResultFromConsoleObserver |
|
840 { |
|
841 public: |
|
842 virtual void PasskeyComplete(TInt aReason)=0; |
|
843 }; |
|
844 |
|
845 |
|
846 class CBTUIPasskeyEntryEngine; |
|
847 |
|
848 NONSHARABLE_CLASS(CBTUIPasskeyEntry) |
|
849 : public CBase |
|
850 , public MNotifierBase2 |
|
851 , public MBTGetPasskeyResultFromConsoleObserver |
|
852 { |
|
853 public: |
|
854 static CBTUIPasskeyEntry* NewLC(); |
|
855 |
|
856 private: // from MNotifierBase2 |
|
857 void Release(); |
|
858 TNotifierInfo RegisterL(); |
|
859 TNotifierInfo Info() const; |
|
860 TPtrC8 StartL(const TDesC8& aBuffer); |
|
861 void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); |
|
862 void Cancel(); |
|
863 TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
864 |
|
865 private: // from MBTGetPasskeyResultFromConsoleObserver |
|
866 void PasskeyComplete(TInt aReason); |
|
867 |
|
868 private: |
|
869 void ConstructL(); |
|
870 ~CBTUIPasskeyEntry(); |
|
871 |
|
872 private: |
|
873 TNotifierInfo iInfo; |
|
874 CBTUIPasskeyEntryEngine* iEngine; |
|
875 RMessage2 iMessage; |
|
876 TInt iReplySlot; |
|
877 TBTPasskeyDisplayParamsPckg iPasskeyDisplayParamsPckg; |
|
878 TBTDevAddr iAddr; |
|
879 TBTDeviceName iName; |
|
880 TUint32 iNumericValue; |
|
881 TBool iNeedToCompleteMessage; |
|
882 }; |
|
883 |
|
884 NONSHARABLE_CLASS(CBTUIPasskeyEntryEngine) |
|
885 : public CActive |
|
886 { |
|
887 public: |
|
888 static CBTUIPasskeyEntryEngine* NewL(MBTGetPasskeyResultFromConsoleObserver& aObserver); |
|
889 static CBTUIPasskeyEntryEngine* NewLC(MBTGetPasskeyResultFromConsoleObserver& aObserver); |
|
890 ~CBTUIPasskeyEntryEngine(); |
|
891 |
|
892 void DoPasskeyL(TBTPasskeyDisplayParams& aPasskeyParams); |
|
893 TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
894 void Stop(); |
|
895 void RunL(); |
|
896 void DoCancel(); |
|
897 |
|
898 private: |
|
899 CBTUIPasskeyEntryEngine(MBTGetPasskeyResultFromConsoleObserver& aObserver); |
|
900 void ConstructL(); |
|
901 void IssueRequest(); |
|
902 |
|
903 private: |
|
904 MBTGetPasskeyResultFromConsoleObserver& iObserver; |
|
905 CConsoleBase* iConsole; |
|
906 }; |
|
907 |
|
908 |
|
909 #endif // __BT_TEXT_NOTIFIERS_NO_SSP__ |
|
910 |
|
911 |
|
912 |
|
913 #endif // BTTEXTNOTIFIERS_H |