|
1 // Copyright (c) 1999-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 #ifndef BTMANCLIENT_H |
|
17 #define BTMANCLIENT_H |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <e32base.h> |
|
21 #include <btdevice.h> |
|
22 |
|
23 static const TInt KErrBluetoothRegistryCorrupt = -6501; |
|
24 |
|
25 /** The type of device class search to perform. |
|
26 |
|
27 The enumeration is of masks. Valid combinations are: |
|
28 |
|
29 EMajorDevice only |
|
30 EMajorDevice & EMinorDevice |
|
31 |
|
32 Note: EMinorDevice may not be used on its own. |
|
33 @publishedAll |
|
34 @released |
|
35 */ |
|
36 enum TBTDeviceClassSearch |
|
37 { |
|
38 EMajorDevice = 0x01,/*!< Indicates the major device class search criteria. */ |
|
39 EMinorDevice = 0x02,/*!< Indicates the minor device class search criteria. */ |
|
40 }; |
|
41 |
|
42 |
|
43 NONSHARABLE_CLASS(TBTRegistrySearch) |
|
44 /** Set search criteria on the Bluetooth Registry. |
|
45 |
|
46 The search logic is "AND", so if device bonded is set, and code set to |
|
47 headsets the search results contain all the bonded headsets in the registry. |
|
48 |
|
49 Other things can be added to the search criteria e.g. recently used headsets |
|
50 can easil be found by adding in the LastUsed criterion. |
|
51 @publishedAll |
|
52 @released |
|
53 */ |
|
54 { |
|
55 friend class RBTDbQuery; |
|
56 public: |
|
57 IMPORT_C TBTRegistrySearch(); |
|
58 IMPORT_C TBTRegistrySearch(const TBTRegistrySearch& aSearch); |
|
59 IMPORT_C void Reset(); |
|
60 IMPORT_C void FindAll(); |
|
61 IMPORT_C void FindAddress(const TBTDevAddr& aAddress); |
|
62 IMPORT_C void FindBonded(); |
|
63 IMPORT_C void FindTrusted(); |
|
64 IMPORT_C void FindCoD(const TBTDeviceClass& aClass); |
|
65 IMPORT_C void FindCoD(const TBTDeviceClass& aClass, TBTDeviceClassSearch aPref); |
|
66 IMPORT_C void FindSinceSeen(const TTime& aLastSeen); |
|
67 IMPORT_C void FindSinceUsed(const TTime& aLastUsed); |
|
68 IMPORT_C void FindBluetoothName(const TDesC8& aName); |
|
69 IMPORT_C void FindFriendlyName(const TDesC& aName); |
|
70 IMPORT_C void FindCurrentProcessOwned(); |
|
71 IMPORT_C void FindUiCookie(TUint32 aUiCookie); |
|
72 IMPORT_C void FindUiCookie(TUint32 aUiCookie, TUint32 aUiCookieMask); |
|
73 IMPORT_C TBTRegistrySearch& operator=(const TBTRegistrySearch& aSearch); |
|
74 private: |
|
75 enum TSearchMask |
|
76 { |
|
77 EAddress = 0x0001, |
|
78 EBonded = 0x0002, |
|
79 ETrusted = 0x0004, |
|
80 ECoD = 0x0008, |
|
81 ECoDMajorDev = 0x0010, |
|
82 ECoDMinorDev = 0x0020, |
|
83 ECoDService = 0x0040, // not used at present |
|
84 ELastSeen = 0x0080, |
|
85 ELastUsed = 0x0100, |
|
86 EBTName = 0x0200, |
|
87 EFriendlyName = 0x0400, |
|
88 EUiCookie = 0x2000, |
|
89 EProcess = 0x4000, |
|
90 EAll = 0x8000, |
|
91 // Top bit reserved for if the class needs to be extended. |
|
92 EExtension = 0x80000000 |
|
93 }; |
|
94 private: |
|
95 TUint iSearchMask; // what we actually have set to search on |
|
96 TBTDevAddr iDeviceAddress; |
|
97 TBTDeviceClass iDeviceClass; |
|
98 TTime iLastSeen; |
|
99 TTime iLastUsed; |
|
100 TPtrC8 iBluetoothName; |
|
101 TPtrC iFriendlyName; |
|
102 TUid iCurrentProcessSID; |
|
103 TUint32 iUiCookie; |
|
104 TUint32 iUiCookieMask; |
|
105 |
|
106 //TUint32 iPadding1; // used for UI Cookie |
|
107 //TUint32 iPadding2; // used for UI Cookie mask. |
|
108 }; |
|
109 |
|
110 |
|
111 NONSHARABLE_CLASS(RBTMan) : public RSessionBase |
|
112 /** Creates a sessions over which the Bluetooth security manager is accessible. |
|
113 |
|
114 A session must be used in order to access a subsession, RBTManSubSession, |
|
115 that allows access to the Security Manager. The following example creates and |
|
116 connects to the security manager session. |
|
117 |
|
118 @code |
|
119 RBTMan secMan; |
|
120 User::LeaveIfError(secMan.Connect()); |
|
121 @endcode |
|
122 |
|
123 Sessions available thus far are Registry-like |
|
124 @publishedAll |
|
125 @released |
|
126 */ |
|
127 { |
|
128 public: |
|
129 IMPORT_C RBTMan(); |
|
130 IMPORT_C TInt Connect(); |
|
131 IMPORT_C TVersion Version() const; |
|
132 |
|
133 private: |
|
134 // This data padding has been added to help prevent future binary compatibility breaks |
|
135 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used |
|
136 TUint32 iPadding1; |
|
137 TUint32 iPadding2; |
|
138 }; |
|
139 |
|
140 struct TBTManClientServerMessage |
|
141 /** |
|
142 This is to only be used by phone manufacturers, not by application developers. |
|
143 @publishedAll |
|
144 */ |
|
145 { |
|
146 public: |
|
147 TRequestStatus* iClientStatusToCancel; |
|
148 TBool iClientBusy; |
|
149 }; |
|
150 |
|
151 NONSHARABLE_CLASS(RBTManSubSession) : public RSubSessionBase |
|
152 /** A subsession for the RBTMan session. |
|
153 |
|
154 RBTManSubSession provides the actual access to the security manager. |
|
155 |
|
156 Contains basic subssession functionality. |
|
157 @publishedAll |
|
158 @released |
|
159 */ |
|
160 { |
|
161 public: |
|
162 /** Used to close the subsession. */ |
|
163 virtual void Close() = 0; // All subsessions must provide Close overrides |
|
164 IMPORT_C void CancelRequest(TRequestStatus& aStatus); |
|
165 void LocalComplete(TRequestStatus& aStatus, TInt aErr); |
|
166 |
|
167 protected: |
|
168 IMPORT_C RBTManSubSession(); |
|
169 TBool IsBusy() const; |
|
170 void SetBusy(TRequestStatus& aStatus); |
|
171 |
|
172 protected: |
|
173 TPckgBuf<TBTManClientServerMessage> iClientServerMsg; |
|
174 |
|
175 // This data padding has been added to help prevent future binary compatibility breaks |
|
176 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used |
|
177 TUint32 iPadding1; |
|
178 TUint32 iPadding2; |
|
179 }; |
|
180 |
|
181 NONSHARABLE_CLASS(RBTRegServ) : protected RBTMan |
|
182 /** Registry access session. |
|
183 |
|
184 It has a RBTMan session as implementation. |
|
185 @released |
|
186 @publishedAll |
|
187 */ |
|
188 { |
|
189 public: |
|
190 IMPORT_C RBTRegServ(); |
|
191 IMPORT_C TInt Connect(); |
|
192 IMPORT_C void Close(); |
|
193 IMPORT_C RBTMan& Session(); |
|
194 IMPORT_C TInt SetHeapFailure(TInt aType,TInt aRate); |
|
195 IMPORT_C TInt ResourceCount(); |
|
196 |
|
197 private: |
|
198 // This data padding has been added to help prevent future binary compatibility breaks |
|
199 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used |
|
200 TUint32 iPadding1; |
|
201 TUint32 iPadding2; |
|
202 }; |
|
203 |
|
204 // other functional sessions can derive from RBTMan |
|
205 |
|
206 typedef RPointerArray<CBTDevice> RBTDeviceArray; /*!<RPointerArray of CBTDevices*/ |
|
207 typedef TPckgBuf<TBTNamelessDevice> TBTNamelessDevicePckgBuf; /*!<packagebuf of TBTNamelessDevice*/ |
|
208 typedef TPckgC<TBTDevAddr> TBTDevAddrPckg; /*!<const package (not buf) of TBTDevAddr*/ |
|
209 typedef TPckgBuf<TBTDevAddr> TBTDevAddrPckgBuf; /*!<packagebuf of TBTDevAddr*/ |
|
210 typedef TPckgBuf<TBTRegistrySearch> TBTRegistrySearchPckgBuf; /*!<packagebuf of TBTRegistrySearch*/ |
|
211 |
|
212 class RBTRegistry; |
|
213 |
|
214 |
|
215 NONSHARABLE_CLASS(CBTRegistryResponse) : public CActive |
|
216 /** Retrieves a set of results from the Registry. |
|
217 |
|
218 This is a helper class that retrieves the set of results from a view set-up in the registry. |
|
219 A view is set-up in the registry using RBTRegistry::CreateView. |
|
220 |
|
221 @see RBTRegistry |
|
222 @publishedAll |
|
223 @released |
|
224 */ |
|
225 { |
|
226 public: |
|
227 IMPORT_C static CBTRegistryResponse* NewL(RBTRegistry& aView); |
|
228 IMPORT_C void Start(TRequestStatus& aClientStatus); |
|
229 IMPORT_C RBTDeviceArray& Results(); |
|
230 IMPORT_C ~CBTRegistryResponse(); |
|
231 private: |
|
232 CBTRegistryResponse(RBTRegistry& aView); |
|
233 void RunL(); |
|
234 TInt RunError(TInt aError); |
|
235 void DoCancel(); |
|
236 void DoGet(); |
|
237 void ConstructL(); |
|
238 enum TState {EGettingSize, EGettingResults}; |
|
239 private: |
|
240 RBTRegistry& iView; |
|
241 RBTDeviceArray iArray; |
|
242 HBufC8* iResponseBuf; |
|
243 TPtr8 iResponsePtr; |
|
244 TState iState; |
|
245 TRequestStatus* iClientStatus; |
|
246 }; |
|
247 |
|
248 NONSHARABLE_CLASS(RBTRegistry) : public RBTManSubSession |
|
249 /** Creates and opens a subsession on the BT Registry Server for remote devices. |
|
250 |
|
251 This subsession allows details of remote devices to be updated, modified, examined etc. |
|
252 @publishedAll |
|
253 @released |
|
254 */ |
|
255 { |
|
256 public: |
|
257 IMPORT_C RBTRegistry(); |
|
258 IMPORT_C TInt Open(RBTRegServ& aSession); |
|
259 IMPORT_C void AddDeviceL(const CBTDevice& aDeviceDetails, TRequestStatus& aStatus); |
|
260 IMPORT_C void GetDevice(TBTNamelessDevice& aDevice, TRequestStatus& aStatus); // nameless device |
|
261 IMPORT_C void ModifyDevice(const TBTNamelessDevice& aDevice, TRequestStatus& aStatus); //namesless device |
|
262 IMPORT_C void UnpairDevice(const TBTDevAddr& aAddress, TRequestStatus& aStatus); |
|
263 IMPORT_C void ModifyFriendlyDeviceNameL(const TBTDevAddr& aAddress, const TDesC& aNewName, TRequestStatus& aStatus); |
|
264 IMPORT_C void ModifyBluetoothDeviceNameL(const TBTDevAddr& aAddress, const TDesC8& aNewName, TRequestStatus& aStatus); |
|
265 IMPORT_C void CreateView(const TBTRegistrySearch& aSearch, TRequestStatus& aStatus); |
|
266 IMPORT_C void UnpairAllInView(TRequestStatus& aStatus); |
|
267 IMPORT_C void DeleteAllInView(TRequestStatus& aStatus); // depends on client process capabilities |
|
268 IMPORT_C void Close(); |
|
269 IMPORT_C TInt CloseView(); |
|
270 IMPORT_C void NotifyViewChange(TRequestStatus& aStatus); |
|
271 |
|
272 |
|
273 void PreLoad(TRequestStatus& aStatus); |
|
274 void GetResults(TPtr8& aResultBuf, TRequestStatus& aStatus); |
|
275 private: |
|
276 CBufFlat* iSendBuffer; // lazily constructed |
|
277 TPtrC8 iSendBufferPtr; |
|
278 TBTRegistrySearchPckgBuf iSearchPckg; |
|
279 TPckg<TBTNamelessDevice> iDevicePckg; |
|
280 TPckgBuf<TBTDevAddr> iAddrBuf; |
|
281 |
|
282 // This data padding has been added to help prevent future binary compatibility breaks |
|
283 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used |
|
284 TUint32 iPadding1; |
|
285 TUint32 iPadding2; |
|
286 }; |
|
287 |
|
288 NONSHARABLE_CLASS(RBTLocalDevice) : public RBTManSubSession |
|
289 /** Creates and opens a subsession on BT Registry Server for local devices. |
|
290 |
|
291 This subsession allows the local device to be updated, modified, examined etc. |
|
292 @publishedAll |
|
293 @released |
|
294 */ |
|
295 { |
|
296 public: |
|
297 IMPORT_C RBTLocalDevice(); |
|
298 IMPORT_C TInt Open(RBTRegServ& aSession); |
|
299 IMPORT_C TInt Get(TBTLocalDevice& aLocalDevice); |
|
300 IMPORT_C TInt Modify(const TBTLocalDevice& aLocalDevice); |
|
301 IMPORT_C void Modify(const TBTLocalDevice& aLocalDevice, TRequestStatus& aStatus); |
|
302 IMPORT_C void Close(); |
|
303 private: |
|
304 TPckg<TBTLocalDevice> iLocalDevicePckg; |
|
305 |
|
306 // This data padding has been added to help prevent future binary compatibility breaks |
|
307 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used |
|
308 TUint32 iPadding1; |
|
309 TUint32 iPadding2; |
|
310 }; |
|
311 |
|
312 |
|
313 /** |
|
314 UID of the PIN entry RNotifier plugin |
|
315 This is only to be used with notifiers. |
|
316 @publishedPartner |
|
317 @released |
|
318 */ |
|
319 const TUid KBTManPinNotifierUid={0x100069c9}; |
|
320 |
|
321 /** |
|
322 UID of the authorisation RNotifier plugin |
|
323 This is only to be used with notifiers. |
|
324 @publishedPartner |
|
325 @released |
|
326 */ |
|
327 const TUid KBTManAuthNotifierUid={0x100069cf}; |
|
328 |
|
329 |
|
330 |
|
331 NONSHARABLE_CLASS(TBTNotifierUpdateParams) |
|
332 /** Sends parameter updates to the notifier. |
|
333 |
|
334 Struct to allow us to send a device name to the Passkey Entry and Authorisation RNotifier plugins. |
|
335 This is only to be used with notifiers. |
|
336 @publishedPartner |
|
337 @released |
|
338 */ |
|
339 { |
|
340 public: |
|
341 /** The device name that has been retrieved since security procedures started. */ |
|
342 TBTDeviceName iName; |
|
343 /** The result. */ |
|
344 TInt iResult; |
|
345 }; |
|
346 |
|
347 NONSHARABLE_CLASS(TBTNotifierParams) |
|
348 /** The device name parameter for the security notifier. |
|
349 This is only to be used with notifiers. |
|
350 @publishedPartner |
|
351 @released |
|
352 */ |
|
353 { |
|
354 public: |
|
355 /** Device address of remote device requiring authorisation. */ |
|
356 TBTDevAddr iBDAddr; |
|
357 /** The device name that has been retrieved since security procedures started. */ |
|
358 TBTDeviceName iName; |
|
359 }; |
|
360 |
|
361 NONSHARABLE_CLASS(TBTAuthorisationParams) : public TBTNotifierParams |
|
362 /** Bluetooth authorisation parameters. |
|
363 This is only to be used with notifiers. |
|
364 Struct to allow us to send params from the security manager to the Authorisation RNotifier plugin. |
|
365 @publishedPartner |
|
366 @released |
|
367 */ |
|
368 { |
|
369 public: |
|
370 /** UID of the service requesting authorisation. */ |
|
371 TUid iUid; |
|
372 }; |
|
373 |
|
374 NONSHARABLE_CLASS(TBTPasskeyNotifierParams) : public TBTNotifierParams |
|
375 /** The passkey parameter for the security notifier. |
|
376 This is only to be used with notifiers. |
|
377 @publishedPartner |
|
378 @released |
|
379 */ |
|
380 { |
|
381 public: |
|
382 /** A min passkey length required. 0 means, no length requirement */ |
|
383 TUint iPasskeyMinLength; |
|
384 /** true - locally initiated connection, false - remote side initiated */ |
|
385 TBool iLocallyInitiated; |
|
386 }; |
|
387 |
|
388 // These are only to be used with notifiers. |
|
389 typedef TPckgBuf<TBTNotifierUpdateParams> TBTNotifierUpdateParamsPckg; /*!< packagebuf of TBTNotifierUpdateParams*/ |
|
390 typedef TPckgBuf<TBTNotifierParams> TBTNotifierParamsPckg; /*!< packagebuf of TBTNotifierParams*/ |
|
391 typedef TPckgBuf<TBTAuthorisationParams> TBTAuthorisationParamsPckg; /*!< packagebuf of TBTAuthorisationParams*/ |
|
392 typedef TPckgBuf<TBTPasskeyNotifierParams> TBTPasskeyNotifierParamsPckg; /*!< packagebuf of TBTPasskeyNotifierParams*/ |
|
393 |
|
394 #endif |