epoc32/include/btmanclient.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     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".
     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 @internalComponent
   143 */
   144 	{
   145 public:
   146 	TRequestStatus* iClientStatusToCancel;
   147 	TBool			iClientBusy;
   148 	};
   149 
   150 NONSHARABLE_CLASS(RBTManSubSession) : public RSubSessionBase
   151     /** A subsession for the RBTMan session.
   152 
   153     RBTManSubSession provides the actual access to the security manager.
   154 
   155     Contains basic subssession functionality.
   156 	@publishedAll
   157 	@released
   158 	*/
   159 	{
   160 public:
   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);
   165 
   166 protected:
   167 	IMPORT_C RBTManSubSession();
   168 	TBool IsBusy() const;
   169 	void SetBusy(TRequestStatus& aStatus);
   170 	
   171 protected:
   172 	TPckgBuf<TBTManClientServerMessage>	iClientServerMsg;
   173 
   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	
   176 	TUint32     iPadding1; 
   177 	TUint32     iPadding2;  
   178 	};
   179 
   180 NONSHARABLE_CLASS(RBTRegServ) : protected RBTMan
   181     /** Registry access session.
   182 
   183     It has a RBTMan session as implementation.
   184 	@released
   185 	@publishedAll
   186 	*/
   187 	{
   188 public:
   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();
   195 	
   196 private:
   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
   199 	TUint32     iPadding1; 
   200 	TUint32     iPadding2; 
   201 	};
   202 
   203 // other functional sessions can derive from RBTMan
   204 
   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*/
   210 
   211 class RBTRegistry;
   212 
   213 
   214 NONSHARABLE_CLASS(CBTRegistryResponse) : public CActive
   215     /** Retrieves a set of results from the Registry.
   216 	 
   217 	This is a helper class that retrieves a set of results as a view from the registry.
   218 	@publishedAll
   219 	@released
   220 	*/
   221 	{
   222 public:
   223 	IMPORT_C static CBTRegistryResponse* NewL(RBTRegistry& aView);
   224 	IMPORT_C void Start(TRequestStatus& aClientStatus);
   225 	IMPORT_C RBTDeviceArray& Results();
   226 	IMPORT_C ~CBTRegistryResponse();
   227 private:
   228 	CBTRegistryResponse(RBTRegistry& aView);
   229 	void RunL();
   230 	TInt RunError(TInt aError);
   231 	void DoCancel();
   232 	void DoGet();
   233 	void ConstructL();
   234 	enum TState {EGettingSize, EGettingResults};
   235 private:
   236 	RBTRegistry&		iView;
   237 	RBTDeviceArray		iArray;
   238 	HBufC8*				iResponseBuf;
   239 	TPtr8				iResponsePtr;
   240 	TState				iState;
   241 	TRequestStatus*		iClientStatus;
   242 	};
   243 
   244 NONSHARABLE_CLASS(RBTRegistry) : public RBTManSubSession
   245     /** Creates and opens a subsession on the BT Registry Server for remote devices.
   246 	
   247 	This subsession allows details of remote devices to be updated, modified, examined etc.
   248 	@publishedAll
   249 	@released
   250 	*/
   251 	{
   252 public:
   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();
   266 	
   267 
   268 	void PreLoad(TRequestStatus& aStatus);
   269 	void GetResults(TPtr8& aResultBuf, TRequestStatus& aStatus);
   270 private:
   271 	CBufFlat*	iSendBuffer;	// lazily constructed
   272 	TPtrC8		iSendBufferPtr;
   273 	TBTRegistrySearchPckgBuf	iSearchPckg;
   274 	TPckg<TBTNamelessDevice>	iDevicePckg;
   275 	TPckgBuf<TBTDevAddr>		iAddrBuf;
   276 	
   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
   279 	TUint32     iPadding1; 
   280 	TUint32     iPadding2; 	
   281 	};
   282 
   283 NONSHARABLE_CLASS(RBTLocalDevice) : public RBTManSubSession
   284     /** Creates and opens a subsession on BT Registry Server for local devices.
   285 
   286     This subsession allows the local device to be updated, modified, examined etc.
   287 	@publishedAll
   288     @released
   289     */
   290 	{
   291 public:
   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();
   298 private:
   299 	TPckg<TBTLocalDevice> iLocalDevicePckg;
   300 	
   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
   303 	TUint32     iPadding1; 
   304 	TUint32     iPadding2; 	
   305 	};
   306 
   307 
   308 /**
   309 UID of the PIN entry RNotifier plugin
   310 @publishedPartner
   311 @released
   312 */
   313 const TUid KBTManPinNotifierUid={0x100069c9};
   314 
   315 /**
   316 UID of the authorisation RNotifier plugin
   317 @publishedPartner
   318 @released
   319 */
   320 const TUid KBTManAuthNotifierUid={0x100069cf};
   321 
   322 
   323 NONSHARABLE_CLASS(TBTNotifierUpdateParams)
   324 	/** Sends parameter updates to the notifier.
   325 	
   326 	Struct to allow us to send a device name to the Passkey Entry and Authorisation RNotifier plugins.
   327 	@publishedPartner
   328 	@released
   329 	*/
   330 	{
   331 public:
   332 	/** The device name that has been retrieved since security procedures started. */
   333 	TBTDeviceName iName;
   334 	/** The result. */
   335 	TInt iResult;
   336 	};
   337 
   338 NONSHARABLE_CLASS(TBTNotifierParams)
   339 	/** The device name parameter for the security notifier.
   340 	
   341 	@publishedPartner
   342 	@released
   343 	*/
   344 	{
   345 public:
   346     /** Device address of remote device requiring authorisation. */
   347 	TBTDevAddr iBDAddr;
   348 	/** The device name that has been retrieved since security procedures started. */
   349 	TBTDeviceName iName;
   350 	};
   351 	
   352 NONSHARABLE_CLASS(TBTAuthorisationParams) : public TBTNotifierParams
   353     /** Bluetooth authorisation parameters.
   354 	 
   355 	Struct to allow us to send params from the security manager to the Authorisation RNotifier plugin.
   356 	@publishedPartner
   357 	@released
   358 	*/
   359 	{
   360 public:
   361     /** UID of the service requesting authorisation. */
   362 	TUid iUid;
   363 	};
   364 
   365 NONSHARABLE_CLASS(TBTPasskeyNotifierParams) : public TBTNotifierParams
   366 	/** The passkey parameter for the security notifier.
   367 	
   368 	@publishedPartner
   369 	@released
   370 	*/
   371 	{
   372 public:
   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;		
   377 	};
   378 
   379 
   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*/
   384 
   385 
   386 #endif