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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.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
146 TRequestStatus* iClientStatusToCancel;
150 NONSHARABLE_CLASS(RBTManSubSession) : public RSubSessionBase
151 /** A subsession for the RBTMan session.
153 RBTManSubSession provides the actual access to the security manager.
155 Contains basic subssession functionality.
161 /** Used to close the subsession. */
162 virtual void Close() = 0; // All subsessions must provide Close overrides
163 IMPORT_C void CancelRequest(TRequestStatus& aStatus);
164 void LocalComplete(TRequestStatus& aStatus, TInt aErr);
167 IMPORT_C RBTManSubSession();
168 TBool IsBusy() const;
169 void SetBusy(TRequestStatus& aStatus);
172 TPckgBuf<TBTManClientServerMessage> iClientServerMsg;
174 // This data padding has been added to help prevent future binary compatibility breaks
175 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
180 NONSHARABLE_CLASS(RBTRegServ) : protected RBTMan
181 /** Registry access session.
183 It has a RBTMan session as implementation.
189 IMPORT_C RBTRegServ();
190 IMPORT_C TInt Connect();
191 IMPORT_C void Close();
192 IMPORT_C RBTMan& Session();
193 IMPORT_C TInt SetHeapFailure(TInt aType,TInt aRate);
194 IMPORT_C TInt ResourceCount();
197 // This data padding has been added to help prevent future binary compatibility breaks
198 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
203 // other functional sessions can derive from RBTMan
205 typedef RPointerArray<CBTDevice> RBTDeviceArray; /*!<RPointerArray of CBTDevices*/
206 typedef TPckgBuf<TBTNamelessDevice> TBTNamelessDevicePckgBuf; /*!<packagebuf of TBTNamelessDevice*/
207 typedef TPckgC<TBTDevAddr> TBTDevAddrPckg; /*!<const package (not buf) of TBTDevAddr*/
208 typedef TPckgBuf<TBTDevAddr> TBTDevAddrPckgBuf; /*!<packagebuf of TBTDevAddr*/
209 typedef TPckgBuf<TBTRegistrySearch> TBTRegistrySearchPckgBuf; /*!<packagebuf of TBTRegistrySearch*/
214 NONSHARABLE_CLASS(CBTRegistryResponse) : public CActive
215 /** Retrieves a set of results from the Registry.
217 This is a helper class that retrieves a set of results as a view from the registry.
223 IMPORT_C static CBTRegistryResponse* NewL(RBTRegistry& aView);
224 IMPORT_C void Start(TRequestStatus& aClientStatus);
225 IMPORT_C RBTDeviceArray& Results();
226 IMPORT_C ~CBTRegistryResponse();
228 CBTRegistryResponse(RBTRegistry& aView);
230 TInt RunError(TInt aError);
234 enum TState {EGettingSize, EGettingResults};
237 RBTDeviceArray iArray;
238 HBufC8* iResponseBuf;
241 TRequestStatus* iClientStatus;
244 NONSHARABLE_CLASS(RBTRegistry) : public RBTManSubSession
245 /** Creates and opens a subsession on the BT Registry Server for remote devices.
247 This subsession allows details of remote devices to be updated, modified, examined etc.
253 IMPORT_C RBTRegistry();
254 IMPORT_C TInt Open(RBTRegServ& aSession);
255 IMPORT_C void AddDeviceL(const CBTDevice& aDeviceDetails, TRequestStatus& aStatus);
256 IMPORT_C void GetDevice(TBTNamelessDevice& aDevice, TRequestStatus& aStatus); // nameless device
257 IMPORT_C void ModifyDevice(const TBTNamelessDevice& aDevice, TRequestStatus& aStatus); //namesless device
258 IMPORT_C void UnpairDevice(const TBTDevAddr& aAddress, TRequestStatus& aStatus);
259 IMPORT_C void ModifyFriendlyDeviceNameL(const TBTDevAddr& aAddress, const TDesC& aNewName, TRequestStatus& aStatus);
260 IMPORT_C void ModifyBluetoothDeviceNameL(const TBTDevAddr& aAddress, const TDesC8& aNewName, TRequestStatus& aStatus);
261 IMPORT_C void CreateView(const TBTRegistrySearch& aSearch, TRequestStatus& aStatus);
262 IMPORT_C void UnpairAllInView(TRequestStatus& aStatus);
263 IMPORT_C void DeleteAllInView(TRequestStatus& aStatus); // depends on client process capabilities
264 IMPORT_C void Close();
265 IMPORT_C TInt CloseView();
268 void PreLoad(TRequestStatus& aStatus);
269 void GetResults(TPtr8& aResultBuf, TRequestStatus& aStatus);
271 CBufFlat* iSendBuffer; // lazily constructed
272 TPtrC8 iSendBufferPtr;
273 TBTRegistrySearchPckgBuf iSearchPckg;
274 TPckg<TBTNamelessDevice> iDevicePckg;
275 TPckgBuf<TBTDevAddr> iAddrBuf;
277 // This data padding has been added to help prevent future binary compatibility breaks
278 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
283 NONSHARABLE_CLASS(RBTLocalDevice) : public RBTManSubSession
284 /** Creates and opens a subsession on BT Registry Server for local devices.
286 This subsession allows the local device to be updated, modified, examined etc.
292 IMPORT_C RBTLocalDevice();
293 IMPORT_C TInt Open(RBTRegServ& aSession);
294 IMPORT_C TInt Get(TBTLocalDevice& aLocalDevice);
295 IMPORT_C TInt Modify(const TBTLocalDevice& aLocalDevice);
296 IMPORT_C void Modify(const TBTLocalDevice& aLocalDevice, TRequestStatus& aStatus);
297 IMPORT_C void Close();
299 TPckg<TBTLocalDevice> iLocalDevicePckg;
301 // This data padding has been added to help prevent future binary compatibility breaks
302 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
309 UID of the PIN entry RNotifier plugin
313 const TUid KBTManPinNotifierUid={0x100069c9};
316 UID of the authorisation RNotifier plugin
320 const TUid KBTManAuthNotifierUid={0x100069cf};
323 NONSHARABLE_CLASS(TBTNotifierUpdateParams)
324 /** Sends parameter updates to the notifier.
326 Struct to allow us to send a device name to the Passkey Entry and Authorisation RNotifier plugins.
332 /** The device name that has been retrieved since security procedures started. */
338 NONSHARABLE_CLASS(TBTNotifierParams)
339 /** The device name parameter for the security notifier.
346 /** Device address of remote device requiring authorisation. */
348 /** The device name that has been retrieved since security procedures started. */
352 NONSHARABLE_CLASS(TBTAuthorisationParams) : public TBTNotifierParams
353 /** Bluetooth authorisation parameters.
355 Struct to allow us to send params from the security manager to the Authorisation RNotifier plugin.
361 /** UID of the service requesting authorisation. */
365 NONSHARABLE_CLASS(TBTPasskeyNotifierParams) : public TBTNotifierParams
366 /** The passkey parameter for the security notifier.
373 /** A min passkey length required. 0 means, no length requirement */
374 TUint iPasskeyMinLength;
375 /** true - locally initiated connection, false - remote side initiated */
376 TBool iLocallyInitiated;
380 typedef TPckgBuf<TBTNotifierUpdateParams> TBTNotifierUpdateParamsPckg; /*!< packagebuf of TBTNotifierUpdateParams*/
381 typedef TPckgBuf<TBTNotifierParams> TBTNotifierParamsPckg; /*!< packagebuf of TBTNotifierParams*/
382 typedef TPckgBuf<TBTAuthorisationParams> TBTAuthorisationParamsPckg; /*!< packagebuf of TBTAuthorisationParams*/
383 typedef TPckgBuf<TBTPasskeyNotifierParams> TBTPasskeyNotifierParamsPckg; /*!< packagebuf of TBTPasskeyNotifierParams*/