1 /* |
|
2 * Copyright (c) 2010 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: an extended BT device offering properties of |
|
15 * a Bluetooth device that may be needed by Bluetooth UIs |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef BTDEVEXTENSION_H |
|
20 #define BTDEVEXTENSION_H |
|
21 |
|
22 #include <btdevice.h> |
|
23 #include <btmanclient.h> |
|
24 #include <bt_sock.h> |
|
25 #include <btengconstants.h> |
|
26 |
|
27 /** |
|
28 * APIs from this class offer functionalities that are common in mw and app |
|
29 * components of Bluetooth packages. They do not serve as domain APIs. |
|
30 * |
|
31 * Using these from external components is risky, due to possible source |
|
32 * and binary breaks in future. |
|
33 * |
|
34 */ |
|
35 |
|
36 /** |
|
37 * The option for specify the default name for a BT device in |
|
38 * case the device has neither a device name nor a friendly name. |
|
39 */ |
|
40 enum TDefaultDevNameOption |
|
41 { |
|
42 ENoDefaultName, |
|
43 EColonSeperatedBDAddr, // device name will be formated |
|
44 EPlainBDAddr, |
|
45 }; |
|
46 |
|
47 /** |
|
48 * Class CBtDevExtension |
|
49 * |
|
50 * This class provides the access to the properties of devices from BT registry. |
|
51 * In addition, it provides other dynamic properties such as the connection |
|
52 * and proximity statuses. Note that client should not store the dynamic |
|
53 * properties for future use since they may change frequently. |
|
54 * |
|
55 */ |
|
56 NONSHARABLE_CLASS( CBtDevExtension ) : public CBase |
|
57 { |
|
58 |
|
59 public: |
|
60 // placeholder for providing more properties of a device |
|
61 enum TBtDevStatus |
|
62 { |
|
63 EUndefinedStatus, |
|
64 EInRangUnknown = 0x01, |
|
65 EInRange = 0x02, |
|
66 EPermanentInRegistry = 0x04, |
|
67 }; |
|
68 |
|
69 /** |
|
70 * Two-phase constructor |
|
71 * @param aDev a CBTDevice instance. The ownership is transferred. |
|
72 * @param aNameOption the option for formating the default device |
|
73 * name when the given aDev instance has no valid name. |
|
74 */ |
|
75 IMPORT_C static CBtDevExtension* NewLC( CBTDevice* aDev, |
|
76 TDefaultDevNameOption aNameOption = EColonSeperatedBDAddr ); |
|
77 |
|
78 /** |
|
79 * Two-phase constructor |
|
80 * @param aAddr the inquiry socket address of the device. |
|
81 * @param aName the device-name of the device. |
|
82 * @param aNameOption the option for formating the default device |
|
83 * name when the given name is empty. |
|
84 */ |
|
85 IMPORT_C static CBtDevExtension* NewLC( |
|
86 const TInquirySockAddr& aAddr, |
|
87 const TDesC& aName = KNullDesC, |
|
88 TDefaultDevNameOption aNameOption = EColonSeperatedBDAddr ); |
|
89 |
|
90 /** |
|
91 * Two-phase constructor |
|
92 * @param aAddr the bd_addr of the device. |
|
93 * @param aName the device-name of the device. |
|
94 * @param aNameOption the option for formating the default device |
|
95 * name when the given name is empty. |
|
96 */ |
|
97 IMPORT_C static CBtDevExtension* NewLC( |
|
98 const TBTDevAddr& aAddr, |
|
99 const TDesC& aName = KNullDesC, |
|
100 TDefaultDevNameOption aNameOption = EColonSeperatedBDAddr ); |
|
101 |
|
102 /** |
|
103 * Destructor |
|
104 */ |
|
105 IMPORT_C virtual ~CBtDevExtension(); |
|
106 |
|
107 /** |
|
108 * Tells if the given device is bonded regardless of whether the pairing was |
|
109 * performed under user awareness. |
|
110 * |
|
111 * @return ETrue if it is bonded. |
|
112 */ |
|
113 IMPORT_C static TBool IsBonded( const TBTNamelessDevice &dev ); |
|
114 |
|
115 /** |
|
116 * Tells if the given device is bonded with the Just Works pairing model. |
|
117 * |
|
118 * @return ETrue if it is bonded and the pairing was performed with Just Works. |
|
119 */ |
|
120 IMPORT_C static TBool IsJustWorksBonded( const TBTNamelessDevice &dev ); |
|
121 |
|
122 /** |
|
123 * Tells if the given device has been bonded under user awareness. |
|
124 * User awareness refers that the user interacted or was informed during or |
|
125 * immediately after the pairing completed. |
|
126 * |
|
127 * @return ETrue if the user is aware of the bonding. |
|
128 */ |
|
129 IMPORT_C static TBool IsUserAwareBonded( const TBTNamelessDevice &dev ); |
|
130 |
|
131 /** |
|
132 * Guesses if the given device is a headset. |
|
133 * |
|
134 * @param the Class of Device of the device of which the type is |
|
135 * determined. |
|
136 * @return ETrue if it is probably a headset. EFalse otherwise. |
|
137 */ |
|
138 IMPORT_C static TBool IsHeadset( const TBTDeviceClass &aCod ); |
|
139 |
|
140 /** |
|
141 * Returns the display name of this device for end users. |
|
142 * @return the friendly name of the device if it is available; else, the device |
|
143 * name if it is available; otherwise, the BDADDR seperated with ":". |
|
144 */ |
|
145 IMPORT_C const TDesC& Alias() const; |
|
146 |
|
147 /** |
|
148 * Gets the device address. |
|
149 * @return the device. |
|
150 */ |
|
151 IMPORT_C const TBTDevAddr& Addr() const; |
|
152 |
|
153 /** |
|
154 * Gets the CBTDevice instance. |
|
155 * @return the device. |
|
156 */ |
|
157 IMPORT_C const CBTDevice& Device() const; |
|
158 |
|
159 /** |
|
160 * Checks if this device was bonded under user awareness. |
|
161 * @return ETrue if it is user-aware bonded. |
|
162 */ |
|
163 IMPORT_C TBool IsUserAwareBonded() const; |
|
164 |
|
165 /** |
|
166 * |
|
167 * Returns the service (limited to services managed in bteng scope) |
|
168 * level connection status of the specified device. |
|
169 * |
|
170 * @param aAddr the address of the device |
|
171 * @return one of TBTEngConnectionStatus enums |
|
172 */ |
|
173 IMPORT_C TBTEngConnectionStatus ServiceConnectionStatus() const; |
|
174 |
|
175 /** |
|
176 * Sets a device. The ownership is transferred. |
|
177 * |
|
178 * @param aDev the device to be set. |
|
179 */ |
|
180 IMPORT_C void SetDeviceL( CBTDevice* aDev ); |
|
181 |
|
182 /** |
|
183 * Make a copy of this evice. |
|
184 * |
|
185 * @return a new device instance. |
|
186 */ |
|
187 IMPORT_C CBtDevExtension* CopyL(); |
|
188 |
|
189 public: |
|
190 |
|
191 /** |
|
192 * Internally invoked in this module, not a DLL level API. |
|
193 * |
|
194 * Sets the service connection status of this device. |
|
195 */ |
|
196 void SetServiceConnectionStatus( TBTEngConnectionStatus aStatus ); |
|
197 |
|
198 private: |
|
199 |
|
200 /** |
|
201 * C++ default constructor |
|
202 */ |
|
203 CBtDevExtension( TDefaultDevNameOption aNameOption ); |
|
204 |
|
205 /** |
|
206 * Symbian 2nd-phase constructor |
|
207 */ |
|
208 void ConstructL( CBTDevice* aDev ); |
|
209 |
|
210 /** |
|
211 * Update device properties due to setDeviceL or other events. |
|
212 */ |
|
213 void UpdateNameL(); |
|
214 |
|
215 /** |
|
216 * Update the service connection status for this device: |
|
217 */ |
|
218 //void UpdateServiceStatusL(); |
|
219 |
|
220 /** |
|
221 * formats the BD_Addr as the device name. |
|
222 */ |
|
223 void FormatAddressAsNameL(); |
|
224 |
|
225 private: |
|
226 |
|
227 RBuf iAlias; // contains: |
|
228 // friendly name, if it is not empty; else |
|
229 // device name, if it is not empty; else |
|
230 // the assignment depending on the option chosen by client. |
|
231 |
|
232 // The Device instance ( in most case it is given by registry) |
|
233 CBTDevice* iDev; |
|
234 |
|
235 // The bits of dynamic status |
|
236 TInt iDynamicStatus; |
|
237 |
|
238 // Indicates the service connection status of this device |
|
239 TBTEngConnectionStatus iServiceStatus; |
|
240 |
|
241 // The option chosen by the client to deal with default BT name assignment. |
|
242 TDefaultDevNameOption iNameOption; |
|
243 }; |
|
244 |
|
245 typedef RPointerArray<CBtDevExtension> RDevExtensionArray; |
|
246 |
|
247 #endif /*BTDEVEXTENSION_H*/ |
|