diff -r 000000000000 -r 29b1cd4cb562 bluetooth/btextnotifiers/src/BTExtNotifiers.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetooth/btextnotifiers/src/BTExtNotifiers.cpp Fri Jan 15 08:13:17 2010 +0200 @@ -0,0 +1,857 @@ +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_BTNOTIFIERS); +#endif + +/** +Constructor. +Sets iValidDeviceClass and iValidUuid to EFalse. +**/ +EXPORT_C TBTDeviceSelectionParams::TBTDeviceSelectionParams() + { + iValidDeviceClass=EFalse; + iValidUuid=EFalse; + } + +/** +Sets the UUID to aUUID. +@param aUUID "The UUID" +**/ +EXPORT_C void TBTDeviceSelectionParams::SetUUID(const TUUID& aUUID) + { + iSdpUuid=aUUID; + iValidUuid=ETrue; + } + +/** +Sets the device class to aClass. +@param aClass "The device class" +**/ +EXPORT_C void TBTDeviceSelectionParams::SetDeviceClass(TBTDeviceClass aClass) + { + iDeviceClass=aClass; + iValidDeviceClass=ETrue; + } + +/** +Returns the UUID contained within these params. +@return The UUID. The reference will remain valid while this object is in scope. +**/ +EXPORT_C const TUUID& TBTDeviceSelectionParams::UUID() + { + return iSdpUuid; + } + +/** +Returns the device class contained within these params. +@return The device class. +**/ +EXPORT_C TBTDeviceClass TBTDeviceSelectionParams::DeviceClass() + { + return iDeviceClass; + } + +/** +Returns ETrue if the device class has been set using SetDeviceClass(.). +@return ETrue if the device class has been set, EFalse if not. +**/ +EXPORT_C TBool TBTDeviceSelectionParams::IsValidDeviceClass() + { + return iValidDeviceClass; + } + +/** +Returns ETrue if the UUID has been set using SetUUID(.). +@return ETrue if the UUID has been set, EFalse if not. +**/ +EXPORT_C TBool TBTDeviceSelectionParams::IsValidUUID() + { + return iValidUuid; + } + +/** +Constructor. +Sets iValidBDAddr, iValidDeviceName and iValidDeviceClass to EFalse; +**/ +EXPORT_C TBTDeviceResponseParams::TBTDeviceResponseParams() + { + iValidBDAddr=EFalse; + iValidDeviceName=EFalse; + iValidDeviceClass=EFalse; + } + +/** +Sets the device address to aBDAddr. +@param aBDAddr "The device address" +**/ +EXPORT_C void TBTDeviceResponseParams::SetDeviceAddress(const TBTDevAddr& aBDAddr) + { + iBDAddr=aBDAddr; + iValidBDAddr=ETrue; + } + +/** +Sets the device name to aName. +@param aName "The device name" +**/ +EXPORT_C void TBTDeviceResponseParams::SetDeviceName(const TDesC& aName) + { + iDeviceName=aName; + iValidDeviceName=ETrue; + } + +/** +Sets the device class to aClass. +@param aClass "The device class" +**/ +EXPORT_C void TBTDeviceResponseParams::SetDeviceClass(TBTDeviceClass aClass) + { + iDeviceClass=aClass; + iValidDeviceClass=ETrue; + } + + +/** +Returns the device address contained within these params. +@return The device address. The reference will be valid while this object is in scope. +**/ +EXPORT_C const TBTDevAddr& TBTDeviceResponseParams::BDAddr() const + { + return iBDAddr; + } + +/** +Returns the device name contained within these params. +@return The device name. The reference will be valid while this object is in scope. +**/ +EXPORT_C const TDesC& TBTDeviceResponseParams::DeviceName() const + { + return iDeviceName; + } + +/** +Returns the device class contained within these params. +@return The device class. +**/ +EXPORT_C TBTDeviceClass TBTDeviceResponseParams::DeviceClass() + { + return iDeviceClass; + } + +/** +Returns ETrue if the device address has been set using SetDeviceAddress. +@return ETrue if the device address has been set, EFalse if not. +**/ +EXPORT_C TBool TBTDeviceResponseParams::IsValidBDAddr() const + { + return iValidBDAddr; + } + +/** +Returns ETrue if the device name has been set using SetDeviceName. +@return ETrue if the device name has been set, EFalse if not. +**/ +EXPORT_C TBool TBTDeviceResponseParams::IsValidDeviceName() const + { + return iValidDeviceName; + } + +/** +Returns ETrue if the device class has been set using SetDeviceClass(.). +@return ETrue if the device class has been set, EFalse if not. +**/ +EXPORT_C TBool TBTDeviceResponseParams::IsValidDeviceClass() + { + return iValidDeviceClass; + } + +EXPORT_C TBTDeviceList::TBTDeviceList() : + iPtr(iDevices), iKNullDevAddr(MAKE_TINT64(0x0000, 0x00000000)) +/** + +*/ + { + iDevices.Reset(); + iPosition = 0; + } + +EXPORT_C TInt TBTDeviceList::AddDevice(const TBTDevAddr& aDevAddr) +/** +Add a new device to the list +@note This always appends the new device to the end of the list +@return KErrNone if successful; KErrOverflow if there is no space left in the array +*/ + { + for(TInt i=0; i < iDevices.Count(); ++i) + { + if(iDevices[i] == iKNullDevAddr) + { + iDevices[i] = aDevAddr; + return KErrNone; + } + } + return KErrOverflow; + } + +EXPORT_C TInt TBTDeviceList::GetDevice(TBTDevAddr& aDevAddr) +/** +Get the next device address from the list +@note This method is stateful, and advances automatically to the next device address each time +*/ + { + if(iDevices[iPosition]!=iKNullDevAddr) + { + aDevAddr = iDevices[iPosition]; + ++iPosition; + return KErrNone; + } + else + { + return KErrEof; + } + } + +EXPORT_C void TBTDeviceList::Reset() +/** +Reset the contents of the array +*/ + { + iDevices.Reset(); + iPosition = 0; + } + +EXPORT_C TBTDeviceList::operator const TDesC8&() + { + return iPtr; + } + +EXPORT_C TBTDeviceList::operator TDes8&() + { + return iPtr; + } + +EXPORT_C TUint TBTDeviceList::MaxNumberOfDevices() + { + return KMaxDevicesForSimultaneousSelection; + } + +/** +Constructor. +Sets iRealmTruncated, iValidRealm, iValidRemoteAddr to EFalse; +**/ +EXPORT_C TPbapAuthNotifierParams::TPbapAuthNotifierParams() + { + iRealmTruncated = EFalse; + iValidRealm = EFalse; + iValidRemoteAddr = EFalse; + } + +/** +Sets the realm to aRealm. If the length of aRealm is greater than the maximum +length of iRealm then aRealm will be truncated. +@param aRealm "The Realm" +**/ +EXPORT_C void TPbapAuthNotifierParams::SetRealm(const TDesC& aRealm) + { + iRealm = aRealm.Left(KPbapAuthRealmLength); + iValidRealm = ETrue; + + // check if iRealm was truncated + iRealmTruncated = (aRealm.Length() > KPbapAuthRealmLength) ? ETrue : EFalse; + } + +/** +Sets the remote device address to aBDAddr. +@param aBDAddr "The remote device address" +**/ +EXPORT_C void TPbapAuthNotifierParams::SetRemoteAddr(const TBTDevAddr& aBDAddr) + { + iRemoteAddr = aBDAddr; + iValidRemoteAddr = ETrue; + } + +/** +Returns the realm contained within these params. +@return The realm. The reference will be valid while this object is in scope. +**/ +EXPORT_C const TDesC& TPbapAuthNotifierParams::Realm() const + { + return iRealm; + } + +/** +Returns ETrue if the realm was truncated during call to SetRealm. +@return ETrue if the realm was truncated during call to SetRealm, EFalse if not. +**/ +EXPORT_C TBool TPbapAuthNotifierParams::RealmTruncated() const + { + return iRealmTruncated; + } + +/** +Returns the remote device address contained within these params. +@return The remote device address. The reference will be valid while this object is in scope. +**/ +EXPORT_C const TBTDevAddr& TPbapAuthNotifierParams::RemoteAddr() const + { + return iRemoteAddr; + } + +/** +Returns ETrue if the realm has been set. +@return ETrue if the realm has been set, EFalse if not. +**/ +EXPORT_C TBool TPbapAuthNotifierParams::IsValidRealm() const + { + return iValidRealm; + } + +/** +Returns ETrue if the remote device address has been set. +@return ETrue if the remote device address has been set, EFalse if not. +**/ +EXPORT_C TBool TPbapAuthNotifierParams::IsValidRemoteAddr() const + { + return iValidRemoteAddr; + } + + +/** +Constructor. +Sets iValidPassword to EFalse; +**/ +EXPORT_C TPbapAuthNotifierResponse::TPbapAuthNotifierResponse() + { + iValidPassword = EFalse; + } + +/** +Sets the password to aPassword. If the length of aPassword is greater than the maximum +length of iPassword then the password will not be set and EFalse will be returned. +@param aPassword "The Authentication Password" +@return ETrue if the password was successfully set, EFalse if not. +**/ +EXPORT_C TBool TPbapAuthNotifierResponse::SetPassword(const TDesC& aPassword) + { + if (aPassword.Length() <= KPbapAuthPasswordLength) + { + iPassword = aPassword; + iValidPassword = ETrue; + } + else + { + iPassword.Zero(); + iValidPassword = EFalse; + } + + return iValidPassword; + } + +/** +Clears any password contained within these params. +**/ +EXPORT_C void TPbapAuthNotifierResponse::ResetPassword() + { + iPassword.Zero(); + iValidPassword = EFalse; + } + +/** +Returns the password contained within these params. +@return The password. The reference will be valid while this object is in scope. +**/ +EXPORT_C const TDesC& TPbapAuthNotifierResponse::Password() const + { + return iPassword; + } + +/** +Returns ETrue if the password has been set. +@return ETrue if the password has been set, EFalse if not. +**/ +EXPORT_C TBool TPbapAuthNotifierResponse::IsValidPassword() const + { + return iValidPassword; + } + + +// +// TPanConnection +// +EXPORT_C TPanConnection::TPanConnection(TBTDevAddr& aRemoteDeviceAddress, + TBool aUplinkAccessAllowed) + : iRemoteDeviceAddress(aRemoteDeviceAddress), + iUplinkAccessAllowed(aUplinkAccessAllowed) + { + } + +EXPORT_C TPanConnection::TPanConnection() + : iRemoteDeviceAddress(0), + iUplinkAccessAllowed(EFalse) + { + } + +EXPORT_C const TBTDevAddr& TPanConnection::RemoteDeviceAddress() const + { + return iRemoteDeviceAddress; + } + +EXPORT_C TBool TPanConnection::UplinkAccessAllowed() const + { + return iUplinkAccessAllowed; + } + +EXPORT_C TBool TPanConnection::IsValid() const + { + // Check if the address is valid (0x0000 0000 0000 is not a valid address). + return (iRemoteDeviceAddress != 0); + } + + +// +// TPanConnectionList +// +EXPORT_C TPanConnectionList::TPanConnectionList() + : iPosition(0) + { + } + +EXPORT_C void TPanConnectionList::AddRemoteConnectionL(const TPanConnection& aRemoteConnection) +/** +Add a new PAN connection to the list +@note This always appends the new connection to the end of the list +@leave KErrNone if successful; KErrOverflow if there is no space left in the array +*/ + { + TInt err = KErrOverflow; + for(TInt i=0;i