bluetoothmgmt/btmgr/Inc/btdevice.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     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 BTDEVICE_H
       
    17 #define BTDEVICE_H
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <e32base.h>
       
    21 #include <s32mem.h>
       
    22 
       
    23 #include <bluetooth/hci/hciopcodes.h>
       
    24 #include <bluetooth/hci/hciconsts.h>
       
    25 
       
    26 /** The maximum length of a bluetooth device name, as stored in CBTDevice.
       
    27 @publishedAll
       
    28 @released
       
    29 **/
       
    30 static const TInt KMaxBluetoothNameLen = KHCILocalDeviceNameMaxLength;
       
    31 
       
    32 /** The maximum length of the user-assinged friendly name for a bluetooth device, as stored in CBTDevice.
       
    33 @publishedAll
       
    34 @released
       
    35 **/
       
    36 static const TInt KMaxFriendlyNameLen = 100;
       
    37 
       
    38 /** Length of a bluetooth device name. This is not to be used outside of the sub-system. Retained for binary compatibility.
       
    39 @internalComponent
       
    40 @deprecated
       
    41 **/
       
    42 static const TInt KMaxBCBluetoothNameLen = 256;
       
    43 
       
    44 //forward declarations
       
    45 class TBTDeviceClass;
       
    46 class CBTDevice;
       
    47 class TBTServiceSecurityPerDevice;
       
    48 
       
    49 /** A typedef'ed array of CBTDevice objects.
       
    50 @publishedAll
       
    51 @released
       
    52 **/
       
    53 typedef CArrayPtrFlat<CBTDevice> CBTDeviceArray;
       
    54 
       
    55 /** A typedef'ed array of TBTServiceSecurityPerDevice objects.
       
    56 @publishedAll
       
    57 @released
       
    58 **/
       
    59 typedef RArray<TBTServiceSecurityPerDevice> RBTSecurityArray;
       
    60 
       
    61 /** Wide descriptor of correct length to hold a bluetooth device name.
       
    62 @publishedAll
       
    63 @released
       
    64 **/
       
    65 typedef TBuf<KMaxBCBluetoothNameLen> TBTDeviceName;
       
    66 
       
    67 /** Narrow descriptor of correct length to hold a bluetooth device name.
       
    68 
       
    69 @publishedAll
       
    70 @released
       
    71 **/
       
    72 typedef TBuf8<KMaxBluetoothNameLen> TBTDeviceName8;
       
    73 
       
    74 /** Utility class to convert between a wide TBTDeviceName and a narrow TBTDeviceName8.
       
    75 @publishedAll
       
    76 @released
       
    77 **/
       
    78 class BTDeviceNameConverter
       
    79 	{
       
    80 public:
       
    81 	IMPORT_C static TBTDeviceName ToUnicodeL(const TBTDeviceName8& aName);
       
    82 	IMPORT_C static TBTDeviceName8 ToUTF8L(const TBTDeviceName& aName);
       
    83 	};
       
    84 
       
    85 /** Cleanup utility for CBTDeviceArrays.
       
    86 
       
    87 Creates a TCleanupItem that calls ResetAndDestroy and then deletes the array.
       
    88 
       
    89 @publishedAll
       
    90 @released
       
    91 */
       
    92 class BTDeviceArrayCleanupStack
       
    93 
       
    94 	{
       
    95 public:
       
    96 	IMPORT_C static void PushL(CBTDeviceArray* aBTDeviceArray);
       
    97 private:
       
    98 	static void ResetAndDestroy(TAny* aBTDeviceArray);
       
    99 	};
       
   100 
       
   101 /** Enum used to describe the Bluetooth major service classes.  
       
   102 
       
   103 See the bluetooth specification for more details.
       
   104 
       
   105 @publishedAll
       
   106 @released
       
   107 **/
       
   108 enum TBTMajorServiceClass
       
   109 	{												//23        13	<- bit number
       
   110 	/** Limited discoverable mode **/
       
   111 	EMajorServiceLimitedDiscoverableMode = 0x01,	//00000000001
       
   112 	/** Positioning **/
       
   113 	EMajorServicePositioning = 0x08,				//00000001000
       
   114 	/** Networking **/
       
   115 	EMajorServiceNetworking = 0x10,					//00000010000
       
   116 	/** Rendering **/
       
   117 	EMajorServiceRendering = 0x20,					//00000100000
       
   118 	/** Capturing **/
       
   119 	EMajorServiceCapturing = 0x40,					//00001000000
       
   120 	/** Object transfer **/
       
   121 	EMajorServiceObjectTransfer = 0x80,				//00010000000
       
   122 	/** Audio **/
       
   123 	EMajorServiceAudio = 0x100,						//00100000000
       
   124 	/** Telephony **/
       
   125 	EMajorServiceTelephony = 0x200,					//01000000000
       
   126 	/** Information **/
       
   127 	EMajorServiceInformation = 0x400,				//10000000000
       
   128 	/**
       
   129 	 * Old name kept for SC.
       
   130 	 * @deprecated
       
   131 	 * @see EMajorServiceAudio
       
   132 	 */
       
   133 	EMajorServiceAudioService = 0x100				//00100000000
       
   134 	};
       
   135 
       
   136 /** Enum used to describe the Bluetooth major device classes.  
       
   137 
       
   138 See the bluetooth specification for more details.
       
   139 
       
   140 @publishedAll
       
   141 @released
       
   142 **/
       
   143 enum TBTMajorDeviceClass
       
   144 	{												//12  8	<- bit number
       
   145 	/** Miscellaneous device **/
       
   146 	EMajorDeviceMisc = 0x0,							//00000
       
   147 	/** Computer device **/
       
   148 	EMajorDeviceComputer = 0x1,						//00001
       
   149 	/** Phone device **/
       
   150 	EMajorDevicePhone = 0x2,						//00010
       
   151 	/** LAN access point device **/
       
   152 	EMajorDeviceLanAccessPoint = 0x3,				//00011
       
   153 	/** Audio-video device **/
       
   154 	EMajorDeviceAV = 0x4,							//00100
       
   155 	/** Peripheral device **/
       
   156 	EMajorDevicePeripheral = 0x5,					//00101
       
   157 	/** Imaging device **/
       
   158 	EMajorDeviceImaging = 0x6,						//00110
       
   159 	/** Wearable device **/
       
   160 	EMajorDeviceWearable = 0x7,						//00111
       
   161 	/** Toy device **/
       
   162 	EMajorDeviceToy = 0x8,							//01000
       
   163 	/** Unclassified device **/
       
   164 	EMajorDeviceUnclassified = 0x1F,				//11111
       
   165 	/**
       
   166 	 * Old name kept for SC.
       
   167 	 * @deprecated
       
   168 	 * @see EMajorDeviceAV
       
   169 	 */
       
   170 	EMajorDeviceAudioDevice = 0x4,					//00100
       
   171 	/**
       
   172 	 * Old name kept for SC.
       
   173 	 * @deprecated
       
   174 	 * @see EMajorDeviceUnclassified
       
   175 	 */
       
   176 	EMajorDeviceDeviceUnclassified = 0x1F			//11111
       
   177 	};
       
   178 
       
   179 /** Enum used to describe the Bluetooth minor device classes relating to the "Computer" major device class.
       
   180 
       
   181 See the bluetooth specification for more details.
       
   182 
       
   183 @publishedAll
       
   184 @released
       
   185 **/
       
   186 enum TBTMinorDeviceClassComputer
       
   187 	{										//7    2	<- bit number
       
   188 	/** Unclassified computer device **/
       
   189 	EMinorDeviceComputerUnclassified = 0x0,	//000000
       
   190 	/** Desktop computer device **/
       
   191 	EMinorDeviceComputerDesktop = 0x1,		//000001
       
   192 	/** Server computer device **/
       
   193 	EMinorDeviceComputerServer = 0x2,		//000010
       
   194 	/** Laptop computer device **/
       
   195 	EMinorDeviceComputerLaptop = 0x3,		//000011
       
   196 	/** Handheld computer device **/
       
   197 	EMinorDeviceComputerHandheld = 0x4,		//000100
       
   198 	/** Palm computer device **/
       
   199 	EMinorDeviceComputerPalmSize = 0x5,		//000101
       
   200 	/** Wearable computer device **/
       
   201 	EMinorDeviceComputerWearable = 0x6		//000110
       
   202 	};
       
   203 
       
   204 /** Enum used to describe the Bluetooth minor device classes relating to the "phone" major device class.
       
   205 
       
   206 See the bluetooth specification for more details.
       
   207 
       
   208 @publishedAll
       
   209 @released
       
   210 **/
       
   211 enum TBTMinorDeviceClassPhone
       
   212 	{										//7    2	<- bit number
       
   213 	/** Unclassified phone device **/
       
   214 	EMinorDevicePhoneUnclassified = 0x0,	//000000
       
   215 	/** Cellular phone device **/
       
   216 	EMinorDevicePhoneCellular = 0x1,		//000001
       
   217 	/** Cordless phone device **/
       
   218 	EMinorDevicePhoneCordless = 0x2,		//000010
       
   219 	/** Smart phone device **/
       
   220 	EMinorDevicePhoneSmartPhone = 0x3,		//000011
       
   221 	/** Wired modem phone device **/
       
   222 	EMinorDevicePhoneWiredModem = 0x4,		//000100
       
   223 	/** ISDN phone device **/
       
   224 	EMinorDevicePhoneCommonISDNAccess = 0x5	//000101
       
   225 	};
       
   226 
       
   227 /** Enum used to describe the Bluetooth minor device classes relating to the "LAN" major device class.
       
   228 
       
   229 See the bluetooth specification for more details.
       
   230 @publishedAll
       
   231 @released
       
   232 **/
       
   233 enum TBTMinorDeviceClassLAN
       
   234 	{										//7    2	<- bit number
       
   235 	/** LAN is currently 0% utilitized **/
       
   236 	EMinorDeviceLANFullyAvailable = 0x0,	//000000
       
   237 	/** LAN is currently 1-17% utilitized **/
       
   238 	EMinorDeviceLANServiceOne = 0x8,		//001000
       
   239 	/** LAN is currently 17-33% utilitized **/
       
   240 	EMinorDeviceLANServiceTwo = 0x10,		//010000
       
   241 	/** LAN is currently 33-50% utilitized **/
       
   242 	EMinorDeviceLANServiceThree = 0x18,		//011000
       
   243 	/** LAN is currently 50-67% utilitized **/
       
   244 	EMinorDeviceLANServiceFour = 0x20,		//100000
       
   245 	/** LAN is currently 67-83% utilitized **/
       
   246 	EMinorDeviceLANServiceFive = 0x28,		//101000
       
   247 	/** LAN is currently 83-99% utilitized **/
       
   248 	EMinorDeviceLANServiceSix = 0x30,		//110000
       
   249 	/** LAN is currently 100% utilitized **/
       
   250 	EMinorDeviceLANNoService = 0x38			//111000
       
   251 	};
       
   252 
       
   253 /** Enum used to describe the Bluetooth minor device classes relating to the "AV" major device class.
       
   254 
       
   255 See the bluetooth specification for more details.
       
   256 
       
   257 @publishedAll
       
   258 @released
       
   259 **/
       
   260 enum TBTMinorDeviceClassAV
       
   261 	{												//7    2
       
   262 	/** Unclassified AV Device **/
       
   263 	EMinorDeviceAVUnclassified = 0x0,				//000000
       
   264 	/** Headset AV Device **/
       
   265 	EMinorDeviceAVHeadset = 0x1,					//000001
       
   266 	/** Handsfree AV Device **/
       
   267 	EMinorDeviceAVHandsfree = 0x2,					//000010
       
   268 	/** Microphone AV Device **/
       
   269 	EMinorDeviceAVMicrophone = 0x4,					//000100
       
   270 	/** Loudspeaker AV Device **/
       
   271 	EMinorDeviceAVLoudspeaker = 0x5,				//000101
       
   272 	/** Headphone AV Device **/
       
   273 	EMinorDeviceAVHeadphones = 0x6,					//000110
       
   274 	/** Portable audio AV Device **/
       
   275 	EMinorDeviceAVPortableAudio = 0x7,				//000111
       
   276 	/** Car audio AV Device **/
       
   277 	EMinorDeviceAVCarAudio = 0x8,					//001000
       
   278 	/** Set top box AV Device **/
       
   279 	EMinorDeviceAVSetTopBox = 0x9,					//001001
       
   280 	/** Hifi audio AV Device **/
       
   281 	EMinorDeviceAVHiFiAudio = 0xA,					//001010
       
   282 	/** VCR AV Device **/
       
   283 	EMinorDeviceAVVCR = 0xB,						//001011
       
   284 	/** Video camera AV Device **/
       
   285 	EMinorDeviceAVVideoCamera = 0xC,				//001100
       
   286 	/** Camcorder AV Device **/
       
   287 	EMinorDeviceAVCamcorder = 0xD,					//001101
       
   288 	/** Video monitor AV Device **/
       
   289 	EMinorDeviceAVVideoMonitor = 0xE,				//001110
       
   290 	/** Video display and loudspeaker AV Device **/
       
   291 	EMinorDeviceAVVideoDisplayAndLoudspeaker = 0xF,	//001111
       
   292 	/** Video conferencing AV Device **/
       
   293 	EMinorDeviceAVVideoConferencing = 0x10,			//010000
       
   294 	/** Gaming toy AV Device **/
       
   295 	EMinorDeviceAVGamingToy = 0x12					//010010
       
   296 	};	
       
   297 	
       
   298 /** Enum used to describe the Bluetooth minor device classes relating to the "Peripheral" major device class.
       
   299 
       
   300 See the bluetooth specification for more details.
       
   301 @publishedAll
       
   302 @released
       
   303 **/
       
   304 enum TBTMinorDeviceClassPeripheral
       
   305 	{													//7    2
       
   306 	/** Keyboard peripheral device.
       
   307 	
       
   308 	Note that the keyboard bit can be independently
       
   309 	or'd with all other bits.
       
   310 	**/
       
   311 	EMinorDevicePeripheralKeyboard = 0x10,				//010000
       
   312 	/** Pointer peripheral device.
       
   313 	
       
   314 	Note that the pointer bit can be independently
       
   315 	or'd with all other bits.
       
   316 	**/
       
   317 	EMinorDevicePeripheralPointer = 0x20,				//100000
       
   318 	//
       
   319 	// All other bits are mutually exclusive
       
   320 	//
       
   321 	/** Uncategorized peripheral device **/
       
   322 	EMinorDevicePeripheralUncategorized = 0x00,			//000000
       
   323 	/** Joystick peripheral device **/
       
   324 	EMinorDevicePeripheralJoystick = 0x01,				//000001
       
   325 	/** Gamepad peripheral device **/
       
   326 	EMinorDevicePeripheralGamepad = 0x02,				//000010
       
   327 	/** Remote control peripheral device **/
       
   328 	EMinorDevicePeripheralRemoteControl = 0x03,			//000011
       
   329 	/** Sensing peripheral device **/
       
   330 	EMinorDevicePeripheralSensingDevice = 0x04,			//000100
       
   331 	/** Digitizer tablet peripheral device **/
       
   332 	EMinorDevicePeripheralDigitizerTablet = 0x05,		//000101
       
   333 	/** Card reader peripheral device **/
       
   334 	EMinorDevicePeripheralCardReader = 0x06				//000110
       
   335 	};
       
   336 
       
   337 /** Enum used to describe the Bluetooth minor device classes relating to the "Imaging" major device class.
       
   338 
       
   339 See the bluetooth specification for more details.
       
   340 @publishedAll
       
   341 @released
       
   342 
       
   343 **/
       
   344 enum TBTMinorDeviceClassImaging
       
   345 	{											//7    2
       
   346 	/** Display imaging device **/
       
   347 	EMinorDeviceImagingDisplay = 0x04,			//000100
       
   348 	/** Camera imaging device **/
       
   349 	EMinorDeviceImagingCamera = 0x08,			//001000
       
   350 	/** Scanner imaging device **/
       
   351 	EMinorDeviceImagingScanner = 0x10,			//010000
       
   352 	/** Printer imaging device **/
       
   353 	EMinorDeviceImagingPrinter = 0x20,			//100000
       
   354 	};
       
   355 
       
   356 /** Enum used to describe the Bluetooth minor device classes relating to the "Wearable" major device class.
       
   357 
       
   358 See the bluetooth specification for more details.
       
   359 @publishedAll
       
   360 @released
       
   361 
       
   362 **/
       
   363 enum TBTMinorDeviceClassWearable
       
   364 	{											//7    2
       
   365 	/** Wrist watch wearable device **/
       
   366 	EMinorDeviceWearableWatch = 0x01,			//000001
       
   367 	/** Pager wearable device **/
       
   368 	EMinorDeviceWearablePager = 0x02,			//000010
       
   369 	/** Jacket wearable device **/
       
   370 	EMinorDeviceWearableJacket = 0x03,			//000011
       
   371 	/** Helmet wearable device **/
       
   372 	EMinorDeviceWearableHelmet = 0x04,			//000100
       
   373 	/** Glasses wearable device **/
       
   374 	EMinorDeviceWearableGlasses = 0x05,			//000101	
       
   375 	};
       
   376 
       
   377 /** Enum used to describe the Bluetooth minor device classes relating to the "Toy" major device class.
       
   378 
       
   379 See the bluetooth specification for more details.
       
   380 @publishedAll
       
   381 @released
       
   382 
       
   383 **/
       
   384 enum TBTMinorDeviceClassToy
       
   385 	{											//7    2
       
   386 	/** Robot toy device **/
       
   387 	EMinorDeviceToyRobot = 0x01,				//000001
       
   388 	/** Vehicle toy device **/
       
   389 	EMinorDeviceToyVehicle = 0x02,				//000010
       
   390 	/** Doll toy device **/
       
   391 	EMinorDeviceToyDoll = 0x03,					//000011
       
   392 	/** Controller toy device **/
       
   393 	EMinorDeviceToyController = 0x04,			//000100
       
   394 	/** Game toy device **/
       
   395 	EMinorDeviceToyGame = 0x05,					//000101	
       
   396 	};
       
   397 	
       
   398 /** Encapsulation of device class definitions.
       
   399 
       
   400 Contains a single TInt as member data and methods to extract the major, minor and service
       
   401 class information from that TInt.
       
   402 @publishedAll
       
   403 @released
       
   404 **/
       
   405 NONSHARABLE_CLASS(TBTDeviceClass)
       
   406 	{
       
   407 public:
       
   408 	IMPORT_C TBTDeviceClass();
       
   409 	IMPORT_C TBTDeviceClass(TUint32 aDeviceClass);
       
   410 	IMPORT_C TBTDeviceClass(TUint16 aMajorServiceClass, TUint8 aMajorDeviceClass,
       
   411 							TUint8 aMinorDeviceClass);
       
   412 
       
   413 	IMPORT_C TUint16 MajorServiceClass() const;
       
   414 	IMPORT_C TUint8 MajorDeviceClass() const;
       
   415 	IMPORT_C TUint8 MinorDeviceClass() const;
       
   416 	IMPORT_C TUint32 DeviceClass() const;
       
   417 	
       
   418 	IMPORT_C TBool operator==(const TBTDeviceClass& aDeviceClass) const;
       
   419 	IMPORT_C TBTDeviceClass& operator=(const TBTDeviceClass& aDeviceClass);
       
   420 	
       
   421 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   422 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
   423 private:
       
   424 	static const TUint32 KStreamVersion = 0x00000001;
       
   425 private:
       
   426 	TUint32	iDeviceClass;
       
   427 	
       
   428 	// This data padding has been added to help prevent future binary compatibility breaks	
       
   429 	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
       
   430 	TUint32	iPadding1; 
       
   431 	TUint32	iPadding2; 
       
   432 	};
       
   433 
       
   434 /** Class to store the security override parameters for a particular remote device.
       
   435 
       
   436 @publishedAll
       
   437 @released
       
   438 */
       
   439 NONSHARABLE_CLASS(TBTDeviceSecurity)
       
   440 	{
       
   441 public:
       
   442 	/** Enumeration to provide select MITM protection required. */
       
   443 	enum TMitmRequired
       
   444 		{
       
   445 		EMitmUnspecified,	/*!< No specific MITM protection requirements */
       
   446 		EMitmRequired		/*!< Require the link is MITM protected */
       
   447 		};
       
   448 	
       
   449 public:
       
   450 	IMPORT_C TBTDeviceSecurity();
       
   451 	IMPORT_C TBTDeviceSecurity(TUint8 aSecurity);
       
   452 	IMPORT_C TBTDeviceSecurity(TUint8 aSecurity, TUint aPasskeyMinLength);
       
   453 	IMPORT_C TBTDeviceSecurity(TBool aNoAuthenticate, TBool aNoAuthorise, TBool aEncrypt, TBool aBanned);
       
   454 	IMPORT_C TBTDeviceSecurity(TMitmRequired aMitmRequirements, TBool aNoAuthorise, TBool aEncrypt, TBool aBanned);
       
   455 	
       
   456 	IMPORT_C void SetNoAuthenticate(TBool aDecision);
       
   457 	IMPORT_C void SetMitmRequirements(TMitmRequired aDecision);
       
   458 	IMPORT_C void SetNoAuthorise(TBool aDecision);
       
   459 	IMPORT_C void SetEncrypt(TBool aDecision);
       
   460 	IMPORT_C void SetBanned(TBool aDecision);
       
   461 	
       
   462 	IMPORT_C TBool NoAuthenticate() const;
       
   463 	IMPORT_C TMitmRequired MitmRequirements() const;
       
   464 	IMPORT_C TBool NoAuthorise() const;
       
   465 	IMPORT_C TBool Encrypt() const;
       
   466 	IMPORT_C TBool Banned() const;
       
   467 	IMPORT_C TUint PasskeyMinLength() const;
       
   468 	
       
   469 	
       
   470 	IMPORT_C TUint8 SecurityValue() const;
       
   471 	IMPORT_C void SetSecurityValue(TUint8 aDeviceSecurity);
       
   472 	IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);	
       
   473 	
       
   474 	
       
   475 	IMPORT_C TBool operator==(const TBTDeviceSecurity& aDeviceSecurity) const;
       
   476 	IMPORT_C TBool operator!=(const TBTDeviceSecurity& aDeviceSecurity) const;
       
   477 	
       
   478 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   479 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
   480 
       
   481 public:
       
   482 	/** Enumeration to assist in parsing of security settings. */
       
   483 	enum TBTDeviceSecuritySettings
       
   484 		{
       
   485 		ENoAuthenticate			= 0x01, /*!< Don't authenticate the link @deprecated */
       
   486 		ENoAuthorise			= 0x02, /*!< Don't authorise the connection */
       
   487 		EEncrypt				= 0x04, /*!< Encrypt the link */
       
   488 		EBanned					= 0x08, /*!< Don't connect to the device */
       
   489 		EMitmProtectionRequired	= 0x10, /*!< Require the link is MITM protected */
       
   490 		};
       
   491 	
       
   492 private:
       
   493 	static const TUint32 KStreamVersion = 0x00000001;
       
   494 
       
   495 private:
       
   496 	TUint8	iSecurity;
       
   497 	TUint	iPasskeyMinLength;	
       
   498 	
       
   499 	// This data padding has been added to help prevent future binary compatibility breaks	
       
   500 	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
       
   501 	TUint32	iPadding1; 
       
   502 	TUint32	iPadding2; 
       
   503 	};
       
   504 
       
   505 /** Class to tie a service uid with a device security setting.
       
   506 
       
   507 This allows us to have service-specific security settings for a device.
       
   508 
       
   509 @publishedAll
       
   510 @released
       
   511 */
       
   512 NONSHARABLE_CLASS(TBTServiceSecurityPerDevice)
       
   513 	{
       
   514 public:
       
   515 	IMPORT_C TBTServiceSecurityPerDevice();
       
   516 	IMPORT_C TBTServiceSecurityPerDevice(const TBTDevAddr& aDevice, const TBTDeviceSecurity& aSecuritySettings);
       
   517 	IMPORT_C TBTServiceSecurityPerDevice(const TBTServiceSecurityPerDevice&);
       
   518 	
       
   519 	IMPORT_C void SetDeviceSecurity(const TBTDeviceSecurity& aSecuritySettings);
       
   520 	IMPORT_C void SetAddress(const TBTDevAddr& aAddress);
       
   521 
       
   522 	IMPORT_C const TBTDeviceSecurity& DeviceSecurity() const;
       
   523 	IMPORT_C const TBTDevAddr& DeviceAddress() const;
       
   524 	
       
   525 	IMPORT_C void operator=(const TBTServiceSecurityPerDevice& aServiceSecurityPerDevice);
       
   526 	IMPORT_C TBool operator==(const TBTServiceSecurityPerDevice& aServiceSecurityPerDevice) const;
       
   527 	IMPORT_C TBool operator!=(const TBTServiceSecurityPerDevice& aServiceSecurityPerDevice) const;
       
   528 	
       
   529 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   530 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
   531 private:
       
   532 	static const TUint32 KStreamVersion = 0x00000001;
       
   533 private:
       
   534 	TBTDevAddr			iDeviceAddress;		/*!< the address of the device for the overriding security **/
       
   535 	TBTDeviceSecurity	iDeviceSecurity;	/*!< the overriding security */
       
   536 	
       
   537 	// This data padding has been added to help prevent future binary compatibility breaks	
       
   538 	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
       
   539 	TUint32		iPadding1; 
       
   540 	TUint32		iPadding2; 	
       
   541 	};
       
   542 
       
   543 /** Stores parameters for a nameless device.
       
   544 
       
   545 A class which stores useful parameters concerning a remote device
       
   546 But *not* including names
       
   547 @see CBTDevice
       
   548 @publishedAll
       
   549 @released
       
   550 */
       
   551 NONSHARABLE_CLASS(TBTNamelessDevice)
       
   552 	{
       
   553 friend class CBTDevice;
       
   554 
       
   555 private:
       
   556 	/** For Symbian use only
       
   557 	@internalComponent	
       
   558 	*/
       
   559 	NONSHARABLE_CLASS(TBTBasebandParameters)
       
   560 		{
       
   561 	public:
       
   562 		void ExternalizeL(RWriteStream& aStream) const;
       
   563 		void InternalizeL(RReadStream& aStream);
       
   564 
       
   565 		TUint8 iPageScanRepetitionMode;			/*!< Page Scan repetition mode of remote device ( valid if > 0 ) */
       
   566 		TUint8 iPageScanPeriodMode;				/*!< Page scan period mode of remote device */
       
   567 		TUint8 iPageScanMode;					/*!< Page scan mode of remote device ( valid if > 0 ) */
       
   568 		TUint16 iClockOffset;					/*!< clock off set of remote device ( valid if > 0 ) */
       
   569 		
       
   570 	private:
       
   571 		static const TUint32 KStreamVersion = 0x00000001;
       
   572 		};
       
   573 public:
       
   574 	
       
   575 	IMPORT_C TBTNamelessDevice();
       
   576 	IMPORT_C const TBTDevAddr& Address() const;
       
   577 	IMPORT_C const TBTDeviceClass& DeviceClass() const;
       
   578 	IMPORT_C const TBTLinkKey& LinkKey() const;
       
   579 	IMPORT_C TBTLinkKeyType LinkKeyType() const;
       
   580 	IMPORT_C TUint8 PageScanRepMode() const;
       
   581 	IMPORT_C TUint8 PageScanMode() const;
       
   582 	IMPORT_C TUint8 PageScanPeriodMode() const;
       
   583 	IMPORT_C TUint16 ClockOffset() const;
       
   584 	IMPORT_C const TTime& Seen() const;
       
   585 	IMPORT_C const TTime& Used() const;
       
   586 	IMPORT_C const TBTDeviceSecurity& GlobalSecurity() const;
       
   587 	IMPORT_C void SetAddress(const TBTDevAddr& aBDAddr);
       
   588 	IMPORT_C void SetDeviceClass(TBTDeviceClass aDeviceClass);
       
   589 	IMPORT_C void SetLinkKey(const TBTLinkKey& aLinkKey);
       
   590 	IMPORT_C void SetLinkKey(const TBTLinkKey& aLinkKey, TBTLinkKeyType aLinkKeyType);
       
   591 	IMPORT_C void SetPageScanRepMode(TUint8 aPageScanRepMode);
       
   592 	IMPORT_C void SetPageScanPeriodMode(TUint8 aPageScanPeriodMode);
       
   593 	IMPORT_C void SetPageScanMode(TUint8 aPageScanMode);
       
   594 	IMPORT_C void SetClockOffset(TUint16 aClockOffSet);
       
   595 	IMPORT_C void SetGlobalSecurity(const TBTDeviceSecurity& aSetting);
       
   596 	IMPORT_C void SetUsed(const TTime& aDateTime);
       
   597 	IMPORT_C void SetSeen(const TTime& aDateTime);
       
   598 	IMPORT_C TBool IsValidAddress() const;
       
   599 	IMPORT_C TBool IsValidDeviceClass() const;
       
   600 	IMPORT_C TBool IsValidLinkKey() const;
       
   601 	IMPORT_C TBool IsValidGlobalSecurity() const;
       
   602 	IMPORT_C TBool IsValidPageScanRepMode() const;
       
   603 	IMPORT_C TBool IsValidPageScanMode() const;
       
   604 	IMPORT_C TBool IsValidPageScanPeriodMode() const;
       
   605 	IMPORT_C TBool IsValidClockOffset() const;
       
   606 	IMPORT_C TBool IsValidUsed() const;
       
   607 	IMPORT_C TBool IsValidSeen() const;
       
   608 	IMPORT_C void DeleteLinkKey();
       
   609 	IMPORT_C void Update(const TBTNamelessDevice& aDevice);
       
   610 	IMPORT_C TBTNamelessDevice& operator=(const TBTNamelessDevice& aDevice);
       
   611 	IMPORT_C TBool operator==(const TBTNamelessDevice& aDevice) const;
       
   612 	IMPORT_C TBool operator!=(const TBTNamelessDevice& aDevice) const;
       
   613 	IMPORT_C TUint CompareTo(const TBTNamelessDevice& aDevice) const;
       
   614 	IMPORT_C TBool IsPaired() const;
       
   615 	IMPORT_C void SetPaired(TBool aPaired);
       
   616 	IMPORT_C void SetPaired(TBTLinkKeyType aLinkKeyType);
       
   617 	IMPORT_C TBool IsValidPaired() const;
       
   618 	IMPORT_C const TBTPinCode& PassKey() const;
       
   619 	IMPORT_C void  SetPassKey(const TBTPinCode& aPassKey);
       
   620 	IMPORT_C TBool IsValidPassKey() const;
       
   621 	IMPORT_C TUint PassKeyLength() const;
       
   622 	IMPORT_C TBool IsValidUiCookie() const;
       
   623 	IMPORT_C void SetUiCookie(TUint32 aUiCookie);
       
   624 	IMPORT_C TUint32 UiCookie() const;
       
   625 	
       
   626 	/**	Bitfield of TBTNamelessDevice attributes
       
   627 	This enum is to only be used by phone manufacturers, not by application developers.
       
   628 	@publishedPartner
       
   629 	@released
       
   630 	*/	
       
   631 	enum TBTDeviceSet
       
   632 		{
       
   633 		EAddress				=	0x000001, /*!< Device address */
       
   634 		EDeviceClass			=	0x000002, /*!< Device class */
       
   635 		ELinkKey				=	0x000004, /*!< Link key */
       
   636 		EGlobalSecurity			=	0x000008, /*!< Global security settings */
       
   637 		EPageScanRepMode		=	0x000010, /*!< Page scan repition mode */
       
   638 		EPageScanMode			=	0x000020, /*!< Page scan mode */
       
   639 		EPageScanPeriodMode		=	0x000040, /*!< Page scan period */
       
   640 		EClockOffset			=	0x000080, /*!< Clock offset */
       
   641 		EUsed					=	0x000100, /*!< Last used */
       
   642 		ESeen					=	0x000200, /*!< Last seen */
       
   643 		EIsPaired				=	0x000400, /*!< Is paired */
       
   644 		EPassKey				=	0x000800, /*!< PassKey */
       
   645 		EUiCookie				=	0x001000, /*!< User interface specific cookie */
       
   646 
       
   647 		EAllNamelessProperties	= 0x00ffffff, /*!< All nameless properties set */
       
   648 		// Two highest nibbles used by CBTDevice
       
   649 		};
       
   650 
       
   651 private:
       
   652 	TUint32					iSetMask;		/*!< Bit mask indicating the data members that have been set */
       
   653 	TBTDevAddr				iBDAddr; 		/*!< The BT address of the remote device */
       
   654 	TBTDeviceClass			iDeviceClass;	/*!< The class(es) of the remote device */
       
   655 	TBTLinkKey				iLinkKey;		/*!< The link key */
       
   656 	TBTDeviceSecurity		iGlobalSecurity;/*!< The overall security criteria for all services which this device may wish to use */
       
   657 	TBTBasebandParameters	iBasebandParams;/*!< The baseband parameters */
       
   658 	TTime					iUsed;			/*!< when last connect from/to */
       
   659 	TTime					iSeen;			/*!< when last seen in inquiry */
       
   660 	TBool					iPaired;		/*!< Whether this device is paired */
       
   661 	TBTPinCode				iPassKey;		/*!< PassKey */
       
   662 	TBTLinkKeyType			iLinkKeyType;	/*!< Link Key Type */
       
   663 	TUint32					iUiCookie;		/*!< The cookie attached to this device by the UI */
       
   664 	
       
   665 	// This data padding has been added to help prevent future binary compatibility breaks.
       
   666 	// iPadding1 has been used for iLinkKeyType
       
   667 	// iPadding2 has been used for iUiCookie 
       
   668 	TUint32		iPadding3; 
       
   669 	TUint32		iPadding4; 
       
   670 	};
       
   671 
       
   672 
       
   673 /** Encapsulates all information that must be known about a device.
       
   674 
       
   675 Stores useful information concerning a remote device, including names
       
   676 
       
   677 @publishedAll
       
   678 @released
       
   679 */
       
   680 NONSHARABLE_CLASS(CBTDevice) : public CBase
       
   681 	{
       
   682 friend class TBTNamelessDevice;
       
   683 public:
       
   684 	
       
   685 	IMPORT_C static CBTDevice* NewL(const TBTDevAddr& aBDAddr);
       
   686 	IMPORT_C static CBTDevice* NewLC(const TBTDevAddr& aBDAddr);
       
   687 	IMPORT_C static CBTDevice* NewL(const TBTNamelessDevice& aNamelessDevice);
       
   688 	IMPORT_C static CBTDevice* NewLC(const TBTNamelessDevice& aNamelessDevice);
       
   689 	IMPORT_C static CBTDevice* NewL();
       
   690 	IMPORT_C static CBTDevice* NewLC();
       
   691 	IMPORT_C ~CBTDevice();
       
   692 	IMPORT_C CBTDevice* CopyL() const;
       
   693 	IMPORT_C void UpdateL(const CBTDevice& aDevice);
       
   694 	IMPORT_C void AssignL(CBTDevice& aDevice);
       
   695 	IMPORT_C const TDesC8& DeviceName() const;
       
   696 	IMPORT_C const TDesC& FriendlyName() const;
       
   697 	IMPORT_C void SetDeviceNameL(const TDesC8& aName);
       
   698 	IMPORT_C void SetFriendlyNameL(const TDesC& aName);
       
   699 	IMPORT_C TBool IsValidDeviceName() const;
       
   700 	IMPORT_C TBool IsValidFriendlyName() const;
       
   701 	IMPORT_C TBool operator==(const CBTDevice& aDevice) const;
       
   702 	IMPORT_C TBool operator!=(const CBTDevice& aDevice) const;
       
   703 	IMPORT_C TUint CompareTo(const CBTDevice& aDevice) const;
       
   704 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   705 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
   706 	IMPORT_C const TBTDevAddr& BDAddr() const;
       
   707 	IMPORT_C const TBTLinkKey& LinkKey() const;
       
   708 	IMPORT_C TBTLinkKeyType LinkKeyType() const;
       
   709 	IMPORT_C TBTDeviceClass DeviceClass() const;
       
   710 	IMPORT_C const TBTDeviceSecurity GlobalSecurity() const;
       
   711 	IMPORT_C void SetDeviceAddress(const TBTDevAddr& aBDAddr);
       
   712 	IMPORT_C void SetDeviceClass(TBTDeviceClass aDeviceClass);
       
   713 	IMPORT_C void SetLinkKey(const TBTLinkKey& aLinkKey);
       
   714 	IMPORT_C void SetLinkKey(const TBTLinkKey& aLinkKey, TBTLinkKeyType aLinkKeyType);
       
   715 	IMPORT_C void SetGlobalSecurity(const TBTDeviceSecurity& aSetting);
       
   716 	IMPORT_C void DeleteLinkKey();
       
   717 	IMPORT_C TBool IsValidBDAddr() const;
       
   718 	IMPORT_C TBool IsValidDeviceClass() const;
       
   719 	IMPORT_C TBool IsValidLinkKey() const;
       
   720 	IMPORT_C TBool IsValidGlobalSecurity() const;
       
   721 	IMPORT_C const TTime& Seen() const;	
       
   722 	IMPORT_C const TTime& Used() const;
       
   723 	IMPORT_C void SetUsed(const TTime& aDateTime);
       
   724 	IMPORT_C void SetSeen(const TTime& aDateTime);
       
   725 	IMPORT_C TBool IsValidUsed() const;
       
   726 	IMPORT_C TBool IsValidSeen() const;
       
   727 	IMPORT_C TBTNamelessDevice& AsNamelessDevice();	
       
   728 	IMPORT_C const TBTNamelessDevice& AsNamelessDevice() const;
       
   729 	IMPORT_C TBool IsPaired() const;
       
   730 	IMPORT_C void SetPaired(TBool aPaired);
       
   731 	IMPORT_C void SetPaired(TBTLinkKeyType aLinkKeyType);
       
   732 	IMPORT_C TBool IsValidPaired() const;
       
   733 	IMPORT_C const TBTPinCode& PassKey() const;		
       
   734 	IMPORT_C void  SetPassKey(const TBTPinCode& aPassKey);		
       
   735 	IMPORT_C TBool IsValidPassKey() const;
       
   736 	IMPORT_C TUint PassKeyLength() const;
       
   737 	IMPORT_C TBool IsValidUiCookie() const;
       
   738 	IMPORT_C void SetUiCookie(TUint32 aUiCookie);
       
   739 	IMPORT_C TUint32 UiCookie() const;
       
   740 	
       
   741 private:
       
   742 	CBTDevice();
       
   743 	void ConstructL();
       
   744 	void ConstructL(const TBTDevAddr& aAddr);
       
   745 	void ConstructL(const TBTNamelessDevice& aNamelessDevice);
       
   746 	void CommonConstructL();
       
   747 		
       
   748 public:
       
   749 	/** Describes the similarities between two devices. */
       
   750 	enum TBTDeviceNameSelector // not very encapsulated - we extend the enum of TBTNamelessDevice
       
   751 		{
       
   752 		/** Device name. */
       
   753 		EDeviceName		= 0x40000000,
       
   754 		/** Friendly name. */
       
   755 		EFriendlyName	= 0x80000000,
       
   756 		/** 
       
   757 		All name properties
       
   758 		*/
       
   759 		EAllNameProperties = 0xff000000,
       
   760 		/** Last enum. This is NOT a name property */
       
   761 		ELast 			= KMaxTUint,
       
   762 		// All but two highest nibbles used by TBTNamelessDevice
       
   763 		};
       
   764 private:
       
   765 	static const TUint32 KStreamVersion = 0x00000001;
       
   766 private:
       
   767 	HBufC8*	iDeviceName;
       
   768 	HBufC*	iFriendlyName;
       
   769 	TBTNamelessDevice iDevice;
       
   770 	};
       
   771 
       
   772 
       
   773 /**Number of bytes in an AFH Host Channel Classification. 
       
   774 
       
   775 Size and Length of the TBTAFHHostChannelClassification Descriptor
       
   776 
       
   777 @see TBTAFHHostChannelClassification
       
   778 @publishedAll
       
   779 @released
       
   780 */
       
   781 const TUint8 KHCIAFHHostChannelClassificationSize=10;
       
   782 
       
   783 
       
   784 /**Required number of unknown channels in an AFH Host Channel Classification.
       
   785 
       
   786 That is least number of channels in the 79 channel set that must be left
       
   787 NOT set to bad. In AFH host channel classification a channel may labelled
       
   788 'bad' (implies do not use) or 'unknown' (implies that it is up to the 
       
   789 controller to decide if should be used). An attempt to create a 
       
   790 TBTAFHHostChannelClassification with more than KAFHMinUnknownChannels 
       
   791 set to 'bad' will result in a KErrUnderflow error being returned.
       
   792 
       
   793 @see TBTAFHHostChannelClassification
       
   794 @publishedAll
       
   795 @released
       
   796 */
       
   797 const TUint8 KAFHMinUnknownChannels=20;
       
   798 
       
   799 
       
   800 /**Number of channels in the Bluetooth channel set that is used with AFH
       
   801 
       
   802 The Bluetooth channel set is the set of frequencies used in the Bluetooth
       
   803 hopping sequence. AFH allows a connection to opt not to use some of the 
       
   804 frequencies in this set.
       
   805 
       
   806 @see TBTAFHHostChannelClassification
       
   807 @publishedAll
       
   808 @released
       
   809 */
       
   810 const TUint8 KAFHNumChannels=79;
       
   811 
       
   812 
       
   813 /**Descriptor class that should be used to help set up an 
       
   814 AFH host channel classification for the controller.
       
   815 
       
   816 The bits in each byte of this descriptor are used
       
   817 to tell the controller which channels the host
       
   818 anticipates will become busy and so advisable for
       
   819 Bluetooth to avoid. Such channels are referred to 
       
   820 as 'bad', and are represented by bits set to 0.  
       
   821 Channels that are not 'bad' are referred to as 'unknown' implying
       
   822 simply that the host has no knowledge that they are, or
       
   823 are about to become 'bad'. These are represented by bits set to 1.
       
   824 Note: The Bluetooth specification demands that at least 20 channels 
       
   825 must be set to 'unknown'. Any attempt by the user of this class
       
   826 to set too many 'bad' channels will result in the return of a 
       
   827 KErrNotSupported error, and the attempt having no effect.
       
   828 
       
   829 
       
   830 @publishedAll
       
   831 @released
       
   832 */
       
   833 NONSHARABLE_CLASS(TBTAFHHostChannelClassification) : public TBuf8<KHCIAFHHostChannelClassificationSize>
       
   834 	{
       
   835 public:
       
   836 	IMPORT_C TBTAFHHostChannelClassification();
       
   837 	IMPORT_C void Reset();
       
   838 	IMPORT_C TInt Validate() const;
       
   839 	IMPORT_C TInt SetChannelBad(const TUint8 aChannel);
       
   840 	IMPORT_C TInt SetChannelRangeBad(const TUint8 aChannelRangeLowest, const TUint8 aChannelRangeHighest);
       
   841 	
       
   842 private:
       
   843 	TInt DoSetChannelBad(const TUint8 aChannel);
       
   844 	TInt BitByteIndices(TUint8& aByteIndex, TUint8& aBitIndex, const TUint8 aChannel) const;
       
   845 	TUint8 NumUnknownsWithinRange(const TUint8 aChannelRangeLowest, const TUint8 aChannelRangeHighest) const;
       
   846 	
       
   847 	// This data padding has been added to help prevent future binary compatibility breaks
       
   848 	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used	
       
   849 	TUint32     iPadding1; 
       
   850 	TUint32     iPadding2;	
       
   851     };
       
   852 
       
   853 
       
   854 /** Class used to exchange the local settings with the Registry server.
       
   855 
       
   856 	Not a complete set of details of the local device
       
   857 
       
   858 	@publishedAll
       
   859 	@released
       
   860 
       
   861 */
       
   862 NONSHARABLE_CLASS(TBTLocalDevice)
       
   863 	{
       
   864 public:
       
   865 	IMPORT_C TBTLocalDevice();	
       
   866 	IMPORT_C const TBTDevAddr& Address() const;
       
   867 	IMPORT_C TUint32 DeviceClass() const;	
       
   868 	IMPORT_C const TDesC8& DeviceName() const;	
       
   869 	IMPORT_C THCIScanEnable ScanEnable() const;	
       
   870 	IMPORT_C TBool LimitedDiscoverable() const;	
       
   871 	IMPORT_C TUint8 PowerSetting() const;
       
   872 	IMPORT_C TBool AFHChannelAssessmentMode() const;
       
   873 	IMPORT_C TBool AcceptPairedOnlyMode() const;
       
   874 	IMPORT_C void SetAddress(const TBTDevAddr& aAddr);	
       
   875 	IMPORT_C void SetDeviceClass(TUint32 aCod);	
       
   876 	IMPORT_C void SetDeviceName(const TDesC8& aName);	
       
   877 	IMPORT_C void SetScanEnable(THCIScanEnable aEnable);	
       
   878 	IMPORT_C void SetLimitedDiscoverable(TBool aOn);	
       
   879 	IMPORT_C void SetPowerSetting(TUint8 aPowerSetting);	
       
   880 	IMPORT_C void SetAFHChannelAssessmentMode(TBool aOn);	
       
   881 	IMPORT_C void SetAcceptPairedOnlyMode(TBool aOn);	
       
   882 	IMPORT_C TBool IsValidAddress() const;	
       
   883 	IMPORT_C TBool IsValidDeviceClass() const;	
       
   884 	IMPORT_C TBool IsValidDeviceName() const;	
       
   885 	IMPORT_C TBool IsValidScanEnable() const;	
       
   886 	IMPORT_C TBool IsValidLimitedDiscoverable() const;	
       
   887 	IMPORT_C TBool IsValidPowerSetting() const;
       
   888 	IMPORT_C TBool IsValidAFHChannelAssessmentMode() const;
       
   889 	IMPORT_C TBool IsValidAcceptPairedOnlyMode() const;
       
   890 
       
   891 protected:
       
   892 	enum
       
   893 		{
       
   894 		EAddress					= 0x0001,
       
   895 		ECoD						= 0x0002,
       
   896 		EDeviceName					= 0x0004,
       
   897 		EPowerSetting				= 0x0008,
       
   898 		EScanEnable					= 0x0010,
       
   899 		ELimitedDiscoverable 		= 0x0020,
       
   900 		EAFHChannelAssessmentMode	= 0x0040,
       
   901 		EAcceptPairedOnlyMode 		= 0x0080,
       
   902 		};	//< Used for indicating if a setting has been set (i.e. not a default/random value) @see iBitMask
       
   903 		
       
   904 private:		
       
   905 	enum
       
   906 		{
       
   907 		EAFHChannelAssessmentModeValue	= 0x0001,
       
   908 		EAcceptPairedOnlyModeValue		= 0x0002,
       
   909 		};	//< Used for settings requiring little space: allows new settings ot be introduced without increasing the size of this class @see iSimpleSettings
       
   910 			
       
   911 		
       
   912 
       
   913 	TUint			iSetMask;		 //< Bit mask indicating the data members that have been set
       
   914 	TBTDevAddr		iAddress;
       
   915 	TUint32			iCod;
       
   916 	TBTDeviceName8	iLocalName;
       
   917 	TUint8			iPowerSetting;
       
   918 	THCIScanEnable	iScanEnable;
       
   919 	TBool			iLimitedDiscoverable;
       
   920 	TUint32			iSimpleSettings; //< Only first two bits currently used - for AFH Channel Assessment Mode, and Accept Paired Only Mode
       
   921 	};
       
   922 
       
   923 
       
   924 #endif