bluetoothmgmt/bluetoothclientlib/btlib/btlib.cpp
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2000-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 #include <bttypes.h>
       
    17 #include <bt_sock.h>
       
    18 
       
    19 /** 
       
    20 Constructor
       
    21 Start with no requests to update the required configuration.
       
    22 */
       
    23 EXPORT_C TL2CapConfig::TL2CapConfig()
       
    24  : iSpecifiedMask(ENoConfigElementsSpecified)
       
    25  	{
       
    26  	}
       
    27  	
       
    28 /** 
       
    29 Request a new preferred Max Transmit Unit size.
       
    30 	
       
    31 The L2CAP channel configuration process will attempt to configure with this MTU
       
    32 size. The resulting negotiated MTU will be at most this size and at least the
       
    33 size given by the minimum acceptable MTU option (@see SetMinMTU).
       
    34 Please note that if the minimum acceptable MTU is not specified along with this
       
    35 parameter, it is taken to be equal to the preferred value, so a smaller MTU
       
    36 value will not be accepted from the peer during the negotiation.
       
    37 
       
    38 @param aSize the MTU size for use in configuration
       
    39 @return error code, KErrArgument if MTU set too small, otherwise KErrNone
       
    40 */
       
    41 EXPORT_C TInt TL2CapConfig::SetMaxTransmitUnitSize(TUint16 aSize)
       
    42 	{
       
    43 	TInt rerr = KErrArgument;
       
    44 	if(aSize >= KL2MinMTU)
       
    45 		{		
       
    46 		iMTUSize = aSize;
       
    47 		iSpecifiedMask |= EMTUSizeSpecifiedMask;
       
    48 		rerr = KErrNone;
       
    49 		}
       
    50 	return rerr;
       
    51 	}
       
    52 	
       
    53 /** 
       
    54 Returns preferred MTU.
       
    55 	
       
    56 Also allows the user to know whether that value has been set, 
       
    57 or whether it is a random value that will be ignored. 
       
    58 This is done via the parameter 'aIsSpecified'. 
       
    59 	
       
    60 @param aIsSpecified Used to tell the caller whether the MTU value has been set. 
       
    61 @return preferred MTU
       
    62 */
       
    63 EXPORT_C TUint16 TL2CapConfig::MaxTransmitUnitSize(TBool& aIsSpecified) const
       
    64 	{
       
    65 	aIsSpecified = ((iSpecifiedMask & EMTUSizeSpecifiedMask) != 0);
       
    66 	return iMTUSize;
       
    67 	}
       
    68 	
       
    69 /** 
       
    70 Request a new preferred Max Receive Unit size.
       
    71 
       
    72 The L2CAP channel configuration process will attempt to configure with this MRU
       
    73 size.  The resulting negotiated MRU will be at most this size and at least the
       
    74 size given by the minimum acceptable MRU option (@see SetMinMRU).
       
    75 Please note that if the minimum acceptable MRU is not specified, it is taken by
       
    76 APIs using this class to be equal to the protocol minimum (48 bytes). 
       
    77 
       
    78 @param aSize the MRU size for use in configuration
       
    79 @return error code, KErrArgument if MRU set too small, otherwise KErrNone
       
    80 */
       
    81 EXPORT_C TInt TL2CapConfig::SetMaxReceiveUnitSize(TUint16 aSize)
       
    82 	{
       
    83 	TInt rerr = KErrArgument;
       
    84 	if(aSize >= KL2MinMTU)
       
    85 		{		
       
    86 		iMRUSize = aSize;
       
    87 		iSpecifiedMask |= EMRUSizeSpecifiedMask;
       
    88 		rerr = KErrNone;
       
    89 		}
       
    90 	return rerr;
       
    91 	}
       
    92 	
       
    93 /** 
       
    94 Returns preferred MRU.
       
    95 	
       
    96 Also allows the user to know whether that value has been set, 
       
    97 or whether it is a random value that will be ignored. 
       
    98 This is done via the parameter 'aIsSpecified'. 
       
    99 
       
   100 @param aIsSpecified Used to tell the caller whether the MRU value has been set. 
       
   101 @return preferred MRU
       
   102 */
       
   103 EXPORT_C TUint16 TL2CapConfig::MaxReceiveUnitSize(TBool& aIsSpecified) const
       
   104 	{
       
   105 	aIsSpecified = ((iSpecifiedMask & EMRUSizeSpecifiedMask) != 0);
       
   106 	return iMRUSize;
       
   107 	}
       
   108 
       
   109 /**
       
   110 Set the minimum MTU acceptable during L2CAP channel configuration.
       
   111 
       
   112 The configuration process will attempt to configure with the largest possible
       
   113 MTU that's greater than or equal to this boundary and less than or equal to
       
   114 the preferred value (@see SetMaxTransmitUnitSize) or the preferred stack
       
   115 default.
       
   116 
       
   117 A peer's proposal of any value below the minimum will be rejected and replied to
       
   118 with a value equal to the acceptable minimum. The peer will then choose to
       
   119 either close the connection or proceed with the acceptable minimum.
       
   120 
       
   121 @param aSize the smallest acceptable MTU size
       
   122 @return error code, KErrArgument if MTU set too small, otherwise KErrNone
       
   123 */
       
   124 EXPORT_C TInt TL2CapConfig::SetMinMTU(TUint16 aSize)
       
   125 	{
       
   126 	TInt rerr = KErrArgument;
       
   127 	if(aSize >= KL2MinMTU)
       
   128 		{		
       
   129 		iMinMTUSize = aSize;
       
   130 		iSpecifiedMask |= EMinMTUSizeSpecifiedMask;
       
   131 		rerr = KErrNone;
       
   132 		}
       
   133 	return rerr;
       
   134 	}
       
   135 
       
   136 /** 
       
   137 Returns the minimum acceptable negotiated MTU.
       
   138 	
       
   139 Also allows the user to know whether that value has been set, 
       
   140 or whether it is a random value that will be ignored. 
       
   141 This is done via the parameter 'aIsSpecified'. 
       
   142 
       
   143 @param aIsSpecified Used to tell the caller whether the smallest acceptable MTU
       
   144 	value has been set. 
       
   145 @return Requested smallest acceptable MTU.
       
   146 */
       
   147 EXPORT_C TUint16 TL2CapConfig::MinMTU(TBool& aIsSpecified) const
       
   148 	{
       
   149 	aIsSpecified = ((iSpecifiedMask & EMinMTUSizeSpecifiedMask) != 0);
       
   150 	return iMinMTUSize;
       
   151 	}
       
   152 
       
   153 /**
       
   154 Set the minimum MRU acceptable during L2CAP channel configuration.
       
   155 
       
   156 The configuration process will attempt to configure with the largest possible
       
   157 MRU that's greater than or equal to this boundary and less than or equal to
       
   158 the preferred value (@see SetMaxReceiveUnitSize) or the preferred stack
       
   159 default.
       
   160 
       
   161 If the peer proposes an MRU below the minimum the L2CAP channel will be
       
   162 disconnected, so this option should not be specified unless the application/profile
       
   163 requires a guarantee of MRU of certain size and can not work with a smaller one.
       
   164 
       
   165 @param aSize the smallest acceptable MRU size
       
   166 @return error code, KErrArgument if MRU set too small, otherwise KErrNone
       
   167 */
       
   168 EXPORT_C TInt TL2CapConfig::SetMinMRU(TUint16 aSize)
       
   169 	{
       
   170 	TInt rerr = KErrArgument;
       
   171 	if(aSize >= KL2MinMTU)
       
   172 		{		
       
   173 		iMinMRUSize = aSize;
       
   174 		iSpecifiedMask |= EMinMRUSizeSpecifiedMask;
       
   175 		rerr = KErrNone;
       
   176 		}
       
   177 	return rerr;
       
   178 	}
       
   179 	
       
   180 /** 
       
   181 Returns the minimum acceptable negotiated MRU.
       
   182 	
       
   183 Also allows the user to know whether that value has been set, 
       
   184 or whether it is a random value that will be ignored. 
       
   185 This is done via the parameter 'aIsSpecified'. 
       
   186 
       
   187 @param aIsSpecified Used to tell the caller whether the smallest acceptable MRU
       
   188 	value has been set. 
       
   189 @return Requested smallest acceptable MRU.
       
   190 */
       
   191 EXPORT_C TUint16 TL2CapConfig::MinMRU(TBool& aIsSpecified) const
       
   192 	{
       
   193 	aIsSpecified = ((iSpecifiedMask & EMinMRUSizeSpecifiedMask) != 0);
       
   194 	return iMinMRUSize;
       
   195 	}
       
   196 
       
   197 /** 
       
   198 Request a reliable channel.
       
   199 
       
   200 A reliable channel relies on the retransmission by L2Cap of unacknowledged 
       
   201 L2Cap packets. 
       
   202 Retransmissions are continued for a specified length of time. 
       
   203 If this time is exceeded the L2Cap channel is disconnected.
       
   204 
       
   205 The resulting behaviour depends on the setting of the LegacyModesDisallowed
       
   206 option (@see SetLegacyModesDisallowed). If that option is disabled (which is the
       
   207 default setting), then the channel mode attempted in L2CAP configuration process
       
   208 will be Enhanced Retransmission Mode if the peer supports it, else
       
   209 Retransmission Mode if the peer supports it, else Basic Mode.
       
   210 
       
   211 If the LegacyModesDisallowed option is enabled, then the connection will only
       
   212 be made if the peer supports and accepts the Enhanced Retransmission Mode.
       
   213 If it doesn't then the connection will not be made.
       
   214 
       
   215 Note that due to the nature of the negotiation process, it is not guranteed that
       
   216 a mode will be negotiated even if it's supported by a peer.
       
   217 
       
   218 The KL2CAPNegotiatedChannelMode socket option can be used to obtain the
       
   219 negotiated channel mode after a socket has been connected.
       
   220 
       
   221 @param aRetransmissionTimer The length of time allowed for l2Cap transmissions.
       
   222 Note that the value of this parameter does not directly drive the L2CAP
       
   223 retransmission timer. It is instead translated into a corresponding value for
       
   224 the maximum number of transmissions of a single packet. If that number is
       
   225 exceeded, then the connection is closed.
       
   226 @return error code, currently KErrNone
       
   227 */
       
   228 EXPORT_C TInt TL2CapConfig::ConfigureReliableChannel(TUint16 aRetransmissionTimer)
       
   229 	{
       
   230 	iChannelReliability = EReliableChannel;
       
   231 	iChannelReliabilityTimer = aRetransmissionTimer;
       
   232 	iSpecifiedMask |= EReliabilitySpecifiedMask;
       
   233 	return KErrNone;
       
   234 	}
       
   235 	
       
   236 	
       
   237 /** 
       
   238 Request a reliable channel.
       
   239 
       
   240 This is a deprecated version of the ConfigureReliableChannel method and its
       
   241 behaviour is exactly the same.
       
   242 
       
   243 @param aRetransmissionTimer The length of time allowed for l2Cap transmissions
       
   244 @return error code, currently KErrNone
       
   245 @deprecated
       
   246 Use ConfigureReliableChannel(TUint16 aRetransmissionTimer) instead
       
   247 */
       
   248 EXPORT_C TInt TL2CapConfig::SetupReliableChannel(TUint16 aRetransmissionTimer)
       
   249 	{
       
   250 	iChannelReliability = EReliableChannel;
       
   251 	iChannelReliabilityTimer = aRetransmissionTimer;
       
   252 	iSpecifiedMask |= EReliabilitySpecifiedMask;
       
   253 	return KErrNone;
       
   254 	}
       
   255 
       
   256 /** 
       
   257 Request an unreliable channel.
       
   258 
       
   259 An unreliable channel allows L2Cap packets to be dropped by the baseband.
       
   260 It helps to maintain low latency at the cost of reliability.
       
   261 
       
   262 The resulting behaviour depends on the setting of the LegacyModesDisallowed
       
   263 option (@see SetLegacyModesDisallowed). If that option is disabled (which is the
       
   264 default setting), then the channel mode attempted in L2CAP configuration process
       
   265 will be Streaming Mode if the peer supports it, else Flow Control Mode if the
       
   266 peer supports it, else Basic Mode.
       
   267 
       
   268 If the LegacyModesDisallowed option is enabled, then the connection will only
       
   269 be made if the peer supports and accepts Streaming Mode. If it doesn't then the
       
   270 connection will not be made.
       
   271 
       
   272 Note that due to the nature of the negotiation process, it is not guranteed that
       
   273 a mode will be negotiated even if it's supported by a peer.
       
   274 
       
   275 The KL2CAPNegotiatedChannelMode socket option can be used to obtain the
       
   276 negotiated channel modes after a socket has been connected.
       
   277 
       
   278 @param aObsolescenceTimer The time after which a packet may be dropped 
       
   279 or "flushed" by the baseband. Note that outgoing packet flushing may not be
       
   280 implemented on all Symbian OS platforms.
       
   281 @return error code, KErrArgument if the obsolescence time is made shorter than is 
       
   282 physically possible, otherwise KErrNone
       
   283 
       
   284 */
       
   285 EXPORT_C TInt TL2CapConfig::ConfigureUnreliableChannel(TUint16 aObsolescenceTimer)
       
   286 	{
       
   287 	TInt rerr = KErrNone;
       
   288 
       
   289 	// Only flush timers above a certain physical limit are permitted.
       
   290 	if(aObsolescenceTimer < EMinDataObsolescenceTimeout)
       
   291 		{
       
   292 		rerr = KErrArgument;
       
   293 		}
       
   294 	else
       
   295 		{
       
   296 		iChannelReliability = EUnreliableChannel;
       
   297 		iChannelReliabilityTimer = aObsolescenceTimer;
       
   298 		iSpecifiedMask |= EReliabilitySpecifiedMask;
       
   299 		}
       
   300 	return rerr;
       
   301 	}
       
   302 
       
   303 /** 
       
   304 Request an unreliable channel.
       
   305 
       
   306 This is a deprecated version of the ConfigureReliableChannel method and its
       
   307 behaviour is exactly the same.
       
   308 
       
   309 @param aObsolescenceTimer The time after which a packet may be dropped 
       
   310 or "flushed" by the baseband.
       
   311 @return error code, KErrArgument if the obsolescence time is made shorter than is 
       
   312 physically possible, otherwise KErrNone
       
   313 @deprecated
       
   314 Use ConfigureUnreliableChannel(TUint16 aObsolescenceTimer) instead
       
   315 */
       
   316 EXPORT_C TInt TL2CapConfig::SetupUnreliableChannel(TUint16 aObsolescenceTimer)
       
   317 	{
       
   318 	TInt rerr = KErrNone;
       
   319 
       
   320 	// Only flush timers above a certain physical limit are permitted.
       
   321 	if(aObsolescenceTimer < EMinDataObsolescenceTimeout)
       
   322 		{
       
   323 		rerr = KErrArgument;
       
   324 		}
       
   325 	else
       
   326 		{
       
   327 		iChannelReliability = EUnreliableChannel;
       
   328 		iChannelReliabilityTimer = aObsolescenceTimer;
       
   329 		iSpecifiedMask |= EReliabilitySpecifiedMask;
       
   330 		}
       
   331 	return rerr;
       
   332 	}
       
   333 	
       
   334 /** 
       
   335 Request an unreliable channel, but allow any channel mode to be negotiated.
       
   336 
       
   337 This will configure the socket to prefer unreliable modes during L2CAP channel
       
   338 configuration, but accept any mode proposed by the peer.
       
   339 The purpose of this interface is to be used with listening sockets which need
       
   340 to accept both reliable and unreliable mode connections on a single PSM.
       
   341 The ConfigureReliableChannel and ConfigureUnreliableChannel methods should be
       
   342 used in preference to this one in normal situations.
       
   343 
       
   344 The LegacyModesDisallowed option does not influence the behavior of this method.
       
   345 
       
   346 The KL2CAPNegotiatedChannelMode socket option can be used to obtain the
       
   347 negotiated channel modes after a socket has been connected.
       
   348 
       
   349 @param aObsolescenceTimer The time after which a packet may be dropped 
       
   350 or "flushed" by the baseband if an Unreliable channel is negotiated.
       
   351 Note that outgoing packet flushing may not be implemented on all Symbian OS
       
   352 platforms.
       
   353 
       
   354 @param aRetransmissionTimer The length of time allowed for l2Cap transmissions
       
   355 if a Reliable channel is negotiated.
       
   356 Note that the value of this parameter does not directly drive the L2CAP
       
   357 retransmission timer. It is instead translated into a corresponding value for
       
   358 the maximum number of transmissions of a single packet. If that number is
       
   359 exceeded, then the connection is closed.
       
   360 @return error code, KErrArgument if the obsolescence time is made shorter than is 
       
   361 physically possible, otherwise KErrNone
       
   362 */
       
   363 EXPORT_C TInt TL2CapConfig::ConfigureUnreliableDesiredChannel(TUint16 aObsolescenceTimer, TUint16 aRetransmissionTimer)
       
   364 	{
       
   365 	TInt rerr = KErrNone;
       
   366 
       
   367 	// Only flush timers above a certain physical limit are permitted.
       
   368 	if(aObsolescenceTimer < EMinDataObsolescenceTimeout)
       
   369 		{
       
   370 		rerr = KErrArgument;
       
   371 		}
       
   372 	else
       
   373 		{
       
   374 		iChannelReliability = EUnreliableDesiredChannel;
       
   375 		iChannelReliabilityTimer = aObsolescenceTimer;
       
   376 		iAdditionalChannelReliabilityTimer = aRetransmissionTimer;
       
   377 		iSpecifiedMask |= EReliabilitySpecifiedMask;
       
   378 		}
       
   379 	return rerr;
       
   380 	}
       
   381 
       
   382 /** 
       
   383 Disallow usage of legacy L2CAP channel modes.
       
   384 
       
   385 This option influences the behavior of ConfigureReliableChannel and
       
   386 ConfigureUnreliableChannel. If it's enabled, then only the newest
       
   387 reliable/unreliable modes will be allowed during L2CAP channel configuration.
       
   388 
       
   389 The default value is to allow the usage of legacy modes.
       
   390 
       
   391 @param aDisallowed Whether the usage of legacy modes is disallowed.
       
   392 */
       
   393 EXPORT_C void TL2CapConfig::SetLegacyModesDisallowed(TBool aDisallowed)
       
   394 	{
       
   395 	if (aDisallowed)
       
   396 		{
       
   397 		iSpecifiedMask |= ELegacyModesDisallowedSpecifiedMask;
       
   398 		}
       
   399 	else
       
   400 		{
       
   401 		iSpecifiedMask &= ~ELegacyModesDisallowedSpecifiedMask;
       
   402 		}
       
   403 	}
       
   404 
       
   405 /** 
       
   406 Checks if the usage of legacy L2CAP channel modes is disallowed.
       
   407 The default value is to allow the usage of legacy modes.
       
   408 
       
   409 @param aDisallowed Whether the usage of legacy modes is disallowed.
       
   410 */
       
   411 EXPORT_C TBool TL2CapConfig::LegacyModesDisallowed() const
       
   412 	{
       
   413 	return iSpecifiedMask & ELegacyModesDisallowedSpecifiedMask;
       
   414 	}
       
   415 
       
   416 
       
   417 /** 
       
   418 Returns the channel reliability and the associated timer.
       
   419 
       
   420 Also allows the user to know whether reliability has been set up, 
       
   421 or whether it is a random value that will be ignored. 
       
   422 This is done via the parameter 'aIsSpecified'. 
       
   423 The associated timer is the obsolescence timer if the channel is unreliable 
       
   424 and the retransmission timer if it is reliable.
       
   425 This is returned via the parameter 'aAssociatedTimer'.
       
   426 Note that if ConfigureUnreliableDesiredChannel was used then both timer values
       
   427 have been set and this method will only return the obsolescence timeout.
       
   428 The overload of this method which doesn't return a timer value together
       
   429 with the timer value getters can be used instead of this one to uniformly handle
       
   430 all cases.
       
   431 
       
   432 @param aIsSpecified Used to tell the caller whether reliability has been set up. 
       
   433 @param aAssociatedTimer This is a 'return' value. The associated timer is the obsolescence timer if the channel is unreliable 
       
   434 and the retransmission timer if it is reliable. 
       
   435 @return the reliability
       
   436 */
       
   437 EXPORT_C TL2CapConfig::TChannelReliability TL2CapConfig::ChannelReliability(TBool& aIsSpecified, TUint16& aAssociatedTimer) const
       
   438 	{
       
   439 	aIsSpecified = ((iSpecifiedMask & EReliabilitySpecifiedMask) != 0);
       
   440 	aAssociatedTimer = iChannelReliabilityTimer;
       
   441 	return iChannelReliability;
       
   442 	}
       
   443 
       
   444 /** 
       
   445 Returns the channel reliability.
       
   446 
       
   447 Also allows the user to know whether reliability has been set up, 
       
   448 or whether it is a random value that will be ignored. 
       
   449 This is done via the parameter 'aIsSpecified'. 
       
   450 The associated timer is the obsolescence timer if the channel is unreliable, 
       
   451 the retransmission timer if it is reliable, and both timers if it's 'unreliable
       
   452 desired'.
       
   453 The associated timer values can be obtained with RetransmissionTimer() and
       
   454 ObsolescenceTimer() methods.
       
   455 
       
   456 @param aIsSpecified Used to tell the caller whether reliability has been set up. 
       
   457 @return the reliability
       
   458 */
       
   459 EXPORT_C TL2CapConfig::TChannelReliability TL2CapConfig::ChannelReliability(TBool& aIsSpecified) const
       
   460 	{
       
   461 	aIsSpecified = ((iSpecifiedMask & EReliabilitySpecifiedMask) != 0);
       
   462 	return iChannelReliability;
       
   463 	}
       
   464 
       
   465 /** 
       
   466 Returns the retransmission timer.
       
   467 
       
   468 @param aIsSpecified Used to tell the caller whether the timer value has been set.
       
   469 @return The value of the timer.
       
   470 */
       
   471 EXPORT_C TUint16 TL2CapConfig::RetransmissionTimer(TBool& aIsSpecified) const
       
   472 	{
       
   473 	TUint16 timer = 0;
       
   474 	aIsSpecified = EFalse;
       
   475 	TBool reliabilitySpecified = ((iSpecifiedMask & EReliabilitySpecifiedMask) != 0);
       
   476 	if (reliabilitySpecified)
       
   477 		{
       
   478 		if (iChannelReliability == EReliableChannel)
       
   479 			{
       
   480 			aIsSpecified = ETrue;
       
   481 			// It's the only timer specified, so it's in iChannelReliabilityTimer.
       
   482 			timer = iChannelReliabilityTimer;
       
   483 			}
       
   484 		else if (iChannelReliability == EUnreliableDesiredChannel)
       
   485 			{
       
   486 			aIsSpecified = ETrue;
       
   487 			// We've got 2 timers specified, Retransmission goes in the additional field
       
   488 			// (see the note accompanying field declarations).
       
   489 			timer = iAdditionalChannelReliabilityTimer;
       
   490 			}
       
   491 		}
       
   492 	return timer;
       
   493 	}
       
   494 
       
   495 /** 
       
   496 Returns the obsolescence timer.
       
   497 
       
   498 @param aIsSpecified Used to tell the caller whether the timer value has been set.
       
   499 @return The value of the timer.
       
   500 */
       
   501 EXPORT_C TUint16 TL2CapConfig::ObsolescenceTimer(TBool& aIsSpecified) const
       
   502 	{
       
   503 	TUint16 timer = 0;
       
   504 	aIsSpecified = EFalse;
       
   505 
       
   506 	if ((iSpecifiedMask & EReliabilitySpecifiedMask) != 0)
       
   507 		{
       
   508 		if (iChannelReliability == EUnreliableChannel || iChannelReliability == EUnreliableDesiredChannel)
       
   509 			{
       
   510 			aIsSpecified = ETrue;
       
   511 			// Flush timeout always goes in iChannelReliabilityTimer
       
   512 			// (see the note accompanying field declarations).
       
   513 			timer = iChannelReliabilityTimer;
       
   514 			}
       
   515 		}
       
   516 	return timer;
       
   517 	}
       
   518 
       
   519 /** 
       
   520 Request a new channel priority.
       
   521 
       
   522 L2Cap channels have three priorities, low, medium, and high. Data on channels with 
       
   523 higher priority may be sent before data on channels with lower priority.
       
   524 
       
   525 @param aPriority the priority to be used for this L2Cap channel
       
   526 @return error code, currently KErrNone
       
   527 */
       
   528 EXPORT_C TInt TL2CapConfig::ConfigureChannelPriority(TL2CapConfig::TChannelPriority aPriority)
       
   529 	{
       
   530 	iChannelPriority = aPriority;
       
   531 	iSpecifiedMask |= EPrioritySpecifiedMask;
       
   532 	return KErrNone;
       
   533 	}
       
   534 
       
   535 /** 
       
   536 Request a new channel priority.
       
   537 
       
   538 L2Cap channels have three priorities, low, medium, and high. Data on channels with 
       
   539 higher priority may be sent before data on channels with lower priority.
       
   540 
       
   541 @param aPriority the priority to be used for this L2Cap channel
       
   542 @return error code, currently KErrNone
       
   543 @deprecated
       
   544 Use ConfigureChannelPriority(TChannelPriority aPriority) instead
       
   545 */
       
   546 EXPORT_C TInt TL2CapConfig::SetChannelPriority(TL2CapConfig::TChannelPriority aPriority)
       
   547 	{
       
   548 	iChannelPriority = aPriority;
       
   549 	iSpecifiedMask |= EPrioritySpecifiedMask;
       
   550 	return KErrNone;
       
   551 	}
       
   552 	
       
   553 /** 
       
   554 Returns requested channel priority.
       
   555 
       
   556 Also allows the user to know whether that priority has been set, 
       
   557 or whether it is a random value that will be ignored. 
       
   558 This is done via the parameter 'aIsSpecified'. 
       
   559 
       
   560 @param aIsSpecified Used to tell the caller whether the priority has been set. 
       
   561 @return requested channel priority.
       
   562 */
       
   563 EXPORT_C TL2CapConfig::TChannelPriority TL2CapConfig::ChannelPriority(TBool& aIsSpecified) const
       
   564 	{
       
   565 	aIsSpecified = ((iSpecifiedMask & EPrioritySpecifiedMask) != 0);
       
   566 	return iChannelPriority;
       
   567 	}
       
   568 
       
   569 /**
       
   570 Comparison operator.
       
   571 
       
   572 Compare the pincode length first, if equal, then compare each individual bits
       
   573 
       
   574 @param aPINCodeV10 Object to compare to this.
       
   575 @return ETrue if aPINCodeV10 is the same as this, EFalse if not.
       
   576 */
       
   577 EXPORT_C TBool TPINCodeV10::operator==(const TPINCodeV10& aPINCodeV10) const
       
   578 	{
       
   579 	TBool equal = EFalse;
       
   580 	
       
   581 	if (iLength == aPINCodeV10.iLength)
       
   582 		{
       
   583 		equal = ETrue; 
       
   584 		
       
   585 		//check for individual bits, if not equal, then set equal variable to EFalse
       
   586 		for (TInt i = 0; i < iLength; i++)
       
   587 			{
       
   588 			if (iPIN[i] != aPINCodeV10.iPIN[i])
       
   589 				{
       
   590 				equal = EFalse;
       
   591 				break;
       
   592 				}
       
   593 			}
       
   594 		}
       
   595 	
       
   596 	return equal;
       
   597 	}