|
1 /* |
|
2 * Copyright (c) 2009 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: Utilities that may be useful for components of |
|
15 * Bluetooth Engine subsystem |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef BTENGUTIL_H |
|
20 #define BTENGUTIL_H |
|
21 |
|
22 #include <btdevice.h> |
|
23 #include <btengconstants.h> |
|
24 |
|
25 /** |
|
26 Tells if the given device has been paired regardless of user awareness. |
|
27 (User aware paired devices are those seen in the paired device view of |
|
28 Bluetooth application.) |
|
29 */ |
|
30 inline TBool IsPaired( const TBTNamelessDevice &dev ) |
|
31 { |
|
32 // IsValidPaired tells if the paired bit of dev is valid |
|
33 // and IsPaired tells if the device is paired or not: |
|
34 return dev.IsValidPaired() && |
|
35 dev.IsPaired() && |
|
36 // Authentication due to OBEX cases e.g. file transfer, is not |
|
37 // considered as paired in Bluetooth engine scope: |
|
38 dev.LinkKeyType() != ELinkKeyUnauthenticatedUpgradable; |
|
39 } |
|
40 |
|
41 /** |
|
42 Tells if the given device has been paired with Just Works model. |
|
43 */ |
|
44 inline TBool IsJustWorksPaired( const TBTNamelessDevice &dev ) |
|
45 { |
|
46 return IsPaired( dev ) && |
|
47 dev.LinkKeyType() == ELinkKeyUnauthenticatedNonUpgradable; |
|
48 } |
|
49 |
|
50 /** |
|
51 Tells if the given device has been paired under user awareness. |
|
52 (User aware paired devices are those seen in the paired device view of |
|
53 Bluetooth application.) |
|
54 */ |
|
55 inline TBool IsUserAwarePaired( const TBTNamelessDevice &dev ) |
|
56 { |
|
57 if ( IsJustWorksPaired( dev ) ) |
|
58 { |
|
59 // Just Works paired devices can happen without user awareness. |
|
60 // For example, paired due to an incoming service connection request |
|
61 // from a device without IO. |
|
62 // We use cookies to identify if this JW pairing is user aware or not: |
|
63 TInt32 cookie = dev.IsValidUiCookie() ? dev.UiCookie() : EBTUiCookieUndefined; |
|
64 return (cookie & EBTUiCookieJustWorksPaired ); |
|
65 } |
|
66 // Pairing in other mode than Just Works are always user-aware: |
|
67 return IsPaired( dev ); |
|
68 } |
|
69 |
|
70 #endif /*BTENGUTIL_H*/ |