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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
23 static const TInt KErrBluetoothRegistryCorrupt = -6501;
25 /** The type of device class search to perform.
27 The enumeration is of masks. Valid combinations are:
30 EMajorDevice & EMinorDevice
32 Note: EMinorDevice may not be used on its own.
36 enum TBTDeviceClassSearch
38 EMajorDevice = 0x01,/*!< Indicates the major device class search criteria. */
39 EMinorDevice = 0x02,/*!< Indicates the minor device class search criteria. */
43 NONSHARABLE_CLASS(TBTRegistrySearch)
44 /** Set search criteria on the Bluetooth Registry.
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.
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.
55 friend class RBTDbQuery;
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);
81 ECoDMajorDev = 0x0010,
82 ECoDMinorDev = 0x0020,
83 ECoDService = 0x0040, // not used at present
87 EFriendlyName = 0x0400,
91 // Top bit reserved for if the class needs to be extended.
92 EExtension = 0x80000000
95 TUint iSearchMask; // what we actually have set to search on
96 TBTDevAddr iDeviceAddress;
97 TBTDeviceClass iDeviceClass;
100 TPtrC8 iBluetoothName;
102 TUid iCurrentProcessSID;
104 TUint32 iUiCookieMask;
106 //TUint32 iPadding1; // used for UI Cookie
107 //TUint32 iPadding2; // used for UI Cookie mask.
111 NONSHARABLE_CLASS(RBTMan) : public RSessionBase
112 /** Creates a sessions over which the Bluetooth security manager is accessible.
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.
120 User::LeaveIfError(secMan.Connect());
123 Sessions available thus far are Registry-like
130 IMPORT_C TInt Connect();
131 IMPORT_C TVersion Version() const;
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
140 struct TBTManClientServerMessage
142 This is to only be used by phone manufacturers, not by application developers.
147 TRequestStatus* iClientStatusToCancel;
151 NONSHARABLE_CLASS(RBTManSubSession) : public RSubSessionBase
152 /** A subsession for the RBTMan session.
154 RBTManSubSession provides the actual access to the security manager.
156 Contains basic subssession functionality.
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);
168 IMPORT_C RBTManSubSession();
169 TBool IsBusy() const;
170 void SetBusy(TRequestStatus& aStatus);
173 TPckgBuf<TBTManClientServerMessage> iClientServerMsg;
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
181 NONSHARABLE_CLASS(RBTRegServ) : protected RBTMan
182 /** Registry access session.
184 It has a RBTMan session as implementation.
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();
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
204 // other functional sessions can derive from RBTMan
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*/
215 NONSHARABLE_CLASS(CBTRegistryResponse) : public CActive
216 /** Retrieves a set of results from the Registry.
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.
227 IMPORT_C static CBTRegistryResponse* NewL(RBTRegistry& aView);
228 IMPORT_C void Start(TRequestStatus& aClientStatus);
229 IMPORT_C RBTDeviceArray& Results();
230 IMPORT_C ~CBTRegistryResponse();
232 CBTRegistryResponse(RBTRegistry& aView);
234 TInt RunError(TInt aError);
238 enum TState {EGettingSize, EGettingResults};
241 RBTDeviceArray iArray;
242 HBufC8* iResponseBuf;
245 TRequestStatus* iClientStatus;
248 NONSHARABLE_CLASS(RBTRegistry) : public RBTManSubSession
249 /** Creates and opens a subsession on the BT Registry Server for remote devices.
251 This subsession allows details of remote devices to be updated, modified, examined etc.
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);
273 void PreLoad(TRequestStatus& aStatus);
274 void GetResults(TPtr8& aResultBuf, TRequestStatus& aStatus);
276 CBufFlat* iSendBuffer; // lazily constructed
277 TPtrC8 iSendBufferPtr;
278 TBTRegistrySearchPckgBuf iSearchPckg;
279 TPckg<TBTNamelessDevice> iDevicePckg;
280 TPckgBuf<TBTDevAddr> iAddrBuf;
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
288 NONSHARABLE_CLASS(RBTLocalDevice) : public RBTManSubSession
289 /** Creates and opens a subsession on BT Registry Server for local devices.
291 This subsession allows the local device to be updated, modified, examined etc.
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();
304 TPckg<TBTLocalDevice> iLocalDevicePckg;
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
314 UID of the PIN entry RNotifier plugin
315 This is only to be used with notifiers.
319 const TUid KBTManPinNotifierUid={0x100069c9};
322 UID of the authorisation RNotifier plugin
323 This is only to be used with notifiers.
327 const TUid KBTManAuthNotifierUid={0x100069cf};
331 NONSHARABLE_CLASS(TBTNotifierUpdateParams)
332 /** Sends parameter updates to the notifier.
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.
341 /** The device name that has been retrieved since security procedures started. */
347 NONSHARABLE_CLASS(TBTNotifierParams)
348 /** The device name parameter for the security notifier.
349 This is only to be used with notifiers.
355 /** Device address of remote device requiring authorisation. */
357 /** The device name that has been retrieved since security procedures started. */
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.
370 /** UID of the service requesting authorisation. */
374 NONSHARABLE_CLASS(TBTPasskeyNotifierParams) : public TBTNotifierParams
375 /** The passkey parameter for the security notifier.
376 This is only to be used with notifiers.
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;
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*/